From 429302d2dcbb68ea7d3023b82760431de5251fca Mon Sep 17 00:00:00 2001 From: Shane32 Date: Sat, 1 Jun 2024 16:22:13 -0400 Subject: [PATCH 1/5] Add NRT attributes --- QRCoder/AbstractQRCode.cs | 3 +- QRCoder/ArtQRCode.cs | 12 +- QRCoder/Attributes/PolyfillAttributes.cs | 27 +++ QRCoder/Extensions/StringExtensions.cs | 6 +- QRCoder/Extensions/StringValueAttribute.cs | 6 +- QRCoder/PayloadGenerator/BezahlCode.cs | 3 +- QRCoder/PayloadGenerator/BitcoinAddress.cs | 2 +- .../PayloadGenerator/BitcoinCashAddress.cs | 2 +- .../BitcoinLikeCryptoCurrencyAddress.cs | 17 +- QRCoder/PayloadGenerator/CalendarEvent.cs | 7 +- QRCoder/PayloadGenerator/ContactData.cs | 32 +-- QRCoder/PayloadGenerator/LitecoinAddress.cs | 2 +- QRCoder/PayloadGenerator/Mail.cs | 8 +- QRCoder/PayloadGenerator/MoneroTransaction.cs | 7 +- QRCoder/PayloadGenerator/OneTimePassword.cs | 12 +- .../PayloadGenerator/RussiaPaymentOrder.cs | 150 +++++++------- QRCoder/PayloadGenerator/ShadowSocksConfig.cs | 9 +- QRCoder/PayloadGenerator/SlovenianUpnQr.cs | 2 +- QRCoder/PayloadGenerator/SwissQrCode.cs | 61 +++--- QRCoder/PdfByteQRCode.cs | 2 +- QRCoder/PngByteQRCode.cs | 2 +- QRCoder/PostscriptQRCode.cs | 8 +- QRCoder/QRCode.cs | 22 +- QRCoder/QRCodeData.cs | 2 +- QRCoder/QRCodeGenerator.cs | 7 +- .../ModulePlacer.BlockedModules.cs | 4 +- QRCoder/QRCodeGenerator/ModulePlacer.cs | 4 +- QRCoder/QRCodeGenerator/Polynom.cs | 11 +- QRCoder/QRCoder.csproj | 2 + QRCoder/SvgQRCode.cs | 24 +-- .../QRCoder.approved.txt | 190 +++++++++--------- .../net60-windows/QRCoder.approved.txt | 190 +++++++++--------- QRCoderApiTests/net60/QRCoder.approved.txt | 176 ++++++++-------- .../netstandard13/QRCoder.approved.txt | 158 +++++++-------- 34 files changed, 602 insertions(+), 568 deletions(-) create mode 100644 QRCoder/Attributes/PolyfillAttributes.cs diff --git a/QRCoder/AbstractQRCode.cs b/QRCoder/AbstractQRCode.cs index 4c4b486f..a123c482 100644 --- a/QRCoder/AbstractQRCode.cs +++ b/QRCoder/AbstractQRCode.cs @@ -5,6 +5,7 @@ public abstract class AbstractQRCode protected QRCodeData QrCodeData { get; set; } protected AbstractQRCode() { + this.QrCodeData = null!; } protected AbstractQRCode(QRCodeData data) { @@ -22,7 +23,7 @@ virtual public void SetQRCodeData(QRCodeData data) { public void Dispose() { this.QrCodeData?.Dispose(); - this.QrCodeData = null; + this.QrCodeData = null!; } } } \ No newline at end of file diff --git a/QRCoder/ArtQRCode.cs b/QRCoder/ArtQRCode.cs index af56e658..b80f5178 100644 --- a/QRCoder/ArtQRCode.cs +++ b/QRCoder/ArtQRCode.cs @@ -40,7 +40,7 @@ public Bitmap GetGraphic(int pixelsPerModule) /// /// A bitmap object that will be used as background picture /// QRCode graphic as bitmap - public Bitmap GetGraphic(Bitmap backgroundImage = null) + public Bitmap GetGraphic(Bitmap? backgroundImage = null) { return this.GetGraphic(10, Color.Black, Color.White, Color.Transparent, backgroundImage: backgroundImage); } @@ -59,9 +59,9 @@ public Bitmap GetGraphic(Bitmap backgroundImage = null) /// Style of the background image (if set). Fill=spanning complete graphic; DataAreaOnly=Don't paint background into quietzone /// Optional image that should be used instead of the default finder patterns /// QRCode graphic as bitmap - public Bitmap GetGraphic(int pixelsPerModule, Color darkColor, Color lightColor, Color backgroundColor, Bitmap backgroundImage = null, double pixelSizeFactor = 1, + public Bitmap GetGraphic(int pixelsPerModule, Color darkColor, Color lightColor, Color backgroundColor, Bitmap? backgroundImage = null, double pixelSizeFactor = 1, bool drawQuietZones = true, QuietZoneStyle quietZoneRenderingStyle = QuietZoneStyle.Dotted, - BackgroundImageStyle backgroundImageStyle = BackgroundImageStyle.DataAreaOnly, Bitmap finderPatternImage = null) + BackgroundImageStyle backgroundImageStyle = BackgroundImageStyle.DataAreaOnly, Bitmap? finderPatternImage = null) { if (pixelSizeFactor > 1) throw new Exception("The parameter pixelSize must be between 0 and 1. (0-100%)"); @@ -211,8 +211,6 @@ private bool IsPartOfFinderPattern(int x, int y, int numModules, int offset) /// Resized image as bitmap private Bitmap Resize(Bitmap image, int newSize) { - if (image == null) return null; - float scale = Math.Min((float)newSize / image.Width, (float)newSize / image.Height); var scaledWidth = (int)(image.Width * scale); var scaledHeight = (int)(image.Height * scale); @@ -284,9 +282,9 @@ public static class ArtQRCodeHelper /// Optional image that should be used instead of the default finder patterns /// QRCode graphic as bitmap public static Bitmap GetQRCode(string plainText, int pixelsPerModule, Color darkColor, Color lightColor, Color backgroundColor, ECCLevel eccLevel, bool forceUtf8 = false, - bool utf8BOM = false, EciMode eciMode = EciMode.Default, int requestedVersion = -1, Bitmap backgroundImage = null, double pixelSizeFactor = 1.0, + bool utf8BOM = false, EciMode eciMode = EciMode.Default, int requestedVersion = -1, Bitmap? backgroundImage = null, double pixelSizeFactor = 1.0, bool drawQuietZones = true, QuietZoneStyle quietZoneRenderingStyle = QuietZoneStyle.Flat, - BackgroundImageStyle backgroundImageStyle = BackgroundImageStyle.DataAreaOnly, Bitmap finderPatternImage = null) + BackgroundImageStyle backgroundImageStyle = BackgroundImageStyle.DataAreaOnly, Bitmap? finderPatternImage = null) { using (var qrGenerator = new QRCodeGenerator()) using (var qrCodeData = qrGenerator.CreateQrCode(plainText, eccLevel, forceUtf8, utf8BOM, eciMode, requestedVersion)) diff --git a/QRCoder/Attributes/PolyfillAttributes.cs b/QRCoder/Attributes/PolyfillAttributes.cs new file mode 100644 index 00000000..c92cb180 --- /dev/null +++ b/QRCoder/Attributes/PolyfillAttributes.cs @@ -0,0 +1,27 @@ +#if !NETCOREAPP +namespace System.Diagnostics.CodeAnalysis +{ + /// + /// Specifies that when a method returns System.Diagnostics.CodeAnalysis.NotNullWhenAttribute.ReturnValue, + /// the parameter will not be null even if the corresponding type allows it. + /// + [AttributeUsage(AttributeTargets.Parameter, Inherited = false)] + public sealed class NotNullWhenAttribute : Attribute + { + /// + /// Initializes the attribute with the specified return value condition. + /// + /// If the method returns this value, the associated parameter will not be null. + public NotNullWhenAttribute(bool returnValue) + { + ReturnValue = returnValue; + } + + /// + /// Gets the return value condition. If the method returns this value, the associated + /// parameter will not be null. + /// + public bool ReturnValue { get; } + } +} +#endif diff --git a/QRCoder/Extensions/StringExtensions.cs b/QRCoder/Extensions/StringExtensions.cs index 34a44272..51830f92 100644 --- a/QRCoder/Extensions/StringExtensions.cs +++ b/QRCoder/Extensions/StringExtensions.cs @@ -1,3 +1,5 @@ +using System.Diagnostics.CodeAnalysis; + namespace QRCoder { internal static class StringExtensions @@ -8,7 +10,9 @@ internal static class StringExtensions /// /// if the is null, empty, or white space; otherwise, . /// - public static bool IsNullOrWhiteSpace(this string value) + public static bool IsNullOrWhiteSpace( + [NotNullWhen(false)] + this string? value) { #if NET35 if (value == null) return true; diff --git a/QRCoder/Extensions/StringValueAttribute.cs b/QRCoder/Extensions/StringValueAttribute.cs index f8ff37ef..461b8131 100644 --- a/QRCoder/Extensions/StringValueAttribute.cs +++ b/QRCoder/Extensions/StringValueAttribute.cs @@ -44,15 +44,15 @@ public static class CustomExtensions #if NET6_0_OR_GREATER [RequiresUnreferencedCode("This method uses reflection to examine the provided enum value.")] #endif - public static string GetStringValue(this Enum value) + public static string? GetStringValue(this Enum value) { #if NETSTANDARD1_3 var fieldInfo = value.GetType().GetRuntimeField(value.ToString()); #else - var fieldInfo = value.GetType().GetField(value.ToString()); + var fieldInfo = value.GetType().GetField(value.ToString())!; #endif var attr = fieldInfo.GetCustomAttributes(typeof(StringValueAttribute), false) as StringValueAttribute[]; - return attr.Length > 0 ? attr[0].StringValue : null; + return attr!.Length > 0 ? attr[0].StringValue : null; } } } diff --git a/QRCoder/PayloadGenerator/BezahlCode.cs b/QRCoder/PayloadGenerator/BezahlCode.cs index 24f9dd18..4d47cec7 100644 --- a/QRCoder/PayloadGenerator/BezahlCode.cs +++ b/QRCoder/PayloadGenerator/BezahlCode.cs @@ -9,7 +9,8 @@ public class BezahlCode : Payload { //BezahlCode specification: http://www.bezahlcode.de/wp-content/uploads/BezahlCode_TechDok.pdf - private readonly string name, iban, bic, account, bnc, sepaReference, reason, creditorId, mandateId, periodicTimeunit; + private readonly string? iban, bic, account, bnc, sepaReference, creditorId, mandateId, periodicTimeunit; + private readonly string name, reason; private readonly decimal amount; private readonly int postingKey, periodicTimeunitRotation; private readonly Currency currency; diff --git a/QRCoder/PayloadGenerator/BitcoinAddress.cs b/QRCoder/PayloadGenerator/BitcoinAddress.cs index b76776c5..94361e13 100644 --- a/QRCoder/PayloadGenerator/BitcoinAddress.cs +++ b/QRCoder/PayloadGenerator/BitcoinAddress.cs @@ -4,7 +4,7 @@ public static partial class PayloadGenerator { public class BitcoinAddress : BitcoinLikeCryptoCurrencyAddress { - public BitcoinAddress(string address, double? amount, string label = null, string message = null) + public BitcoinAddress(string address, double? amount, string? label = null, string? message = null) : base(BitcoinLikeCryptoCurrencyType.Bitcoin, address, amount, label, message) { } } } diff --git a/QRCoder/PayloadGenerator/BitcoinCashAddress.cs b/QRCoder/PayloadGenerator/BitcoinCashAddress.cs index fa14d7a6..32293491 100644 --- a/QRCoder/PayloadGenerator/BitcoinCashAddress.cs +++ b/QRCoder/PayloadGenerator/BitcoinCashAddress.cs @@ -4,7 +4,7 @@ public static partial class PayloadGenerator { public class BitcoinCashAddress : BitcoinLikeCryptoCurrencyAddress { - public BitcoinCashAddress(string address, double? amount, string label = null, string message = null) + public BitcoinCashAddress(string address, double? amount, string? label = null, string? message = null) : base(BitcoinLikeCryptoCurrencyType.BitcoinCash, address, amount, label, message) { } } } diff --git a/QRCoder/PayloadGenerator/BitcoinLikeCryptoCurrencyAddress.cs b/QRCoder/PayloadGenerator/BitcoinLikeCryptoCurrencyAddress.cs index bda54eae..8ca46a4a 100644 --- a/QRCoder/PayloadGenerator/BitcoinLikeCryptoCurrencyAddress.cs +++ b/QRCoder/PayloadGenerator/BitcoinLikeCryptoCurrencyAddress.cs @@ -10,7 +10,8 @@ public static partial class PayloadGenerator public class BitcoinLikeCryptoCurrencyAddress : Payload { private readonly BitcoinLikeCryptoCurrencyType currencyType; - private readonly string address, label, message; + private readonly string address; + private readonly string? label, message; private readonly double? amount; /// @@ -21,7 +22,7 @@ public class BitcoinLikeCryptoCurrencyAddress : Payload /// Amount of coins to transfer /// Reference label /// Referece text aka message - public BitcoinLikeCryptoCurrencyAddress(BitcoinLikeCryptoCurrencyType currencyType, string address, double? amount, string label = null, string message = null) + public BitcoinLikeCryptoCurrencyAddress(BitcoinLikeCryptoCurrencyType currencyType, string address, double? amount, string? label = null, string? message = null) { this.currencyType = currencyType; this.address = address; @@ -41,12 +42,12 @@ public BitcoinLikeCryptoCurrencyAddress(BitcoinLikeCryptoCurrencyType currencyTy public override string ToString() { - string query = null; + string? query = null; - var queryValues = new KeyValuePair[]{ - new KeyValuePair(nameof(label), label), - new KeyValuePair(nameof(message), message), - new KeyValuePair(nameof(amount), amount.HasValue ? amount.Value.ToString("#.########", CultureInfo.InvariantCulture) : null) + var queryValues = new KeyValuePair[]{ + new KeyValuePair(nameof(label), label), + new KeyValuePair(nameof(message), message), + new KeyValuePair(nameof(amount), amount.HasValue ? amount.Value.ToString("#.########", CultureInfo.InvariantCulture) : null) }; if (queryValues.Any(keyPair => !string.IsNullOrEmpty(keyPair.Value))) @@ -57,7 +58,7 @@ public override string ToString() .ToArray()); } - return $"{Enum.GetName(typeof(BitcoinLikeCryptoCurrencyType), currencyType).ToLower()}:{address}{query}"; + return $"{Enum.GetName(typeof(BitcoinLikeCryptoCurrencyType), currencyType)!.ToLower()}:{address}{query}"; } public enum BitcoinLikeCryptoCurrencyType diff --git a/QRCoder/PayloadGenerator/CalendarEvent.cs b/QRCoder/PayloadGenerator/CalendarEvent.cs index 4b75a3ee..f0cf9507 100644 --- a/QRCoder/PayloadGenerator/CalendarEvent.cs +++ b/QRCoder/PayloadGenerator/CalendarEvent.cs @@ -6,7 +6,8 @@ public static partial class PayloadGenerator { public class CalendarEvent : Payload { - private readonly string subject, description, location, start, end; + private readonly string subject, start, end; + private readonly string? description, location; private readonly EventEncoding encoding; /// @@ -19,7 +20,7 @@ public class CalendarEvent : Payload /// End time (incl. UTC offset) of the event /// Is it a full day event? /// Type of encoding (universal or iCal) - public CalendarEvent(string subject, string description, string location, DateTimeOffset start, DateTimeOffset end, bool allDayEvent, EventEncoding encoding = EventEncoding.Universal) : this(subject, description, location, start.UtcDateTime, end.UtcDateTime, allDayEvent, encoding) + public CalendarEvent(string subject, string? description, string? location, DateTimeOffset start, DateTimeOffset end, bool allDayEvent, EventEncoding encoding = EventEncoding.Universal) : this(subject, description, location, start.UtcDateTime, end.UtcDateTime, allDayEvent, encoding) { } @@ -33,7 +34,7 @@ public CalendarEvent(string subject, string description, string location, DateTi /// End time of the event /// Is it a full day event? /// Type of encoding (universal or iCal) - public CalendarEvent(string subject, string description, string location, DateTime start, DateTime end, bool allDayEvent, EventEncoding encoding = EventEncoding.Universal) + public CalendarEvent(string subject, string? description, string? location, DateTime start, DateTime end, bool allDayEvent, EventEncoding encoding = EventEncoding.Universal) { this.subject = subject; this.description = description; diff --git a/QRCoder/PayloadGenerator/ContactData.cs b/QRCoder/PayloadGenerator/ContactData.cs index 28fba67f..e7d054b7 100644 --- a/QRCoder/PayloadGenerator/ContactData.cs +++ b/QRCoder/PayloadGenerator/ContactData.cs @@ -8,22 +8,22 @@ public class ContactData : Payload { private readonly string firstname; private readonly string lastname; - private readonly string nickname; - private readonly string org; - private readonly string orgTitle; - private readonly string phone; - private readonly string mobilePhone; - private readonly string workPhone; - private readonly string email; + private readonly string? nickname; + private readonly string? org; + private readonly string? orgTitle; + private readonly string? phone; + private readonly string? mobilePhone; + private readonly string? workPhone; + private readonly string? email; private readonly DateTime? birthday; - private readonly string website; - private readonly string street; - private readonly string houseNumber; - private readonly string city; - private readonly string zipCode; - private readonly string stateRegion; - private readonly string country; - private readonly string note; + private readonly string? website; + private readonly string? street; + private readonly string? houseNumber; + private readonly string? city; + private readonly string? zipCode; + private readonly string? stateRegion; + private readonly string? country; + private readonly string? note; private readonly ContactOutputType outputType; private readonly AddressOrder addressOrder; @@ -51,7 +51,7 @@ public class ContactData : Payload /// Memo text / notes /// Organisation/Company /// Organisation/Company Title - public ContactData(ContactOutputType outputType, string firstname, string lastname, string nickname = null, string phone = null, string mobilePhone = null, string workPhone = null, string email = null, DateTime? birthday = null, string website = null, string street = null, string houseNumber = null, string city = null, string zipCode = null, string country = null, string note = null, string stateRegion = null, AddressOrder addressOrder = AddressOrder.Default, string org = null, string orgTitle = null) + public ContactData(ContactOutputType outputType, string firstname, string lastname, string? nickname = null, string? phone = null, string? mobilePhone = null, string? workPhone = null, string? email = null, DateTime? birthday = null, string? website = null, string? street = null, string? houseNumber = null, string? city = null, string? zipCode = null, string? country = null, string? note = null, string? stateRegion = null, AddressOrder addressOrder = AddressOrder.Default, string? org = null, string? orgTitle = null) { this.firstname = firstname; this.lastname = lastname; diff --git a/QRCoder/PayloadGenerator/LitecoinAddress.cs b/QRCoder/PayloadGenerator/LitecoinAddress.cs index b2e5e76f..d403d319 100644 --- a/QRCoder/PayloadGenerator/LitecoinAddress.cs +++ b/QRCoder/PayloadGenerator/LitecoinAddress.cs @@ -4,7 +4,7 @@ public static partial class PayloadGenerator { public class LitecoinAddress : BitcoinLikeCryptoCurrencyAddress { - public LitecoinAddress(string address, double? amount, string label = null, string message = null) + public LitecoinAddress(string address, double? amount, string? label = null, string? message = null) : base(BitcoinLikeCryptoCurrencyType.Litecoin, address, amount, label, message) { } } } diff --git a/QRCoder/PayloadGenerator/Mail.cs b/QRCoder/PayloadGenerator/Mail.cs index 217733f9..6ef23d3d 100644 --- a/QRCoder/PayloadGenerator/Mail.cs +++ b/QRCoder/PayloadGenerator/Mail.cs @@ -8,7 +8,7 @@ public static partial class PayloadGenerator { public class Mail : Payload { - private readonly string mailReceiver, subject, message; + private readonly string? mailReceiver, subject, message; private readonly MailEncoding encoding; @@ -19,7 +19,7 @@ public class Mail : Payload /// Subject line of the email /// Message content of the email /// Payload encoding type. Choose dependent on your QR Code scanner app. - public Mail(string mailReceiver = null, string subject = null, string message = null, MailEncoding encoding = MailEncoding.MAILTO) + public Mail(string? mailReceiver = null, string? subject = null, string? message = null, MailEncoding encoding = MailEncoding.MAILTO) { this.mailReceiver = mailReceiver; this.subject = subject; @@ -42,10 +42,10 @@ public override string ToString() returnVal = $"mailto:{this.mailReceiver}{queryString}"; break; case MailEncoding.MATMSG: - returnVal = $"MATMSG:TO:{this.mailReceiver};SUB:{EscapeInput(this.subject)};BODY:{EscapeInput(this.message)};;"; + returnVal = $"MATMSG:TO:{this.mailReceiver};SUB:{EscapeInput(this.subject ?? "")};BODY:{EscapeInput(this.message ?? "")};;"; break; case MailEncoding.SMTP: - returnVal = $"SMTP:{this.mailReceiver}:{EscapeInput(this.subject, true)}:{EscapeInput(this.message, true)}"; + returnVal = $"SMTP:{this.mailReceiver}:{EscapeInput(this.subject ?? "", true)}:{EscapeInput(this.message ?? "", true)}"; break; } return returnVal; diff --git a/QRCoder/PayloadGenerator/MoneroTransaction.cs b/QRCoder/PayloadGenerator/MoneroTransaction.cs index 8deb0ddf..acedf10f 100644 --- a/QRCoder/PayloadGenerator/MoneroTransaction.cs +++ b/QRCoder/PayloadGenerator/MoneroTransaction.cs @@ -6,7 +6,8 @@ public static partial class PayloadGenerator { public class MoneroTransaction : Payload { - private readonly string address, txPaymentId, recipientName, txDescription; + private readonly string address; + private readonly string? txPaymentId, recipientName, txDescription; private readonly float? txAmount; /// @@ -17,7 +18,7 @@ public class MoneroTransaction : Payload /// Payment id /// Receipient's name /// Reference text / payment description - public MoneroTransaction(string address, float? txAmount = null, string txPaymentId = null, string recipientName = null, string txDescription = null) + public MoneroTransaction(string address, float? txAmount = null, string? txPaymentId = null, string? recipientName = null, string? txDescription = null) { if (string.IsNullOrEmpty(address)) throw new MoneroTransactionException("The address is mandatory and has to be set."); @@ -35,7 +36,7 @@ public override string ToString() var moneroUri = $"monero://{address}{(!string.IsNullOrEmpty(txPaymentId) || !string.IsNullOrEmpty(recipientName) || !string.IsNullOrEmpty(txDescription) || txAmount != null ? "?" : string.Empty)}"; moneroUri += (!string.IsNullOrEmpty(txPaymentId) ? $"tx_payment_id={Uri.EscapeDataString(txPaymentId)}&" : string.Empty); moneroUri += (!string.IsNullOrEmpty(recipientName) ? $"recipient_name={Uri.EscapeDataString(recipientName)}&" : string.Empty); - moneroUri += (txAmount != null ? $"tx_amount={txAmount.ToString().Replace(",",".")}&" : string.Empty); + moneroUri += (txAmount != null ? $"tx_amount={txAmount.ToString()!.Replace(",",".")}&" : string.Empty); moneroUri += (!string.IsNullOrEmpty(txDescription) ? $"tx_description={Uri.EscapeDataString(txDescription)}" : string.Empty); return moneroUri.TrimEnd('&'); } diff --git a/QRCoder/PayloadGenerator/OneTimePassword.cs b/QRCoder/PayloadGenerator/OneTimePassword.cs index b1fb0682..672919dc 100644 --- a/QRCoder/PayloadGenerator/OneTimePassword.cs +++ b/QRCoder/PayloadGenerator/OneTimePassword.cs @@ -9,7 +9,7 @@ public class OneTimePassword : Payload { //https://github.com/google/google-authenticator/wiki/Key-Uri-Format public OneTimePasswordAuthType Type { get; set; } = OneTimePasswordAuthType.TOTP; - public string Secret { get; set; } + public string Secret { get; set; } = null!; public OneTimePasswordAuthAlgorithm AuthAlgorithm { get; set; } = OneTimePasswordAuthAlgorithm.SHA1; @@ -20,8 +20,8 @@ public OoneTimePasswordAuthAlgorithm Algorithm set { AuthAlgorithm = (OneTimePasswordAuthAlgorithm)Enum.Parse(typeof(OneTimePasswordAuthAlgorithm), value.ToString()); } } - public string Issuer { get; set; } - public string Label { get; set; } + public string? Issuer { get; set; } + public string? Label { get; set; } public int Digits { get; set; } = 6; public int? Counter { get; set; } = null; public int? Period { get; set; } = 30; @@ -97,9 +97,9 @@ private void ProcessCommonFields(StringBuilder sb) throw new Exception("Secret must be a filled out base32 encoded string"); } string strippedSecret = Secret.Replace(" ", ""); - string escapedIssuer = null; - string escapedLabel = null; - string label = null; + string? escapedIssuer = null; + string? escapedLabel = null; + string? label = null; if (!Issuer.IsNullOrWhiteSpace()) { diff --git a/QRCoder/PayloadGenerator/RussiaPaymentOrder.cs b/QRCoder/PayloadGenerator/RussiaPaymentOrder.cs index 8e41b332..9bf96753 100644 --- a/QRCoder/PayloadGenerator/RussiaPaymentOrder.cs +++ b/QRCoder/PayloadGenerator/RussiaPaymentOrder.cs @@ -44,7 +44,7 @@ private RussiaPaymentOrder() /// Box number / account payee's bank (Номер кор./сч. банка получателя платежа) /// An (optional) object of additional fields /// Type of encoding (default UTF-8) - public RussiaPaymentOrder(string name, string personalAcc, string bankName, string BIC, string correspAcc, OptionalFields optionalFields = null, CharacterSets characterSet = CharacterSets.utf_8) : this() + public RussiaPaymentOrder(string name, string personalAcc, string bankName, string BIC, string correspAcc, OptionalFields? optionalFields = null, CharacterSets characterSet = CharacterSets.utf_8) : this() { this.characterSet = characterSet; mFields.Name = ValidateInput(name, "Name", @"^.{1,160}$"); @@ -156,7 +156,7 @@ private List GetOptionalFieldsAsList() .Where(field => field.GetValue(oFields, null) != null) .Select(field => { var objValue = field.GetValue(oFields, null); - var value = field.PropertyType.Equals(typeof(DateTime?)) ? ((DateTime)objValue).ToString("dd.MM.yyyy") : objValue.ToString(); + var value = field.PropertyType.Equals(typeof(DateTime?)) ? ((DateTime)objValue!).ToString("dd.MM.yyyy") : objValue!.ToString(); return $"{field.Name}={value}"; }) .ToList(); @@ -184,7 +184,7 @@ private List GetMandatoryFieldsAsList() .Where(field => field.GetValue(mFields) != null) .Select(field => { var objValue = field.GetValue(mFields); - var value = field.FieldType.Equals(typeof(DateTime?)) ? ((DateTime)objValue).ToString("dd.MM.yyyy") : objValue.ToString(); + var value = field.FieldType.Equals(typeof(DateTime?)) ? ((DateTime)objValue!).ToString("dd.MM.yyyy") : objValue!.ToString(); return $"{field.Name}={value}"; }) .ToList(); @@ -199,7 +199,7 @@ private List GetMandatoryFieldsAsList() /// A regex pattern to be used for validation /// An optional error text. If null, a standard error text is generated /// Input value (in case it is valid) - private static string ValidateInput(string input, string fieldname, string pattern, string errorText = null) + private static string ValidateInput(string input, string fieldname, string pattern, string? errorText = null) { return ValidateInput(input, fieldname, new string[] { pattern }, errorText); } @@ -212,7 +212,7 @@ private static string ValidateInput(string input, string fieldname, string patte /// An array of regex patterns to be used for validation /// An optional error text. If null, a standard error text is generated /// Input value (in case it is valid) - private static string ValidateInput(string input, string fieldname, string[] patterns, string errorText = null) + private static string ValidateInput(string input, string fieldname, string[] patterns, string? errorText = null) { if (input == null) throw new RussiaPaymentOrderException($"The input for '{fieldname}' must not be null."); @@ -226,134 +226,134 @@ private static string ValidateInput(string input, string fieldname, string[] pat private class MandatoryFields { - public string Name; - public string PersonalAcc; - public string BankName; - public string BIC; - public string CorrespAcc; + public string Name = null!; + public string PersonalAcc = null!; + public string BankName = null!; + public string BIC = null!; + public string CorrespAcc = null!; } public class OptionalFields { - private string _sum; + private string? _sum; /// /// Payment amount, in kopecks (FTI’s Amount.) /// Сумма платежа, в копейках /// - public string Sum + public string? Sum { get { return _sum; } - set { _sum = ValidateInput(value, "Sum", @"^\d{1,18}$"); } + set { _sum = value == null ? null : ValidateInput(value, "Sum", @"^\d{1,18}$"); } } - private string _purpose; + private string? _purpose; /// /// Payment name (purpose) /// Наименование платежа (назначение) /// - public string Purpose + public string? Purpose { get { return _purpose; } - set { _purpose = ValidateInput(value, "Purpose", @"^.{1,160}$"); } + set { _purpose = value == null ? null : ValidateInput(value, "Purpose", @"^.{1,160}$"); } } - private string _payeeInn; + private string? _payeeInn; /// /// Payee's INN (Resident Tax Identification Number; Text, up to 12 characters.) /// ИНН получателя платежа /// - public string PayeeINN + public string? PayeeINN { get { return _payeeInn; } - set { _payeeInn = ValidateInput(value, "PayeeINN", @"^.{1,12}$"); } + set { _payeeInn = value == null ? null : ValidateInput(value, "PayeeINN", @"^.{1,12}$"); } } - private string _payerInn; + private string? _payerInn; /// /// Payer's INN (Resident Tax Identification Number; Text, up to 12 characters.) /// ИНН плательщика /// - public string PayerINN + public string? PayerINN { get { return _payerInn; } - set { _payerInn = ValidateInput(value, "PayerINN", @"^.{1,12}$"); } + set { _payerInn = value == null ? null : ValidateInput(value, "PayerINN", @"^.{1,12}$"); } } - private string _drawerStatus; + private string? _drawerStatus; /// /// Status compiler payment document /// Статус составителя платежного документа /// - public string DrawerStatus + public string? DrawerStatus { get { return _drawerStatus; } - set { _drawerStatus = ValidateInput(value, "DrawerStatus", @"^.{1,2}$"); } + set { _drawerStatus = value == null ? null : ValidateInput(value, "DrawerStatus", @"^.{1,2}$"); } } - private string _kpp; + private string? _kpp; /// /// KPP of the payee (Tax Registration Code; Text, up to 9 characters.) /// КПП получателя платежа /// - public string KPP + public string? KPP { get { return _kpp; } - set { _kpp = ValidateInput(value, "KPP", @"^.{1,9}$"); } + set { _kpp = value == null ? null : ValidateInput(value, "KPP", @"^.{1,9}$"); } } - private string _cbc; + private string? _cbc; /// /// CBC /// КБК /// - public string CBC + public string? CBC { get { return _cbc; } - set { _cbc = ValidateInput(value, "CBC", @"^.{1,20}$"); } + set { _cbc = value == null ? null : ValidateInput(value, "CBC", @"^.{1,20}$"); } } - private string _oktmo; + private string? _oktmo; /// /// All-Russian classifier territories of municipal formations /// Общероссийский классификатор территорий муниципальных образований /// - public string OKTMO + public string? OKTMO { get { return _oktmo; } - set { _oktmo = ValidateInput(value, "OKTMO", @"^.{1,11}$"); } + set { _oktmo = value == null ? null : ValidateInput(value, "OKTMO", @"^.{1,11}$"); } } - private string _paytReason; + private string? _paytReason; /// /// Basis of tax payment /// Основание налогового платежа /// - public string PaytReason + public string? PaytReason { get { return _paytReason; } - set { _paytReason = ValidateInput(value, "PaytReason", @"^.{1,2}$"); } + set { _paytReason = value == null ? null : ValidateInput(value, "PaytReason", @"^.{1,2}$"); } } - private string _taxPeriod; + private string? _taxPeriod; /// /// Taxable period /// Налоговый период /// - public string TaxPeriod + public string? TaxPeriod { get { return _taxPeriod; } - set { _taxPeriod = ValidateInput(value, "ТaxPeriod", @"^.{1,10}$"); } + set { _taxPeriod = value == null ? null : ValidateInput(value, "ТaxPeriod", @"^.{1,10}$"); } } - private string _docNo; + private string? _docNo; /// /// Document number /// Номер документа /// - public string DocNo + public string? DocNo { get { return _docNo; } - set { _docNo = ValidateInput(value, "DocNo", @"^.{1,15}$"); } + set { _docNo = value == null ? null : ValidateInput(value, "DocNo", @"^.{1,15}$"); } } /// @@ -362,15 +362,15 @@ public string DocNo /// public DateTime? DocDate { get; set; } - private string _taxPaytKind; + private string? _taxPaytKind; /// /// Payment type /// Тип платежа /// - public string TaxPaytKind + public string? TaxPaytKind { get { return _taxPaytKind; } - set { _taxPaytKind = ValidateInput(value, "TaxPaytKind", @"^.{1,2}$"); } + set { _taxPaytKind = value == null ? null : ValidateInput(value, "TaxPaytKind", @"^.{1,2}$"); } } /************************************************************************** @@ -383,85 +383,85 @@ public string TaxPaytKind /// Payer's surname /// Фамилия плательщика /// - public string LastName { get; set; } + public string? LastName { get; set; } /// /// Payer's name /// Имя плательщика /// - public string FirstName { get; set; } + public string? FirstName { get; set; } /// /// Payer's patronymic /// Отчество плательщика /// - public string MiddleName { get; set; } + public string? MiddleName { get; set; } /// /// Payer's address /// Адрес плательщика /// - public string PayerAddress { get; set; } + public string? PayerAddress { get; set; } /// /// Personal account of a budget recipient /// Лицевой счет бюджетного получателя /// - public string PersonalAccount { get; set; } + public string? PersonalAccount { get; set; } /// /// Payment document index /// Индекс платежного документа /// - public string DocIdx { get; set; } + public string? DocIdx { get; set; } /// /// Personal account number in the personalized accounting system in the Pension Fund of the Russian Federation - SNILS /// № лицевого счета в системе персонифицированного учета в ПФР - СНИЛС /// - public string PensAcc { get; set; } + public string? PensAcc { get; set; } /// /// Number of contract /// Номер договора /// - public string Contract { get; set; } + public string? Contract { get; set; } /// /// Personal account number of the payer in the organization (in the accounting system of the PU) /// Номер лицевого счета плательщика в организации (в системе учета ПУ) /// - public string PersAcc { get; set; } + public string? PersAcc { get; set; } /// /// Apartment number /// Номер квартиры /// - public string Flat { get; set; } + public string? Flat { get; set; } /// /// Phone number /// Номер телефона /// - public string Phone { get; set; } + public string? Phone { get; set; } /// /// DUL payer type /// Вид ДУЛ плательщика /// - public string PayerIdType { get; set; } + public string? PayerIdType { get; set; } /// /// DUL number of the payer /// Номер ДУЛ плательщика /// - public string PayerIdNum { get; set; } + public string? PayerIdNum { get; set; } /// /// FULL NAME. child / student /// Ф.И.О. ребенка/учащегося /// - public string ChildFio { get; set; } + public string? ChildFio { get; set; } /// /// Date of birth @@ -473,43 +473,43 @@ public string TaxPaytKind /// Due date / Invoice date /// Срок платежа/дата выставления счета /// - public string PaymTerm { get; set; } + public string? PaymTerm { get; set; } /// /// Payment period /// Период оплаты /// - public string PaymPeriod { get; set; } + public string? PaymPeriod { get; set; } /// /// Payment type /// Вид платежа /// - public string Category { get; set; } + public string? Category { get; set; } /// /// Service code / meter name /// Код услуги/название прибора учета /// - public string ServiceName { get; set; } + public string? ServiceName { get; set; } /// /// Metering device number /// Номер прибора учета /// - public string CounterId { get; set; } + public string? CounterId { get; set; } /// /// Meter reading /// Показание прибора учета /// - public string CounterVal { get; set; } + public string? CounterVal { get; set; } /// /// Notification, accrual, account number /// Номер извещения, начисления, счета /// - public string QuittId { get; set; } + public string? QuittId { get; set; } /// /// Date of notification / accrual / invoice / resolution (for traffic police) @@ -521,49 +521,49 @@ public string TaxPaytKind /// Institution number (educational, medical) /// Номер учреждения (образовательного, медицинского) /// - public string InstNum { get; set; } + public string? InstNum { get; set; } /// /// Kindergarten / school class number /// Номер группы детсада/класса школы /// - public string ClassNum { get; set; } + public string? ClassNum { get; set; } /// /// Full name of the teacher, specialist providing the service /// ФИО преподавателя, специалиста, оказывающего услугу /// - public string SpecFio { get; set; } + public string? SpecFio { get; set; } /// /// Insurance / additional service amount / Penalty amount (in kopecks) /// Сумма страховки/дополнительной услуги/Сумма пени (в копейках) /// - public string AddAmount { get; set; } + public string? AddAmount { get; set; } /// /// Resolution number (for traffic police) /// Номер постановления (для ГИБДД) /// - public string RuleId { get; set; } + public string? RuleId { get; set; } /// /// Enforcement Proceedings Number /// Номер исполнительного производства /// - public string ExecId { get; set; } + public string? ExecId { get; set; } /// /// Type of payment code (for example, for payments to Rosreestr) /// Код вида платежа (например, для платежей в адрес Росреестра) /// - public string RegType { get; set; } + public string? RegType { get; set; } /// /// Unique accrual identifier /// Уникальный идентификатор начисления /// - public string UIN { get; set; } + public string? UIN { get; set; } /// /// The technical code recommended by the service provider. Maybe used by the receiving organization to call the appropriate processing IT system. diff --git a/QRCoder/PayloadGenerator/ShadowSocksConfig.cs b/QRCoder/PayloadGenerator/ShadowSocksConfig.cs index 61a6098d..a5a4278d 100644 --- a/QRCoder/PayloadGenerator/ShadowSocksConfig.cs +++ b/QRCoder/PayloadGenerator/ShadowSocksConfig.cs @@ -9,7 +9,8 @@ public static partial class PayloadGenerator { public class ShadowSocksConfig : Payload { - private readonly string hostname, password, tag, methodStr, parameter; + private readonly string hostname, password, methodStr; + private readonly string? tag, parameter; private readonly Method method; private readonly int port; private Dictionary encryptionTexts = new Dictionary() { @@ -66,11 +67,11 @@ public class ShadowSocksConfig : Payload /// Password of the SS proxy /// Encryption type /// Optional tag line - public ShadowSocksConfig(string hostname, int port, string password, Method method, string tag = null) : + public ShadowSocksConfig(string hostname, int port, string password, Method method, string? tag = null) : this(hostname, port, password, method, null, tag) { } - public ShadowSocksConfig(string hostname, int port, string password, Method method, string plugin, string pluginOption, string tag = null) : + public ShadowSocksConfig(string hostname, int port, string password, Method method, string plugin, string? pluginOption, string? tag = null) : this(hostname, port, password, method, new Dictionary { ["plugin"] = plugin + ( @@ -124,7 +125,7 @@ private string UrlEncode(string i) return j; } - public ShadowSocksConfig(string hostname, int port, string password, Method method, Dictionary parameters, string tag = null) + public ShadowSocksConfig(string hostname, int port, string password, Method method, Dictionary? parameters, string? tag = null) { this.hostname = Uri.CheckHostName(hostname) == UriHostNameType.IPv6 ? $"[{hostname}]" diff --git a/QRCoder/PayloadGenerator/SlovenianUpnQr.cs b/QRCoder/PayloadGenerator/SlovenianUpnQr.cs index 9d423946..cacf6a0c 100644 --- a/QRCoder/PayloadGenerator/SlovenianUpnQr.cs +++ b/QRCoder/PayloadGenerator/SlovenianUpnQr.cs @@ -45,7 +45,7 @@ public SlovenianUpnQr(string payerName, string payerAddress, string payerPlace, _amount = FormatAmount(amount); _code = LimitLength(code.Trim().ToUpper(), 4); _purpose = LimitLength(description.Trim(), 42); - _deadLine = (deadline == null) ? "" : deadline?.ToString("dd.MM.yyyy"); + _deadLine = (deadline == null) ? "" : deadline.Value.ToString("dd.MM.yyyy"); _recipientIban = LimitLength(recipientIban.Trim(), 34); _recipientName = LimitLength(recipientName.Trim(), 33); _recipientAddress = LimitLength(recipientAddress.Trim(), 33); diff --git a/QRCoder/PayloadGenerator/SwissQrCode.cs b/QRCoder/PayloadGenerator/SwissQrCode.cs index 06fcbbac..225563d5 100644 --- a/QRCoder/PayloadGenerator/SwissQrCode.cs +++ b/QRCoder/PayloadGenerator/SwissQrCode.cs @@ -16,10 +16,11 @@ public class SwissQrCode : Payload //Changes between version 1.0 and 2.0: https://www.paymentstandards.ch/dam/downloads/change-documentation-qrr-de.pdf private readonly string br = "\r\n"; - private readonly string alternativeProcedure1, alternativeProcedure2; + private readonly string? alternativeProcedure1, alternativeProcedure2; private readonly Iban iban; private readonly decimal? amount; - private readonly Contact creditor, ultimateCreditor, debitor; + private readonly Contact creditor; + private readonly Contact? ultimateCreditor, debitor; private readonly Currency currency; private readonly DateTime? requestedDateOfPayment; private readonly Reference reference; @@ -41,16 +42,16 @@ public class SwissQrCode : Payload /// Ultimate creditor information (use only in consultation with your bank - for future use only!) /// Optional command for alternative processing mode - line 1 /// Optional command for alternative processing mode - line 2 - public SwissQrCode(Iban iban, Currency currency, Contact creditor, Reference reference, AdditionalInformation additionalInformation = null, Contact debitor = null, decimal? amount = null, DateTime? requestedDateOfPayment = null, Contact ultimateCreditor = null, string alternativeProcedure1 = null, string alternativeProcedure2 = null) + public SwissQrCode(Iban iban, Currency currency, Contact creditor, Reference reference, AdditionalInformation? additionalInformation = null, Contact? debitor = null, decimal? amount = null, DateTime? requestedDateOfPayment = null, Contact? ultimateCreditor = null, string? alternativeProcedure1 = null, string? alternativeProcedure2 = null) { this.iban = iban; this.creditor = creditor; this.ultimateCreditor = ultimateCreditor; - this.additionalInformation = additionalInformation != null ? additionalInformation : new AdditionalInformation(); + this.additionalInformation = additionalInformation ?? new AdditionalInformation(); - if (amount != null && amount.ToString().Length > 12) + if (amount != null && amount.ToString()!.Length > 12) throw new SwissQrCodeException("Amount (including decimals) must be shorter than 13 places."); this.amount = amount; @@ -74,14 +75,15 @@ public SwissQrCode(Iban iban, Currency currency, Contact creditor, Reference ref public class AdditionalInformation { - private readonly string unstructuredMessage, billInformation, trailer; + private readonly string trailer; + private readonly string? unstructuredMessage, billInformation; /// /// Creates an additional information object. Both parameters are optional and must be shorter than 141 chars in combination. /// /// Unstructured text message /// Bill information - public AdditionalInformation(string unstructuredMessage = null, string billInformation = null) + public AdditionalInformation(string? unstructuredMessage = null, string? billInformation = null) { if (((unstructuredMessage != null ? unstructuredMessage.Length : 0) + (billInformation != null ? billInformation.Length : 0)) > 140) throw new SwissQrCodeAdditionalInformationException("Unstructured message and bill information must be shorter than 141 chars in total/combined."); @@ -90,14 +92,14 @@ public AdditionalInformation(string unstructuredMessage = null, string billInfor this.trailer = "EPD"; } - public string UnstructureMessage + public string? UnstructureMessage { - get { return !string.IsNullOrEmpty(unstructuredMessage) ? unstructuredMessage.Replace("\n", "") : null; } + get { return !string.IsNullOrEmpty(unstructuredMessage) ? unstructuredMessage!.Replace("\n", "") : null; } } - public string BillInformation + public string? BillInformation { - get { return !string.IsNullOrEmpty(billInformation) ? billInformation.Replace("\n", "") : null; } + get { return !string.IsNullOrEmpty(billInformation) ? billInformation!.Replace("\n", "") : null; } } public string Trailer @@ -127,7 +129,7 @@ public SwissQrCodeAdditionalInformationException(string message, Exception inner public class Reference { private readonly ReferenceType referenceType; - private readonly string reference; + private readonly string? reference; private readonly ReferenceTextType? referenceTextType; /// @@ -136,7 +138,7 @@ public class Reference /// Type of the reference (QRR, SCOR or NON) /// Reference text /// Type of the reference text (QR-reference or Creditor Reference) - public Reference(ReferenceType referenceType, string reference = null, ReferenceTextType? referenceTextType = null) + public Reference(ReferenceType referenceType, string? reference = null, ReferenceTextType? referenceTextType = null) { this.referenceType = referenceType; this.referenceTextType = referenceTextType; @@ -161,9 +163,9 @@ public ReferenceType RefType { get { return referenceType; } } - public string ReferenceText + public string? ReferenceText { - get { return !string.IsNullOrEmpty(reference) ? reference.Replace("\n", "") : null; } + get { return !string.IsNullOrEmpty(reference) ? reference!.Replace("\n", "") : null; } } /// @@ -260,7 +262,8 @@ public class Contact { private static readonly HashSet twoLetterCodes = ValidTwoLetterCodes(); private string br = "\r\n"; - private string name, streetOrAddressline1, houseNumberOrAddressline2, zipCode, city, country; + private string name, zipCode, city, country; + private string? streetOrAddressline1, houseNumberOrAddressline2; private AddressType adrType; /// @@ -273,7 +276,7 @@ public class Contact /// Streetname without house number /// House number [Obsolete("This constructor is deprecated. Use WithStructuredAddress instead.")] - public Contact(string name, string zipCode, string city, string country, string street = null, string houseNumber = null) : this (name, zipCode, city, country, street, houseNumber, AddressType.StructuredAddress) + public Contact(string name, string zipCode, string city, string country, string? street = null, string? houseNumber = null) : this (name, zipCode, city, country, street, houseNumber, AddressType.StructuredAddress) { } @@ -290,7 +293,7 @@ public Contact(string name, string country, string addressLine1, string addressL { } - public static Contact WithStructuredAddress(string name, string zipCode, string city, string country, string street = null, string houseNumber = null) + public static Contact WithStructuredAddress(string name, string zipCode, string city, string country, string? street = null, string? houseNumber = null) { return new Contact(name, zipCode, city, country, street, houseNumber, AddressType.StructuredAddress); } @@ -301,7 +304,7 @@ public static Contact WithCombinedAddress(string name, string country, string ad } - private Contact(string name, string zipCode, string city, string country, string streetOrAddressline1, string houseNumberOrAddressline2, AddressType addressType) + private Contact(string name, string? zipCode, string? city, string country, string? streetOrAddressline1, string? houseNumberOrAddressline2, AddressType addressType) { //Pattern extracted from https://qr-validation.iso-payments.ch as explained in https://github.com/codebude/QRCoder/issues/97 var charsetPattern = @"^([a-zA-Z0-9\.,;:'\ \+\-/\(\)?\*\[\]\{\}\\`´~ ^|]|[!""#%&<>÷=@_$£¡¢¤¥¦§¨©ª«¬®¯°±²³µ¶·¸¹º»¼½¾¿×Ø€]|[àáâäãåāăąçćĉċčďđèéêëēĕėęěĝğġģĥħìíîïĩīĭįıijķĸĺļľŀłñńņňʼnŋòóôöōŏőõŕŗřśŝşšșţťŧțùúûüũūŭůűųŵýÿŷźżžßÀÁÂÄÃÅĀĂĄÇĆĈĊČĎĐÈÉÊËĒĔĖĘĚĜĞĠĢĤĦÌÍÎÏĨĪĬĮİIJĴĵĶĹĻĽĿŁÑŃŅŇŊÒÓÔÖÕŌŎŐŔŖŘŚŜŞŠȘŢŤŦȚÙÚÛÜŨŪŬŮŰŲŴÝŶŸŹŻŽÆÐÞæðøþŒœſ])*$"; @@ -318,19 +321,19 @@ private Contact(string name, string zipCode, string city, string country, string if (AddressType.StructuredAddress == this.adrType) { - if (!string.IsNullOrEmpty(streetOrAddressline1) && (streetOrAddressline1.Length > 70)) + if (!string.IsNullOrEmpty(streetOrAddressline1) && (streetOrAddressline1!.Length > 70)) throw new SwissQrCodeContactException("Street must be shorter than 71 chars."); if (!string.IsNullOrEmpty(streetOrAddressline1) && !Regex.IsMatch(streetOrAddressline1, charsetPattern)) throw new SwissQrCodeContactException($"Street must match the following pattern as defined in pain.001: {charsetPattern}"); this.streetOrAddressline1 = streetOrAddressline1; - if (!string.IsNullOrEmpty(houseNumberOrAddressline2) && houseNumberOrAddressline2.Length > 16) + if (!string.IsNullOrEmpty(houseNumberOrAddressline2) && houseNumberOrAddressline2!.Length > 16) throw new SwissQrCodeContactException("House number must be shorter than 17 chars."); this.houseNumberOrAddressline2 = houseNumberOrAddressline2; } else { - if (!string.IsNullOrEmpty(streetOrAddressline1) && (streetOrAddressline1.Length > 70)) + if (!string.IsNullOrEmpty(streetOrAddressline1) && (streetOrAddressline1!.Length > 70)) throw new SwissQrCodeContactException("Address line 1 must be shorter than 71 chars."); if (!string.IsNullOrEmpty(streetOrAddressline1) && !Regex.IsMatch(streetOrAddressline1, charsetPattern)) throw new SwissQrCodeContactException($"Address line 1 must match the following pattern as defined in pain.001: {charsetPattern}"); @@ -338,7 +341,7 @@ private Contact(string name, string zipCode, string city, string country, string if (string.IsNullOrEmpty(houseNumberOrAddressline2)) throw new SwissQrCodeContactException("Address line 2 must be provided for combined addresses (address line-based addresses)."); - if (!string.IsNullOrEmpty(houseNumberOrAddressline2) && (houseNumberOrAddressline2.Length > 70)) + if (!string.IsNullOrEmpty(houseNumberOrAddressline2) && (houseNumberOrAddressline2!.Length > 70)) throw new SwissQrCodeContactException("Address line 2 must be shorter than 71 chars."); if (!string.IsNullOrEmpty(houseNumberOrAddressline2) && !Regex.IsMatch(houseNumberOrAddressline2, charsetPattern)) throw new SwissQrCodeContactException($"Address line 2 must match the following pattern as defined in pain.001: {charsetPattern}"); @@ -348,7 +351,7 @@ private Contact(string name, string zipCode, string city, string country, string if (AddressType.StructuredAddress == this.adrType) { if (string.IsNullOrEmpty(zipCode)) throw new SwissQrCodeContactException("Zip code must not be empty."); - if (zipCode.Length > 16) + if (zipCode!.Length > 16) throw new SwissQrCodeContactException("Zip code must be shorter than 17 chars."); if (!Regex.IsMatch(zipCode, charsetPattern)) throw new SwissQrCodeContactException($"Zip code must match the following pattern as defined in pain.001: {charsetPattern}"); @@ -356,7 +359,7 @@ private Contact(string name, string zipCode, string city, string country, string if (string.IsNullOrEmpty(city)) throw new SwissQrCodeContactException("City must not be empty."); - if (city.Length > 35) + if (city!.Length > 35) throw new SwissQrCodeContactException("City name must be shorter than 36 chars."); if (!Regex.IsMatch(city, charsetPattern)) throw new SwissQrCodeContactException($"City name must match the following pattern as defined in pain.001: {charsetPattern}"); @@ -385,8 +388,8 @@ public override string ToString() { string contactData = $"{(AddressType.StructuredAddress == adrType ? "S" : "K")}{br}"; //AdrTp contactData += name.Replace("\n", "") + br; //Name - contactData += (!string.IsNullOrEmpty(streetOrAddressline1) ? streetOrAddressline1.Replace("\n","") : string.Empty) + br; //StrtNmOrAdrLine1 - contactData += (!string.IsNullOrEmpty(houseNumberOrAddressline2) ? houseNumberOrAddressline2.Replace("\n", "") : string.Empty) + br; //BldgNbOrAdrLine2 + contactData += (!string.IsNullOrEmpty(streetOrAddressline1) ? streetOrAddressline1!.Replace("\n","") : string.Empty) + br; //StrtNmOrAdrLine1 + contactData += (!string.IsNullOrEmpty(houseNumberOrAddressline2) ? houseNumberOrAddressline2!.Replace("\n", "") : string.Empty) + br; //BldgNbOrAdrLine2 contactData += zipCode.Replace("\n", "") + br; //PstCd contactData += city.Replace("\n", "") + br; //TwnNm contactData += country + br; //Ctry @@ -462,9 +465,9 @@ public override string ToString() //AltPmtInf "logical" element if (!string.IsNullOrEmpty(alternativeProcedure1)) - SwissQrCodePayload += alternativeProcedure1.Replace("\n", "") + br; //AltPmt + SwissQrCodePayload += alternativeProcedure1!.Replace("\n", "") + br; //AltPmt if (!string.IsNullOrEmpty(alternativeProcedure2)) - SwissQrCodePayload += alternativeProcedure2.Replace("\n", "") + br; //AltPmt + SwissQrCodePayload += alternativeProcedure2!.Replace("\n", "") + br; //AltPmt //S-QR specification 2.0, chapter 4.2.3 if (SwissQrCodePayload.EndsWith(br)) diff --git a/QRCoder/PdfByteQRCode.cs b/QRCoder/PdfByteQRCode.cs index 68269eed..14854139 100644 --- a/QRCoder/PdfByteQRCode.cs +++ b/QRCoder/PdfByteQRCode.cs @@ -62,7 +62,7 @@ private byte[] HexColorToByteArray(string colorString) /// public byte[] GetGraphic(int pixelsPerModule, string darkColorHtmlHex, string lightColorHtmlHex, int dpi = 150, long jpgQuality = 85) { - byte[] jpgArray = null, pngArray = null; + byte[] jpgArray, pngArray; var imgSize = QrCodeData.ModuleMatrix.Count * pixelsPerModule; var pdfMediaSize = (imgSize * 72 / dpi).ToString(CultureInfo.InvariantCulture); diff --git a/QRCoder/PngByteQRCode.cs b/QRCoder/PngByteQRCode.cs index 239287d7..c21ada11 100644 --- a/QRCoder/PngByteQRCode.cs +++ b/QRCoder/PngByteQRCode.cs @@ -131,7 +131,7 @@ public enum ColorType : byte public void Dispose() { this.stream?.Dispose(); - this.stream = null; + this.stream = null!; } public byte[] GetBytes() diff --git a/QRCoder/PostscriptQRCode.cs b/QRCoder/PostscriptQRCode.cs index d0484a9b..42953886 100644 --- a/QRCoder/PostscriptQRCode.cs +++ b/QRCoder/PostscriptQRCode.cs @@ -25,7 +25,7 @@ public string GetGraphic(int pointsPerModule, Color darkColor, Color lightColor, return this.GetGraphic(viewBox, darkColor, lightColor, drawQuietZones, epsFormat); } - public string GetGraphic(int pointsPerModule, string darkColorHex, string lightColorHex, bool drawQuietZones = true, bool epsFormat = false) + public string GetGraphic(int pointsPerModule, string? darkColorHex, string? lightColorHex, bool drawQuietZones = true, bool epsFormat = false) { var viewBox = new Size(pointsPerModule * this.QrCodeData.ModuleMatrix.Count, pointsPerModule * this.QrCodeData.ModuleMatrix.Count); return this.GetGraphic(viewBox, darkColorHex, lightColorHex, drawQuietZones, epsFormat); @@ -36,9 +36,9 @@ public string GetGraphic(Size viewBox, bool drawQuietZones = true, bool epsForma return this.GetGraphic(viewBox, Color.Black, Color.White, drawQuietZones, epsFormat); } - public string GetGraphic(Size viewBox, string darkColorHex, string lightColorHex, bool drawQuietZones = true, bool epsFormat = false) + public string GetGraphic(Size viewBox, string? darkColorHex, string? lightColorHex, bool drawQuietZones = true, bool epsFormat = false) { - return this.GetGraphic(viewBox, ColorTranslator.FromHtml(darkColorHex), ColorTranslator.FromHtml(lightColorHex), drawQuietZones, epsFormat); + return this.GetGraphic(viewBox, ColorTranslator.FromHtml(darkColorHex!), ColorTranslator.FromHtml(lightColorHex!), drawQuietZones, epsFormat); } public string GetGraphic(Size viewBox, Color darkColor, Color lightColor, bool drawQuietZones = true, bool epsFormat = false) @@ -142,7 +142,7 @@ sc sc scale public static class PostscriptQRCodeHelper { - public static string GetQRCode(string plainText, int pointsPerModule, string darkColorHex, string lightColorHex, ECCLevel eccLevel, bool forceUtf8 = false, bool utf8BOM = false, EciMode eciMode = EciMode.Default, int requestedVersion = -1, bool drawQuietZones = true, bool epsFormat = false) + public static string GetQRCode(string plainText, int pointsPerModule, string? darkColorHex, string? lightColorHex, ECCLevel eccLevel, bool forceUtf8 = false, bool utf8BOM = false, EciMode eciMode = EciMode.Default, int requestedVersion = -1, bool drawQuietZones = true, bool epsFormat = false) { using (var qrGenerator = new QRCodeGenerator()) using (var qrCodeData = qrGenerator.CreateQrCode(plainText, eccLevel, forceUtf8, utf8BOM, eciMode, requestedVersion)) diff --git a/QRCoder/QRCode.cs b/QRCoder/QRCode.cs index 6ba4b629..29efc638 100644 --- a/QRCoder/QRCode.cs +++ b/QRCoder/QRCode.cs @@ -16,16 +16,16 @@ public class QRCode : AbstractQRCode, IDisposable /// public QRCode() { } - public QRCode(QRCodeData data) : base(data) {} + public QRCode(QRCodeData data) : base(data) { } public Bitmap GetGraphic(int pixelsPerModule) { return this.GetGraphic(pixelsPerModule, Color.Black, Color.White, true); } - public Bitmap GetGraphic(int pixelsPerModule, string darkColorHtmlHex, string lightColorHtmlHex, bool drawQuietZones = true) + public Bitmap GetGraphic(int pixelsPerModule, string? darkColorHtmlHex, string? lightColorHtmlHex, bool drawQuietZones = true) { - return this.GetGraphic(pixelsPerModule, ColorTranslator.FromHtml(darkColorHtmlHex), ColorTranslator.FromHtml(lightColorHtmlHex), drawQuietZones); + return this.GetGraphic(pixelsPerModule, ColorTranslator.FromHtml(darkColorHtmlHex!), ColorTranslator.FromHtml(lightColorHtmlHex!), drawQuietZones); } public Bitmap GetGraphic(int pixelsPerModule, Color darkColor, Color lightColor, bool drawQuietZones = true) @@ -61,7 +61,7 @@ public Bitmap GetGraphic(int pixelsPerModule, Color darkColor, Color lightColor, return bmp; } - public Bitmap GetGraphic(int pixelsPerModule, Color darkColor, Color lightColor, Bitmap icon=null, int iconSizePercent=15, int iconBorderWidth = 0, bool drawQuietZones = true, Color? iconBackgroundColor = null) + public Bitmap GetGraphic(int pixelsPerModule, Color darkColor, Color lightColor, Bitmap? icon = null, int iconSizePercent = 15, int iconBorderWidth = 0, bool drawQuietZones = true, Color? iconBackgroundColor = null) { var size = (this.QrCodeData.ModuleMatrix.Count - (drawQuietZones ? 0 : 8)) * pixelsPerModule; var offset = drawQuietZones ? 0 : 4 * pixelsPerModule; @@ -76,20 +76,20 @@ public Bitmap GetGraphic(int pixelsPerModule, Color darkColor, Color lightColor, gfx.CompositingQuality = CompositingQuality.HighQuality; gfx.Clear(lightColor); var drawIconFlag = icon != null && iconSizePercent > 0 && iconSizePercent <= 100; - + for (var x = 0; x < size + offset; x = x + pixelsPerModule) { for (var y = 0; y < size + offset; y = y + pixelsPerModule) { var moduleBrush = this.QrCodeData.ModuleMatrix[(y + pixelsPerModule) / pixelsPerModule - 1][(x + pixelsPerModule) / pixelsPerModule - 1] ? darkBrush : lightBrush; - gfx.FillRectangle(moduleBrush , new Rectangle(x - offset, y - offset, pixelsPerModule, pixelsPerModule)); + gfx.FillRectangle(moduleBrush, new Rectangle(x - offset, y - offset, pixelsPerModule, pixelsPerModule)); } } if (drawIconFlag) { float iconDestWidth = iconSizePercent * bmp.Width / 100f; - float iconDestHeight = drawIconFlag ? iconDestWidth * icon.Height / icon.Width : 0; + float iconDestHeight = drawIconFlag ? iconDestWidth * icon!.Height / icon.Width : 0; float iconX = (bmp.Width - iconDestWidth) / 2; float iconY = (bmp.Height - iconDestHeight) / 2; var centerDest = new RectangleF(iconX - iconBorderWidth, iconY - iconBorderWidth, iconDestWidth + iconBorderWidth * 2, iconDestHeight + iconBorderWidth * 2); @@ -97,13 +97,13 @@ public Bitmap GetGraphic(int pixelsPerModule, Color darkColor, Color lightColor, var iconBgBrush = iconBackgroundColor != null ? new SolidBrush((Color)iconBackgroundColor) : lightBrush; //Only render icon/logo background, if iconBorderWith is set > 0 if (iconBorderWidth > 0) - { + { using (GraphicsPath iconPath = CreateRoundedRectanglePath(centerDest, iconBorderWidth * 2)) - { + { gfx.FillPath(iconBgBrush, iconPath); } } - gfx.DrawImage(icon, iconDestRect, new RectangleF(0, 0, icon.Width, icon.Height), GraphicsUnit.Pixel); + gfx.DrawImage(icon!, iconDestRect, new RectangleF(0, 0, icon!.Width, icon.Height), GraphicsUnit.Pixel); } gfx.Save(); @@ -133,7 +133,7 @@ internal GraphicsPath CreateRoundedRectanglePath(RectangleF rect, int cornerRadi #endif public static class QRCodeHelper { - public static Bitmap GetQRCode(string plainText, int pixelsPerModule, Color darkColor, Color lightColor, ECCLevel eccLevel, bool forceUtf8 = false, bool utf8BOM = false, EciMode eciMode = EciMode.Default, int requestedVersion = -1, Bitmap icon = null, int iconSizePercent = 15, int iconBorderWidth = 0, bool drawQuietZones = true) + public static Bitmap GetQRCode(string plainText, int pixelsPerModule, Color darkColor, Color lightColor, ECCLevel eccLevel, bool forceUtf8 = false, bool utf8BOM = false, EciMode eciMode = EciMode.Default, int requestedVersion = -1, Bitmap? icon = null, int iconSizePercent = 15, int iconBorderWidth = 0, bool drawQuietZones = true) { using (var qrGenerator = new QRCodeGenerator()) using (var qrCodeData = qrGenerator.CreateQrCode(plainText, eccLevel, forceUtf8, utf8BOM, eciMode, requestedVersion)) diff --git a/QRCoder/QRCodeData.cs b/QRCoder/QRCodeData.cs index dbb0f06c..5a553458 100644 --- a/QRCoder/QRCodeData.cs +++ b/QRCoder/QRCodeData.cs @@ -174,7 +174,7 @@ private static int ModulesPerSideFromVersion(int version) public void Dispose() { - this.ModuleMatrix = null; + this.ModuleMatrix = null!; this.Version = 0; } diff --git a/QRCoder/QRCodeGenerator.cs b/QRCoder/QRCodeGenerator.cs index f8da2bf6..dd7897f0 100644 --- a/QRCoder/QRCodeGenerator.cs +++ b/QRCoder/QRCodeGenerator.cs @@ -914,7 +914,7 @@ private static BitArray PlainTextToBinaryAlphanumeric(string plainText) #else Encoding.GetEncoding(28591); // ISO-8859-1 #endif - private static Encoding _iso8859_2; + private static Encoding? _iso8859_2; /// /// Converts plain text into a binary format using byte mode encoding, which supports various character encodings through ECI (Extended Channel Interpretations). @@ -954,8 +954,7 @@ private static BitArray PlainTextToBinaryByte(string plainText, EciMode eciMode, // // Users must install the System.Text.Encoding.CodePages package and call Encoding.RegisterProvider(CodePagesEncodingProvider.Instance) // before using this encoding mode. - if (_iso8859_2 == null) - _iso8859_2 = Encoding.GetEncoding(28592); // ISO-8859-2 + _iso8859_2 ??= Encoding.GetEncoding(28592); // ISO-8859-2 // Convert text to ISO-8859-2 and encode. targetEncoding = _iso8859_2; utf8BOM = false; @@ -974,7 +973,7 @@ private static BitArray PlainTextToBinaryByte(string plainText, EciMode eciMode, const int MAX_STACK_SIZE_IN_BYTES = 512; int count = targetEncoding.GetByteCount(plainText); - byte[] bufferFromPool = null; + byte[]? bufferFromPool = null; Span codeBytes = (count <= MAX_STACK_SIZE_IN_BYTES) ? (stackalloc byte[MAX_STACK_SIZE_IN_BYTES]) : (bufferFromPool = ArrayPool.Shared.Rent(count)); diff --git a/QRCoder/QRCodeGenerator/ModulePlacer.BlockedModules.cs b/QRCoder/QRCodeGenerator/ModulePlacer.BlockedModules.cs index 555bc143..94f4a1db 100644 --- a/QRCoder/QRCodeGenerator/ModulePlacer.BlockedModules.cs +++ b/QRCoder/QRCodeGenerator/ModulePlacer.BlockedModules.cs @@ -15,7 +15,7 @@ public struct BlockedModules : IDisposable { private readonly BitArray[] _blockedModules; - private static BitArray[] _staticBlockedModules; + private static BitArray[]? _staticBlockedModules; /// /// Initializes a new instance of the struct with a specified capacity. @@ -23,7 +23,7 @@ public struct BlockedModules : IDisposable /// The initial capacity of the blocked modules list. public BlockedModules(int size) { - _blockedModules = Interlocked.Exchange(ref _staticBlockedModules, null); + _blockedModules = Interlocked.Exchange(ref _staticBlockedModules, null)!; if (_blockedModules != null && _blockedModules.Length >= size) { for (int i = 0; i < size; i++) diff --git a/QRCoder/QRCodeGenerator/ModulePlacer.cs b/QRCoder/QRCodeGenerator/ModulePlacer.cs index 5bcd49d8..f83142b1 100644 --- a/QRCoder/QRCodeGenerator/ModulePlacer.cs +++ b/QRCoder/QRCodeGenerator/ModulePlacer.cs @@ -90,7 +90,7 @@ public static int MaskCode(QRCodeData qrCode, int version, BlockedModules blocke // Temporary QRCodeData object to test different mask patterns without altering the original. var qrTemp = new QRCodeData(version, false); - BitArray versionString = null; + BitArray? versionString = null; if (version >= 7) { versionString = new BitArray(18); @@ -115,7 +115,7 @@ public static int MaskCode(QRCodeData qrCode, int version, BlockedModules blocke ModulePlacer.PlaceFormat(qrTemp, formatStr, false); // Place version information if applicable. - if (version >= 7) + if (versionString != null) // aka if (version >= 7) { ModulePlacer.PlaceVersion(qrTemp, versionString, false); } diff --git a/QRCoder/QRCodeGenerator/Polynom.cs b/QRCoder/QRCodeGenerator/Polynom.cs index 90d7239a..01a02b62 100644 --- a/QRCoder/QRCodeGenerator/Polynom.cs +++ b/QRCoder/QRCodeGenerator/Polynom.cs @@ -171,7 +171,7 @@ public override string ToString() public void Dispose() { ReturnArray(_polyItems); - _polyItems = null; + _polyItems = null!; } /// @@ -219,7 +219,7 @@ private static void ReturnArray(PolynomItem[] array) #else // Implement a poor-man's array pool for .NET Framework [ThreadStatic] - private static List _arrayPool; + private static List? _arrayPool; /// /// Rents memory for the polynomial terms from a shared memory pool. @@ -258,7 +258,7 @@ void ThrowArgumentOutOfRangeException() private static void ReturnArray(PolynomItem[] array) { if (array == null) - ThrowArgumentNullException(); + return; // Initialize the thread-local pool if it's not already done if (_arrayPool == null) @@ -266,11 +266,6 @@ private static void ReturnArray(PolynomItem[] array) // Add the buffer back to the pool _arrayPool.Add(array); - - void ThrowArgumentNullException() - { - throw new ArgumentNullException(nameof(array)); - } } #endif diff --git a/QRCoder/QRCoder.csproj b/QRCoder/QRCoder.csproj index cb1bb0a9..d42fcc06 100644 --- a/QRCoder/QRCoder.csproj +++ b/QRCoder/QRCoder.csproj @@ -9,6 +9,8 @@ false true true + enable + 9.0 diff --git a/QRCoder/SvgQRCode.cs b/QRCoder/SvgQRCode.cs index 2ac3b4d7..c0056794 100644 --- a/QRCoder/SvgQRCode.cs +++ b/QRCoder/SvgQRCode.cs @@ -40,7 +40,7 @@ public string GetGraphic(int pixelsPerModule) /// Defines if width/height or viewbox should be used for size definition /// A (optional) logo to be rendered on the code (either Bitmap or SVG) /// SVG as string - public string GetGraphic(int pixelsPerModule, Color darkColor, Color lightColor, bool drawQuietZones = true, SizingMode sizingMode = SizingMode.WidthHeightAttribute, SvgLogo logo = null) + public string GetGraphic(int pixelsPerModule, Color darkColor, Color lightColor, bool drawQuietZones = true, SizingMode sizingMode = SizingMode.WidthHeightAttribute, SvgLogo? logo = null) { var offset = drawQuietZones ? 0 : 4; var edgeSize = this.QrCodeData.ModuleMatrix.Count * pixelsPerModule - (offset * 2 * pixelsPerModule); @@ -58,7 +58,7 @@ public string GetGraphic(int pixelsPerModule, Color darkColor, Color lightColor, /// Defines if width/height or viewbox should be used for size definition /// A (optional) logo to be rendered on the code (either Bitmap or SVG) /// SVG as string - public string GetGraphic(int pixelsPerModule, string darkColorHex, string lightColorHex, bool drawQuietZones = true, SizingMode sizingMode = SizingMode.WidthHeightAttribute, SvgLogo logo = null) + public string GetGraphic(int pixelsPerModule, string darkColorHex, string lightColorHex, bool drawQuietZones = true, SizingMode sizingMode = SizingMode.WidthHeightAttribute, SvgLogo? logo = null) { var offset = drawQuietZones ? 0 : 4; var edgeSize = this.QrCodeData.ModuleMatrix.Count * pixelsPerModule - (offset * 2 * pixelsPerModule); @@ -74,7 +74,7 @@ public string GetGraphic(int pixelsPerModule, string darkColorHex, string lightC /// Defines if width/height or viewbox should be used for size definition /// A (optional) logo to be rendered on the code (either Bitmap or SVG) /// SVG as string - public string GetGraphic(Size viewBox, bool drawQuietZones = true, SizingMode sizingMode = SizingMode.WidthHeightAttribute, SvgLogo logo = null) + public string GetGraphic(Size viewBox, bool drawQuietZones = true, SizingMode sizingMode = SizingMode.WidthHeightAttribute, SvgLogo? logo = null) { return this.GetGraphic(viewBox, Color.Black, Color.White, drawQuietZones, sizingMode, logo); } @@ -89,7 +89,7 @@ public string GetGraphic(Size viewBox, bool drawQuietZones = true, SizingMode si /// Defines if width/height or viewbox should be used for size definition /// A (optional) logo to be rendered on the code (either Bitmap or SVG) /// SVG as string - public string GetGraphic(Size viewBox, Color darkColor, Color lightColor, bool drawQuietZones = true, SizingMode sizingMode = SizingMode.WidthHeightAttribute, SvgLogo logo = null) + public string GetGraphic(Size viewBox, Color darkColor, Color lightColor, bool drawQuietZones = true, SizingMode sizingMode = SizingMode.WidthHeightAttribute, SvgLogo? logo = null) { return this.GetGraphic(viewBox, ColorTranslator.ToHtml(Color.FromArgb(darkColor.ToArgb())), ColorTranslator.ToHtml(Color.FromArgb(lightColor.ToArgb())), drawQuietZones, sizingMode, logo); } @@ -104,7 +104,7 @@ public string GetGraphic(Size viewBox, Color darkColor, Color lightColor, bool d /// Defines if width/height or viewbox should be used for size definition /// A (optional) logo to be rendered on the code (either Bitmap or SVG) /// SVG as string - public string GetGraphic(Size viewBox, string darkColorHex, string lightColorHex, bool drawQuietZones = true, SizingMode sizingMode = SizingMode.WidthHeightAttribute, SvgLogo logo = null) + public string GetGraphic(Size viewBox, string darkColorHex, string lightColorHex, bool drawQuietZones = true, SizingMode sizingMode = SizingMode.WidthHeightAttribute, SvgLogo? logo = null) { int offset = drawQuietZones ? 0 : 4; int drawableModulesCount = this.QrCodeData.ModuleMatrix.Count - (drawQuietZones ? 0 : offset * 2); @@ -126,7 +126,7 @@ public string GetGraphic(Size viewBox, string darkColorHex, string lightColorHex for (int xi = 0; xi < drawableModulesCount; xi += 1) { matrix[yi, xi] = 0; - if (bitArray[xi+offset] && (logo == null || !logo.FillLogoBackground() || !IsBlockedByLogo(xi * pixelsPerModule, yi * pixelsPerModule, logoAttr, pixelsPerModule))) + if (bitArray[xi+offset] && (logo == null || !logo.FillLogoBackground() || !IsBlockedByLogo(xi * pixelsPerModule, yi * pixelsPerModule, logoAttr!.Value, pixelsPerModule))) { if(x0 == -1) { @@ -178,7 +178,7 @@ public string GetGraphic(Size viewBox, string darkColorHex, string lightColorHex // Output SVG rectangles double x = xi * pixelsPerModule; - if (logo == null || !logo.FillLogoBackground() || !IsBlockedByLogo(x, y, logoAttr, pixelsPerModule)) + if (logo == null || !logo.FillLogoBackground() || !IsBlockedByLogo(x, y, logoAttr!.Value, pixelsPerModule)) svgFile.AppendLine($@""); } } @@ -190,14 +190,14 @@ public string GetGraphic(Size viewBox, string darkColorHex, string lightColorHex if (!logo.IsEmbedded()) { svgFile.AppendLine($@""); - svgFile.AppendLine($@""); + svgFile.AppendLine($@""); svgFile.AppendLine(@""); } else { var rawLogo = (string)logo.GetRawLogo(); var svg = System.Xml.Linq.XDocument.Parse(rawLogo); - svg.Root.SetAttributeValue("x", CleanSvgVal(logoAttr.Value.X)); + svg.Root!.SetAttributeValue("x", CleanSvgVal(logoAttr!.Value.X)); svg.Root.SetAttributeValue("y", CleanSvgVal(logoAttr.Value.Y)); svg.Root.SetAttributeValue("width", CleanSvgVal(logoAttr.Value.Width)); svg.Root.SetAttributeValue("height", CleanSvgVal(logoAttr.Value.Height)); @@ -210,9 +210,9 @@ public string GetGraphic(Size viewBox, string darkColorHex, string lightColorHex return svgFile.ToString(); } - private bool IsBlockedByLogo(double x, double y, ImageAttributes? attr, double pixelPerModule) + private bool IsBlockedByLogo(double x, double y, ImageAttributes attr, double pixelPerModule) { - return x + pixelPerModule >= attr.Value.X && x <= attr.Value.X + attr.Value.Width && y + pixelPerModule >= attr.Value.Y && y <= attr.Value.Y + attr.Value.Height; + return x + pixelPerModule >= attr.X && x <= attr.X + attr.Width && y + pixelPerModule >= attr.Y && y <= attr.Y + attr.Height; } private ImageAttributes GetLogoAttributes(SvgLogo logo, Size viewBox) @@ -416,7 +416,7 @@ private string GetMimeType(MediaType type) public static class SvgQRCodeHelper { - public static string GetQRCode(string plainText, int pixelsPerModule, string darkColorHex, string lightColorHex, ECCLevel eccLevel, bool forceUtf8 = false, bool utf8BOM = false, EciMode eciMode = EciMode.Default, int requestedVersion = -1, bool drawQuietZones = true, SizingMode sizingMode = SizingMode.WidthHeightAttribute, SvgLogo logo = null) + public static string GetQRCode(string plainText, int pixelsPerModule, string darkColorHex, string lightColorHex, ECCLevel eccLevel, bool forceUtf8 = false, bool utf8BOM = false, EciMode eciMode = EciMode.Default, int requestedVersion = -1, bool drawQuietZones = true, SizingMode sizingMode = SizingMode.WidthHeightAttribute, SvgLogo? logo = null) { using (var qrGenerator = new QRCodeGenerator()) using (var qrCodeData = qrGenerator.CreateQrCode(plainText, eccLevel, forceUtf8, utf8BOM, eciMode, requestedVersion)) diff --git a/QRCoderApiTests/net35+net40+net50+net50-windows+netstandard20/QRCoder.approved.txt b/QRCoderApiTests/net35+net40+net50+net50-windows+netstandard20/QRCoder.approved.txt index 4c5794a4..4df87c92 100644 --- a/QRCoderApiTests/net35+net40+net50+net50-windows+netstandard20/QRCoder.approved.txt +++ b/QRCoderApiTests/net35+net40+net50+net50-windows+netstandard20/QRCoder.approved.txt @@ -12,9 +12,9 @@ namespace QRCoder { public ArtQRCode() { } public ArtQRCode(QRCoder.QRCodeData data) { } - public System.Drawing.Bitmap GetGraphic(System.Drawing.Bitmap backgroundImage = null) { } + public System.Drawing.Bitmap GetGraphic(System.Drawing.Bitmap? backgroundImage = null) { } public System.Drawing.Bitmap GetGraphic(int pixelsPerModule) { } - public System.Drawing.Bitmap GetGraphic(int pixelsPerModule, System.Drawing.Color darkColor, System.Drawing.Color lightColor, System.Drawing.Color backgroundColor, System.Drawing.Bitmap backgroundImage = null, double pixelSizeFactor = 1, bool drawQuietZones = true, QRCoder.ArtQRCode.QuietZoneStyle quietZoneRenderingStyle = 0, QRCoder.ArtQRCode.BackgroundImageStyle backgroundImageStyle = 1, System.Drawing.Bitmap finderPatternImage = null) { } + public System.Drawing.Bitmap GetGraphic(int pixelsPerModule, System.Drawing.Color darkColor, System.Drawing.Color lightColor, System.Drawing.Color backgroundColor, System.Drawing.Bitmap? backgroundImage = null, double pixelSizeFactor = 1, bool drawQuietZones = true, QRCoder.ArtQRCode.QuietZoneStyle quietZoneRenderingStyle = 0, QRCoder.ArtQRCode.BackgroundImageStyle backgroundImageStyle = 1, System.Drawing.Bitmap? finderPatternImage = null) { } public enum BackgroundImageStyle { Fill = 0, @@ -39,12 +39,12 @@ namespace QRCoder bool utf8BOM = false, QRCoder.QRCodeGenerator.EciMode eciMode = 0, int requestedVersion = -1, - System.Drawing.Bitmap backgroundImage = null, + System.Drawing.Bitmap? backgroundImage = null, double pixelSizeFactor = 1, bool drawQuietZones = true, QRCoder.ArtQRCode.QuietZoneStyle quietZoneRenderingStyle = 1, QRCoder.ArtQRCode.BackgroundImageStyle backgroundImageStyle = 1, - System.Drawing.Bitmap finderPatternImage = null) { } + System.Drawing.Bitmap? finderPatternImage = null) { } } public class AsciiQRCode : QRCoder.AbstractQRCode, System.IDisposable { @@ -345,15 +345,15 @@ namespace QRCoder } public class BitcoinAddress : QRCoder.PayloadGenerator.BitcoinLikeCryptoCurrencyAddress { - public BitcoinAddress(string address, double? amount, string label = null, string message = null) { } + public BitcoinAddress(string address, double? amount, string? label = null, string? message = null) { } } public class BitcoinCashAddress : QRCoder.PayloadGenerator.BitcoinLikeCryptoCurrencyAddress { - public BitcoinCashAddress(string address, double? amount, string label = null, string message = null) { } + public BitcoinCashAddress(string address, double? amount, string? label = null, string? message = null) { } } public class BitcoinLikeCryptoCurrencyAddress : QRCoder.PayloadGenerator.Payload { - public BitcoinLikeCryptoCurrencyAddress(QRCoder.PayloadGenerator.BitcoinLikeCryptoCurrencyAddress.BitcoinLikeCryptoCurrencyType currencyType, string address, double? amount, string label = null, string message = null) { } + public BitcoinLikeCryptoCurrencyAddress(QRCoder.PayloadGenerator.BitcoinLikeCryptoCurrencyAddress.BitcoinLikeCryptoCurrencyType currencyType, string address, double? amount, string? label = null, string? message = null) { } public override string ToString() { } public enum BitcoinLikeCryptoCurrencyType { @@ -369,8 +369,8 @@ namespace QRCoder } public class CalendarEvent : QRCoder.PayloadGenerator.Payload { - public CalendarEvent(string subject, string description, string location, System.DateTime start, System.DateTime end, bool allDayEvent, QRCoder.PayloadGenerator.CalendarEvent.EventEncoding encoding = 1) { } - public CalendarEvent(string subject, string description, string location, System.DateTimeOffset start, System.DateTimeOffset end, bool allDayEvent, QRCoder.PayloadGenerator.CalendarEvent.EventEncoding encoding = 1) { } + public CalendarEvent(string subject, string? description, string? location, System.DateTime start, System.DateTime end, bool allDayEvent, QRCoder.PayloadGenerator.CalendarEvent.EventEncoding encoding = 1) { } + public CalendarEvent(string subject, string? description, string? location, System.DateTimeOffset start, System.DateTimeOffset end, bool allDayEvent, QRCoder.PayloadGenerator.CalendarEvent.EventEncoding encoding = 1) { } public override string ToString() { } public enum EventEncoding { @@ -384,23 +384,23 @@ namespace QRCoder QRCoder.PayloadGenerator.ContactData.ContactOutputType outputType, string firstname, string lastname, - string nickname = null, - string phone = null, - string mobilePhone = null, - string workPhone = null, - string email = null, + string? nickname = null, + string? phone = null, + string? mobilePhone = null, + string? workPhone = null, + string? email = null, System.DateTime? birthday = default, - string website = null, - string street = null, - string houseNumber = null, - string city = null, - string zipCode = null, - string country = null, - string note = null, - string stateRegion = null, + string? website = null, + string? street = null, + string? houseNumber = null, + string? city = null, + string? zipCode = null, + string? country = null, + string? note = null, + string? stateRegion = null, QRCoder.PayloadGenerator.ContactData.AddressOrder addressOrder = 0, - string org = null, - string orgTitle = null) { } + string? org = null, + string? orgTitle = null) { } public override string ToString() { } public enum AddressOrder { @@ -460,7 +460,7 @@ namespace QRCoder } public class LitecoinAddress : QRCoder.PayloadGenerator.BitcoinLikeCryptoCurrencyAddress { - public LitecoinAddress(string address, double? amount, string label = null, string message = null) { } + public LitecoinAddress(string address, double? amount, string? label = null, string? message = null) { } } public class MMS : QRCoder.PayloadGenerator.Payload { @@ -475,7 +475,7 @@ namespace QRCoder } public class Mail : QRCoder.PayloadGenerator.Payload { - public Mail(string mailReceiver = null, string subject = null, string message = null, QRCoder.PayloadGenerator.Mail.MailEncoding encoding = 0) { } + public Mail(string? mailReceiver = null, string? subject = null, string? message = null, QRCoder.PayloadGenerator.Mail.MailEncoding encoding = 0) { } public override string ToString() { } public enum MailEncoding { @@ -486,7 +486,7 @@ namespace QRCoder } public class MoneroTransaction : QRCoder.PayloadGenerator.Payload { - public MoneroTransaction(string address, float? txAmount = default, string txPaymentId = null, string recipientName = null, string txDescription = null) { } + public MoneroTransaction(string address, float? txAmount = default, string? txPaymentId = null, string? recipientName = null, string? txDescription = null) { } public override string ToString() { } public class MoneroTransactionException : System.Exception { @@ -503,8 +503,8 @@ namespace QRCoder public QRCoder.PayloadGenerator.OneTimePassword.OneTimePasswordAuthAlgorithm AuthAlgorithm { get; set; } public int? Counter { get; set; } public int Digits { get; set; } - public string Issuer { get; set; } - public string Label { get; set; } + public string? Issuer { get; set; } + public string? Label { get; set; } public int? Period { get; set; } public string Secret { get; set; } public QRCoder.PayloadGenerator.OneTimePassword.OneTimePasswordAuthType Type { get; set; } @@ -543,7 +543,7 @@ namespace QRCoder } public class RussiaPaymentOrder : QRCoder.PayloadGenerator.Payload { - public RussiaPaymentOrder(string name, string personalAcc, string bankName, string BIC, string correspAcc, QRCoder.PayloadGenerator.RussiaPaymentOrder.OptionalFields optionalFields = null, QRCoder.PayloadGenerator.RussiaPaymentOrder.CharacterSets characterSet = 2) { } + public RussiaPaymentOrder(string name, string personalAcc, string bankName, string BIC, string correspAcc, QRCoder.PayloadGenerator.RussiaPaymentOrder.OptionalFields? optionalFields = null, QRCoder.PayloadGenerator.RussiaPaymentOrder.CharacterSets characterSet = 2) { } public byte[] ToBytes() { } public override string ToString() { } public enum CharacterSets @@ -555,51 +555,51 @@ namespace QRCoder public class OptionalFields { public OptionalFields() { } - public string AddAmount { get; set; } + public string? AddAmount { get; set; } public System.DateTime? BirthDate { get; set; } - public string CBC { get; set; } - public string Category { get; set; } - public string ChildFio { get; set; } - public string ClassNum { get; set; } - public string Contract { get; set; } - public string CounterId { get; set; } - public string CounterVal { get; set; } + public string? CBC { get; set; } + public string? Category { get; set; } + public string? ChildFio { get; set; } + public string? ClassNum { get; set; } + public string? Contract { get; set; } + public string? CounterId { get; set; } + public string? CounterVal { get; set; } public System.DateTime? DocDate { get; set; } - public string DocIdx { get; set; } - public string DocNo { get; set; } - public string DrawerStatus { get; set; } - public string ExecId { get; set; } - public string FirstName { get; set; } - public string Flat { get; set; } - public string InstNum { get; set; } - public string KPP { get; set; } - public string LastName { get; set; } - public string MiddleName { get; set; } - public string OKTMO { get; set; } - public string PayeeINN { get; set; } - public string PayerAddress { get; set; } - public string PayerINN { get; set; } - public string PayerIdNum { get; set; } - public string PayerIdType { get; set; } - public string PaymPeriod { get; set; } - public string PaymTerm { get; set; } - public string PaytReason { get; set; } - public string PensAcc { get; set; } - public string PersAcc { get; set; } - public string PersonalAccount { get; set; } - public string Phone { get; set; } - public string Purpose { get; set; } + public string? DocIdx { get; set; } + public string? DocNo { get; set; } + public string? DrawerStatus { get; set; } + public string? ExecId { get; set; } + public string? FirstName { get; set; } + public string? Flat { get; set; } + public string? InstNum { get; set; } + public string? KPP { get; set; } + public string? LastName { get; set; } + public string? MiddleName { get; set; } + public string? OKTMO { get; set; } + public string? PayeeINN { get; set; } + public string? PayerAddress { get; set; } + public string? PayerINN { get; set; } + public string? PayerIdNum { get; set; } + public string? PayerIdType { get; set; } + public string? PaymPeriod { get; set; } + public string? PaymTerm { get; set; } + public string? PaytReason { get; set; } + public string? PensAcc { get; set; } + public string? PersAcc { get; set; } + public string? PersonalAccount { get; set; } + public string? Phone { get; set; } + public string? Purpose { get; set; } public System.DateTime? QuittDate { get; set; } - public string QuittId { get; set; } - public string RegType { get; set; } - public string RuleId { get; set; } - public string ServiceName { get; set; } - public string SpecFio { get; set; } - public string Sum { get; set; } - public string TaxPaytKind { get; set; } - public string TaxPeriod { get; set; } + public string? QuittId { get; set; } + public string? RegType { get; set; } + public string? RuleId { get; set; } + public string? ServiceName { get; set; } + public string? SpecFio { get; set; } + public string? Sum { get; set; } + public string? TaxPaytKind { get; set; } + public string? TaxPeriod { get; set; } public QRCoder.PayloadGenerator.RussiaPaymentOrder.TechCode? TechCode { get; set; } - public string UIN { get; set; } + public string? UIN { get; set; } } public class RussiaPaymentOrderException : System.Exception { @@ -638,9 +638,9 @@ namespace QRCoder } public class ShadowSocksConfig : QRCoder.PayloadGenerator.Payload { - public ShadowSocksConfig(string hostname, int port, string password, QRCoder.PayloadGenerator.ShadowSocksConfig.Method method, string tag = null) { } - public ShadowSocksConfig(string hostname, int port, string password, QRCoder.PayloadGenerator.ShadowSocksConfig.Method method, System.Collections.Generic.Dictionary parameters, string tag = null) { } - public ShadowSocksConfig(string hostname, int port, string password, QRCoder.PayloadGenerator.ShadowSocksConfig.Method method, string plugin, string pluginOption, string tag = null) { } + public ShadowSocksConfig(string hostname, int port, string password, QRCoder.PayloadGenerator.ShadowSocksConfig.Method method, string? tag = null) { } + public ShadowSocksConfig(string hostname, int port, string password, QRCoder.PayloadGenerator.ShadowSocksConfig.Method method, System.Collections.Generic.Dictionary? parameters, string? tag = null) { } + public ShadowSocksConfig(string hostname, int port, string password, QRCoder.PayloadGenerator.ShadowSocksConfig.Method method, string plugin, string? pluginOption, string? tag = null) { } public override string ToString() { } public enum Method { @@ -705,16 +705,16 @@ namespace QRCoder } public class SwissQrCode : QRCoder.PayloadGenerator.Payload { - public SwissQrCode(QRCoder.PayloadGenerator.SwissQrCode.Iban iban, QRCoder.PayloadGenerator.SwissQrCode.Currency currency, QRCoder.PayloadGenerator.SwissQrCode.Contact creditor, QRCoder.PayloadGenerator.SwissQrCode.Reference reference, QRCoder.PayloadGenerator.SwissQrCode.AdditionalInformation additionalInformation = null, QRCoder.PayloadGenerator.SwissQrCode.Contact debitor = null, decimal? amount = default, System.DateTime? requestedDateOfPayment = default, QRCoder.PayloadGenerator.SwissQrCode.Contact ultimateCreditor = null, string alternativeProcedure1 = null, string alternativeProcedure2 = null) { } + public SwissQrCode(QRCoder.PayloadGenerator.SwissQrCode.Iban iban, QRCoder.PayloadGenerator.SwissQrCode.Currency currency, QRCoder.PayloadGenerator.SwissQrCode.Contact creditor, QRCoder.PayloadGenerator.SwissQrCode.Reference reference, QRCoder.PayloadGenerator.SwissQrCode.AdditionalInformation? additionalInformation = null, QRCoder.PayloadGenerator.SwissQrCode.Contact? debitor = null, decimal? amount = default, System.DateTime? requestedDateOfPayment = default, QRCoder.PayloadGenerator.SwissQrCode.Contact? ultimateCreditor = null, string? alternativeProcedure1 = null, string? alternativeProcedure2 = null) { } public override QRCoder.QRCodeGenerator.ECCLevel EccLevel { get; } public override QRCoder.QRCodeGenerator.EciMode EciMode { get; } public override string ToString() { } public class AdditionalInformation { - public AdditionalInformation(string unstructuredMessage = null, string billInformation = null) { } - public string BillInformation { get; } + public AdditionalInformation(string? unstructuredMessage = null, string? billInformation = null) { } + public string? BillInformation { get; } public string Trailer { get; } - public string UnstructureMessage { get; } + public string? UnstructureMessage { get; } public class SwissQrCodeAdditionalInformationException : System.Exception { public SwissQrCodeAdditionalInformationException() { } @@ -727,10 +727,10 @@ namespace QRCoder [System.Obsolete("This constructor is deprecated. Use WithCombinedAddress instead.")] public Contact(string name, string country, string addressLine1, string addressLine2) { } [System.Obsolete("This constructor is deprecated. Use WithStructuredAddress instead.")] - public Contact(string name, string zipCode, string city, string country, string street = null, string houseNumber = null) { } + public Contact(string name, string zipCode, string city, string country, string? street = null, string? houseNumber = null) { } public override string ToString() { } public static QRCoder.PayloadGenerator.SwissQrCode.Contact WithCombinedAddress(string name, string country, string addressLine1, string addressLine2) { } - public static QRCoder.PayloadGenerator.SwissQrCode.Contact WithStructuredAddress(string name, string zipCode, string city, string country, string street = null, string houseNumber = null) { } + public static QRCoder.PayloadGenerator.SwissQrCode.Contact WithStructuredAddress(string name, string zipCode, string city, string country, string? street = null, string? houseNumber = null) { } public enum AddressType { StructuredAddress = 0, @@ -767,9 +767,9 @@ namespace QRCoder } public class Reference { - public Reference(QRCoder.PayloadGenerator.SwissQrCode.Reference.ReferenceType referenceType, string reference = null, QRCoder.PayloadGenerator.SwissQrCode.Reference.ReferenceTextType? referenceTextType = default) { } + public Reference(QRCoder.PayloadGenerator.SwissQrCode.Reference.ReferenceType referenceType, string? reference = null, QRCoder.PayloadGenerator.SwissQrCode.Reference.ReferenceTextType? referenceTextType = default) { } public QRCoder.PayloadGenerator.SwissQrCode.Reference.ReferenceType RefType { get; } - public string ReferenceText { get; } + public string? ReferenceText { get; } public enum ReferenceTextType { QrReference = 0, @@ -850,13 +850,13 @@ namespace QRCoder public string GetGraphic(int pointsPerModule, bool epsFormat = false) { } public string GetGraphic(System.Drawing.Size viewBox, bool drawQuietZones = true, bool epsFormat = false) { } public string GetGraphic(System.Drawing.Size viewBox, System.Drawing.Color darkColor, System.Drawing.Color lightColor, bool drawQuietZones = true, bool epsFormat = false) { } - public string GetGraphic(System.Drawing.Size viewBox, string darkColorHex, string lightColorHex, bool drawQuietZones = true, bool epsFormat = false) { } + public string GetGraphic(System.Drawing.Size viewBox, string? darkColorHex, string? lightColorHex, bool drawQuietZones = true, bool epsFormat = false) { } public string GetGraphic(int pointsPerModule, System.Drawing.Color darkColor, System.Drawing.Color lightColor, bool drawQuietZones = true, bool epsFormat = false) { } - public string GetGraphic(int pointsPerModule, string darkColorHex, string lightColorHex, bool drawQuietZones = true, bool epsFormat = false) { } + public string GetGraphic(int pointsPerModule, string? darkColorHex, string? lightColorHex, bool drawQuietZones = true, bool epsFormat = false) { } } public static class PostscriptQRCodeHelper { - public static string GetQRCode(string plainText, int pointsPerModule, string darkColorHex, string lightColorHex, QRCoder.QRCodeGenerator.ECCLevel eccLevel, bool forceUtf8 = false, bool utf8BOM = false, QRCoder.QRCodeGenerator.EciMode eciMode = 0, int requestedVersion = -1, bool drawQuietZones = true, bool epsFormat = false) { } + public static string GetQRCode(string plainText, int pointsPerModule, string? darkColorHex, string? lightColorHex, QRCoder.QRCodeGenerator.ECCLevel eccLevel, bool forceUtf8 = false, bool utf8BOM = false, QRCoder.QRCodeGenerator.EciMode eciMode = 0, int requestedVersion = -1, bool drawQuietZones = true, bool epsFormat = false) { } } public class QRCode : QRCoder.AbstractQRCode, System.IDisposable { @@ -864,8 +864,8 @@ namespace QRCoder public QRCode(QRCoder.QRCodeData data) { } public System.Drawing.Bitmap GetGraphic(int pixelsPerModule) { } public System.Drawing.Bitmap GetGraphic(int pixelsPerModule, System.Drawing.Color darkColor, System.Drawing.Color lightColor, bool drawQuietZones = true) { } - public System.Drawing.Bitmap GetGraphic(int pixelsPerModule, string darkColorHtmlHex, string lightColorHtmlHex, bool drawQuietZones = true) { } - public System.Drawing.Bitmap GetGraphic(int pixelsPerModule, System.Drawing.Color darkColor, System.Drawing.Color lightColor, System.Drawing.Bitmap icon = null, int iconSizePercent = 15, int iconBorderWidth = 0, bool drawQuietZones = true, System.Drawing.Color? iconBackgroundColor = default) { } + public System.Drawing.Bitmap GetGraphic(int pixelsPerModule, string? darkColorHtmlHex, string? lightColorHtmlHex, bool drawQuietZones = true) { } + public System.Drawing.Bitmap GetGraphic(int pixelsPerModule, System.Drawing.Color darkColor, System.Drawing.Color lightColor, System.Drawing.Bitmap? icon = null, int iconSizePercent = 15, int iconBorderWidth = 0, bool drawQuietZones = true, System.Drawing.Color? iconBackgroundColor = default) { } } public class QRCodeData : System.IDisposable { @@ -915,18 +915,18 @@ namespace QRCoder } public static class QRCodeHelper { - public static System.Drawing.Bitmap GetQRCode(string plainText, int pixelsPerModule, System.Drawing.Color darkColor, System.Drawing.Color lightColor, QRCoder.QRCodeGenerator.ECCLevel eccLevel, bool forceUtf8 = false, bool utf8BOM = false, QRCoder.QRCodeGenerator.EciMode eciMode = 0, int requestedVersion = -1, System.Drawing.Bitmap icon = null, int iconSizePercent = 15, int iconBorderWidth = 0, bool drawQuietZones = true) { } + public static System.Drawing.Bitmap GetQRCode(string plainText, int pixelsPerModule, System.Drawing.Color darkColor, System.Drawing.Color lightColor, QRCoder.QRCodeGenerator.ECCLevel eccLevel, bool forceUtf8 = false, bool utf8BOM = false, QRCoder.QRCodeGenerator.EciMode eciMode = 0, int requestedVersion = -1, System.Drawing.Bitmap? icon = null, int iconSizePercent = 15, int iconBorderWidth = 0, bool drawQuietZones = true) { } } public class SvgQRCode : QRCoder.AbstractQRCode, System.IDisposable { public SvgQRCode() { } public SvgQRCode(QRCoder.QRCodeData data) { } public string GetGraphic(int pixelsPerModule) { } - public string GetGraphic(System.Drawing.Size viewBox, bool drawQuietZones = true, QRCoder.SvgQRCode.SizingMode sizingMode = 0, QRCoder.SvgQRCode.SvgLogo logo = null) { } - public string GetGraphic(System.Drawing.Size viewBox, System.Drawing.Color darkColor, System.Drawing.Color lightColor, bool drawQuietZones = true, QRCoder.SvgQRCode.SizingMode sizingMode = 0, QRCoder.SvgQRCode.SvgLogo logo = null) { } - public string GetGraphic(System.Drawing.Size viewBox, string darkColorHex, string lightColorHex, bool drawQuietZones = true, QRCoder.SvgQRCode.SizingMode sizingMode = 0, QRCoder.SvgQRCode.SvgLogo logo = null) { } - public string GetGraphic(int pixelsPerModule, System.Drawing.Color darkColor, System.Drawing.Color lightColor, bool drawQuietZones = true, QRCoder.SvgQRCode.SizingMode sizingMode = 0, QRCoder.SvgQRCode.SvgLogo logo = null) { } - public string GetGraphic(int pixelsPerModule, string darkColorHex, string lightColorHex, bool drawQuietZones = true, QRCoder.SvgQRCode.SizingMode sizingMode = 0, QRCoder.SvgQRCode.SvgLogo logo = null) { } + public string GetGraphic(System.Drawing.Size viewBox, bool drawQuietZones = true, QRCoder.SvgQRCode.SizingMode sizingMode = 0, QRCoder.SvgQRCode.SvgLogo? logo = null) { } + public string GetGraphic(System.Drawing.Size viewBox, System.Drawing.Color darkColor, System.Drawing.Color lightColor, bool drawQuietZones = true, QRCoder.SvgQRCode.SizingMode sizingMode = 0, QRCoder.SvgQRCode.SvgLogo? logo = null) { } + public string GetGraphic(System.Drawing.Size viewBox, string darkColorHex, string lightColorHex, bool drawQuietZones = true, QRCoder.SvgQRCode.SizingMode sizingMode = 0, QRCoder.SvgQRCode.SvgLogo? logo = null) { } + public string GetGraphic(int pixelsPerModule, System.Drawing.Color darkColor, System.Drawing.Color lightColor, bool drawQuietZones = true, QRCoder.SvgQRCode.SizingMode sizingMode = 0, QRCoder.SvgQRCode.SvgLogo? logo = null) { } + public string GetGraphic(int pixelsPerModule, string darkColorHex, string lightColorHex, bool drawQuietZones = true, QRCoder.SvgQRCode.SizingMode sizingMode = 0, QRCoder.SvgQRCode.SvgLogo? logo = null) { } public enum SizingMode { WidthHeightAttribute = 0, @@ -954,7 +954,7 @@ namespace QRCoder } public static class SvgQRCodeHelper { - public static string GetQRCode(string plainText, int pixelsPerModule, string darkColorHex, string lightColorHex, QRCoder.QRCodeGenerator.ECCLevel eccLevel, bool forceUtf8 = false, bool utf8BOM = false, QRCoder.QRCodeGenerator.EciMode eciMode = 0, int requestedVersion = -1, bool drawQuietZones = true, QRCoder.SvgQRCode.SizingMode sizingMode = 0, QRCoder.SvgQRCode.SvgLogo logo = null) { } + public static string GetQRCode(string plainText, int pixelsPerModule, string darkColorHex, string lightColorHex, QRCoder.QRCodeGenerator.ECCLevel eccLevel, bool forceUtf8 = false, bool utf8BOM = false, QRCoder.QRCodeGenerator.EciMode eciMode = 0, int requestedVersion = -1, bool drawQuietZones = true, QRCoder.SvgQRCode.SizingMode sizingMode = 0, QRCoder.SvgQRCode.SvgLogo? logo = null) { } } } namespace QRCoder.Exceptions @@ -970,7 +970,7 @@ namespace QRCoder.Extensions [System.Obsolete("This class will be removed in a future version of QRCoder.")] public static class CustomExtensions { - public static string GetStringValue(this System.Enum value) { } + public static string? GetStringValue(this System.Enum value) { } } [System.Obsolete("This attribute will be removed in a future version of QRCoder.")] public class StringValueAttribute : System.Attribute diff --git a/QRCoderApiTests/net60-windows/QRCoder.approved.txt b/QRCoderApiTests/net60-windows/QRCoder.approved.txt index 52c12031..e28f12f3 100644 --- a/QRCoderApiTests/net60-windows/QRCoder.approved.txt +++ b/QRCoderApiTests/net60-windows/QRCoder.approved.txt @@ -13,9 +13,9 @@ namespace QRCoder { public ArtQRCode() { } public ArtQRCode(QRCoder.QRCodeData data) { } - public System.Drawing.Bitmap GetGraphic(System.Drawing.Bitmap backgroundImage = null) { } + public System.Drawing.Bitmap GetGraphic(System.Drawing.Bitmap? backgroundImage = null) { } public System.Drawing.Bitmap GetGraphic(int pixelsPerModule) { } - public System.Drawing.Bitmap GetGraphic(int pixelsPerModule, System.Drawing.Color darkColor, System.Drawing.Color lightColor, System.Drawing.Color backgroundColor, System.Drawing.Bitmap backgroundImage = null, double pixelSizeFactor = 1, bool drawQuietZones = true, QRCoder.ArtQRCode.QuietZoneStyle quietZoneRenderingStyle = 0, QRCoder.ArtQRCode.BackgroundImageStyle backgroundImageStyle = 1, System.Drawing.Bitmap finderPatternImage = null) { } + public System.Drawing.Bitmap GetGraphic(int pixelsPerModule, System.Drawing.Color darkColor, System.Drawing.Color lightColor, System.Drawing.Color backgroundColor, System.Drawing.Bitmap? backgroundImage = null, double pixelSizeFactor = 1, bool drawQuietZones = true, QRCoder.ArtQRCode.QuietZoneStyle quietZoneRenderingStyle = 0, QRCoder.ArtQRCode.BackgroundImageStyle backgroundImageStyle = 1, System.Drawing.Bitmap? finderPatternImage = null) { } public enum BackgroundImageStyle { Fill = 0, @@ -41,12 +41,12 @@ namespace QRCoder bool utf8BOM = false, QRCoder.QRCodeGenerator.EciMode eciMode = 0, int requestedVersion = -1, - System.Drawing.Bitmap backgroundImage = null, + System.Drawing.Bitmap? backgroundImage = null, double pixelSizeFactor = 1, bool drawQuietZones = true, QRCoder.ArtQRCode.QuietZoneStyle quietZoneRenderingStyle = 1, QRCoder.ArtQRCode.BackgroundImageStyle backgroundImageStyle = 1, - System.Drawing.Bitmap finderPatternImage = null) { } + System.Drawing.Bitmap? finderPatternImage = null) { } } public class AsciiQRCode : QRCoder.AbstractQRCode, System.IDisposable { @@ -350,15 +350,15 @@ namespace QRCoder } public class BitcoinAddress : QRCoder.PayloadGenerator.BitcoinLikeCryptoCurrencyAddress { - public BitcoinAddress(string address, double? amount, string label = null, string message = null) { } + public BitcoinAddress(string address, double? amount, string? label = null, string? message = null) { } } public class BitcoinCashAddress : QRCoder.PayloadGenerator.BitcoinLikeCryptoCurrencyAddress { - public BitcoinCashAddress(string address, double? amount, string label = null, string message = null) { } + public BitcoinCashAddress(string address, double? amount, string? label = null, string? message = null) { } } public class BitcoinLikeCryptoCurrencyAddress : QRCoder.PayloadGenerator.Payload { - public BitcoinLikeCryptoCurrencyAddress(QRCoder.PayloadGenerator.BitcoinLikeCryptoCurrencyAddress.BitcoinLikeCryptoCurrencyType currencyType, string address, double? amount, string label = null, string message = null) { } + public BitcoinLikeCryptoCurrencyAddress(QRCoder.PayloadGenerator.BitcoinLikeCryptoCurrencyAddress.BitcoinLikeCryptoCurrencyType currencyType, string address, double? amount, string? label = null, string? message = null) { } public override string ToString() { } public enum BitcoinLikeCryptoCurrencyType { @@ -374,8 +374,8 @@ namespace QRCoder } public class CalendarEvent : QRCoder.PayloadGenerator.Payload { - public CalendarEvent(string subject, string description, string location, System.DateTime start, System.DateTime end, bool allDayEvent, QRCoder.PayloadGenerator.CalendarEvent.EventEncoding encoding = 1) { } - public CalendarEvent(string subject, string description, string location, System.DateTimeOffset start, System.DateTimeOffset end, bool allDayEvent, QRCoder.PayloadGenerator.CalendarEvent.EventEncoding encoding = 1) { } + public CalendarEvent(string subject, string? description, string? location, System.DateTime start, System.DateTime end, bool allDayEvent, QRCoder.PayloadGenerator.CalendarEvent.EventEncoding encoding = 1) { } + public CalendarEvent(string subject, string? description, string? location, System.DateTimeOffset start, System.DateTimeOffset end, bool allDayEvent, QRCoder.PayloadGenerator.CalendarEvent.EventEncoding encoding = 1) { } public override string ToString() { } public enum EventEncoding { @@ -389,23 +389,23 @@ namespace QRCoder QRCoder.PayloadGenerator.ContactData.ContactOutputType outputType, string firstname, string lastname, - string nickname = null, - string phone = null, - string mobilePhone = null, - string workPhone = null, - string email = null, + string? nickname = null, + string? phone = null, + string? mobilePhone = null, + string? workPhone = null, + string? email = null, System.DateTime? birthday = default, - string website = null, - string street = null, - string houseNumber = null, - string city = null, - string zipCode = null, - string country = null, - string note = null, - string stateRegion = null, + string? website = null, + string? street = null, + string? houseNumber = null, + string? city = null, + string? zipCode = null, + string? country = null, + string? note = null, + string? stateRegion = null, QRCoder.PayloadGenerator.ContactData.AddressOrder addressOrder = 0, - string org = null, - string orgTitle = null) { } + string? org = null, + string? orgTitle = null) { } public override string ToString() { } public enum AddressOrder { @@ -465,7 +465,7 @@ namespace QRCoder } public class LitecoinAddress : QRCoder.PayloadGenerator.BitcoinLikeCryptoCurrencyAddress { - public LitecoinAddress(string address, double? amount, string label = null, string message = null) { } + public LitecoinAddress(string address, double? amount, string? label = null, string? message = null) { } } public class MMS : QRCoder.PayloadGenerator.Payload { @@ -480,7 +480,7 @@ namespace QRCoder } public class Mail : QRCoder.PayloadGenerator.Payload { - public Mail(string mailReceiver = null, string subject = null, string message = null, QRCoder.PayloadGenerator.Mail.MailEncoding encoding = 0) { } + public Mail(string? mailReceiver = null, string? subject = null, string? message = null, QRCoder.PayloadGenerator.Mail.MailEncoding encoding = 0) { } public override string ToString() { } public enum MailEncoding { @@ -491,7 +491,7 @@ namespace QRCoder } public class MoneroTransaction : QRCoder.PayloadGenerator.Payload { - public MoneroTransaction(string address, float? txAmount = default, string txPaymentId = null, string recipientName = null, string txDescription = null) { } + public MoneroTransaction(string address, float? txAmount = default, string? txPaymentId = null, string? recipientName = null, string? txDescription = null) { } public override string ToString() { } public class MoneroTransactionException : System.Exception { @@ -508,8 +508,8 @@ namespace QRCoder public QRCoder.PayloadGenerator.OneTimePassword.OneTimePasswordAuthAlgorithm AuthAlgorithm { get; set; } public int? Counter { get; set; } public int Digits { get; set; } - public string Issuer { get; set; } - public string Label { get; set; } + public string? Issuer { get; set; } + public string? Label { get; set; } public int? Period { get; set; } public string Secret { get; set; } public QRCoder.PayloadGenerator.OneTimePassword.OneTimePasswordAuthType Type { get; set; } @@ -548,7 +548,7 @@ namespace QRCoder } public class RussiaPaymentOrder : QRCoder.PayloadGenerator.Payload { - public RussiaPaymentOrder(string name, string personalAcc, string bankName, string BIC, string correspAcc, QRCoder.PayloadGenerator.RussiaPaymentOrder.OptionalFields optionalFields = null, QRCoder.PayloadGenerator.RussiaPaymentOrder.CharacterSets characterSet = 2) { } + public RussiaPaymentOrder(string name, string personalAcc, string bankName, string BIC, string correspAcc, QRCoder.PayloadGenerator.RussiaPaymentOrder.OptionalFields? optionalFields = null, QRCoder.PayloadGenerator.RussiaPaymentOrder.CharacterSets characterSet = 2) { } public byte[] ToBytes() { } public override string ToString() { } public enum CharacterSets @@ -560,51 +560,51 @@ namespace QRCoder public class OptionalFields { public OptionalFields() { } - public string AddAmount { get; set; } + public string? AddAmount { get; set; } public System.DateTime? BirthDate { get; set; } - public string CBC { get; set; } - public string Category { get; set; } - public string ChildFio { get; set; } - public string ClassNum { get; set; } - public string Contract { get; set; } - public string CounterId { get; set; } - public string CounterVal { get; set; } + public string? CBC { get; set; } + public string? Category { get; set; } + public string? ChildFio { get; set; } + public string? ClassNum { get; set; } + public string? Contract { get; set; } + public string? CounterId { get; set; } + public string? CounterVal { get; set; } public System.DateTime? DocDate { get; set; } - public string DocIdx { get; set; } - public string DocNo { get; set; } - public string DrawerStatus { get; set; } - public string ExecId { get; set; } - public string FirstName { get; set; } - public string Flat { get; set; } - public string InstNum { get; set; } - public string KPP { get; set; } - public string LastName { get; set; } - public string MiddleName { get; set; } - public string OKTMO { get; set; } - public string PayeeINN { get; set; } - public string PayerAddress { get; set; } - public string PayerINN { get; set; } - public string PayerIdNum { get; set; } - public string PayerIdType { get; set; } - public string PaymPeriod { get; set; } - public string PaymTerm { get; set; } - public string PaytReason { get; set; } - public string PensAcc { get; set; } - public string PersAcc { get; set; } - public string PersonalAccount { get; set; } - public string Phone { get; set; } - public string Purpose { get; set; } + public string? DocIdx { get; set; } + public string? DocNo { get; set; } + public string? DrawerStatus { get; set; } + public string? ExecId { get; set; } + public string? FirstName { get; set; } + public string? Flat { get; set; } + public string? InstNum { get; set; } + public string? KPP { get; set; } + public string? LastName { get; set; } + public string? MiddleName { get; set; } + public string? OKTMO { get; set; } + public string? PayeeINN { get; set; } + public string? PayerAddress { get; set; } + public string? PayerINN { get; set; } + public string? PayerIdNum { get; set; } + public string? PayerIdType { get; set; } + public string? PaymPeriod { get; set; } + public string? PaymTerm { get; set; } + public string? PaytReason { get; set; } + public string? PensAcc { get; set; } + public string? PersAcc { get; set; } + public string? PersonalAccount { get; set; } + public string? Phone { get; set; } + public string? Purpose { get; set; } public System.DateTime? QuittDate { get; set; } - public string QuittId { get; set; } - public string RegType { get; set; } - public string RuleId { get; set; } - public string ServiceName { get; set; } - public string SpecFio { get; set; } - public string Sum { get; set; } - public string TaxPaytKind { get; set; } - public string TaxPeriod { get; set; } + public string? QuittId { get; set; } + public string? RegType { get; set; } + public string? RuleId { get; set; } + public string? ServiceName { get; set; } + public string? SpecFio { get; set; } + public string? Sum { get; set; } + public string? TaxPaytKind { get; set; } + public string? TaxPeriod { get; set; } public QRCoder.PayloadGenerator.RussiaPaymentOrder.TechCode? TechCode { get; set; } - public string UIN { get; set; } + public string? UIN { get; set; } } public class RussiaPaymentOrderException : System.Exception { @@ -643,9 +643,9 @@ namespace QRCoder } public class ShadowSocksConfig : QRCoder.PayloadGenerator.Payload { - public ShadowSocksConfig(string hostname, int port, string password, QRCoder.PayloadGenerator.ShadowSocksConfig.Method method, string tag = null) { } - public ShadowSocksConfig(string hostname, int port, string password, QRCoder.PayloadGenerator.ShadowSocksConfig.Method method, System.Collections.Generic.Dictionary parameters, string tag = null) { } - public ShadowSocksConfig(string hostname, int port, string password, QRCoder.PayloadGenerator.ShadowSocksConfig.Method method, string plugin, string pluginOption, string tag = null) { } + public ShadowSocksConfig(string hostname, int port, string password, QRCoder.PayloadGenerator.ShadowSocksConfig.Method method, string? tag = null) { } + public ShadowSocksConfig(string hostname, int port, string password, QRCoder.PayloadGenerator.ShadowSocksConfig.Method method, System.Collections.Generic.Dictionary? parameters, string? tag = null) { } + public ShadowSocksConfig(string hostname, int port, string password, QRCoder.PayloadGenerator.ShadowSocksConfig.Method method, string plugin, string? pluginOption, string? tag = null) { } public override string ToString() { } public enum Method { @@ -710,16 +710,16 @@ namespace QRCoder } public class SwissQrCode : QRCoder.PayloadGenerator.Payload { - public SwissQrCode(QRCoder.PayloadGenerator.SwissQrCode.Iban iban, QRCoder.PayloadGenerator.SwissQrCode.Currency currency, QRCoder.PayloadGenerator.SwissQrCode.Contact creditor, QRCoder.PayloadGenerator.SwissQrCode.Reference reference, QRCoder.PayloadGenerator.SwissQrCode.AdditionalInformation additionalInformation = null, QRCoder.PayloadGenerator.SwissQrCode.Contact debitor = null, decimal? amount = default, System.DateTime? requestedDateOfPayment = default, QRCoder.PayloadGenerator.SwissQrCode.Contact ultimateCreditor = null, string alternativeProcedure1 = null, string alternativeProcedure2 = null) { } + public SwissQrCode(QRCoder.PayloadGenerator.SwissQrCode.Iban iban, QRCoder.PayloadGenerator.SwissQrCode.Currency currency, QRCoder.PayloadGenerator.SwissQrCode.Contact creditor, QRCoder.PayloadGenerator.SwissQrCode.Reference reference, QRCoder.PayloadGenerator.SwissQrCode.AdditionalInformation? additionalInformation = null, QRCoder.PayloadGenerator.SwissQrCode.Contact? debitor = null, decimal? amount = default, System.DateTime? requestedDateOfPayment = default, QRCoder.PayloadGenerator.SwissQrCode.Contact? ultimateCreditor = null, string? alternativeProcedure1 = null, string? alternativeProcedure2 = null) { } public override QRCoder.QRCodeGenerator.ECCLevel EccLevel { get; } public override QRCoder.QRCodeGenerator.EciMode EciMode { get; } public override string ToString() { } public class AdditionalInformation { - public AdditionalInformation(string unstructuredMessage = null, string billInformation = null) { } - public string BillInformation { get; } + public AdditionalInformation(string? unstructuredMessage = null, string? billInformation = null) { } + public string? BillInformation { get; } public string Trailer { get; } - public string UnstructureMessage { get; } + public string? UnstructureMessage { get; } public class SwissQrCodeAdditionalInformationException : System.Exception { public SwissQrCodeAdditionalInformationException() { } @@ -732,10 +732,10 @@ namespace QRCoder [System.Obsolete("This constructor is deprecated. Use WithCombinedAddress instead.")] public Contact(string name, string country, string addressLine1, string addressLine2) { } [System.Obsolete("This constructor is deprecated. Use WithStructuredAddress instead.")] - public Contact(string name, string zipCode, string city, string country, string street = null, string houseNumber = null) { } + public Contact(string name, string zipCode, string city, string country, string? street = null, string? houseNumber = null) { } public override string ToString() { } public static QRCoder.PayloadGenerator.SwissQrCode.Contact WithCombinedAddress(string name, string country, string addressLine1, string addressLine2) { } - public static QRCoder.PayloadGenerator.SwissQrCode.Contact WithStructuredAddress(string name, string zipCode, string city, string country, string street = null, string houseNumber = null) { } + public static QRCoder.PayloadGenerator.SwissQrCode.Contact WithStructuredAddress(string name, string zipCode, string city, string country, string? street = null, string? houseNumber = null) { } public enum AddressType { StructuredAddress = 0, @@ -772,9 +772,9 @@ namespace QRCoder } public class Reference { - public Reference(QRCoder.PayloadGenerator.SwissQrCode.Reference.ReferenceType referenceType, string reference = null, QRCoder.PayloadGenerator.SwissQrCode.Reference.ReferenceTextType? referenceTextType = default) { } + public Reference(QRCoder.PayloadGenerator.SwissQrCode.Reference.ReferenceType referenceType, string? reference = null, QRCoder.PayloadGenerator.SwissQrCode.Reference.ReferenceTextType? referenceTextType = default) { } public QRCoder.PayloadGenerator.SwissQrCode.Reference.ReferenceType RefType { get; } - public string ReferenceText { get; } + public string? ReferenceText { get; } public enum ReferenceTextType { QrReference = 0, @@ -857,13 +857,13 @@ namespace QRCoder public string GetGraphic(int pointsPerModule, bool epsFormat = false) { } public string GetGraphic(System.Drawing.Size viewBox, bool drawQuietZones = true, bool epsFormat = false) { } public string GetGraphic(System.Drawing.Size viewBox, System.Drawing.Color darkColor, System.Drawing.Color lightColor, bool drawQuietZones = true, bool epsFormat = false) { } - public string GetGraphic(System.Drawing.Size viewBox, string darkColorHex, string lightColorHex, bool drawQuietZones = true, bool epsFormat = false) { } + public string GetGraphic(System.Drawing.Size viewBox, string? darkColorHex, string? lightColorHex, bool drawQuietZones = true, bool epsFormat = false) { } public string GetGraphic(int pointsPerModule, System.Drawing.Color darkColor, System.Drawing.Color lightColor, bool drawQuietZones = true, bool epsFormat = false) { } - public string GetGraphic(int pointsPerModule, string darkColorHex, string lightColorHex, bool drawQuietZones = true, bool epsFormat = false) { } + public string GetGraphic(int pointsPerModule, string? darkColorHex, string? lightColorHex, bool drawQuietZones = true, bool epsFormat = false) { } } public static class PostscriptQRCodeHelper { - public static string GetQRCode(string plainText, int pointsPerModule, string darkColorHex, string lightColorHex, QRCoder.QRCodeGenerator.ECCLevel eccLevel, bool forceUtf8 = false, bool utf8BOM = false, QRCoder.QRCodeGenerator.EciMode eciMode = 0, int requestedVersion = -1, bool drawQuietZones = true, bool epsFormat = false) { } + public static string GetQRCode(string plainText, int pointsPerModule, string? darkColorHex, string? lightColorHex, QRCoder.QRCodeGenerator.ECCLevel eccLevel, bool forceUtf8 = false, bool utf8BOM = false, QRCoder.QRCodeGenerator.EciMode eciMode = 0, int requestedVersion = -1, bool drawQuietZones = true, bool epsFormat = false) { } } [System.Runtime.Versioning.SupportedOSPlatform("windows")] public class QRCode : QRCoder.AbstractQRCode, System.IDisposable @@ -872,8 +872,8 @@ namespace QRCoder public QRCode(QRCoder.QRCodeData data) { } public System.Drawing.Bitmap GetGraphic(int pixelsPerModule) { } public System.Drawing.Bitmap GetGraphic(int pixelsPerModule, System.Drawing.Color darkColor, System.Drawing.Color lightColor, bool drawQuietZones = true) { } - public System.Drawing.Bitmap GetGraphic(int pixelsPerModule, string darkColorHtmlHex, string lightColorHtmlHex, bool drawQuietZones = true) { } - public System.Drawing.Bitmap GetGraphic(int pixelsPerModule, System.Drawing.Color darkColor, System.Drawing.Color lightColor, System.Drawing.Bitmap icon = null, int iconSizePercent = 15, int iconBorderWidth = 0, bool drawQuietZones = true, System.Drawing.Color? iconBackgroundColor = default) { } + public System.Drawing.Bitmap GetGraphic(int pixelsPerModule, string? darkColorHtmlHex, string? lightColorHtmlHex, bool drawQuietZones = true) { } + public System.Drawing.Bitmap GetGraphic(int pixelsPerModule, System.Drawing.Color darkColor, System.Drawing.Color lightColor, System.Drawing.Bitmap? icon = null, int iconSizePercent = 15, int iconBorderWidth = 0, bool drawQuietZones = true, System.Drawing.Color? iconBackgroundColor = default) { } } public class QRCodeData : System.IDisposable { @@ -924,18 +924,18 @@ namespace QRCoder [System.Runtime.Versioning.SupportedOSPlatform("windows")] public static class QRCodeHelper { - public static System.Drawing.Bitmap GetQRCode(string plainText, int pixelsPerModule, System.Drawing.Color darkColor, System.Drawing.Color lightColor, QRCoder.QRCodeGenerator.ECCLevel eccLevel, bool forceUtf8 = false, bool utf8BOM = false, QRCoder.QRCodeGenerator.EciMode eciMode = 0, int requestedVersion = -1, System.Drawing.Bitmap icon = null, int iconSizePercent = 15, int iconBorderWidth = 0, bool drawQuietZones = true) { } + public static System.Drawing.Bitmap GetQRCode(string plainText, int pixelsPerModule, System.Drawing.Color darkColor, System.Drawing.Color lightColor, QRCoder.QRCodeGenerator.ECCLevel eccLevel, bool forceUtf8 = false, bool utf8BOM = false, QRCoder.QRCodeGenerator.EciMode eciMode = 0, int requestedVersion = -1, System.Drawing.Bitmap? icon = null, int iconSizePercent = 15, int iconBorderWidth = 0, bool drawQuietZones = true) { } } public class SvgQRCode : QRCoder.AbstractQRCode, System.IDisposable { public SvgQRCode() { } public SvgQRCode(QRCoder.QRCodeData data) { } public string GetGraphic(int pixelsPerModule) { } - public string GetGraphic(System.Drawing.Size viewBox, bool drawQuietZones = true, QRCoder.SvgQRCode.SizingMode sizingMode = 0, QRCoder.SvgQRCode.SvgLogo logo = null) { } - public string GetGraphic(System.Drawing.Size viewBox, System.Drawing.Color darkColor, System.Drawing.Color lightColor, bool drawQuietZones = true, QRCoder.SvgQRCode.SizingMode sizingMode = 0, QRCoder.SvgQRCode.SvgLogo logo = null) { } - public string GetGraphic(System.Drawing.Size viewBox, string darkColorHex, string lightColorHex, bool drawQuietZones = true, QRCoder.SvgQRCode.SizingMode sizingMode = 0, QRCoder.SvgQRCode.SvgLogo logo = null) { } - public string GetGraphic(int pixelsPerModule, System.Drawing.Color darkColor, System.Drawing.Color lightColor, bool drawQuietZones = true, QRCoder.SvgQRCode.SizingMode sizingMode = 0, QRCoder.SvgQRCode.SvgLogo logo = null) { } - public string GetGraphic(int pixelsPerModule, string darkColorHex, string lightColorHex, bool drawQuietZones = true, QRCoder.SvgQRCode.SizingMode sizingMode = 0, QRCoder.SvgQRCode.SvgLogo logo = null) { } + public string GetGraphic(System.Drawing.Size viewBox, bool drawQuietZones = true, QRCoder.SvgQRCode.SizingMode sizingMode = 0, QRCoder.SvgQRCode.SvgLogo? logo = null) { } + public string GetGraphic(System.Drawing.Size viewBox, System.Drawing.Color darkColor, System.Drawing.Color lightColor, bool drawQuietZones = true, QRCoder.SvgQRCode.SizingMode sizingMode = 0, QRCoder.SvgQRCode.SvgLogo? logo = null) { } + public string GetGraphic(System.Drawing.Size viewBox, string darkColorHex, string lightColorHex, bool drawQuietZones = true, QRCoder.SvgQRCode.SizingMode sizingMode = 0, QRCoder.SvgQRCode.SvgLogo? logo = null) { } + public string GetGraphic(int pixelsPerModule, System.Drawing.Color darkColor, System.Drawing.Color lightColor, bool drawQuietZones = true, QRCoder.SvgQRCode.SizingMode sizingMode = 0, QRCoder.SvgQRCode.SvgLogo? logo = null) { } + public string GetGraphic(int pixelsPerModule, string darkColorHex, string lightColorHex, bool drawQuietZones = true, QRCoder.SvgQRCode.SizingMode sizingMode = 0, QRCoder.SvgQRCode.SvgLogo? logo = null) { } public enum SizingMode { WidthHeightAttribute = 0, @@ -964,7 +964,7 @@ namespace QRCoder } public static class SvgQRCodeHelper { - public static string GetQRCode(string plainText, int pixelsPerModule, string darkColorHex, string lightColorHex, QRCoder.QRCodeGenerator.ECCLevel eccLevel, bool forceUtf8 = false, bool utf8BOM = false, QRCoder.QRCodeGenerator.EciMode eciMode = 0, int requestedVersion = -1, bool drawQuietZones = true, QRCoder.SvgQRCode.SizingMode sizingMode = 0, QRCoder.SvgQRCode.SvgLogo logo = null) { } + public static string GetQRCode(string plainText, int pixelsPerModule, string darkColorHex, string lightColorHex, QRCoder.QRCodeGenerator.ECCLevel eccLevel, bool forceUtf8 = false, bool utf8BOM = false, QRCoder.QRCodeGenerator.EciMode eciMode = 0, int requestedVersion = -1, bool drawQuietZones = true, QRCoder.SvgQRCode.SizingMode sizingMode = 0, QRCoder.SvgQRCode.SvgLogo? logo = null) { } } } namespace QRCoder.Exceptions @@ -981,7 +981,7 @@ namespace QRCoder.Extensions public static class CustomExtensions { [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("This method uses reflection to examine the provided enum value.")] - public static string GetStringValue(this System.Enum value) { } + public static string? GetStringValue(this System.Enum value) { } } [System.Obsolete("This attribute will be removed in a future version of QRCoder.")] public class StringValueAttribute : System.Attribute diff --git a/QRCoderApiTests/net60/QRCoder.approved.txt b/QRCoderApiTests/net60/QRCoder.approved.txt index fd21ee83..e5d9ecae 100644 --- a/QRCoderApiTests/net60/QRCoder.approved.txt +++ b/QRCoderApiTests/net60/QRCoder.approved.txt @@ -308,15 +308,15 @@ namespace QRCoder } public class BitcoinAddress : QRCoder.PayloadGenerator.BitcoinLikeCryptoCurrencyAddress { - public BitcoinAddress(string address, double? amount, string label = null, string message = null) { } + public BitcoinAddress(string address, double? amount, string? label = null, string? message = null) { } } public class BitcoinCashAddress : QRCoder.PayloadGenerator.BitcoinLikeCryptoCurrencyAddress { - public BitcoinCashAddress(string address, double? amount, string label = null, string message = null) { } + public BitcoinCashAddress(string address, double? amount, string? label = null, string? message = null) { } } public class BitcoinLikeCryptoCurrencyAddress : QRCoder.PayloadGenerator.Payload { - public BitcoinLikeCryptoCurrencyAddress(QRCoder.PayloadGenerator.BitcoinLikeCryptoCurrencyAddress.BitcoinLikeCryptoCurrencyType currencyType, string address, double? amount, string label = null, string message = null) { } + public BitcoinLikeCryptoCurrencyAddress(QRCoder.PayloadGenerator.BitcoinLikeCryptoCurrencyAddress.BitcoinLikeCryptoCurrencyType currencyType, string address, double? amount, string? label = null, string? message = null) { } public override string ToString() { } public enum BitcoinLikeCryptoCurrencyType { @@ -332,8 +332,8 @@ namespace QRCoder } public class CalendarEvent : QRCoder.PayloadGenerator.Payload { - public CalendarEvent(string subject, string description, string location, System.DateTime start, System.DateTime end, bool allDayEvent, QRCoder.PayloadGenerator.CalendarEvent.EventEncoding encoding = 1) { } - public CalendarEvent(string subject, string description, string location, System.DateTimeOffset start, System.DateTimeOffset end, bool allDayEvent, QRCoder.PayloadGenerator.CalendarEvent.EventEncoding encoding = 1) { } + public CalendarEvent(string subject, string? description, string? location, System.DateTime start, System.DateTime end, bool allDayEvent, QRCoder.PayloadGenerator.CalendarEvent.EventEncoding encoding = 1) { } + public CalendarEvent(string subject, string? description, string? location, System.DateTimeOffset start, System.DateTimeOffset end, bool allDayEvent, QRCoder.PayloadGenerator.CalendarEvent.EventEncoding encoding = 1) { } public override string ToString() { } public enum EventEncoding { @@ -347,23 +347,23 @@ namespace QRCoder QRCoder.PayloadGenerator.ContactData.ContactOutputType outputType, string firstname, string lastname, - string nickname = null, - string phone = null, - string mobilePhone = null, - string workPhone = null, - string email = null, + string? nickname = null, + string? phone = null, + string? mobilePhone = null, + string? workPhone = null, + string? email = null, System.DateTime? birthday = default, - string website = null, - string street = null, - string houseNumber = null, - string city = null, - string zipCode = null, - string country = null, - string note = null, - string stateRegion = null, + string? website = null, + string? street = null, + string? houseNumber = null, + string? city = null, + string? zipCode = null, + string? country = null, + string? note = null, + string? stateRegion = null, QRCoder.PayloadGenerator.ContactData.AddressOrder addressOrder = 0, - string org = null, - string orgTitle = null) { } + string? org = null, + string? orgTitle = null) { } public override string ToString() { } public enum AddressOrder { @@ -423,7 +423,7 @@ namespace QRCoder } public class LitecoinAddress : QRCoder.PayloadGenerator.BitcoinLikeCryptoCurrencyAddress { - public LitecoinAddress(string address, double? amount, string label = null, string message = null) { } + public LitecoinAddress(string address, double? amount, string? label = null, string? message = null) { } } public class MMS : QRCoder.PayloadGenerator.Payload { @@ -438,7 +438,7 @@ namespace QRCoder } public class Mail : QRCoder.PayloadGenerator.Payload { - public Mail(string mailReceiver = null, string subject = null, string message = null, QRCoder.PayloadGenerator.Mail.MailEncoding encoding = 0) { } + public Mail(string? mailReceiver = null, string? subject = null, string? message = null, QRCoder.PayloadGenerator.Mail.MailEncoding encoding = 0) { } public override string ToString() { } public enum MailEncoding { @@ -449,7 +449,7 @@ namespace QRCoder } public class MoneroTransaction : QRCoder.PayloadGenerator.Payload { - public MoneroTransaction(string address, float? txAmount = default, string txPaymentId = null, string recipientName = null, string txDescription = null) { } + public MoneroTransaction(string address, float? txAmount = default, string? txPaymentId = null, string? recipientName = null, string? txDescription = null) { } public override string ToString() { } public class MoneroTransactionException : System.Exception { @@ -466,8 +466,8 @@ namespace QRCoder public QRCoder.PayloadGenerator.OneTimePassword.OneTimePasswordAuthAlgorithm AuthAlgorithm { get; set; } public int? Counter { get; set; } public int Digits { get; set; } - public string Issuer { get; set; } - public string Label { get; set; } + public string? Issuer { get; set; } + public string? Label { get; set; } public int? Period { get; set; } public string Secret { get; set; } public QRCoder.PayloadGenerator.OneTimePassword.OneTimePasswordAuthType Type { get; set; } @@ -506,7 +506,7 @@ namespace QRCoder } public class RussiaPaymentOrder : QRCoder.PayloadGenerator.Payload { - public RussiaPaymentOrder(string name, string personalAcc, string bankName, string BIC, string correspAcc, QRCoder.PayloadGenerator.RussiaPaymentOrder.OptionalFields optionalFields = null, QRCoder.PayloadGenerator.RussiaPaymentOrder.CharacterSets characterSet = 2) { } + public RussiaPaymentOrder(string name, string personalAcc, string bankName, string BIC, string correspAcc, QRCoder.PayloadGenerator.RussiaPaymentOrder.OptionalFields? optionalFields = null, QRCoder.PayloadGenerator.RussiaPaymentOrder.CharacterSets characterSet = 2) { } public byte[] ToBytes() { } public override string ToString() { } public enum CharacterSets @@ -518,51 +518,51 @@ namespace QRCoder public class OptionalFields { public OptionalFields() { } - public string AddAmount { get; set; } + public string? AddAmount { get; set; } public System.DateTime? BirthDate { get; set; } - public string CBC { get; set; } - public string Category { get; set; } - public string ChildFio { get; set; } - public string ClassNum { get; set; } - public string Contract { get; set; } - public string CounterId { get; set; } - public string CounterVal { get; set; } + public string? CBC { get; set; } + public string? Category { get; set; } + public string? ChildFio { get; set; } + public string? ClassNum { get; set; } + public string? Contract { get; set; } + public string? CounterId { get; set; } + public string? CounterVal { get; set; } public System.DateTime? DocDate { get; set; } - public string DocIdx { get; set; } - public string DocNo { get; set; } - public string DrawerStatus { get; set; } - public string ExecId { get; set; } - public string FirstName { get; set; } - public string Flat { get; set; } - public string InstNum { get; set; } - public string KPP { get; set; } - public string LastName { get; set; } - public string MiddleName { get; set; } - public string OKTMO { get; set; } - public string PayeeINN { get; set; } - public string PayerAddress { get; set; } - public string PayerINN { get; set; } - public string PayerIdNum { get; set; } - public string PayerIdType { get; set; } - public string PaymPeriod { get; set; } - public string PaymTerm { get; set; } - public string PaytReason { get; set; } - public string PensAcc { get; set; } - public string PersAcc { get; set; } - public string PersonalAccount { get; set; } - public string Phone { get; set; } - public string Purpose { get; set; } + public string? DocIdx { get; set; } + public string? DocNo { get; set; } + public string? DrawerStatus { get; set; } + public string? ExecId { get; set; } + public string? FirstName { get; set; } + public string? Flat { get; set; } + public string? InstNum { get; set; } + public string? KPP { get; set; } + public string? LastName { get; set; } + public string? MiddleName { get; set; } + public string? OKTMO { get; set; } + public string? PayeeINN { get; set; } + public string? PayerAddress { get; set; } + public string? PayerINN { get; set; } + public string? PayerIdNum { get; set; } + public string? PayerIdType { get; set; } + public string? PaymPeriod { get; set; } + public string? PaymTerm { get; set; } + public string? PaytReason { get; set; } + public string? PensAcc { get; set; } + public string? PersAcc { get; set; } + public string? PersonalAccount { get; set; } + public string? Phone { get; set; } + public string? Purpose { get; set; } public System.DateTime? QuittDate { get; set; } - public string QuittId { get; set; } - public string RegType { get; set; } - public string RuleId { get; set; } - public string ServiceName { get; set; } - public string SpecFio { get; set; } - public string Sum { get; set; } - public string TaxPaytKind { get; set; } - public string TaxPeriod { get; set; } + public string? QuittId { get; set; } + public string? RegType { get; set; } + public string? RuleId { get; set; } + public string? ServiceName { get; set; } + public string? SpecFio { get; set; } + public string? Sum { get; set; } + public string? TaxPaytKind { get; set; } + public string? TaxPeriod { get; set; } public QRCoder.PayloadGenerator.RussiaPaymentOrder.TechCode? TechCode { get; set; } - public string UIN { get; set; } + public string? UIN { get; set; } } public class RussiaPaymentOrderException : System.Exception { @@ -601,9 +601,9 @@ namespace QRCoder } public class ShadowSocksConfig : QRCoder.PayloadGenerator.Payload { - public ShadowSocksConfig(string hostname, int port, string password, QRCoder.PayloadGenerator.ShadowSocksConfig.Method method, string tag = null) { } - public ShadowSocksConfig(string hostname, int port, string password, QRCoder.PayloadGenerator.ShadowSocksConfig.Method method, System.Collections.Generic.Dictionary parameters, string tag = null) { } - public ShadowSocksConfig(string hostname, int port, string password, QRCoder.PayloadGenerator.ShadowSocksConfig.Method method, string plugin, string pluginOption, string tag = null) { } + public ShadowSocksConfig(string hostname, int port, string password, QRCoder.PayloadGenerator.ShadowSocksConfig.Method method, string? tag = null) { } + public ShadowSocksConfig(string hostname, int port, string password, QRCoder.PayloadGenerator.ShadowSocksConfig.Method method, System.Collections.Generic.Dictionary? parameters, string? tag = null) { } + public ShadowSocksConfig(string hostname, int port, string password, QRCoder.PayloadGenerator.ShadowSocksConfig.Method method, string plugin, string? pluginOption, string? tag = null) { } public override string ToString() { } public enum Method { @@ -668,16 +668,16 @@ namespace QRCoder } public class SwissQrCode : QRCoder.PayloadGenerator.Payload { - public SwissQrCode(QRCoder.PayloadGenerator.SwissQrCode.Iban iban, QRCoder.PayloadGenerator.SwissQrCode.Currency currency, QRCoder.PayloadGenerator.SwissQrCode.Contact creditor, QRCoder.PayloadGenerator.SwissQrCode.Reference reference, QRCoder.PayloadGenerator.SwissQrCode.AdditionalInformation additionalInformation = null, QRCoder.PayloadGenerator.SwissQrCode.Contact debitor = null, decimal? amount = default, System.DateTime? requestedDateOfPayment = default, QRCoder.PayloadGenerator.SwissQrCode.Contact ultimateCreditor = null, string alternativeProcedure1 = null, string alternativeProcedure2 = null) { } + public SwissQrCode(QRCoder.PayloadGenerator.SwissQrCode.Iban iban, QRCoder.PayloadGenerator.SwissQrCode.Currency currency, QRCoder.PayloadGenerator.SwissQrCode.Contact creditor, QRCoder.PayloadGenerator.SwissQrCode.Reference reference, QRCoder.PayloadGenerator.SwissQrCode.AdditionalInformation? additionalInformation = null, QRCoder.PayloadGenerator.SwissQrCode.Contact? debitor = null, decimal? amount = default, System.DateTime? requestedDateOfPayment = default, QRCoder.PayloadGenerator.SwissQrCode.Contact? ultimateCreditor = null, string? alternativeProcedure1 = null, string? alternativeProcedure2 = null) { } public override QRCoder.QRCodeGenerator.ECCLevel EccLevel { get; } public override QRCoder.QRCodeGenerator.EciMode EciMode { get; } public override string ToString() { } public class AdditionalInformation { - public AdditionalInformation(string unstructuredMessage = null, string billInformation = null) { } - public string BillInformation { get; } + public AdditionalInformation(string? unstructuredMessage = null, string? billInformation = null) { } + public string? BillInformation { get; } public string Trailer { get; } - public string UnstructureMessage { get; } + public string? UnstructureMessage { get; } public class SwissQrCodeAdditionalInformationException : System.Exception { public SwissQrCodeAdditionalInformationException() { } @@ -690,10 +690,10 @@ namespace QRCoder [System.Obsolete("This constructor is deprecated. Use WithCombinedAddress instead.")] public Contact(string name, string country, string addressLine1, string addressLine2) { } [System.Obsolete("This constructor is deprecated. Use WithStructuredAddress instead.")] - public Contact(string name, string zipCode, string city, string country, string street = null, string houseNumber = null) { } + public Contact(string name, string zipCode, string city, string country, string? street = null, string? houseNumber = null) { } public override string ToString() { } public static QRCoder.PayloadGenerator.SwissQrCode.Contact WithCombinedAddress(string name, string country, string addressLine1, string addressLine2) { } - public static QRCoder.PayloadGenerator.SwissQrCode.Contact WithStructuredAddress(string name, string zipCode, string city, string country, string street = null, string houseNumber = null) { } + public static QRCoder.PayloadGenerator.SwissQrCode.Contact WithStructuredAddress(string name, string zipCode, string city, string country, string? street = null, string? houseNumber = null) { } public enum AddressType { StructuredAddress = 0, @@ -730,9 +730,9 @@ namespace QRCoder } public class Reference { - public Reference(QRCoder.PayloadGenerator.SwissQrCode.Reference.ReferenceType referenceType, string reference = null, QRCoder.PayloadGenerator.SwissQrCode.Reference.ReferenceTextType? referenceTextType = default) { } + public Reference(QRCoder.PayloadGenerator.SwissQrCode.Reference.ReferenceType referenceType, string? reference = null, QRCoder.PayloadGenerator.SwissQrCode.Reference.ReferenceTextType? referenceTextType = default) { } public QRCoder.PayloadGenerator.SwissQrCode.Reference.ReferenceType RefType { get; } - public string ReferenceText { get; } + public string? ReferenceText { get; } public enum ReferenceTextType { QrReference = 0, @@ -801,13 +801,13 @@ namespace QRCoder public string GetGraphic(int pointsPerModule, bool epsFormat = false) { } public string GetGraphic(System.Drawing.Size viewBox, bool drawQuietZones = true, bool epsFormat = false) { } public string GetGraphic(System.Drawing.Size viewBox, System.Drawing.Color darkColor, System.Drawing.Color lightColor, bool drawQuietZones = true, bool epsFormat = false) { } - public string GetGraphic(System.Drawing.Size viewBox, string darkColorHex, string lightColorHex, bool drawQuietZones = true, bool epsFormat = false) { } + public string GetGraphic(System.Drawing.Size viewBox, string? darkColorHex, string? lightColorHex, bool drawQuietZones = true, bool epsFormat = false) { } public string GetGraphic(int pointsPerModule, System.Drawing.Color darkColor, System.Drawing.Color lightColor, bool drawQuietZones = true, bool epsFormat = false) { } - public string GetGraphic(int pointsPerModule, string darkColorHex, string lightColorHex, bool drawQuietZones = true, bool epsFormat = false) { } + public string GetGraphic(int pointsPerModule, string? darkColorHex, string? lightColorHex, bool drawQuietZones = true, bool epsFormat = false) { } } public static class PostscriptQRCodeHelper { - public static string GetQRCode(string plainText, int pointsPerModule, string darkColorHex, string lightColorHex, QRCoder.QRCodeGenerator.ECCLevel eccLevel, bool forceUtf8 = false, bool utf8BOM = false, QRCoder.QRCodeGenerator.EciMode eciMode = 0, int requestedVersion = -1, bool drawQuietZones = true, bool epsFormat = false) { } + public static string GetQRCode(string plainText, int pointsPerModule, string? darkColorHex, string? lightColorHex, QRCoder.QRCodeGenerator.ECCLevel eccLevel, bool forceUtf8 = false, bool utf8BOM = false, QRCoder.QRCodeGenerator.EciMode eciMode = 0, int requestedVersion = -1, bool drawQuietZones = true, bool epsFormat = false) { } } public class QRCodeData : System.IDisposable { @@ -860,11 +860,11 @@ namespace QRCoder public SvgQRCode() { } public SvgQRCode(QRCoder.QRCodeData data) { } public string GetGraphic(int pixelsPerModule) { } - public string GetGraphic(System.Drawing.Size viewBox, bool drawQuietZones = true, QRCoder.SvgQRCode.SizingMode sizingMode = 0, QRCoder.SvgQRCode.SvgLogo logo = null) { } - public string GetGraphic(System.Drawing.Size viewBox, System.Drawing.Color darkColor, System.Drawing.Color lightColor, bool drawQuietZones = true, QRCoder.SvgQRCode.SizingMode sizingMode = 0, QRCoder.SvgQRCode.SvgLogo logo = null) { } - public string GetGraphic(System.Drawing.Size viewBox, string darkColorHex, string lightColorHex, bool drawQuietZones = true, QRCoder.SvgQRCode.SizingMode sizingMode = 0, QRCoder.SvgQRCode.SvgLogo logo = null) { } - public string GetGraphic(int pixelsPerModule, System.Drawing.Color darkColor, System.Drawing.Color lightColor, bool drawQuietZones = true, QRCoder.SvgQRCode.SizingMode sizingMode = 0, QRCoder.SvgQRCode.SvgLogo logo = null) { } - public string GetGraphic(int pixelsPerModule, string darkColorHex, string lightColorHex, bool drawQuietZones = true, QRCoder.SvgQRCode.SizingMode sizingMode = 0, QRCoder.SvgQRCode.SvgLogo logo = null) { } + public string GetGraphic(System.Drawing.Size viewBox, bool drawQuietZones = true, QRCoder.SvgQRCode.SizingMode sizingMode = 0, QRCoder.SvgQRCode.SvgLogo? logo = null) { } + public string GetGraphic(System.Drawing.Size viewBox, System.Drawing.Color darkColor, System.Drawing.Color lightColor, bool drawQuietZones = true, QRCoder.SvgQRCode.SizingMode sizingMode = 0, QRCoder.SvgQRCode.SvgLogo? logo = null) { } + public string GetGraphic(System.Drawing.Size viewBox, string darkColorHex, string lightColorHex, bool drawQuietZones = true, QRCoder.SvgQRCode.SizingMode sizingMode = 0, QRCoder.SvgQRCode.SvgLogo? logo = null) { } + public string GetGraphic(int pixelsPerModule, System.Drawing.Color darkColor, System.Drawing.Color lightColor, bool drawQuietZones = true, QRCoder.SvgQRCode.SizingMode sizingMode = 0, QRCoder.SvgQRCode.SvgLogo? logo = null) { } + public string GetGraphic(int pixelsPerModule, string darkColorHex, string lightColorHex, bool drawQuietZones = true, QRCoder.SvgQRCode.SizingMode sizingMode = 0, QRCoder.SvgQRCode.SvgLogo? logo = null) { } public enum SizingMode { WidthHeightAttribute = 0, @@ -891,7 +891,7 @@ namespace QRCoder } public static class SvgQRCodeHelper { - public static string GetQRCode(string plainText, int pixelsPerModule, string darkColorHex, string lightColorHex, QRCoder.QRCodeGenerator.ECCLevel eccLevel, bool forceUtf8 = false, bool utf8BOM = false, QRCoder.QRCodeGenerator.EciMode eciMode = 0, int requestedVersion = -1, bool drawQuietZones = true, QRCoder.SvgQRCode.SizingMode sizingMode = 0, QRCoder.SvgQRCode.SvgLogo logo = null) { } + public static string GetQRCode(string plainText, int pixelsPerModule, string darkColorHex, string lightColorHex, QRCoder.QRCodeGenerator.ECCLevel eccLevel, bool forceUtf8 = false, bool utf8BOM = false, QRCoder.QRCodeGenerator.EciMode eciMode = 0, int requestedVersion = -1, bool drawQuietZones = true, QRCoder.SvgQRCode.SizingMode sizingMode = 0, QRCoder.SvgQRCode.SvgLogo? logo = null) { } } } namespace QRCoder.Exceptions @@ -908,7 +908,7 @@ namespace QRCoder.Extensions public static class CustomExtensions { [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("This method uses reflection to examine the provided enum value.")] - public static string GetStringValue(this System.Enum value) { } + public static string? GetStringValue(this System.Enum value) { } } [System.Obsolete("This attribute will be removed in a future version of QRCoder.")] public class StringValueAttribute : System.Attribute diff --git a/QRCoderApiTests/netstandard13/QRCoder.approved.txt b/QRCoderApiTests/netstandard13/QRCoder.approved.txt index bada43f1..343903e1 100644 --- a/QRCoderApiTests/netstandard13/QRCoder.approved.txt +++ b/QRCoderApiTests/netstandard13/QRCoder.approved.txt @@ -288,15 +288,15 @@ namespace QRCoder } public class BitcoinAddress : QRCoder.PayloadGenerator.BitcoinLikeCryptoCurrencyAddress { - public BitcoinAddress(string address, double? amount, string label = null, string message = null) { } + public BitcoinAddress(string address, double? amount, string? label = null, string? message = null) { } } public class BitcoinCashAddress : QRCoder.PayloadGenerator.BitcoinLikeCryptoCurrencyAddress { - public BitcoinCashAddress(string address, double? amount, string label = null, string message = null) { } + public BitcoinCashAddress(string address, double? amount, string? label = null, string? message = null) { } } public class BitcoinLikeCryptoCurrencyAddress : QRCoder.PayloadGenerator.Payload { - public BitcoinLikeCryptoCurrencyAddress(QRCoder.PayloadGenerator.BitcoinLikeCryptoCurrencyAddress.BitcoinLikeCryptoCurrencyType currencyType, string address, double? amount, string label = null, string message = null) { } + public BitcoinLikeCryptoCurrencyAddress(QRCoder.PayloadGenerator.BitcoinLikeCryptoCurrencyAddress.BitcoinLikeCryptoCurrencyType currencyType, string address, double? amount, string? label = null, string? message = null) { } public override string ToString() { } public enum BitcoinLikeCryptoCurrencyType { @@ -312,8 +312,8 @@ namespace QRCoder } public class CalendarEvent : QRCoder.PayloadGenerator.Payload { - public CalendarEvent(string subject, string description, string location, System.DateTime start, System.DateTime end, bool allDayEvent, QRCoder.PayloadGenerator.CalendarEvent.EventEncoding encoding = 1) { } - public CalendarEvent(string subject, string description, string location, System.DateTimeOffset start, System.DateTimeOffset end, bool allDayEvent, QRCoder.PayloadGenerator.CalendarEvent.EventEncoding encoding = 1) { } + public CalendarEvent(string subject, string? description, string? location, System.DateTime start, System.DateTime end, bool allDayEvent, QRCoder.PayloadGenerator.CalendarEvent.EventEncoding encoding = 1) { } + public CalendarEvent(string subject, string? description, string? location, System.DateTimeOffset start, System.DateTimeOffset end, bool allDayEvent, QRCoder.PayloadGenerator.CalendarEvent.EventEncoding encoding = 1) { } public override string ToString() { } public enum EventEncoding { @@ -327,23 +327,23 @@ namespace QRCoder QRCoder.PayloadGenerator.ContactData.ContactOutputType outputType, string firstname, string lastname, - string nickname = null, - string phone = null, - string mobilePhone = null, - string workPhone = null, - string email = null, + string? nickname = null, + string? phone = null, + string? mobilePhone = null, + string? workPhone = null, + string? email = null, System.DateTime? birthday = default, - string website = null, - string street = null, - string houseNumber = null, - string city = null, - string zipCode = null, - string country = null, - string note = null, - string stateRegion = null, + string? website = null, + string? street = null, + string? houseNumber = null, + string? city = null, + string? zipCode = null, + string? country = null, + string? note = null, + string? stateRegion = null, QRCoder.PayloadGenerator.ContactData.AddressOrder addressOrder = 0, - string org = null, - string orgTitle = null) { } + string? org = null, + string? orgTitle = null) { } public override string ToString() { } public enum AddressOrder { @@ -403,7 +403,7 @@ namespace QRCoder } public class LitecoinAddress : QRCoder.PayloadGenerator.BitcoinLikeCryptoCurrencyAddress { - public LitecoinAddress(string address, double? amount, string label = null, string message = null) { } + public LitecoinAddress(string address, double? amount, string? label = null, string? message = null) { } } public class MMS : QRCoder.PayloadGenerator.Payload { @@ -418,7 +418,7 @@ namespace QRCoder } public class Mail : QRCoder.PayloadGenerator.Payload { - public Mail(string mailReceiver = null, string subject = null, string message = null, QRCoder.PayloadGenerator.Mail.MailEncoding encoding = 0) { } + public Mail(string? mailReceiver = null, string? subject = null, string? message = null, QRCoder.PayloadGenerator.Mail.MailEncoding encoding = 0) { } public override string ToString() { } public enum MailEncoding { @@ -429,7 +429,7 @@ namespace QRCoder } public class MoneroTransaction : QRCoder.PayloadGenerator.Payload { - public MoneroTransaction(string address, float? txAmount = default, string txPaymentId = null, string recipientName = null, string txDescription = null) { } + public MoneroTransaction(string address, float? txAmount = default, string? txPaymentId = null, string? recipientName = null, string? txDescription = null) { } public override string ToString() { } public class MoneroTransactionException : System.Exception { @@ -446,8 +446,8 @@ namespace QRCoder public QRCoder.PayloadGenerator.OneTimePassword.OneTimePasswordAuthAlgorithm AuthAlgorithm { get; set; } public int? Counter { get; set; } public int Digits { get; set; } - public string Issuer { get; set; } - public string Label { get; set; } + public string? Issuer { get; set; } + public string? Label { get; set; } public int? Period { get; set; } public string Secret { get; set; } public QRCoder.PayloadGenerator.OneTimePassword.OneTimePasswordAuthType Type { get; set; } @@ -486,7 +486,7 @@ namespace QRCoder } public class RussiaPaymentOrder : QRCoder.PayloadGenerator.Payload { - public RussiaPaymentOrder(string name, string personalAcc, string bankName, string BIC, string correspAcc, QRCoder.PayloadGenerator.RussiaPaymentOrder.OptionalFields optionalFields = null, QRCoder.PayloadGenerator.RussiaPaymentOrder.CharacterSets characterSet = 2) { } + public RussiaPaymentOrder(string name, string personalAcc, string bankName, string BIC, string correspAcc, QRCoder.PayloadGenerator.RussiaPaymentOrder.OptionalFields? optionalFields = null, QRCoder.PayloadGenerator.RussiaPaymentOrder.CharacterSets characterSet = 2) { } public byte[] ToBytes() { } public override string ToString() { } public enum CharacterSets @@ -498,51 +498,51 @@ namespace QRCoder public class OptionalFields { public OptionalFields() { } - public string AddAmount { get; set; } + public string? AddAmount { get; set; } public System.DateTime? BirthDate { get; set; } - public string CBC { get; set; } - public string Category { get; set; } - public string ChildFio { get; set; } - public string ClassNum { get; set; } - public string Contract { get; set; } - public string CounterId { get; set; } - public string CounterVal { get; set; } + public string? CBC { get; set; } + public string? Category { get; set; } + public string? ChildFio { get; set; } + public string? ClassNum { get; set; } + public string? Contract { get; set; } + public string? CounterId { get; set; } + public string? CounterVal { get; set; } public System.DateTime? DocDate { get; set; } - public string DocIdx { get; set; } - public string DocNo { get; set; } - public string DrawerStatus { get; set; } - public string ExecId { get; set; } - public string FirstName { get; set; } - public string Flat { get; set; } - public string InstNum { get; set; } - public string KPP { get; set; } - public string LastName { get; set; } - public string MiddleName { get; set; } - public string OKTMO { get; set; } - public string PayeeINN { get; set; } - public string PayerAddress { get; set; } - public string PayerINN { get; set; } - public string PayerIdNum { get; set; } - public string PayerIdType { get; set; } - public string PaymPeriod { get; set; } - public string PaymTerm { get; set; } - public string PaytReason { get; set; } - public string PensAcc { get; set; } - public string PersAcc { get; set; } - public string PersonalAccount { get; set; } - public string Phone { get; set; } - public string Purpose { get; set; } + public string? DocIdx { get; set; } + public string? DocNo { get; set; } + public string? DrawerStatus { get; set; } + public string? ExecId { get; set; } + public string? FirstName { get; set; } + public string? Flat { get; set; } + public string? InstNum { get; set; } + public string? KPP { get; set; } + public string? LastName { get; set; } + public string? MiddleName { get; set; } + public string? OKTMO { get; set; } + public string? PayeeINN { get; set; } + public string? PayerAddress { get; set; } + public string? PayerINN { get; set; } + public string? PayerIdNum { get; set; } + public string? PayerIdType { get; set; } + public string? PaymPeriod { get; set; } + public string? PaymTerm { get; set; } + public string? PaytReason { get; set; } + public string? PensAcc { get; set; } + public string? PersAcc { get; set; } + public string? PersonalAccount { get; set; } + public string? Phone { get; set; } + public string? Purpose { get; set; } public System.DateTime? QuittDate { get; set; } - public string QuittId { get; set; } - public string RegType { get; set; } - public string RuleId { get; set; } - public string ServiceName { get; set; } - public string SpecFio { get; set; } - public string Sum { get; set; } - public string TaxPaytKind { get; set; } - public string TaxPeriod { get; set; } + public string? QuittId { get; set; } + public string? RegType { get; set; } + public string? RuleId { get; set; } + public string? ServiceName { get; set; } + public string? SpecFio { get; set; } + public string? Sum { get; set; } + public string? TaxPaytKind { get; set; } + public string? TaxPeriod { get; set; } public QRCoder.PayloadGenerator.RussiaPaymentOrder.TechCode? TechCode { get; set; } - public string UIN { get; set; } + public string? UIN { get; set; } } public class RussiaPaymentOrderException : System.Exception { @@ -581,9 +581,9 @@ namespace QRCoder } public class ShadowSocksConfig : QRCoder.PayloadGenerator.Payload { - public ShadowSocksConfig(string hostname, int port, string password, QRCoder.PayloadGenerator.ShadowSocksConfig.Method method, string tag = null) { } - public ShadowSocksConfig(string hostname, int port, string password, QRCoder.PayloadGenerator.ShadowSocksConfig.Method method, System.Collections.Generic.Dictionary parameters, string tag = null) { } - public ShadowSocksConfig(string hostname, int port, string password, QRCoder.PayloadGenerator.ShadowSocksConfig.Method method, string plugin, string pluginOption, string tag = null) { } + public ShadowSocksConfig(string hostname, int port, string password, QRCoder.PayloadGenerator.ShadowSocksConfig.Method method, string? tag = null) { } + public ShadowSocksConfig(string hostname, int port, string password, QRCoder.PayloadGenerator.ShadowSocksConfig.Method method, System.Collections.Generic.Dictionary? parameters, string? tag = null) { } + public ShadowSocksConfig(string hostname, int port, string password, QRCoder.PayloadGenerator.ShadowSocksConfig.Method method, string plugin, string? pluginOption, string? tag = null) { } public override string ToString() { } public enum Method { @@ -648,16 +648,16 @@ namespace QRCoder } public class SwissQrCode : QRCoder.PayloadGenerator.Payload { - public SwissQrCode(QRCoder.PayloadGenerator.SwissQrCode.Iban iban, QRCoder.PayloadGenerator.SwissQrCode.Currency currency, QRCoder.PayloadGenerator.SwissQrCode.Contact creditor, QRCoder.PayloadGenerator.SwissQrCode.Reference reference, QRCoder.PayloadGenerator.SwissQrCode.AdditionalInformation additionalInformation = null, QRCoder.PayloadGenerator.SwissQrCode.Contact debitor = null, decimal? amount = default, System.DateTime? requestedDateOfPayment = default, QRCoder.PayloadGenerator.SwissQrCode.Contact ultimateCreditor = null, string alternativeProcedure1 = null, string alternativeProcedure2 = null) { } + public SwissQrCode(QRCoder.PayloadGenerator.SwissQrCode.Iban iban, QRCoder.PayloadGenerator.SwissQrCode.Currency currency, QRCoder.PayloadGenerator.SwissQrCode.Contact creditor, QRCoder.PayloadGenerator.SwissQrCode.Reference reference, QRCoder.PayloadGenerator.SwissQrCode.AdditionalInformation? additionalInformation = null, QRCoder.PayloadGenerator.SwissQrCode.Contact? debitor = null, decimal? amount = default, System.DateTime? requestedDateOfPayment = default, QRCoder.PayloadGenerator.SwissQrCode.Contact? ultimateCreditor = null, string? alternativeProcedure1 = null, string? alternativeProcedure2 = null) { } public override QRCoder.QRCodeGenerator.ECCLevel EccLevel { get; } public override QRCoder.QRCodeGenerator.EciMode EciMode { get; } public override string ToString() { } public class AdditionalInformation { - public AdditionalInformation(string unstructuredMessage = null, string billInformation = null) { } - public string BillInformation { get; } + public AdditionalInformation(string? unstructuredMessage = null, string? billInformation = null) { } + public string? BillInformation { get; } public string Trailer { get; } - public string UnstructureMessage { get; } + public string? UnstructureMessage { get; } public class SwissQrCodeAdditionalInformationException : System.Exception { public SwissQrCodeAdditionalInformationException() { } @@ -670,10 +670,10 @@ namespace QRCoder [System.Obsolete("This constructor is deprecated. Use WithCombinedAddress instead.")] public Contact(string name, string country, string addressLine1, string addressLine2) { } [System.Obsolete("This constructor is deprecated. Use WithStructuredAddress instead.")] - public Contact(string name, string zipCode, string city, string country, string street = null, string houseNumber = null) { } + public Contact(string name, string zipCode, string city, string country, string? street = null, string? houseNumber = null) { } public override string ToString() { } public static QRCoder.PayloadGenerator.SwissQrCode.Contact WithCombinedAddress(string name, string country, string addressLine1, string addressLine2) { } - public static QRCoder.PayloadGenerator.SwissQrCode.Contact WithStructuredAddress(string name, string zipCode, string city, string country, string street = null, string houseNumber = null) { } + public static QRCoder.PayloadGenerator.SwissQrCode.Contact WithStructuredAddress(string name, string zipCode, string city, string country, string? street = null, string? houseNumber = null) { } public enum AddressType { StructuredAddress = 0, @@ -710,9 +710,9 @@ namespace QRCoder } public class Reference { - public Reference(QRCoder.PayloadGenerator.SwissQrCode.Reference.ReferenceType referenceType, string reference = null, QRCoder.PayloadGenerator.SwissQrCode.Reference.ReferenceTextType? referenceTextType = default) { } + public Reference(QRCoder.PayloadGenerator.SwissQrCode.Reference.ReferenceType referenceType, string? reference = null, QRCoder.PayloadGenerator.SwissQrCode.Reference.ReferenceTextType? referenceTextType = default) { } public QRCoder.PayloadGenerator.SwissQrCode.Reference.ReferenceType RefType { get; } - public string ReferenceText { get; } + public string? ReferenceText { get; } public enum ReferenceTextType { QrReference = 0, @@ -834,7 +834,7 @@ namespace QRCoder.Extensions [System.Obsolete("This class will be removed in a future version of QRCoder.")] public static class CustomExtensions { - public static string GetStringValue(this System.Enum value) { } + public static string? GetStringValue(this System.Enum value) { } } [System.Obsolete("This attribute will be removed in a future version of QRCoder.")] public class StringValueAttribute : System.Attribute From 7140a48d73b9cab8d4e636ab007f62584beede51 Mon Sep 17 00:00:00 2001 From: Shane32 Date: Sat, 1 Jun 2024 16:29:00 -0400 Subject: [PATCH 2/5] Update --- QRCoder/Attributes/PolyfillAttributes.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/QRCoder/Attributes/PolyfillAttributes.cs b/QRCoder/Attributes/PolyfillAttributes.cs index c92cb180..e0aa2a4c 100644 --- a/QRCoder/Attributes/PolyfillAttributes.cs +++ b/QRCoder/Attributes/PolyfillAttributes.cs @@ -6,7 +6,7 @@ namespace System.Diagnostics.CodeAnalysis /// the parameter will not be null even if the corresponding type allows it. /// [AttributeUsage(AttributeTargets.Parameter, Inherited = false)] - public sealed class NotNullWhenAttribute : Attribute + internal sealed class NotNullWhenAttribute : Attribute { /// /// Initializes the attribute with the specified return value condition. From 3d7453fc053ca80c22a0b9bd0e2a71d3d141ca02 Mon Sep 17 00:00:00 2001 From: Shane32 Date: Sat, 1 Jun 2024 16:29:37 -0400 Subject: [PATCH 3/5] Update --- .../Attributes/{PolyfillAttributes.cs => NotNullWhenAttribute.cs} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename QRCoder/Attributes/{PolyfillAttributes.cs => NotNullWhenAttribute.cs} (100%) diff --git a/QRCoder/Attributes/PolyfillAttributes.cs b/QRCoder/Attributes/NotNullWhenAttribute.cs similarity index 100% rename from QRCoder/Attributes/PolyfillAttributes.cs rename to QRCoder/Attributes/NotNullWhenAttribute.cs From eb880bf64ff2584b112549af0e5acea7790fed5c Mon Sep 17 00:00:00 2001 From: Shane32 Date: Sat, 1 Jun 2024 16:35:28 -0400 Subject: [PATCH 4/5] Update color strings --- QRCoder/PostscriptQRCode.cs | 6 +++--- QRCoder/QRCode.cs | 4 ++-- .../QRCoder.approved.txt | 6 +++--- QRCoderApiTests/net60-windows/QRCoder.approved.txt | 6 +++--- QRCoderApiTests/net60/QRCoder.approved.txt | 4 ++-- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/QRCoder/PostscriptQRCode.cs b/QRCoder/PostscriptQRCode.cs index 42953886..1c39ce2e 100644 --- a/QRCoder/PostscriptQRCode.cs +++ b/QRCoder/PostscriptQRCode.cs @@ -25,7 +25,7 @@ public string GetGraphic(int pointsPerModule, Color darkColor, Color lightColor, return this.GetGraphic(viewBox, darkColor, lightColor, drawQuietZones, epsFormat); } - public string GetGraphic(int pointsPerModule, string? darkColorHex, string? lightColorHex, bool drawQuietZones = true, bool epsFormat = false) + public string GetGraphic(int pointsPerModule, string darkColorHex, string lightColorHex, bool drawQuietZones = true, bool epsFormat = false) { var viewBox = new Size(pointsPerModule * this.QrCodeData.ModuleMatrix.Count, pointsPerModule * this.QrCodeData.ModuleMatrix.Count); return this.GetGraphic(viewBox, darkColorHex, lightColorHex, drawQuietZones, epsFormat); @@ -36,9 +36,9 @@ public string GetGraphic(Size viewBox, bool drawQuietZones = true, bool epsForma return this.GetGraphic(viewBox, Color.Black, Color.White, drawQuietZones, epsFormat); } - public string GetGraphic(Size viewBox, string? darkColorHex, string? lightColorHex, bool drawQuietZones = true, bool epsFormat = false) + public string GetGraphic(Size viewBox, string darkColorHex, string lightColorHex, bool drawQuietZones = true, bool epsFormat = false) { - return this.GetGraphic(viewBox, ColorTranslator.FromHtml(darkColorHex!), ColorTranslator.FromHtml(lightColorHex!), drawQuietZones, epsFormat); + return this.GetGraphic(viewBox, ColorTranslator.FromHtml(darkColorHex), ColorTranslator.FromHtml(lightColorHex), drawQuietZones, epsFormat); } public string GetGraphic(Size viewBox, Color darkColor, Color lightColor, bool drawQuietZones = true, bool epsFormat = false) diff --git a/QRCoder/QRCode.cs b/QRCoder/QRCode.cs index 29efc638..e42666b9 100644 --- a/QRCoder/QRCode.cs +++ b/QRCoder/QRCode.cs @@ -23,9 +23,9 @@ public Bitmap GetGraphic(int pixelsPerModule) return this.GetGraphic(pixelsPerModule, Color.Black, Color.White, true); } - public Bitmap GetGraphic(int pixelsPerModule, string? darkColorHtmlHex, string? lightColorHtmlHex, bool drawQuietZones = true) + public Bitmap GetGraphic(int pixelsPerModule, string darkColorHtmlHex, string lightColorHtmlHex, bool drawQuietZones = true) { - return this.GetGraphic(pixelsPerModule, ColorTranslator.FromHtml(darkColorHtmlHex!), ColorTranslator.FromHtml(lightColorHtmlHex!), drawQuietZones); + return this.GetGraphic(pixelsPerModule, ColorTranslator.FromHtml(darkColorHtmlHex), ColorTranslator.FromHtml(lightColorHtmlHex), drawQuietZones); } public Bitmap GetGraphic(int pixelsPerModule, Color darkColor, Color lightColor, bool drawQuietZones = true) diff --git a/QRCoderApiTests/net35+net40+net50+net50-windows+netstandard20/QRCoder.approved.txt b/QRCoderApiTests/net35+net40+net50+net50-windows+netstandard20/QRCoder.approved.txt index 4df87c92..4dd292dc 100644 --- a/QRCoderApiTests/net35+net40+net50+net50-windows+netstandard20/QRCoder.approved.txt +++ b/QRCoderApiTests/net35+net40+net50+net50-windows+netstandard20/QRCoder.approved.txt @@ -850,9 +850,9 @@ namespace QRCoder public string GetGraphic(int pointsPerModule, bool epsFormat = false) { } public string GetGraphic(System.Drawing.Size viewBox, bool drawQuietZones = true, bool epsFormat = false) { } public string GetGraphic(System.Drawing.Size viewBox, System.Drawing.Color darkColor, System.Drawing.Color lightColor, bool drawQuietZones = true, bool epsFormat = false) { } - public string GetGraphic(System.Drawing.Size viewBox, string? darkColorHex, string? lightColorHex, bool drawQuietZones = true, bool epsFormat = false) { } + public string GetGraphic(System.Drawing.Size viewBox, string darkColorHex, string lightColorHex, bool drawQuietZones = true, bool epsFormat = false) { } public string GetGraphic(int pointsPerModule, System.Drawing.Color darkColor, System.Drawing.Color lightColor, bool drawQuietZones = true, bool epsFormat = false) { } - public string GetGraphic(int pointsPerModule, string? darkColorHex, string? lightColorHex, bool drawQuietZones = true, bool epsFormat = false) { } + public string GetGraphic(int pointsPerModule, string darkColorHex, string lightColorHex, bool drawQuietZones = true, bool epsFormat = false) { } } public static class PostscriptQRCodeHelper { @@ -864,7 +864,7 @@ namespace QRCoder public QRCode(QRCoder.QRCodeData data) { } public System.Drawing.Bitmap GetGraphic(int pixelsPerModule) { } public System.Drawing.Bitmap GetGraphic(int pixelsPerModule, System.Drawing.Color darkColor, System.Drawing.Color lightColor, bool drawQuietZones = true) { } - public System.Drawing.Bitmap GetGraphic(int pixelsPerModule, string? darkColorHtmlHex, string? lightColorHtmlHex, bool drawQuietZones = true) { } + public System.Drawing.Bitmap GetGraphic(int pixelsPerModule, string darkColorHtmlHex, string lightColorHtmlHex, bool drawQuietZones = true) { } public System.Drawing.Bitmap GetGraphic(int pixelsPerModule, System.Drawing.Color darkColor, System.Drawing.Color lightColor, System.Drawing.Bitmap? icon = null, int iconSizePercent = 15, int iconBorderWidth = 0, bool drawQuietZones = true, System.Drawing.Color? iconBackgroundColor = default) { } } public class QRCodeData : System.IDisposable diff --git a/QRCoderApiTests/net60-windows/QRCoder.approved.txt b/QRCoderApiTests/net60-windows/QRCoder.approved.txt index e28f12f3..dabf0019 100644 --- a/QRCoderApiTests/net60-windows/QRCoder.approved.txt +++ b/QRCoderApiTests/net60-windows/QRCoder.approved.txt @@ -857,9 +857,9 @@ namespace QRCoder public string GetGraphic(int pointsPerModule, bool epsFormat = false) { } public string GetGraphic(System.Drawing.Size viewBox, bool drawQuietZones = true, bool epsFormat = false) { } public string GetGraphic(System.Drawing.Size viewBox, System.Drawing.Color darkColor, System.Drawing.Color lightColor, bool drawQuietZones = true, bool epsFormat = false) { } - public string GetGraphic(System.Drawing.Size viewBox, string? darkColorHex, string? lightColorHex, bool drawQuietZones = true, bool epsFormat = false) { } + public string GetGraphic(System.Drawing.Size viewBox, string darkColorHex, string lightColorHex, bool drawQuietZones = true, bool epsFormat = false) { } public string GetGraphic(int pointsPerModule, System.Drawing.Color darkColor, System.Drawing.Color lightColor, bool drawQuietZones = true, bool epsFormat = false) { } - public string GetGraphic(int pointsPerModule, string? darkColorHex, string? lightColorHex, bool drawQuietZones = true, bool epsFormat = false) { } + public string GetGraphic(int pointsPerModule, string darkColorHex, string lightColorHex, bool drawQuietZones = true, bool epsFormat = false) { } } public static class PostscriptQRCodeHelper { @@ -872,7 +872,7 @@ namespace QRCoder public QRCode(QRCoder.QRCodeData data) { } public System.Drawing.Bitmap GetGraphic(int pixelsPerModule) { } public System.Drawing.Bitmap GetGraphic(int pixelsPerModule, System.Drawing.Color darkColor, System.Drawing.Color lightColor, bool drawQuietZones = true) { } - public System.Drawing.Bitmap GetGraphic(int pixelsPerModule, string? darkColorHtmlHex, string? lightColorHtmlHex, bool drawQuietZones = true) { } + public System.Drawing.Bitmap GetGraphic(int pixelsPerModule, string darkColorHtmlHex, string lightColorHtmlHex, bool drawQuietZones = true) { } public System.Drawing.Bitmap GetGraphic(int pixelsPerModule, System.Drawing.Color darkColor, System.Drawing.Color lightColor, System.Drawing.Bitmap? icon = null, int iconSizePercent = 15, int iconBorderWidth = 0, bool drawQuietZones = true, System.Drawing.Color? iconBackgroundColor = default) { } } public class QRCodeData : System.IDisposable diff --git a/QRCoderApiTests/net60/QRCoder.approved.txt b/QRCoderApiTests/net60/QRCoder.approved.txt index e5d9ecae..f7875bc9 100644 --- a/QRCoderApiTests/net60/QRCoder.approved.txt +++ b/QRCoderApiTests/net60/QRCoder.approved.txt @@ -801,9 +801,9 @@ namespace QRCoder public string GetGraphic(int pointsPerModule, bool epsFormat = false) { } public string GetGraphic(System.Drawing.Size viewBox, bool drawQuietZones = true, bool epsFormat = false) { } public string GetGraphic(System.Drawing.Size viewBox, System.Drawing.Color darkColor, System.Drawing.Color lightColor, bool drawQuietZones = true, bool epsFormat = false) { } - public string GetGraphic(System.Drawing.Size viewBox, string? darkColorHex, string? lightColorHex, bool drawQuietZones = true, bool epsFormat = false) { } + public string GetGraphic(System.Drawing.Size viewBox, string darkColorHex, string lightColorHex, bool drawQuietZones = true, bool epsFormat = false) { } public string GetGraphic(int pointsPerModule, System.Drawing.Color darkColor, System.Drawing.Color lightColor, bool drawQuietZones = true, bool epsFormat = false) { } - public string GetGraphic(int pointsPerModule, string? darkColorHex, string? lightColorHex, bool drawQuietZones = true, bool epsFormat = false) { } + public string GetGraphic(int pointsPerModule, string darkColorHex, string lightColorHex, bool drawQuietZones = true, bool epsFormat = false) { } } public static class PostscriptQRCodeHelper { From b15d28bb3ac5553b514818d2f407ed38aa8cce0a Mon Sep 17 00:00:00 2001 From: Shane32 Date: Sat, 1 Jun 2024 16:36:43 -0400 Subject: [PATCH 5/5] Update color strings --- QRCoder/PostscriptQRCode.cs | 2 +- .../QRCoder.approved.txt | 2 +- QRCoderApiTests/net60-windows/QRCoder.approved.txt | 2 +- QRCoderApiTests/net60/QRCoder.approved.txt | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/QRCoder/PostscriptQRCode.cs b/QRCoder/PostscriptQRCode.cs index 1c39ce2e..d0484a9b 100644 --- a/QRCoder/PostscriptQRCode.cs +++ b/QRCoder/PostscriptQRCode.cs @@ -142,7 +142,7 @@ sc sc scale public static class PostscriptQRCodeHelper { - public static string GetQRCode(string plainText, int pointsPerModule, string? darkColorHex, string? lightColorHex, ECCLevel eccLevel, bool forceUtf8 = false, bool utf8BOM = false, EciMode eciMode = EciMode.Default, int requestedVersion = -1, bool drawQuietZones = true, bool epsFormat = false) + public static string GetQRCode(string plainText, int pointsPerModule, string darkColorHex, string lightColorHex, ECCLevel eccLevel, bool forceUtf8 = false, bool utf8BOM = false, EciMode eciMode = EciMode.Default, int requestedVersion = -1, bool drawQuietZones = true, bool epsFormat = false) { using (var qrGenerator = new QRCodeGenerator()) using (var qrCodeData = qrGenerator.CreateQrCode(plainText, eccLevel, forceUtf8, utf8BOM, eciMode, requestedVersion)) diff --git a/QRCoderApiTests/net35+net40+net50+net50-windows+netstandard20/QRCoder.approved.txt b/QRCoderApiTests/net35+net40+net50+net50-windows+netstandard20/QRCoder.approved.txt index 4dd292dc..4bc3a2ff 100644 --- a/QRCoderApiTests/net35+net40+net50+net50-windows+netstandard20/QRCoder.approved.txt +++ b/QRCoderApiTests/net35+net40+net50+net50-windows+netstandard20/QRCoder.approved.txt @@ -856,7 +856,7 @@ namespace QRCoder } public static class PostscriptQRCodeHelper { - public static string GetQRCode(string plainText, int pointsPerModule, string? darkColorHex, string? lightColorHex, QRCoder.QRCodeGenerator.ECCLevel eccLevel, bool forceUtf8 = false, bool utf8BOM = false, QRCoder.QRCodeGenerator.EciMode eciMode = 0, int requestedVersion = -1, bool drawQuietZones = true, bool epsFormat = false) { } + public static string GetQRCode(string plainText, int pointsPerModule, string darkColorHex, string lightColorHex, QRCoder.QRCodeGenerator.ECCLevel eccLevel, bool forceUtf8 = false, bool utf8BOM = false, QRCoder.QRCodeGenerator.EciMode eciMode = 0, int requestedVersion = -1, bool drawQuietZones = true, bool epsFormat = false) { } } public class QRCode : QRCoder.AbstractQRCode, System.IDisposable { diff --git a/QRCoderApiTests/net60-windows/QRCoder.approved.txt b/QRCoderApiTests/net60-windows/QRCoder.approved.txt index dabf0019..9f84c603 100644 --- a/QRCoderApiTests/net60-windows/QRCoder.approved.txt +++ b/QRCoderApiTests/net60-windows/QRCoder.approved.txt @@ -863,7 +863,7 @@ namespace QRCoder } public static class PostscriptQRCodeHelper { - public static string GetQRCode(string plainText, int pointsPerModule, string? darkColorHex, string? lightColorHex, QRCoder.QRCodeGenerator.ECCLevel eccLevel, bool forceUtf8 = false, bool utf8BOM = false, QRCoder.QRCodeGenerator.EciMode eciMode = 0, int requestedVersion = -1, bool drawQuietZones = true, bool epsFormat = false) { } + public static string GetQRCode(string plainText, int pointsPerModule, string darkColorHex, string lightColorHex, QRCoder.QRCodeGenerator.ECCLevel eccLevel, bool forceUtf8 = false, bool utf8BOM = false, QRCoder.QRCodeGenerator.EciMode eciMode = 0, int requestedVersion = -1, bool drawQuietZones = true, bool epsFormat = false) { } } [System.Runtime.Versioning.SupportedOSPlatform("windows")] public class QRCode : QRCoder.AbstractQRCode, System.IDisposable diff --git a/QRCoderApiTests/net60/QRCoder.approved.txt b/QRCoderApiTests/net60/QRCoder.approved.txt index f7875bc9..a50f60df 100644 --- a/QRCoderApiTests/net60/QRCoder.approved.txt +++ b/QRCoderApiTests/net60/QRCoder.approved.txt @@ -807,7 +807,7 @@ namespace QRCoder } public static class PostscriptQRCodeHelper { - public static string GetQRCode(string plainText, int pointsPerModule, string? darkColorHex, string? lightColorHex, QRCoder.QRCodeGenerator.ECCLevel eccLevel, bool forceUtf8 = false, bool utf8BOM = false, QRCoder.QRCodeGenerator.EciMode eciMode = 0, int requestedVersion = -1, bool drawQuietZones = true, bool epsFormat = false) { } + public static string GetQRCode(string plainText, int pointsPerModule, string darkColorHex, string lightColorHex, QRCoder.QRCodeGenerator.ECCLevel eccLevel, bool forceUtf8 = false, bool utf8BOM = false, QRCoder.QRCodeGenerator.EciMode eciMode = 0, int requestedVersion = -1, bool drawQuietZones = true, bool epsFormat = false) { } } public class QRCodeData : System.IDisposable {