Skip to content

fix: best practices, new tests, and bilingual documentation - #40

Merged
afonsoft merged 4 commits into
mainfrom
devin/1777836431-best-practices-reorganization
May 3, 2026
Merged

afonsoft merged 4 commits into
mainfrom
devin/1777836431-best-practices-reorganization

Conversation

@devin-ai-integration

Copy link
Copy Markdown
Contributor

All Submissions:

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?

New Feature Submissions:

  1. Does your submission pass tests?
  2. Have you lint your code locally prior to submission?

Changes to Core Features:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your core changes, as applicable?
  • Have you successfully ran tests with your changes locally?

Summary

This PR improves code quality, adds comprehensive test coverage, and creates bilingual documentation for the QRCoder.Core library.

Bug Fixes

  • Fix SkiaSharp platform detection in csproj files: The MSBuild conditions for including SkiaSharp.NativeAssets.Linux/macOS/Win32 were comparing a boolean return value (True/False) against a string ('Linux'), so the native assets were never conditionally included on any platform. Fixed to evaluate the boolean directly.
  • Fix Dispose pattern (CA1816): Added GC.SuppressFinalize(this) to Dispose() in AbstractQRCode, QRCodeData, and QRCodeGenerator — following the standard .NET Dispose pattern.
  • Replace generic exceptions with specific types: ArtQRCode now throws ArgumentOutOfRangeException (was Exception); QRCodeData now throws InvalidOperationException for invalid raw data.
  • Remove obsolete SkiaSharp API usage (CS0618): Removed SKPaint.FilterQuality = SKFilterQuality.High from QRCode.cs and ArtQRCode.cs, eliminating all build warnings.
  • Fix repository URL: Corrected RepositoryUrl in csproj from codebude/QRCoder to afonsoft/QRCoder.Core.

New Tests (+92 tests)

Added BestPracticesTests.cs covering previously untested or low-coverage areas:

  • QRCodeGenerator: ECC levels, encoding modes, UTF-8/BOM, versioning, dispose safety
  • QRCodeData: round-trip serialization (Uncompressed/Deflate/GZip), file I/O, dispose
  • QRCode: colors, hex parsing, quiet zones, parameterless constructor, helper
  • AsciiQRCode: custom symbols, line-by-line, quiet zones, helper
  • PngByteQRCode: PNG validation, alpha colors, quiet zones
  • SKBitmapByteQRCode: default/hex/byte colors, helpers
  • Base64QRCode: PNG/JPEG output, icon support
  • PdfByteQRCode: PDF header validation, colors, DPI
  • PostscriptQRCode: PS/EPS output, colors, view box, quiet zones
  • ArtQRCode: pixel size factor, quiet zone styles, argument validation
  • Extensions: SKColor ToHex/FromHex edge cases, StringValueAttribute
  • DataTooLongException: with/without version
  • Size struct: constructor, defaults, properties
  • PayloadGenerator: WiFi, Mail, URL, SMS, PhoneNumber, Geolocation, Bookmark
  • Cross-platform consistency: deterministic output, scaling

Documentation

  • English Usage Guide: Comprehensive guide with examples for all output formats, payload types, and platform-specific usage (ASP.NET Core API, .NET MAUI, Console).
  • Portuguese Usage Guide: Complete guide in pt-BR with the same coverage.
  • Updated README.md: Bilingual description, links to both docs, updated Quick Start to use SkiaSharp (not System.Drawing), updated test counts.

Test Results

  • Build: Succeeds with 0 warnings (previously had 4 CS0618 warnings)
  • New tests: 92/92 passing
  • Total tests: 401 (391 pass, 10 pre-existing SVG hash failures unrelated to this PR)

Link to Devin session: https://app.devin.ai/sessions/20d5c57d4fc24948a55b3ebb99c84309
Requested by: @afonsoft

devin-ai-integration Bot and others added 3 commits May 3, 2026 19:30
…tion types

- Fix MSBuild OS platform conditions in csproj files (was comparing bool to string)
- Add GC.SuppressFinalize to all Dispose implementations (CA1816)
- Replace generic Exception with ArgumentOutOfRangeException in ArtQRCode
- Replace generic Exception with InvalidOperationException in QRCodeData
- Remove obsolete SKFilterQuality usage (CS0618)
- Fix repository URL to point to afonsoft/QRCoder.Core
- Update test to match new exception type

Co-Authored-By: Afonso Dutra Nogueira Filho <afonsoft@gmail.com>
- QRCodeGenerator: ECC levels, encoding modes, UTF-8, versioning, dispose
- QRCodeData: round-trip serialization (Uncompressed/Deflate/GZip), file I/O
- AbstractQRCode: SetQRCodeData, idempotent Dispose
- QRCode: colors, hex parsing, quiet zones, helper methods
- AsciiQRCode: custom symbols, line-by-line, quiet zones
- PngByteQRCode: validation, alpha colors, quiet zones
- SKBitmapByteQRCode: default/hex/byte colors, helpers
- Base64QRCode: PNG/JPEG output, icon support
- PdfByteQRCode: PDF validation, colors, DPI
- PostscriptQRCode: PS/EPS output, colors, view box
- ArtQRCode: pixel size factor, quiet zone styles, argument validation
- Extensions: SKColor ToHex/FromHex, StringValueAttribute
- DataTooLongException: with/without version
- Size struct: constructor, properties
- PayloadGenerator: WiFi, Mail, URL, SMS, PhoneNumber, Geolocation, Bookmark
- Cross-platform: deterministic output, scaling
- HelperFunctions: hash consistency

Co-Authored-By: Afonso Dutra Nogueira Filho <afonsoft@gmail.com>
- Create comprehensive usage guide in Portuguese (pt-BR)
- Create comprehensive usage guide in English (en-US)
- Both guides cover all output formats: QRCode, PNG, SVG, Base64, PDF,
  ASCII, Postscript, EPS, Artistic, BMP
- Include PayloadGenerator examples: WiFi, URL, Email, SMS, Phone,
  Geolocation, Bitcoin, vCard, Calendar Events
- Add cross-platform examples: ASP.NET Core API, .NET MAUI, Console
- Document ECC levels, serialization, UTF-8, and version settings
- Update README with bilingual description and links to documentation
- Update Quick Start example to use SkiaSharp (not System.Drawing)
- Update test count to reflect new tests

Co-Authored-By: Afonso Dutra Nogueira Filho <afonsoft@gmail.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

C# 7.3 (net48 target) does not support 'using var' declarations.
Changed to match existing test code style.

Co-Authored-By: Afonso Dutra Nogueira Filho <afonsoft@gmail.com>
@sonarqubecloud

sonarqubecloud Bot commented May 3, 2026

Copy link
Copy Markdown

@afonsoft
afonsoft merged commit 20f3f72 into main May 3, 2026
13 of 14 checks passed
@afonsoft
afonsoft deleted the devin/1777836431-best-practices-reorganization branch May 10, 2026 15:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant