From 1b8cd576497585a6bc3b42331ddc274a825e9c9c Mon Sep 17 00:00:00 2001 From: David Britch Date: Tue, 11 Jun 2024 17:21:56 +0100 Subject: [PATCH] Add test harness to support XAML hot reload (#478) * Add test harness to support XAML hot reload. * Make the apps run on WinUI. --- .../NativeEmbeddingDemo.Droid.csproj | 3 + .../NativeEmbeddingDemo.MacCatalyst.csproj | 5 +- .../NativeEmbeddingDemo.WinUI.csproj | 5 +- .../NativeEmbeddingDemo.iOS.csproj | 3 + .../NativeEmbeddingDemo.sln | 21 +- .../NativeEmbeddingDemo/App.xaml | 13 +- .../NativeEmbeddingDemo/MauiProgram.cs | 45 +- .../NativeEmbeddingDemo/MyMauiContent.xaml | 10 + .../Resources/Styles/Colors.xaml | 88 +- .../Resources/Styles/Colors.xaml.cs | 9 + .../Resources/Styles/Styles.xaml | 851 +++++++++--------- .../Resources/Styles/Styles.xaml.cs | 9 + .../NativeEmbeddingDemo/README.md | 10 + .../TestHarnessApp/HostPage.xaml | 8 + .../TestHarnessApp/HostPage.xaml.cs | 9 + .../TestHarnessApp/MauiProgram.cs | 10 + .../Platforms/Android/AndroidManifest.xml | 6 + .../Platforms/Android/MainActivity.cs | 11 + .../Platforms/Android/MainApplication.cs | 16 + .../Android/Resources/values/colors.xml | 6 + .../Platforms/MacCatalyst/AppDelegate.cs | 10 + .../Platforms/MacCatalyst/Entitlements.plist | 14 + .../Platforms/MacCatalyst/Info.plist | 38 + .../Platforms/MacCatalyst/Program.cs | 16 + .../TestHarnessApp/Platforms/Tizen/Main.cs | 17 + .../Platforms/Tizen/tizen-manifest.xml | 15 + .../TestHarnessApp/Platforms/Windows/App.xaml | 9 + .../Platforms/Windows/App.xaml.cs | 25 + .../Platforms/Windows/Package.appxmanifest | 47 + .../Platforms/Windows/app.manifest | 16 + .../Platforms/iOS/AppDelegate.cs | 10 + .../TestHarnessApp/Platforms/iOS/Info.plist | 32 + .../TestHarnessApp/Platforms/iOS/Program.cs | 16 + .../Properties/launchSettings.json | 8 + .../Resources/AppIcon/appicon.svg | 5 + .../Resources/AppIcon/appiconfg.svg | 8 + .../Resources/Splash/splash.svg | 9 + .../TestHarnessApp/TestApp.xaml | 16 + .../TestHarnessApp/TestApp.xaml.cs | 15 + .../TestHarnessApp/TestHarnessApp.csproj | 61 ++ 40 files changed, 1032 insertions(+), 493 deletions(-) create mode 100644 8.0/PlatformIntegration/NativeEmbeddingDemo/NativeEmbeddingDemo/Resources/Styles/Colors.xaml.cs create mode 100644 8.0/PlatformIntegration/NativeEmbeddingDemo/NativeEmbeddingDemo/Resources/Styles/Styles.xaml.cs create mode 100644 8.0/PlatformIntegration/NativeEmbeddingDemo/TestHarnessApp/HostPage.xaml create mode 100644 8.0/PlatformIntegration/NativeEmbeddingDemo/TestHarnessApp/HostPage.xaml.cs create mode 100644 8.0/PlatformIntegration/NativeEmbeddingDemo/TestHarnessApp/MauiProgram.cs create mode 100644 8.0/PlatformIntegration/NativeEmbeddingDemo/TestHarnessApp/Platforms/Android/AndroidManifest.xml create mode 100644 8.0/PlatformIntegration/NativeEmbeddingDemo/TestHarnessApp/Platforms/Android/MainActivity.cs create mode 100644 8.0/PlatformIntegration/NativeEmbeddingDemo/TestHarnessApp/Platforms/Android/MainApplication.cs create mode 100644 8.0/PlatformIntegration/NativeEmbeddingDemo/TestHarnessApp/Platforms/Android/Resources/values/colors.xml create mode 100644 8.0/PlatformIntegration/NativeEmbeddingDemo/TestHarnessApp/Platforms/MacCatalyst/AppDelegate.cs create mode 100644 8.0/PlatformIntegration/NativeEmbeddingDemo/TestHarnessApp/Platforms/MacCatalyst/Entitlements.plist create mode 100644 8.0/PlatformIntegration/NativeEmbeddingDemo/TestHarnessApp/Platforms/MacCatalyst/Info.plist create mode 100644 8.0/PlatformIntegration/NativeEmbeddingDemo/TestHarnessApp/Platforms/MacCatalyst/Program.cs create mode 100644 8.0/PlatformIntegration/NativeEmbeddingDemo/TestHarnessApp/Platforms/Tizen/Main.cs create mode 100644 8.0/PlatformIntegration/NativeEmbeddingDemo/TestHarnessApp/Platforms/Tizen/tizen-manifest.xml create mode 100644 8.0/PlatformIntegration/NativeEmbeddingDemo/TestHarnessApp/Platforms/Windows/App.xaml create mode 100644 8.0/PlatformIntegration/NativeEmbeddingDemo/TestHarnessApp/Platforms/Windows/App.xaml.cs create mode 100644 8.0/PlatformIntegration/NativeEmbeddingDemo/TestHarnessApp/Platforms/Windows/Package.appxmanifest create mode 100644 8.0/PlatformIntegration/NativeEmbeddingDemo/TestHarnessApp/Platforms/Windows/app.manifest create mode 100644 8.0/PlatformIntegration/NativeEmbeddingDemo/TestHarnessApp/Platforms/iOS/AppDelegate.cs create mode 100644 8.0/PlatformIntegration/NativeEmbeddingDemo/TestHarnessApp/Platforms/iOS/Info.plist create mode 100644 8.0/PlatformIntegration/NativeEmbeddingDemo/TestHarnessApp/Platforms/iOS/Program.cs create mode 100644 8.0/PlatformIntegration/NativeEmbeddingDemo/TestHarnessApp/Properties/launchSettings.json create mode 100644 8.0/PlatformIntegration/NativeEmbeddingDemo/TestHarnessApp/Resources/AppIcon/appicon.svg create mode 100644 8.0/PlatformIntegration/NativeEmbeddingDemo/TestHarnessApp/Resources/AppIcon/appiconfg.svg create mode 100644 8.0/PlatformIntegration/NativeEmbeddingDemo/TestHarnessApp/Resources/Splash/splash.svg create mode 100644 8.0/PlatformIntegration/NativeEmbeddingDemo/TestHarnessApp/TestApp.xaml create mode 100644 8.0/PlatformIntegration/NativeEmbeddingDemo/TestHarnessApp/TestApp.xaml.cs create mode 100644 8.0/PlatformIntegration/NativeEmbeddingDemo/TestHarnessApp/TestHarnessApp.csproj diff --git a/8.0/PlatformIntegration/NativeEmbeddingDemo/NativeEmbeddingDemo.Droid/NativeEmbeddingDemo.Droid.csproj b/8.0/PlatformIntegration/NativeEmbeddingDemo/NativeEmbeddingDemo.Droid/NativeEmbeddingDemo.Droid.csproj index 157ef5cd0..84cdd7aea 100644 --- a/8.0/PlatformIntegration/NativeEmbeddingDemo/NativeEmbeddingDemo.Droid/NativeEmbeddingDemo.Droid.csproj +++ b/8.0/PlatformIntegration/NativeEmbeddingDemo/NativeEmbeddingDemo.Droid/NativeEmbeddingDemo.Droid.csproj @@ -9,6 +9,9 @@ true true + + false + com.companyname.nativeembeddingdemo 1 1.0 diff --git a/8.0/PlatformIntegration/NativeEmbeddingDemo/NativeEmbeddingDemo.MacCatalyst/NativeEmbeddingDemo.MacCatalyst.csproj b/8.0/PlatformIntegration/NativeEmbeddingDemo/NativeEmbeddingDemo.MacCatalyst/NativeEmbeddingDemo.MacCatalyst.csproj index fc90824a3..b1d5d75d8 100644 --- a/8.0/PlatformIntegration/NativeEmbeddingDemo/NativeEmbeddingDemo.MacCatalyst/NativeEmbeddingDemo.MacCatalyst.csproj +++ b/8.0/PlatformIntegration/NativeEmbeddingDemo/NativeEmbeddingDemo.MacCatalyst/NativeEmbeddingDemo.MacCatalyst.csproj @@ -1,4 +1,4 @@ - + net8.0-maccatalyst @@ -9,6 +9,9 @@ 14.2 true true + + + false diff --git a/8.0/PlatformIntegration/NativeEmbeddingDemo/NativeEmbeddingDemo.WinUI/NativeEmbeddingDemo.WinUI.csproj b/8.0/PlatformIntegration/NativeEmbeddingDemo/NativeEmbeddingDemo.WinUI/NativeEmbeddingDemo.WinUI.csproj index b80c16694..fcfeeeed4 100644 --- a/8.0/PlatformIntegration/NativeEmbeddingDemo/NativeEmbeddingDemo.WinUI/NativeEmbeddingDemo.WinUI.csproj +++ b/8.0/PlatformIntegration/NativeEmbeddingDemo/NativeEmbeddingDemo.WinUI/NativeEmbeddingDemo.WinUI.csproj @@ -17,6 +17,9 @@ true true false + + + false @@ -30,7 +33,7 @@ - + diff --git a/8.0/PlatformIntegration/NativeEmbeddingDemo/NativeEmbeddingDemo.iOS/NativeEmbeddingDemo.iOS.csproj b/8.0/PlatformIntegration/NativeEmbeddingDemo/NativeEmbeddingDemo.iOS/NativeEmbeddingDemo.iOS.csproj index f5ce970d0..fac3cbfec 100644 --- a/8.0/PlatformIntegration/NativeEmbeddingDemo/NativeEmbeddingDemo.iOS/NativeEmbeddingDemo.iOS.csproj +++ b/8.0/PlatformIntegration/NativeEmbeddingDemo/NativeEmbeddingDemo.iOS/NativeEmbeddingDemo.iOS.csproj @@ -7,6 +7,9 @@ 13.0 true true + + + false diff --git a/8.0/PlatformIntegration/NativeEmbeddingDemo/NativeEmbeddingDemo.sln b/8.0/PlatformIntegration/NativeEmbeddingDemo/NativeEmbeddingDemo.sln index 5d7d21ab7..789e06727 100644 --- a/8.0/PlatformIntegration/NativeEmbeddingDemo/NativeEmbeddingDemo.sln +++ b/8.0/PlatformIntegration/NativeEmbeddingDemo/NativeEmbeddingDemo.sln @@ -13,7 +13,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NativeEmbeddingDemo.Library EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NativeEmbeddingDemo.Droid", "NativeEmbeddingDemo.Droid\NativeEmbeddingDemo.Droid.csproj", "{76B43FBB-1DEA-4260-8802-7DC0015A916F}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NativeEmbeddingDemo.MacCatalyst", "NativeEmbeddingDemo.MacCatalyst\NativeEmbeddingDemo.MacCatalyst.csproj", "{A63220BF-4101-4D60-A75D-CF2693646A6A}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NativeEmbeddingDemo.MacCatalyst", "NativeEmbeddingDemo.MacCatalyst\NativeEmbeddingDemo.MacCatalyst.csproj", "{A63220BF-4101-4D60-A75D-CF2693646A6A}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestHarnessApp", "TestHarnessApp\TestHarnessApp.csproj", "{B14E3633-E1E0-4CD7-A2BC-E8FE76F53560}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -163,6 +165,23 @@ Global {A63220BF-4101-4D60-A75D-CF2693646A6A}.Release|x86.ActiveCfg = Release|Any CPU {A63220BF-4101-4D60-A75D-CF2693646A6A}.Release|x86.Build.0 = Release|Any CPU {A63220BF-4101-4D60-A75D-CF2693646A6A}.Release|x86.Deploy.0 = Release|Any CPU + {B14E3633-E1E0-4CD7-A2BC-E8FE76F53560}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B14E3633-E1E0-4CD7-A2BC-E8FE76F53560}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B14E3633-E1E0-4CD7-A2BC-E8FE76F53560}.Debug|Any CPU.Deploy.0 = Debug|Any CPU + {B14E3633-E1E0-4CD7-A2BC-E8FE76F53560}.Debug|ARM64.ActiveCfg = Debug|Any CPU + {B14E3633-E1E0-4CD7-A2BC-E8FE76F53560}.Debug|ARM64.Build.0 = Debug|Any CPU + {B14E3633-E1E0-4CD7-A2BC-E8FE76F53560}.Debug|x64.ActiveCfg = Debug|Any CPU + {B14E3633-E1E0-4CD7-A2BC-E8FE76F53560}.Debug|x64.Build.0 = Debug|Any CPU + {B14E3633-E1E0-4CD7-A2BC-E8FE76F53560}.Debug|x86.ActiveCfg = Debug|Any CPU + {B14E3633-E1E0-4CD7-A2BC-E8FE76F53560}.Debug|x86.Build.0 = Debug|Any CPU + {B14E3633-E1E0-4CD7-A2BC-E8FE76F53560}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B14E3633-E1E0-4CD7-A2BC-E8FE76F53560}.Release|Any CPU.Build.0 = Release|Any CPU + {B14E3633-E1E0-4CD7-A2BC-E8FE76F53560}.Release|ARM64.ActiveCfg = Release|Any CPU + {B14E3633-E1E0-4CD7-A2BC-E8FE76F53560}.Release|ARM64.Build.0 = Release|Any CPU + {B14E3633-E1E0-4CD7-A2BC-E8FE76F53560}.Release|x64.ActiveCfg = Release|Any CPU + {B14E3633-E1E0-4CD7-A2BC-E8FE76F53560}.Release|x64.Build.0 = Release|Any CPU + {B14E3633-E1E0-4CD7-A2BC-E8FE76F53560}.Release|x86.ActiveCfg = Release|Any CPU + {B14E3633-E1E0-4CD7-A2BC-E8FE76F53560}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/8.0/PlatformIntegration/NativeEmbeddingDemo/NativeEmbeddingDemo/App.xaml b/8.0/PlatformIntegration/NativeEmbeddingDemo/NativeEmbeddingDemo/App.xaml index 4989854ea..f13f4945e 100644 --- a/8.0/PlatformIntegration/NativeEmbeddingDemo/NativeEmbeddingDemo/App.xaml +++ b/8.0/PlatformIntegration/NativeEmbeddingDemo/NativeEmbeddingDemo/App.xaml @@ -1,14 +1,21 @@  - - + + + + + + + diff --git a/8.0/PlatformIntegration/NativeEmbeddingDemo/NativeEmbeddingDemo/MauiProgram.cs b/8.0/PlatformIntegration/NativeEmbeddingDemo/NativeEmbeddingDemo/MauiProgram.cs index 833d00224..1e58432f1 100644 --- a/8.0/PlatformIntegration/NativeEmbeddingDemo/NativeEmbeddingDemo/MauiProgram.cs +++ b/8.0/PlatformIntegration/NativeEmbeddingDemo/NativeEmbeddingDemo/MauiProgram.cs @@ -1,26 +1,39 @@ using Microsoft.Extensions.Logging; -namespace NativeEmbeddingDemo +namespace NativeEmbeddingDemo; + +public static class MauiProgram { - public static class MauiProgram + /// + /// Create a new MauiApp using the default application. + /// + /// + /// + public static MauiApp CreateMauiApp(Action? additional = null) => + CreateMauiApp(additional); + + /// + /// Create a new MauiAPp using the specified application. + /// + /// + /// + /// + public static MauiApp CreateMauiApp(Action? additional = null) where TApp : App { - public static MauiApp CreateMauiApp(Action? additional = null) - { - var builder = MauiApp.CreateBuilder(); - builder - .UseMauiApp() - .ConfigureFonts(fonts => - { - fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular"); - fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold"); - }); + var builder = MauiApp.CreateBuilder(); + builder + .UseMauiApp() + .ConfigureFonts(fonts => + { + fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular"); + fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold"); + }); #if DEBUG - builder.Logging.AddDebug(); + builder.Logging.AddDebug(); #endif - additional?.Invoke(builder); + additional?.Invoke(builder); - return builder.Build(); - } + return builder.Build(); } } diff --git a/8.0/PlatformIntegration/NativeEmbeddingDemo/NativeEmbeddingDemo/MyMauiContent.xaml b/8.0/PlatformIntegration/NativeEmbeddingDemo/NativeEmbeddingDemo/MyMauiContent.xaml index 381bc013e..785ebdc66 100644 --- a/8.0/PlatformIntegration/NativeEmbeddingDemo/NativeEmbeddingDemo/MyMauiContent.xaml +++ b/8.0/PlatformIntegration/NativeEmbeddingDemo/NativeEmbeddingDemo/MyMauiContent.xaml @@ -28,5 +28,15 @@ SemanticProperties.Hint="Counts the number of times you click" Clicked="OnCounterClicked" HorizontalOptions="Fill" /> + +