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

Problems with Formatting of numbers and dates if you run on non English CultureInfo #4

Open
andi0b opened this issue Jul 8, 2021 · 0 comments · May be fixed by #8
Open

Problems with Formatting of numbers and dates if you run on non English CultureInfo #4

andi0b opened this issue Jul 8, 2021 · 0 comments · May be fixed by #8
Labels
bug Something isn't working

Comments

@andi0b
Copy link

andi0b commented Jul 8, 2021

Describe the bug

Formatting values via this library ignores the CultureInfo set to Handlebars.Configuration.FormatProvider.

Numbers and dates will always be formatted with the culture of the current thread. Furthermore there are some tests failing if you run it on a non English locale.

It seems PR #2 broke it.

Expected behavior:

Format JToken with Handlebars.Configuration.FormatProvider

If I set Handlebars.Configuration.FormatProvider to CultureInfo.Invariant I expect numbers to be formatted like 3.14 instead of like my locale would format: 3,14

Test to reproduce

Run current tests on a non English locale (in my case German/Austria) and some will fail:

[xUnit.net 00:00:01.07]     HandlebarsDotNet.Extension.Test.JsonTests.ValueTypes(value: "22474.1") [FAIL]
  Fehler HandlebarsDotNet.Extension.Test.JsonTests.ValueTypes(value: "22474.1") [11 ms]
  Fehlermeldung:
   Assert.Equal() Failure
               ↓ (pos 5)
Expected: 22474.1
Actual:   22474,1
               ↑ (pos 5)
  Stapelverfolgung:
     at HandlebarsDotNet.Extension.Test.JsonTests.ValueTypes(String value) in C:\Users\Andreas\git\github\Handlebars.Net.Extension.NewtonsoftJson\source\Handlebars.Extension.Test\JsonTests.cs:line 50
[xUnit.net 00:00:01.26]     HandlebarsDotNet.Extension.Test.JsonTests.ArrayAccessByIndex(handlebars: HandlebarsEnvironment { Configuration = HandlebarsConfiguration { AliasProviders = [...], BlockHelpers = [...], Compatibility = Compatibility { ... }, CompileTimeConfiguration = CompileTimeConfiguration { ... }, ExpressionNameResolver = null, ... } }) [FAIL]
  Fehler HandlebarsDotNet.Extension.Test.JsonTests.ArrayAccessByIndex(handlebars: HandlebarsEnvironment { Configuration = HandlebarsConfiguration { AliasProviders = [...], BlockHelpers = [...], Compatibility = Compatibility { ... }, CompileTimeConfiguration = CompileTimeConfiguration { ... }, ExpressionNameResolver = null, ... } }) [6 ms]
  Fehlermeldung:
   Assert.Equal() Failure
                        ↓ (pos 14)
Expected: 1,True,False,1.1,,
Actual:   1,True,False,1,1,,
                        ↑ (pos 14)
  Stapelverfolgung:
     at HandlebarsDotNet.Extension.Test.JsonTests.ArrayAccessByIndex(IHandlebars handlebars) in C:\Users\Andreas\git\github\Handlebars.Net.Extension.NewtonsoftJson\source\Handlebars.Extension.Test\JsonTests.cs:line 222

Fehler!      : Fehler:     2, erfolgreich:    25, übersprungen:     0, gesamt:    27, Dauer: 257 ms - Handlebars.Extension.Test.dll (netcoreapp2.1)

I am going to look into this problem and will try to provide a pull request.

@andi0b andi0b added the bug Something isn't working label Jul 8, 2021
@oformaniuk oformaniuk linked a pull request Jun 29, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant