Skip to content

Enable Globalization to read the user setting overrides for current cultures when using ICU #37121

Closed

Description

@DmitryGaravsky

Description

The DateTimeFormatInfo properties in Net Core 5 Preview 4 return different culture-specific information about the format of date and time values compared to .Net Framework in the same environment

Our unit tests detected this issue immediately. (we maintain unit tests for all the released and preview environments like .net core 5 in our codebase). Thus it is an important breaking change for us.

Configuration

OS Version: Microsoft Windows [Version 10.0.18362.535]
.Net Framework Version: Microsoft (R) .NET CLR Version Tool Version 4.8.3928.0
.Net Core Version: SDK Version: 5.0.100-preview.4.20258.7

Regression?

Yes, this works correctly until .Net Core 5 Preview 4

Other information

Here are some tests which fail under .Net Core 5 Preview 4

[TestCase("en-US", "M/d/yyyy", "dddd, MMMM d, yyyy")]
[TestCase("ru-RU", "dd.MM.yyyy", "d MMMM yyyy 'г.'")]
public void DatePatterns(string culture, string pShort, string pLong) {
	CultureInfo c = new CultureInfo(culture);
	Assert.AreEqual(pShort, c.DateTimeFormat.ShortDatePattern);
	Assert.AreEqual(pLong, c.DateTimeFormat.LongDatePattern);
}
[TestCase("en-US", "h:mm tt", "h:mm:ss tt")]
[TestCase("ru-RU", "H:mm", "H:mm:ss")]
public void TimePatterns(string culture, string pShort, string pLong) {
	CultureInfo c = new CultureInfo(culture);
	Assert.AreEqual(pShort, c.DateTimeFormat.ShortTimePattern);
	Assert.AreEqual(pLong, c.DateTimeFormat.LongTimePattern);
}
[TestCase("en-US", "January", "Jan")]
[TestCase("ru-RU", "Январь", "янв")]
public void MonthNames(string culture, string name, string abrName) {
	CultureInfo c = new CultureInfo(culture);
	Assert.AreEqual(name, c.DateTimeFormat.MonthNames[0]);
	Assert.AreEqual(abrName, c.DateTimeFormat.AbbreviatedMonthNames[0]);
}
[TestCase("en-US", "January", "Jan")]
[TestCase("ru-RU", "января", "янв")]
public void MonthGenitiveNames(string culture, string name, string abrName) {
	CultureInfo c = new CultureInfo(culture);
	Assert.AreEqual(name, c.DateTimeFormat.MonthGenitiveNames[0]);
	Assert.AreEqual(abrName, c.DateTimeFormat.AbbreviatedMonthGenitiveNames[0]);
}

Activity

  1. added
    untriaged
    on May 28, 2020
  2. stephentoub commented on May 28, 2020

    @stephentoub
    Member
  3. tarekgh commented on May 28, 2020

    @tarekgh
    Member

    @stephentoub is right. We are now using ICU by default. the doc link that @stephentoub mentioned has the way how to switch back using NLS instead of ICU to revert back to the old behavior. Please send any questions you have and we'll be happy to help with.

  4. DmitryGaravsky commented on May 28, 2020

    @DmitryGaravsky
    ContributorAuthor

    Thanks, @stephentoub and @tarekgh

    I clearly understand the reason - using ICU instead of NLS.
    The single point I can't understand is "Why the results have taken via ICU does not match OS settings for current culture?".

    Should I always switch back to NLS to create desktop applications that take OS settings into account?

    image

  5. safern commented on May 28, 2020

    @safern
    Member

    @Dmitri-Botcharnikov maybe you're hitting this issue: #35638 ?

    This was fixed for Preview5. Could you try with our latest release and see if that works as expected?

    You can get the latest daily build from here: https://github.com/dotnet/installer/blob/master/README.md#installers-and-binaries

  6. tarekgh commented on May 28, 2020

    @tarekgh
    Member

    @DmitryGaravsky that is a good point. we may try to look at this one and figure out if it make-sense using the overrides from the System. I am not expecting users to switch back to NLS just to pick the overrides.

  7. changed the title [-]The DateTimeFormatInfo properties return different value since .Net Core5 Preview 4 in the same environment[/-] [+]Enable Globalization to read the user settings overrides for current cultures when using ICU[/+] on May 28, 2020
  8. changed the title [-]Enable Globalization to read the user settings overrides for current cultures when using ICU[/-] [+]Enable Globalization to read the user setting overrides for current cultures when using ICU[/+] on May 28, 2020
  9. added and removed
    untriaged
    on May 28, 2020
  10. added this to the 5.0 milestone on May 28, 2020
  11. tarekgh commented on May 28, 2020

    @tarekgh
    Member

    @DmitryGaravsky I have changed the title of the issue just to reflect what needs to be fixed.

  12. self-assigned this
    on May 28, 2020
  13. safern commented on May 28, 2020

    @safern
    Member

    Thanks @tarekgh I've self assigned to start looking into it.

  14. DmitryGaravsky commented on May 28, 2020

    @DmitryGaravsky
    ContributorAuthor

    Thanks, guys! I'll stay tuned

  15. iSazonov commented on Jul 3, 2020

    @iSazonov
    Contributor

    What .Net preview version is we get the fix in?

  16. safern commented on Jul 3, 2020

    @safern
    Member

    This is going to land on Preview8. I can’t point you to the first daily build that contains the fix for Powershell to try it out.

  17. safern commented on Jul 16, 2020

    @safern
    Member
  18. ghost locked as resolved and limited conversation to collaborators on Dec 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions