Skip to content

Wrong culture validation in Contact-constructor #208

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

Closed
cyrillgisin opened this issue Oct 17, 2019 · 1 comment
Closed

Wrong culture validation in Contact-constructor #208

cyrillgisin opened this issue Oct 17, 2019 · 1 comment

Comments

@cyrillgisin
Copy link

Type of issue

[x ] Bug
[ ] Question (e.g. about handling/usage)
[ ] Request for new feature/improvement

Expected Behavior

When instantiating a new Contact, the library should not check the ISO 3166-1 (two letters) code with CultureInfo.GetCulture() because this list is incomplete.

Current Behavior

The library throws a SwissQrCodeContactException.

Possible Solution (optional)

Class: PayloadGenerator. Private constructor for Contact.
Please remove the following lines of code:
if (!((IEnumerable<CultureInfo>) CultureInfo.GetCultures(CultureTypes.SpecificCultures)).Where<CultureInfo>((Func<CultureInfo, bool>) (x => new RegionInfo(x.LCID).TwoLetterISORegionName.ToUpper() == country.ToUpper())).Any<CultureInfo>()) throw new PayloadGenerator.SwissQrCode.Contact.SwissQrCodeContactException("Country must be a valid \"two letter\" country code as defined by ISO 3166-1, but it isn't.");

Steps to Reproduce (for bugs)

Instantiate a Contact with the Two-letter-code "GH" for Ghana (parameter: "country"), which is an official ISO 3166-1 code but missing in CultureInfo.GetCultures() from .Net Framework

Your Environment

Not relevant

@codebude
Copy link
Owner

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. :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants