Skip to content
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

Layout Serialization is causing problems due to regional formatting #6

Open
Karmoq opened this issue May 13, 2022 · 4 comments
Open

Comments

@Karmoq
Copy link

Karmoq commented May 13, 2022

Hey Nick,

I'm having an issue with the serialization of layouts, and I believe it is related to regional formatting.
My colleague has czech regional formatting, which uses commas (",") for separating decimal numbers, instead of the usual decimal points (".")

After looking at the serialization, it seems like that when saving the layouts, it uses the GridLength.ToString() method to convert it to strings, which is not culture-invariant. See DockGroupParams.ToGroupParams(this IDockGroup dg), line 149.

But when loading the layouts, it uses the GridLength.Parse method, which, when looking at the Avalonia Source code, correctly uses Invariant Culture for parsing.

In some cases this results in commas being ignored when loading a saved layout:

Before saving
image

After saving
image

I believe this can be fixed by changing the non-culture-invariant call to GridLength.ToString() to something like GridLength.Value.ToString(CultureInfo.Invariant) (of course considering the star etc)

I hope it is clear what I'm explaining :)

Thanks,
Karmoq

@npolyak
Copy link
Owner

npolyak commented Aug 10, 2022

Sorry Karmoq, it took me some time to reply to you.

In the USA, commas are not used for the decimals - only for separation of thousands, Please use period - '.' for the decimals:)

@Karmoq
Copy link
Author

Karmoq commented Aug 10, 2022

Hey Nick,
I think you didn't fully understand the issue, it seems that in with the way how Unidock serializes the layout, it uses culture dependent .ToString() for saving (which uses the machines regional formatting setting) while it uses Invariant parsing for loading.
This means that when the users machine is set to a different regional formatting, Unidock itself generates save files with different formatting than what it expects when loading.
Basically, users with different regional formatting on their machines can't use the layout serialization as it is right now.

@npolyak
Copy link
Owner

npolyak commented Aug 10, 2022

Yes, you are correct. Actually it is a problem with Avalonia's GridLength - they provide local ToString, but locale-invariant parse, but I can fix it and I will

@npolyak
Copy link
Owner

npolyak commented Aug 11, 2022

please, download the next version of UniDock - https://www.nuget.org/packages/NP.Avalonia.UniDock/1.0.37

It should be working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants