Enable recommended analyzers; use invariant culture throughout by Shane32 · Pull Request #640 · Shane32/QRCoder (original) (raw)

📝 Walkthrough

Walkthrough

Project-wide refactors emphasize culture-invariant formatting, stricter exception types, and static helper conversions. Dispose methods in core classes become virtual. A new QRCodeGenerator.EciMode enum is added. Extensions gain HexColorToByteArray and AttributeUsage on StringValueAttribute. Build/test configs adjust analyzer settings and warnings; API approval baselines updated.

Changes

Cohort / File(s) Summary
Analyzer and build configDirectory.Build.props, QRCoderBenchmarks/QRCoderBenchmarks.csproj, QRCoderTests/QRCoderTests.csproj, .editorconfig, QRCoderDemo/QRCoderDemo.csproj, QRCoderApiTests/ApiApprovalTests.cs Enable Recommended analysis mode, add/suppress specific analyzer warnings (CA1822, CA1707, CA1416, CA1861), set NeutralLanguage, and disable IDE0022.
Culture-invariant formattingQRCoder/PayloadGenerator.cs, QRCoder/PayloadGenerator/BezahlCode.cs, .../BitcoinLikeCryptoCurrencyAddress.cs, .../CalendarEvent.cs, .../ContactData.cs, .../Girocode.cs, .../MoneroTransaction.cs, .../RussiaPaymentOrder.cs, .../SlovenianUpnQr.cs, .../SwissQrCode.cs, QRCoder/PostscriptQRCode.cs, QRCoder/SvgQRCode.cs, QRCoderTests/PayloadGeneratorTests/BezahlCodeTests.cs Replace culture-sensitive casing/formatting with invariant variants (ToUpperInvariant/ToLowerInvariant, CultureInfo.InvariantCulture) and minor pragma updates.
Exception type refinementsQRCoder/ASCIIQRCode.cs, QRCoder/ArtQRCode.cs, QRCoder/QRCodeGenerator/Polynom.cs, QRCoder/QRCodeGenerator.cs, QRCoderTests/Helpers/ShouldMatchApprovedBinaryExtensions.cs Swap generic/less-specific exceptions for ArgumentOutOfRangeException/InvalidOperationException/ShouldAssertException; helper rename in Polynom.
Dispose and overridesQRCoder/QRCodeData.cs, QRCoder/QRCodeGenerator.cs Make Dispose methods public virtual and call GC.SuppressFinalize(this); QRCodeData also switches some invalid-data throws to InvalidDataException.
**New enum (feature surface)**QRCoder/QRCodeGenerator/EciMode.cs Add public nested enum QRCodeGenerator.EciMode with documented members (Default, Iso8859_1, Iso8859_2, Utf8); suppress CA1707.
Static helper refactorsQRCoder/ArtQRCode.cs, QRCoder/Base64QRCode.cs, QRCoder/BitmapByteQRCode.cs, QRCoder/PostscriptQRCode.cs, QRCoder/QRCode.cs, QRCoder/SvgQRCode.cs, QRCoder/PayloadGenerator/SlovenianUpnQr.cs, QRCoderConsole/Program.cs Convert various helpers to static; update call sites; make OptionSetter static in console app.
New extensions and attribute usageQRCoder/Extensions/StringExtensions.cs, QRCoder/Extensions/StringValueAttribute.cs Add HexColorToByteArray and a NETSTANDARD1_3 char.ToString extension; restrict StringValueAttribute usage to fields.
Adopt new HexColorToByteArray extensionQRCoder/BitmapByteQRCode.cs, QRCoder/PdfByteQRCode.cs Remove local hex parsers; use string.HexColorToByteArray() extension for color parsing.
Point struct overridesQRCoder/QRCodeGenerator/Point.cs Add overrides for Equals(object?) and GetHashCode (framework-conditional).
Pragma-only updatesQRCoder/PayloadGenerator/SMS.cs, QRCoder/QRCodeGenerator.cs, QRCoderTests/QRGeneratorTests.cs Add/adjust warning suppressions (CA1707, CA1822, CA5350).
Test helpers cleanupQRCoderTests/Helpers/HelperFunctions.cs Remove hashing helpers (BitmapToHash, ByteArrayToHash, StringToHash); keep GetAssemblyPath.
API approval baselinesQRCoderApiTests/net60/QRCoder.approved.txt, .../netstandard13/QRCoder.approved.txt, .../net35+net40+net50+netstandard20+netstandard21/QRCoder.approved.txt Update approved API: virtual Dispose methods, specific Obsolete messages on BezahlCode.AuthorityType members, AttributeUsage on StringValueAttribute.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested labels

enhancement

Suggested reviewers

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)

Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title succinctly captures the core changes—enabling recommended analyzers and applying invariant‐culture usage across the codebase—accurately reflecting the primary objectives without including extraneous details.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✨ Finishing touches


📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 532478d and 7286d0b.

📒 Files selected for processing (5)


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.