-
-
Notifications
You must be signed in to change notification settings - Fork 491
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
Tests failing if current Culture setting does not use decimal point separator #792
Comments
Have you made any changes to the code? These tests run every time code is merged on both windows and Linux machines without any problems. |
Nope. I cloned the repository at Reading the logs in detail it looks the failing test is the same, just repeated multiple times:
It looks a float parsing error I think. Could it be something related to the |
That was my next question after noticing the comma instead of a period in the exponential number of one of the failed tests. I think we can specify the culture at the process level when the test run starts so they can run in any country, maybe. It’s been a long time since I’ve had to deal with globalization and localization in any of my projects. I know the en_US culture works. Not sure how that plays on Linux/windows in other cultures without it installed in the OS though. I can make an attempt at testing it and try and find a workaround but it could be some time before I get a solution in place. If you would like to work on it let me know. Interesting problem. |
Can you try adding this to the test csproj and see if the tests pass in your culture? |
It fails CultureNotFoundException : Only the invariant culture is supported in globalization-invariant mode. See https://aka.ms/GlobalizationInvariantMode for more information.
But, I want to share some insights. The problem it seems are the tests that use > var ic = System.Globalization.CultureInfo.InvariantCulture;
> (2.70).ToString()
"2,7" // Uses comma
> (2.70).ToString(ic)
"2.7" // Uses point
> var value = 2.7;
> value.ToString()
"2,7" // Uses comma
> string.Format(ic, "{0}", value)
"2.7" // Uses point The test that fails are The In the other hand, for |
Ok. My next suggestion would be to set the globalization to en_US at the process level when the test runner starts |
I got fixed [Theory]
[MemberData(nameof(DeserializeScalarEdgeCases_TestCases))]
public void DeserializeScalarEdgeCases(IConvertible value, Type type)
{
var deserializer = new DeserializerBuilder().Build();
+ var stringValue = string.Format(CultureInfo.InvariantCulture, "{0}", value);
- var result = deserializer.Deserialize(value.ToString(), type);
+ var result = deserializer.Deserialize(stringValue, type);
result.Should().Be(value);
} I will keep searching the root cause for |
I discovered the bug. In was a bug with the |
Adds `CultureInfo.InvariantCulture` in parsing method in `ScalarNodeDeserializer.AttemptUnknownTypeDeserialization`. This caused tests to fail in non english culture (Tested with "es-AR")
Adds `YamlFormatter.NumberFormat` in `Parse` methods in `ScalarNodeDeserializer.AttemptUnknownTypeDeserialization`. This caused tests to fail in non english culture (Tested with "es-AR")
@EdwardCooke I opened #793 and #794 to address both problems. |
Describe the bug
I just cloned the repo for the first time to contribute, and tried to run the test suite and it fails. I don't know if I am missing some step or what could be happening.
To Reproduce
git clone git@github.com:aaubry/YamlDotNet.git && cd YamlDotNet
git submodule update --init
dotnet restore
dotnet test
dotnet test results
https://gist.github.com/jhm-ciberman/2dbfe53d6aa41e10e61e0dbb9fea4d5a
I pasted it in a gist because it was too long to include it in the issue. (65536+ chars)
Environment:
The text was updated successfully, but these errors were encountered: