Skip to content
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

DirectoryExtensions.TryGetDateTime() fails in some cultures #138

Closed
twest820 opened this issue Sep 20, 2018 · 1 comment · Fixed by #266
Closed

DirectoryExtensions.TryGetDateTime() fails in some cultures #138

twest820 opened this issue Sep 20, 2018 · 1 comment · Fixed by #266

Comments

@twest820
Copy link
Contributor

Issue is this function calls DateTime.TryParseExact() with a null format provider. The parse therefore can only succeed if the current culture uses the same separators as the file containing the metadata. From a quick review it looks to me like the intent is to perform invariant parsing, in which case the fix would be to pass CultureInfo.InvariantCulture rather than null.

Workaround is to reimplement the method's code. Personally, I hit this on Arabic so setting CultureInfo.CurrentCulture = CultureInfo.GetCultureInfo("ar") on a test thread should provide repro.

@drewnoakes
Copy link
Owner

On the general topic of locale sensitivity, we should enable and review these diagnostics:

# TODO review these diagnostics as many/all are probably valid
dotnet_diagnostic.CA1304.severity = none # Method behaviour depends upon user's locale
dotnet_diagnostic.CA1305.severity = none # Method behaviour depends upon user's locale
dotnet_diagnostic.CA1307.severity = none # Method behaviour depends upon user's locale

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

Successfully merging a pull request may close this issue.

2 participants