-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Microsoft.Maui.Controls.Shapes.PathGeometryConverter
does not load Path
Data
from Resource files in Release mode, but works fine in Debug mode
#20552
Comments
@PieEatingNinjas had the nice idea to create a workaround using an public class PathGeometryFromStringConverter : IValueConverter
{
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
=> new PathGeometryConverter().ConvertFromInvariantString(value?.ToString() ?? string.Empty) as Geometry;
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
=> throw new NotImplementedException();
} This works with a string resource loaded from XAML: <Path Aspect="Uniform"
HeightRequest="100"
WidthRequest="100"
Data="{Binding Source={StaticResource MyIconGeometry},
Converter={StaticResource converter},
Mode=OneTime}" /> |
I've been looking into this together with @hansmbakker . It's something we can easily work around, but the real big problem here IHMO, is the fact that the behavior changes depending whether you're in Debug or not. Things like this can leave (new) developers completely stumbled: what once ran perfectly fine on their machine, is broken once it is built as release. This is not a good developer experience and could completely overshadow the overall .NET MAUI experience. |
I was going through issues related to trimming (given that that is one of the differences between debug / release) and saw it is a development goal for MAUI in .NET 9 Could it be that this issue of the |
@samhouts I guess it is a generic MAUI issue, not limited to android/windows - I just could not test it on other platforms. |
Verified this on VS 17.10.0 Preview 2.0(8.0.7). Repro on Windows 11, Android 14.0-API34, iOS 17.2 and MacCatalyst with below Project: |
Is this still an issue with .NET 8 SR6 ? |
@symbiogenesis @samhouts @XamlTest unfortunately this is still an issue. Tested with .NET MAUI Please checkout the reproduction repository and build in |
@symbiogenesis @samhouts @XamlTest I updated the reproduction repository to MAUI 8.0.70 |
Description
I would like to store my vector art for
Path
s in a reusable way in the resources. I found the idea to do that by putting thePath
Data
as strings in in aResourceDictionary
, because it is not possible to put items of typePathGeometry
in there - I got this idea from https://stackoverflow.com/questions/41020372/pathgeometry-in-resourcedictionary.This approach does work in Debug mode - I can load
Path
Data
from aStaticResource
of type string.When using the Release configuration, the
Path
is not shown.It seems that the
PathGeometryConverter
does not work well with a string loaded from aResourceDictionary
.Debug
Release
Steps to Reproduce
App.xaml
Path
Data
as a resource in the resources XAML filePath
to your XAML page likeLink to public reproduction project repository
https://github.com/hansmbakker/path-data-resources-bugrepro
Version with bug
Initally reported with version
8.0.6
Still an issue with version
8.0.70
Is this a regression from previous behavior?
Not sure, did not test other versions
Last version that worked well
Unknown/Other
Affected platforms
Android, Windows, I was not able test on other platforms
Affected platform versions
No response
Did you find any workaround?
Two options:
Data
string verbatim in thePath
object (avoid using StaticResources) but that defeats the purpose.CustomIconData
class with a static property like so:As for option 2: this only works if you use data type
Geometry
. Using typestring
and hoping to rely on thePathGeometryConverter
implicitly does not work..Relevant log output
The text was updated successfully, but these errors were encountered: