Description
I have some CustomControl like this
public class CustomButton : ContentView
{
//other code
private ButtonConfiguration? _containedButtonConfiguration;
public ButtonConfiguration? ButtonConfig
{
get => _containedButtonConfiguration;
set
{
_containedButtonConfiguration = value;
Draw();
}
}
public CustomButton()
{
HorizontalOptions = VerticalOptions = LayoutOptions.Start;
}
}
and ButtonConfiguration is something like this
[AcceptEmptyServiceProvider]
public abstract class ButtonConfiguration : IMarkupExtension<ButtonConfiguration>
{
public abstract ButtonConfiguration BasedOn { set; }
public abstract View ComposeView();
public ButtonConfiguration ProvideValue(IServiceProvider serviceProvider)
{
return this;
}
object IMarkupExtension.ProvideValue(IServiceProvider serviceProvider)
{
return ProvideValue(serviceProvider);
}
public abstract void ApplyGestureHandler(View parentView, GestureRecognizer customGestureRecognizer);
}
and some ButtonConfiguration is like this
public class IconButtonConfiguration : ButtonConfiguration
{
public Color? Color { get; set; }
public string? IconGlyph { get; set; } = string.Empty;
public double IconSize { get; set; } = 14;
}
and when I set style in App.xaml
<ResourceDictionary>
<system:Double x:Key="LargeIconButtonFontSize">24</system:Double>
<config:IconButtonConfiguration
x:Key="DefaultIconButtonConfig"
IconSize="{StaticResource LargeIconButtonFontSize}"
SpacingEnabled="True"
Color="Black" />
</ResourceDictionary>
this will cause crash when in Release (both on Android and iOS). Debug working fine. But if I set like this
<ResourceDictionary>
<system:Double x:Key="LargeIconButtonFontSize">24</system:Double>
<config:IconButtonConfiguration
x:Key="DefaultIconButtonConfig"
IconSize="18"
SpacingEnabled="True"
Color="Black" />
</ResourceDictionary>
it is working fine in Release. Not really sure what is the cause of this
Steps to Reproduce
- Clone https://github.com/albilaga/mauitest
- Run android or iOS project in Release. This will crash
Link to public reproduction project repository
https://github.com/albilaga/mauitest
Version with bug
9.0.21 SR2.1
Is this a regression from previous behavior?
Yes, this used to work in .NET MAUI
Last version that worked well
8.0.100 SR10
Affected platforms
iOS, Android
Affected platform versions
iOS and Android
Did you find any workaround?
Hard code the value instead of using StaticResource but this mean then when refactoring need to be careful
Relevant log output
iOS
Android
Description
I have some CustomControl like this
and
ButtonConfigurationis something like thisand some ButtonConfiguration is like this
and when I set style in
App.xamlthis will cause crash when in Release (both on Android and iOS). Debug working fine. But if I set like this
it is working fine in Release. Not really sure what is the cause of this
Steps to Reproduce
Link to public reproduction project repository
https://github.com/albilaga/mauitest
Version with bug
9.0.21 SR2.1
Is this a regression from previous behavior?
Yes, this used to work in .NET MAUI
Last version that worked well
8.0.100 SR10
Affected platforms
iOS, Android
Affected platform versions
iOS and Android
Did you find any workaround?
Hard code the value instead of using StaticResource but this mean then when refactoring need to be careful
Relevant log output
iOS
Android