Open-source platform for building cross-platform native Mobile, Web, Desktop and Embedded apps quickly. Create rich, C#/XAML, single-codebase apps from any IDE. Hot Reload included! 90m+ NuGet Downloads!!
Since we know on Windows that calling Convert.ChangeType("Horizontal", typeof(Orientation)) will throw.
And obiviously, .ToString() and Convert.ChangeType(text, type) isn't a safe way to convert?
We could be losing context or performance for complex type.
The very least we should be check if the returned value is of the desired type before attempt to "convert":
boxed is T value ? value : Convert.ChangeType(boxed?.ToString(), typeof(T))
Current behavior
This code below will throw on uno:
Expected behavior
^ should work like on windows.
How to reproduce it (as minimally and precisely as possible)
responsive_value.zip
Workaround
n/a
Works on UWP/WinUI
Yes
Environment
Uno.WinUI / Uno.WinUI.WebAssembly / Uno.WinUI.Skia
NuGet package version(s)
Uno.WinUI@5.0.31
Affected platforms
WebAssembly, Android, iOS, macOS (AppKit), Mac Catalyst, Skia (WPF), Skia (GTK on Linux/macOS/Windows), Skia (Linux Framebuffer), Build tasks
IDE
Visual Studio 2022
IDE version
No response
Relevant plugins
No response
Anything else we need to know?
generated code:
https://github.com/unoplatform/uno/blob/5.0.19/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs#L4680-L4683 ^ doesnt seem right.
Since we know on Windows that calling
Convert.ChangeType("Horizontal", typeof(Orientation))
will throw. And obiviously,.ToString()
andConvert.ChangeType(text, type)
isn't a safe way to convert? We could be losing context or performance for complex type. The very least we should be check if the returned value is of the desired type before attempt to "convert":