dotnet / interactive

.NET Interactive combines the power of .NET with many other languages to create notebooks, REPLs, and embedded coding experiences. Share code, explore data, write, and learn across your apps in ways you couldn't before.
MIT License
2.88k stars 383 forks source link

F# notebook overriding my local culture of "en-GB" to "en" #3160

Open kojo12228 opened 1 year ago

kojo12228 commented 1 year ago

Describe the bug

F# notebook appears to set the global culture to "en", rather than my local "en-GB". This is causing parsing failures only in my F# notebook that I don't see if I run the code elsewhere. If I set the culture specifically to "en-GB", parsing works again.

In the screenshot at the bottom of the issue, I've showed the failed parse on the current culture, the successful parse on "en-GB" and outputted the current culture. No where else in my code have I attempted to set the global culture.

For completeness, the culture according to FSI:

> System.Globalization.CultureInfo.CurrentCulture;;
val it: System.Globalization.CultureInfo =
  en-GB {Calendar = System.Globalization.GregorianCalendar;
         CompareInfo = CompareInfo - en-GB;
         CultureTypes = SpecificCultures, InstalledWin32Cultures;
         DateTimeFormat = System.Globalization.DateTimeFormatInfo;
         DisplayName = "English (United Kingdom)";
         EnglishName = "English (United Kingdom)";
         IetfLanguageTag = "en-GB";
         IsNeutralCulture = false;
         IsReadOnly = true;
         KeyboardLayoutId = 2057;
         LCID = 2057;
         Name = "en-GB";
         NativeName = "English (United Kingdom)";
         NumberFormat = System.Globalization.NumberFormatInfo;
         OptionalCalendars = [|System.Globalization.GregorianCalendar|];
         Parent = en;
         TextInfo = TextInfo - en-GB;
         ThreeLetterISOLanguageName = "eng";
         ThreeLetterWindowsLanguageName = "ENG";
         TwoLetterISOLanguageName = "en";
         UseUserOverride = true;}

Please complete the following:

Which version of .NET Interactive are you using? (In a notebook, run the #!about magic command. ):

Version: 1.0.440301+8915ad98609cad23d5d81765041c2a895afb4782
Library version: 1.0.0-beta.23403.1+8915ad98609cad23d5d81765041c2a895afb4782
Build date: 2023-09-02T06:55:32.4074034Z

Screenshots

image
WillFa commented 5 months ago

Same thing happens to me with Powershell as the default language. It isn't specific to F#.

Changing my scripts to: [float]::Parse($Matches[2], 383, (Get-Culture -Name en-US).NumberFormat)

Stops the errors, but the Notebook's output reverts back to Culture 9.

Culture9 (That's not a $ for the currency symbol)