-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ECC code mismatch detection #526
Conversation
That's a nice solution. I wonder if we shouldn't just include it in the next 1.x.x release. I don't see any reason why we need to keep the change for version 2. Just a small test case (something like generator_throws_argument_exception or similar) would be nice before merging it. |
This particular implementation is a breaking change since I’ve changed the type. But we could add an enum value like EccLevel.Default to do the same thing, which would be backwards compatible. I’ll revise. |
03174ac
to
4ca3ec9
Compare
QRCoderApiTests/net35+net40+net50+net50-windows+netstandard20/QRCoder.approved.txt
Show resolved
Hide resolved
Isn't it a breaking change to throw an exception when previously didn't? Might be worth mentioning in the release notes. |
@csturm83 Thanks for pointing this out. Yes, you're right - this is somehow breaking behaviour but In my opinion nevertheless totally worth it, as cases when the exception will be raised, otherwise would lead to incorrect payloads/QR codes. (Thus I assume the change won't break nearly none implementation out in the wild, because to break it, the implementations must create in correct codes at the moment.) I added a note on this change in the release notes: |
This pull request enhances the QRCoder library by allowing the payload to specify an "unspecified" error correction level (ECC) rather than being restricted to the predefined levels L, M, Q, or H. This new
Default
value in theECCLevel
enum acts as an unspecified placeholder, giving users the flexibility to select an appropriate ECC level while enabling the system to validate the selection.When generating a QR code, if the ECC level is not specified, the system uses the payload's specified ECC level. If the payload's ECC level differs from the user-specified level, the system throws an exception to handle the discrepancy. This enhancement ensures backward compatibility, allowing existing codebases to function as expected while offering users the flexibility to dynamically adjust error correction levels based on their payloads' needs.
See:
This PR also includes bug fix #527 ; please merge it first.