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
Possibly related PRs
- Migrate all assertions to Shouldly syntax; use visual regression checks #624 — Also modifies test helpers/assertions, overlapping with QRCoderTests/Helpers changes.
- Cleanup project files; configure Directory.Build.props #628 — Touches Directory.Build.props analyzer settings, related to this PR’s AnalysisMode change.
- Change PdfByteQRCode to draw rectangles instead of embed JPGs #635 — Adjusts PdfByteQRCode internals; related to this PR’s color parsing refactor to use extensions.
Suggested labels
enhancement
Suggested reviewers
- gfoidl
- codebude
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
- 📝 Generate docstrings 🧪 Generate unit tests (beta)
- Create PR with unit tests
- Post copyable unit tests in a comment
- Commit unit tests in branch
analyzers
📜 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)
QRCoder/ASCIIQRCode.cs(1 hunks)QRCoder/PostscriptQRCode.cs(2 hunks)QRCoderApiTests/net35+net40+net50+netstandard20+netstandard21/QRCoder.approved.txt(4 hunks)QRCoderApiTests/net60/QRCoder.approved.txt(4 hunks)QRCoderTests/QRCoderTests.csproj(2 hunks) 🚧 Files skipped from review as they are similar to previous changes (3)- QRCoderTests/QRCoderTests.csproj
- QRCoder/ASCIIQRCode.cs
- QRCoder/PostscriptQRCode.cs ⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
- GitHub Check: Test .NET Core 2.1
- GitHub Check: Test .NET 5.0 Windows
- GitHub Check: Test .NET 6.0 Windows
- GitHub Check: Test .NET Core 3.1
- GitHub Check: additional-tests
- GitHub Check: Test .NET Framework 4.6.2
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.