What's new in Version 3
Describes the list of changes present in Version 3 of MauiReactor
Version 3 of MauiReactor targets MAUI .NET 9. If you're using an earlier version of MauiReactor, please note the following short-step list of changes required to move forward to version 3.
Hot-reload changes
Hot-reload must be enabled using the new Feature switch available in .NET 9 (https://github.com/dotnet/designs/blob/main/accepted/2020/feature-switch.md).
Remove the EnableMauiReactorHotReload() call in program.cs
:
var builder = MauiApp.CreateBuilder();
builder
.UseMauiReactorApp<HomePage>()
#if DEBUG
.EnableMauiReactorHotReload()
#endif
...;
In the project definition add the following lines:
<ItemGroup Condition="'$(Configuration)'=='Debug'">
<RuntimeHostConfigurationOption Include="MauiReactor.HotReload" Value="true" Trim="false" />
</ItemGroup>
XAML resources
Due to an internal change of the .NET Maui 9 framework, loading the resources (i.e. styles, brushes, etc) from XAML dictionaries is slightly less straightforward.
First, create an App.xaml and App.xaml.cs (or copy them from the standard .NET MAUI template) and link your resources as merged dictionaries of the app:
<?xml version = "1.0" encoding = "UTF-8" ?>
<local:MauiReactorApplication xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:MauiReactor.TestApp"
x:Class="MauiReactor.TestApp.App">
<local:MauiReactorApplication.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Resources/Styles/Colors.xaml" />
<ResourceDictionary Source="Resources/Styles/Styles.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</local:MauiReactorApplication.Resources>
</local:MauiReactorApplication>
In the App.xaml.cs file, create a derived class of the standard MAUI Application like the following:
public partial class App: ReactorApplication<HomePage>
{
public App(IServiceProvider serviceProvider)
:base(serviceProvider)
{
InitializeComponent();
}
}
Note that the class injects the IServiceProvider object and passes it to the base class. HomePage
class represents the root component of the application.
Finally, use the standard UseMauiApp method in your Program.cs file load the application:
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
...
If you need also to customize the MauiReactor application, i.e. also adding your c# styles from the application theming feature, you need to create an additional class that derives from ReactorApplication and set your application theme as shown below:
public partial class App : MauiReactorApplication
{
public App(IServiceProvider serviceProvider)
:base(serviceProvider)
{
InitializeComponent();
}
}
public abstract class MauiReactorApplication : ReactorApplication<HomePage>
{
public MauiReactorApplication(IServiceProvider serviceProvider)
:base(serviceProvider)
{
this.UseTheme<AppTheme>();
}
}
AOT compliance
MauiReactor 3 is fully AOT compatible: to compile your application to a native iOS or Mac Catalyst application you have to add these lines to your project definition:
<ItemGroup Condition="'$(Configuration)'=='Release'">
<RuntimeHostConfigurationOption Include="MauiReactor.HotReload" Value="false" Trim="true" />
</ItemGroup>
Unhandled exception callback
In version 3 you can configure an unhandled exception callback using this code:
.UseMauiReactorApp<ShellPage>(
unhandledExceptionAction: args =>
{
Trace.WriteLine(args.ExceptionObject);
})
Last updated
Was this helpful?