-
Notifications
You must be signed in to change notification settings - Fork 777
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
Fix LogRecordTest by using InvariantCulture. #1683
Fix LogRecordTest by using InvariantCulture. #1683
Conversation
The test would fail if the current locale used something other than a dot as the decimal separator (e.g. comma).
Codecov Report
@@ Coverage Diff @@
## master #1683 +/- ##
=======================================
Coverage 82.09% 82.09%
=======================================
Files 249 249
Lines 6730 6730
=======================================
Hits 5525 5525
Misses 1205 1205 |
Same as #1680: Can we merge this yet? I cannot give you access to my branch since it's an organization repository unfortunately. |
@@ -213,7 +214,16 @@ public void CheckStateForStrucutredLogWithGeneralType() | |||
Assert.Contains(state, item => item.Key == "{OriginalFormat}"); | |||
Assert.Equal("{food}", state.First(item => item.Key == "{OriginalFormat}").Value); | |||
|
|||
Assert.Equal("[Name, truffle], [Price, 299.99]", state.ToString()); | |||
var prevCulture = CultureInfo.CurrentCulture; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there is a common need, consider making this a "using statement".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also, we can move to shared extension method like https://github.com/open-telemetry/opentelemetry-dotnet/blob/master/src/OpenTelemetry.Api/Internal/ExceptionExtensions.cs#L31
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was the only test that failed that way, at least with a German locale.
Fixes #1678.
Changes
Enforce that the current Culture is InvariantCulture around the call to ToString on the log record state.
Note that using
String.Format(CultureInfo.InvariantCulture, "{0}", state)
does not work here.