Browse Source
Merge pull request #8724 from rabbitism/grid_length
Fix to remove GridLength.ToString() culture dependency.
pull/8728/head
Tako
4 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
21 additions and
1 deletions
-
src/Avalonia.Controls/GridLength.cs
-
tests/Avalonia.Controls.UnitTests/GridLengthTests.cs
|
|
|
@ -180,7 +180,7 @@ namespace Avalonia.Controls |
|
|
|
return "Auto"; |
|
|
|
} |
|
|
|
|
|
|
|
string s = _value.ToString(); |
|
|
|
string s = _value.ToString(CultureInfo.InvariantCulture); |
|
|
|
return IsStar ? s + "*" : s; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -1,6 +1,8 @@ |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Globalization; |
|
|
|
using System.Linq; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using Xunit; |
|
|
|
|
|
|
|
namespace Avalonia.Controls.UnitTests |
|
|
|
@ -100,5 +102,23 @@ namespace Avalonia.Controls.UnitTests |
|
|
|
}, |
|
|
|
result); |
|
|
|
} |
|
|
|
|
|
|
|
[Theory] |
|
|
|
[InlineData(1.2d, GridUnitType.Pixel, "1.2")] |
|
|
|
[InlineData(1.2d, GridUnitType.Star, "1.2*")] |
|
|
|
[InlineData(1.2d, GridUnitType.Auto, "Auto")] |
|
|
|
public async void ToString_AllCulture_Should_Pass(double d, GridUnitType type, string result) |
|
|
|
{ |
|
|
|
List<CultureInfo> cultureInfos = CultureInfo.GetCultures(CultureTypes.AllCultures).ToList(); |
|
|
|
GridLength length = new GridLength(d, type); |
|
|
|
foreach(var culture in cultureInfos) |
|
|
|
{ |
|
|
|
await Task.Run(() => |
|
|
|
{ |
|
|
|
CultureInfo.CurrentCulture = culture; |
|
|
|
Assert.Equal(result, length.ToString()); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|