Skip to content

fix: DoubleExtension & IntExtension#2821

Merged
Kryptos-FR merged 5 commits intostride3d:xplat-editorfrom
Jklawreszuk:double-fix
Jun 25, 2025
Merged

fix: DoubleExtension & IntExtension#2821
Kryptos-FR merged 5 commits intostride3d:xplat-editorfrom
Jklawreszuk:double-fix

Conversation

@Jklawreszuk
Copy link
Copy Markdown
Collaborator

@Jklawreszuk Jklawreszuk commented Jun 21, 2025

PR Details

PR fixes following bug:

  1. Run new Avalonia Editor on Windows (dotnet run)
  2. Load any game solution file.
  3. Select any asset or go to settings.
  4. Crash :
Exception: FormatException: The input string '0.5' was not in a correct format.

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

  • Docs change / refactoring / dependency upgrade
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My change requires a change to the documentation.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • I have built and run the editor to try this change out.

}

public DoubleExtension(object value)
public DoubleExtension(string value)
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

We dont need to use object as type since its always a string

@Jklawreszuk Jklawreszuk changed the title Fix: DoubleE fix Fix: DoubleExtension fix Jun 21, 2025
@Jklawreszuk
Copy link
Copy Markdown
Collaborator Author

Jklawreszuk commented Jun 21, 2025

Huh.. I realized that Convert.ToDouble(string, IFormarProvider) uses double.Parse under the hood but is checking for nulls. Lets use that 😄

@Kryptos-FR
Copy link
Copy Markdown
Member

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?

Copy link
Copy Markdown
Member

@Kryptos-FR Kryptos-FR left a comment

Choose a reason for hiding this comment

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

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.

@Jklawreszuk
Copy link
Copy Markdown
Collaborator Author

Double extension is a markup extension which is only used on the xaml side.

Yeah, because it is parsed as text, I concluded that it would be better to declare it as string, for now 😅 But yeah I guess consequently it would be useful to change the rest of the extensions in this way, so I'm going to undo that

I don't have that crash.

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

@Kryptos-FR Kryptos-FR self-assigned this Jun 23, 2025
@Kryptos-FR Kryptos-FR added bug Something isn't working area-GameStudio labels Jun 23, 2025
@Kryptos-FR
Copy link
Copy Markdown
Member

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).

@Kryptos-FR
Copy link
Copy Markdown
Member

With that said, DoubleExtension is not the only one doing a conversion. Others should be fixed as well.

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 Kryptos-FR changed the title Fix: DoubleExtension fix Fix: DoubleExtension & IntExtension Jun 23, 2025
@Kryptos-FR Kryptos-FR changed the title Fix: DoubleExtension & IntExtension fix: DoubleExtension & IntExtension Jun 23, 2025
@Kryptos-FR Kryptos-FR added bug-fix and removed bug Something isn't working labels Jun 23, 2025
@Jklawreszuk
Copy link
Copy Markdown
Collaborator Author

@Kryptos-FR Sounds good to me, let's handle it even though it may be a small chance for an exception.

@Kryptos-FR Kryptos-FR merged commit 32edbc9 into stride3d:xplat-editor Jun 25, 2025
8 checks passed
@Jklawreszuk Jklawreszuk deleted the double-fix branch June 25, 2025 19:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants