fix: DoubleExtension & IntExtension#2821
Conversation
| } | ||
|
|
||
| public DoubleExtension(object value) | ||
| public DoubleExtension(string value) |
There was a problem hiding this comment.
We dont need to use object as type since its always a string
|
Huh.. I realized that Convert.ToDouble(string, IFormarProvider) uses double.Parse under the hood but is checking for nulls. Lets use that 😄 |
|
I don't have that crash. Double extension is a markup extension which is only used on the xaml side. Can you give more details on your config. For instance, what's the current language and locale of your machine? |
Kryptos-FR
left a comment
There was a problem hiding this comment.
I haven't tested with other culture so I kind of understand why the fix could be needed.
With that said, DoubleExtension is not the only one doing a conversion. Others should be fixed as well.
sources/presentation/Stride.Core.Presentation.Avalonia/MarkupExtensions/DoubleExtension.cs
Outdated
Show resolved
Hide resolved
sources/presentation/Stride.Core.Presentation.Avalonia/MarkupExtensions/DoubleExtension.cs
Show resolved
Hide resolved
Yeah, because it is parsed as text, I concluded that it would be better to declare it as
That's because my case is niche, I think? 😅 My current Locale is pl-PL, but OS language is en-US. I'm just used to various settings written in English etc. This is probably the cause of the issue |
|
So the reasons it didn't crash in WPF is that bindings are more tolerant in WPF (exception is caught somewhere and doesn't crash the whole app), and secondly it doesn't look like we had cases where the value had a decimal part (and hence no formatting issue). |
The only other one actually is IntExtension which shouldn't have the same issue since there are no decimal parts. To be safer, let's also force the use of the InvariantCulture for IntExtension. |
|
@Kryptos-FR Sounds good to me, let's handle it even though it may be a small chance for an exception. |
PR Details
PR fixes following bug:
dotnet run)I simply used passed additional CultureInfo argument to take into account the different formats (dots or commas) that occur between languages.
My Current LocaleInfo : pl-PL
Types of changes
Checklist