-
-
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
PayloadGeneratorTest.cs Test Failure #193
Comments
Actually, I think this has been around for a while, but just noticed it when testing all targets. This line doesn't necessarily enforce length of 2 for the country string passed in. I'm not familiar with the spec for this payload. If it strictly requires country code of length 2, then this is a bug. Otherwise, the test should be updated to pass on all targets. Either way, I think the behavior should be made consistent across targets. Related: #208 |
This is fixed in 7e6cc92 Since .NET still doesn't bring a complete list/all-in-one solution for the ISO codes, I decided to add an external solution. If you disagree with the code changes, feel free to re-open the issue. :-) |
I'm not a huge fan of the additional Package Reference for all build targets. Prior to this change, the only build target to have an external Package Reference was netstandard2.0 (System.Drawing.Common), which seems minimal. This ISO3166 package essentially boils down to one file. Why not just import this single file periodically with the proper license header, instead of a Package Reference? Minimal dependencies is a HUGE selling point, in my opinion. |
Also, looking at an open PR in that repository, the package/dll size could potentially increase in the future for a localization feature we likely don't need or care about. |
That's a good argument. Maybe the solution I implemented wasn't well thought. Feel free to add a merge request with a static list/export of the ISO codes. (Otherwise I'll see that I rework the code next week.) |
Yup, looking better.
|
Hi @csturm83 Thanks for the hints.
|
@codebude by "cache it statically", I simply meant to create/store it in a Bummer about the All that said, performance in this particular spot of code is probably not that critical. |
I would probably write something like private static readonly HashSet<string> twoLetterCodes = ValidTwoLetterCodes();
private static HashSet<string> ValidTwoLetterCodes()
{
string[] codes = new string[] {...};
return new HashSet<string>(codes, StringComparer.OrdinalIgnoreCase);
}
private static bool IsValidTwoLetterCode(string code) => twoLetterCodes.Contains(code); The constructor taking an Passing in |
Type of issue
[X] Bug
[ ] Question (e.g. about handling/usage)
[ ] Request for new feature/improvement
Expected Behavior
All tests pass.
Current Behavior
swissqrcode_generator_should_throw_wrong_countrycode test fails after commit bbba9cba
Steps to Reproduce
Run tests on latest version of master branch.
The text was updated successfully, but these errors were encountered: