-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Fix: Make BIC optional for Girocode Version 2 #622
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
base: master
Are you sure you want to change the base?
Conversation
- Modified IsValidBic to accept a 'required' parameter - BIC is now required for Version 1 (as per spec) - BIC is optional for Version 2 (as per spec) - Fixed NullReferenceException when BIC is null - Added comprehensive tests for all scenarios: - Version 2 with null BIC (passes) - Version 2 with empty BIC (passes) - Version 2 with valid BIC (passes) - Version 2 with invalid BIC (throws exception) - Version 1 with null BIC (throws exception) - Version 1 with empty BIC (throws exception) Fixes issue where Girocode constructor threw NullReferenceException when BIC was null with Version 2, which should be allowed per the Girocode specification.
📝 WalkthroughWalkthroughAdds an optional-requirement overload for BIC validation and integrates it into Girocode generation: Version 1 requires a BIC; Version 2 allows empty/absent BIC. Also makes BIC normalization null-safe. New unit tests cover both versions and scenarios (null, empty, valid, invalid BIC). Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant C as Caller
participant G as Girocode (ctor/ToString)
participant V as PayloadGenerator.IsValidBic
Note over C,G: Create Girocode payload
alt Version 1 (BIC required)
C->>G: new Girocode(..., bic, Version1)
G->>V: IsValidBic(bic, required=true)
alt bic null/empty/invalid
V-->>G: false
G-->>C: throw GirocodeException("The BIC is invalid.")
else valid
V-->>G: true
G-->>C: payload with BIC
end
else Version 2 (BIC optional)
C->>G: new Girocode(..., bic, Version2)
G->>V: IsValidBic(bic, required=false)
alt bic null/empty
V-->>G: true
G-->>C: payload without BIC
else bic present
V->>V: IsValidBic(bic) // existing validator
alt invalid
V-->>G: false
G-->>C: throw GirocodeException("The BIC is invalid.")
else valid
V-->>G: true
G-->>C: payload with BIC
end
end
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (3)
🧰 Additional context used🧬 Code graph analysis (2)QRCoder/PayloadGenerator/Girocode.cs (1)
QRCoderTests/PayloadGeneratorTests/GirocodeTests.cs (2)
⏰ 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). (1)
🔇 Additional comments (3)
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. Comment |
Roo: I've successfully fixed the GitHub issue and completed all requested tasks:
Summary of Changes
Fixed Issue
The Girocode constructor was throwing a
NullReferenceException
when BIC was null with Version 2, which should be allowed per the Girocode specification.Changes Made
Modified
IsValidBic()
in PayloadGenerator.cs:required
parametertrue
for null/empty BIC when not requiredfalse
for null/empty BIC when requiredUpdated
Girocode
constructor in Girocode.cs:?.
) and null-coalescing operator (??
) for clean BIC handlingAdded comprehensive tests in GirocodeTests.cs:
Test Results
All 23 Girocode tests passed successfully across all target frameworks (net462, netcoreapp2.1, netcoreapp3.1, net5.0, net5.0-windows, net6.0, net6.0-windows).
Branch and Commit
fix/girocode-version2-bic-optional
You can create a pull request at: https://github.com/Shane32/QRCoder/pull/new/fix/girocode-version2-bic-optional
Summary by CodeRabbit