-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
C#: Enforce globalization code quality rules #87133
C#: Enforce globalization code quality rules #87133
Conversation
4eb5094
to
4b27844
Compare
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.
Partial review.
ff9b22a
to
3106289
Compare
modules/mono/glue/GodotSharp/GodotSharp/Core/StringExtensions.cs
Outdated
Show resolved
Hide resolved
3106289
to
7236dfe
Compare
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.
Great work, thank you so much! I think this looks good but I would appreciate a second pair of eyes to check that I haven't missed anything.
@@ -1329,7 +1330,7 @@ public static bool HtmlIsValid(ReadOnlySpan<char> color) | |||
/// <returns>A string representation of this color.</returns> | |||
public readonly string ToString(string? format) | |||
{ | |||
return $"({R.ToString(format)}, {G.ToString(format)}, {B.ToString(format)}, {A.ToString(format)})"; | |||
return $"({R.ToString(format, null)}, {G.ToString(format, null)}, {B.ToString(format, null)}, {A.ToString(format, null)})"; |
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.
Ditto for Plane
, Projection
, Quaternion
, Vector2
, Vector2I
, Vector3
, Vector3I
, Vector4
, Vector4I
.
Do we really want to use the current culture instead of invariant here? E.g. on my machine, this would represent floating points as 3,1415927
, it feels wrong compared to 3.1415927
. I think we should default to CultureInfo.InvariantCulture.NumberFormat
instead.
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.
While I agree, this was to the end of keeping the previous behavior intact. Plus, we'd probably want a way to change the culture if we're changing the default, which would be outside the scope of this PR. I'm implementing something similar in a seperate PR via IFormattable (#83159), so this default could be applied there instead
Alternatively, if everyone is onboard with making it CultureInfo.InvariantCulture.NumberFormat
, I'm completely fine with applying that instead. Just a matter of gauging the other contributors' thoughts
7236dfe
to
000d12d
Compare
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.
Everything is fine by me. Thanks a lot ❤️
Thanks! |
Implements globalization code quality rules1. Also, removed the relevant
.editorconfig
suppressions of these warnings, as they're now accounted for and should be warned of moving forward.Footnotes
https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/globalization-warnings ↩