Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

[X] ConvertToInvariant is invariant #12834

Merged
merged 1 commit into from
Nov 18, 2020
Merged

[X] ConvertToInvariant is invariant #12834

merged 1 commit into from
Nov 18, 2020

Conversation

StephaneDelcroix
Copy link
Member

@StephaneDelcroix StephaneDelcroix commented Nov 13, 2020

Description of Change

[X] ConvertToInvariant is invariant

Issues Resolved

API Changes

None

Platforms Affected

  • Core/XAML (all platforms)

Behavioral/Visual Changes

None

Before/After Screenshots

Not applicable

Testing Procedure

PR Checklist

  • Targets the correct branch
  • Tests are passing (or failures are unrelated)

@StephaneDelcroix StephaneDelcroix added the external-hotreload Non-Forms bugs that affect Hot Reload label Nov 13, 2020
@@ -58,7 +58,7 @@ public override string ConvertToInvariantString(object value)
{
if (!(value is CornerRadius cr))
throw new NotSupportedException();
return $"{cr.TopLeft}, {cr.TopRight}, {cr.BottomLeft}, {cr.BottomRight}";
return $"{cr.TopLeft.ToString(CultureInfo.InvariantCulture)}, {cr.TopRight.ToString(CultureInfo.InvariantCulture)}, {cr.BottomLeft.ToString(CultureInfo.InvariantCulture)}, {cr.BottomRight.ToString(CultureInfo.InvariantCulture)}";
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: instead of repeating CultureInfo.InvariantCulture multiple times consider using denser form
string.Format(CultureInfo.InvariantCulture, "{0}, {1}, {2}, {3}", cr.TopLeft, cr.TopRight, cr.BottomLeft, cr.BottomRight);

There are other places like this

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could also do:

FormattableString.Invariant($"{cr.TopLeft}, {cr.TopRight}, {cr.BottomLeft}, {cr.BottomRight}");

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GalaxiaGuy nice tip. but we still need to support netstandard1.0 :(

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@etvorun I choose to keep named parameters instead of reverting to positional

@StephaneDelcroix StephaneDelcroix merged commit bef121f into 5.0.0 Nov 18, 2020
@StephaneDelcroix StephaneDelcroix deleted the fix_12828 branch November 18, 2020 10:00
@samhouts samhouts added this to the 5.0.0 milestone Dec 8, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
external-hotreload Non-Forms bugs that affect Hot Reload
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] Many type converters ConvertToInvariantString return localized value
4 participants