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

Maui .NET 8 Support #2919

Merged
merged 6 commits into from
Aug 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/build_maui.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,5 @@ jobs:
with:
name: Build Prism.Maui
solution-path: PrismLibrary_Maui.slnf
dotnet-version: 8.0.x
install-workload: maui maui-tizen
6 changes: 6 additions & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
<PackageVersion Include="Xamarin.Forms" Version="5.0.0.2401" />
<PackageVersion Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.39" />
</ItemGroup>

<!-- Maui -->
<ItemGroup Condition=" $(UseMaui) == 'true' ">
<PackageVersion Include="Microsoft.Maui.Controls.Compatibility" Version="$(MauiVersion)" />
<PackageVersion Include="Microsoft.Maui.Controls" Version="$(MauiVersion)" />
</ItemGroup>
<!-- Uno -->
<ItemGroup Condition=" $(IsUnoProject) == 'true' ">
<PackageVersion Include="Uno.WinUI" Version="4.9.26" />
Expand Down
3 changes: 2 additions & 1 deletion e2e/Maui/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<Project>
<PropertyGroup>
<ImplicitUsings>enable</ImplicitUsings>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
</Project>
</Project>
7 changes: 6 additions & 1 deletion e2e/Maui/MauiModule/MauiModule.csproj
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<UseMaui>true</UseMaui>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" />
<PackageReference Include="Microsoft.Maui.Controls" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\src\Maui\Prism.Maui\Prism.Maui.csproj" />
</ItemGroup>
Expand Down
10 changes: 7 additions & 3 deletions e2e/Maui/MauiRegionsModule/MauiRegionsModule.csproj
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<TargetFramework>net8.0</TargetFramework>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<UseMaui>true</UseMaui>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" />
<PackageReference Include="Microsoft.Maui.Controls" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\src\Maui\Prism.Maui\Prism.Maui.csproj" />
</ItemGroup>
Expand Down
5 changes: 5 additions & 0 deletions e2e/Maui/PrismMauiDemo.sln
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Prism.Core.Tests", "..\..\t
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Prism.Events", "..\..\src\Prism.Events\Prism.Events.csproj", "{5623CB62-59C1-49BC-BB16-4C5D63D82DAC}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{16C4C33B-CC0F-4FA4-A117-B9EF161CB7B8}"
ProjectSection(SolutionItems) = preProject
..\..\Directory.Packages.props = ..\..\Directory.Packages.props
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down
5 changes: 2 additions & 3 deletions e2e/Maui/PrismMauiDemo/App.xaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<prism:PrismApplication xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
<Application xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:prism="http://prismlibrary.com"
xmlns:windows="clr-namespace:Microsoft.Maui.Controls.PlatformConfiguration.WindowsSpecific;assembly=Microsoft.Maui.Controls"
xmlns:local="clr-namespace:PrismMauiDemo"
x:Class="PrismMauiDemo.App"
Expand All @@ -13,4 +12,4 @@
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</prism:PrismApplication>
</Application>
10 changes: 8 additions & 2 deletions e2e/Maui/PrismMauiDemo/PrismMauiDemo.csproj
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net7.0-android;net7.0-ios;net7.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows')) and '$(MSBuildRuntimeType)' == 'Full'">$(TargetFrameworks);net7.0-windows10.0.19041</TargetFrameworks>
<TargetFrameworks>net8.0-android;net8.0-ios;net8.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows')) and '$(MSBuildRuntimeType)' == 'Full'">$(TargetFrameworks);net8.0-windows10.0.19041</TargetFrameworks>
<OutputType>Exe</OutputType>
<RootNamespace>PrismMauiDemo</RootNamespace>
<UseMaui>true</UseMaui>
<SingleProject>true</SingleProject>
<EnablePreviewMsixTooling>true</EnablePreviewMsixTooling>
<AndroidManifest>Platforms/Android/AndroidManifest.xml</AndroidManifest>

<!-- Display name -->
<ApplicationTitle>Prism Maui</ApplicationTitle>
Expand Down Expand Up @@ -49,6 +50,11 @@
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" />
<PackageReference Include="Microsoft.Maui.Controls" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\src\Maui\Prism.DryIoc.Maui\Prism.DryIoc.Maui.csproj" />
<ProjectReference Include="..\..\..\src\Maui\Prism.Maui.Rx\Prism.Maui.Rx.csproj" />
Expand Down
4 changes: 0 additions & 4 deletions global.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
{
"sdk": {
"rollForward": "latestMinor",
"allowPrerelease": false
},
"msbuild-sdks": {
"MSBuild.Sdk.Extras": "3.0.44"
}
Expand Down
4 changes: 3 additions & 1 deletion src/Maui/Prism.DryIoc.Maui/Prism.DryIoc.Maui.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<UseMaui>true</UseMaui>
<ImplicitUsings>true</ImplicitUsings>
Expand All @@ -10,6 +10,8 @@

<ItemGroup>
<PackageReference Include="DryIoc.dll" />
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" />
<PackageReference Include="Microsoft.Maui.Controls" />
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 3 additions & 1 deletion src/Maui/Prism.Maui.Rx/Prism.Maui.Rx.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>true</ImplicitUsings>
<Description>Prism.Maui.Rx is a support package for .NET MAUI developers. This package provides some helpers to access an IObservable for globally handling Navigation Request Results.</Description>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
Expand All @@ -13,6 +13,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" />
<PackageReference Include="Microsoft.Maui.Controls" />
<PackageReference Include="System.Reactive" />
</ItemGroup>

Expand Down
1 change: 0 additions & 1 deletion src/Maui/Prism.Maui/Navigation/IWindowManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@ public interface IWindowManager
void OpenWindow(Window window);
void CloseWindow(Window window);
}

43 changes: 43 additions & 0 deletions src/Maui/Prism.Maui/Navigation/PrismWindowManager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
namespace Prism.Navigation;

internal sealed class PrismWindowManager : IWindowCreator, IWindowManager
{
private IApplication _application { get; }

public PrismWindowManager(IApplication application)
{
_application = application;
}

private Window _initialWindow;

public IReadOnlyList<Window> Windows => _application.Windows.OfType<Window>().ToList();

public Window CreateWindow(Application app, IActivationState activationState)
{
if (_initialWindow is not null)
return _initialWindow;
else if (app.Windows.OfType<PrismWindow>().Any())
return _initialWindow = app.Windows.OfType<PrismWindow>().First();

activationState.Context.Services.GetRequiredService<PrismAppBuilder>().OnAppStarted();

return _initialWindow ?? throw new InvalidNavigationException("Expected Navigation Failed. No Root Window has been created.");
}

public void OpenWindow(Window window)
{
if (_initialWindow is null)
_initialWindow = window;
else
_application.OpenWindow(window);
}

public void CloseWindow(Window window)
{
if (_initialWindow == window)
_initialWindow = null;

_application.CloseWindow(window);
}
}
9 changes: 7 additions & 2 deletions src/Maui/Prism.Maui/Prism.Maui.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net7.0;net7.0-android33.0</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net7.0-windows10.0.19041</TargetFrameworks>
<TargetFrameworks>net8.0;net8.0-android</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net8.0-windows10.0.19041</TargetFrameworks>
<RootNamespace>Prism</RootNamespace>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<UseMaui>true</UseMaui>
Expand All @@ -13,6 +13,11 @@
<ProjectReference Include="..\..\Prism.Core\Prism.Core.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" />
<PackageReference Include="Microsoft.Maui.Controls" />
</ItemGroup>

<ItemGroup>
<InternalsVisibleTo Include="Prism.Maui.Tests" />
<InternalsVisibleTo Include="Prism.DryIoc.Maui.Tests" />
Expand Down
10 changes: 1 addition & 9 deletions src/Maui/Prism.Maui/PrismAppBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -230,15 +230,7 @@ private void RegisterDefaultRequiredTypes(IContainerRegistry containerRegistry)
containerRegistry.RegisterScoped<IPageAccessor, PageAccessor>();
containerRegistry.RegisterScoped<INavigationService, PageNavigationService>();
containerRegistry.Register<INavigationRegistry, NavigationRegistry>();
containerRegistry.Register<IWindowManager>(c =>
{
var app = c.Resolve<IApplication>();
if (app is PrismApplication prismApp)
return prismApp;

throw new InvalidOperationException("The registered application does not inherit from PrismApplication.");
});

containerRegistry.RegisterManySingleton<PrismWindowManager>();
containerRegistry.RegisterPageBehavior<NavigationPage, NavigationPageSystemGoBackBehavior>();
containerRegistry.RegisterPageBehavior<NavigationPage, NavigationPageActiveAwareBehavior>();
containerRegistry.RegisterPageBehavior<TabbedPage, TabbedPageActiveAwareBehavior>();
Expand Down
29 changes: 0 additions & 29 deletions src/Maui/Prism.Maui/PrismApplication.cs

This file was deleted.

4 changes: 2 additions & 2 deletions tests/Maui/Prism.DryIoc.Maui.Tests/Fixtures/TestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ protected TestBase(ITestOutputHelper testOutputHelper)
protected MauiAppBuilder CreateBuilder(Action<PrismAppBuilder> configurePrism)
{
return MauiApp.CreateBuilder()
.UseMauiApp<PrismApplication>()
.UseMauiApp<Application>()
.UsePrism(prism =>
{
prism.RegisterTypes(container =>
Expand Down Expand Up @@ -68,7 +68,7 @@ protected Window GetWindow(MauiApp mauiApp)
{
var app = mauiApp.Services.GetService<IApplication>();
Assert.NotNull(app);
Assert.IsType<PrismApplication>(app);
Assert.IsType<Application>(app);

var state = new ActivationState(new MauiContext(mauiApp.Services));
var window = app.CreateWindow(state);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<Compile Include="..\Prism.Maui.Tests\Mocks\MockResourcesProvider.cs" LinkBase="Mocks" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" />
<PackageReference Include="Microsoft.Maui.Controls" />
<PackageReference Include="GitHubActionsTestLogger">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public EventToCommandBehaviorFixture()
{
DispatcherProvider.SetCurrent(TestDispatcher.Provider);
_ = MauiApp.CreateBuilder()
.UseMauiApp<ApplicationMock>()
.UseMauiApp<Application>()
.Build();
}

Expand Down
52 changes: 0 additions & 52 deletions tests/Maui/Prism.Maui.Tests/Mocks/ApplicationMock.cs

This file was deleted.

Loading
Loading