Skip to content

Commit e366657

Browse files
authored
Update Uno version, Uno TFMs to .NET 8 (#191)
* Update to latest version of Uno * Update Uno TFMs to net8.0 * Fixed new net8.0 compiler warnings/errors * Update package versions for Uno Wasm * Align Android TFM with Uno.UI * Use net8.0-android34.0 for Android TFM * Fix possible nullref assignments on Wasdk * Fixed possible nullrefs on WinAppSdk * Fixed WinUIMajorVersion for single-component Wasdk head
1 parent ce05388 commit e366657

File tree

8 files changed

+51
-43
lines changed

8 files changed

+51
-43
lines changed

CommunityToolkit.App.Shared/App.xaml.cs

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ namespace CommunityToolkit.App.Shared;
1212
public sealed partial class App : Application
1313
{
1414
// MacOS and iOS don't know the correct type without a full namespace declaration, confusing it with NSWindow and UIWindow.
15-
// Using static will not work.
16-
#if WINAPPSDK
17-
public static Microsoft.UI.Xaml.Window currentWindow = Microsoft.UI.Xaml.Window.Current;
18-
#else
19-
private static Windows.UI.Xaml.Window currentWindow = Windows.UI.Xaml.Window.Current;
15+
// 'using static' will not work.
16+
#if WINUI3
17+
public static Microsoft.UI.Xaml.Window? currentWindow = Microsoft.UI.Xaml.Window.Current;
18+
#elif WINUI2
19+
private static Windows.UI.Xaml.Window? currentWindow = Windows.UI.Xaml.Window.Current;
2020
#endif
2121

2222
/// <summary>
@@ -41,28 +41,34 @@ protected override void OnLaunched(LaunchActivatedEventArgs e)
4141
currentWindow.AppWindow.SetIcon("Assets/Icon.ico");
4242
currentWindow.SystemBackdrop = new MicaBackdrop();
4343
#if ALL_SAMPLES
44-
currentWindow.AppWindow.TitleBar.ExtendsContentIntoTitleBar = true;
45-
currentWindow.AppWindow.TitleBar.ButtonBackgroundColor = Microsoft.UI.Colors.Transparent;
44+
if (currentWindow is not null)
45+
{
46+
currentWindow.AppWindow.TitleBar.ExtendsContentIntoTitleBar = true;
47+
currentWindow.AppWindow.TitleBar.ButtonBackgroundColor = Microsoft.UI.Colors.Transparent;
48+
}
4649
#endif
4750
#endif
4851

4952
// Do not repeat app initialization when the Window already has content,
5053
// just ensure that the window is active
51-
if (currentWindow.Content is not Frame rootFrame)
54+
if (currentWindow is not null && currentWindow.Content is not Frame)
5255
{
5356
// Create a Frame to act as the navigation context and navigate to the first page
54-
currentWindow.Content = rootFrame = new Frame();
57+
currentWindow.Content = new Frame();
58+
}
5559

60+
if (currentWindow?.Content is Frame rootFrame)
61+
{
5662
rootFrame.NavigationFailed += OnNavigationFailed;
57-
}
5863

5964
#if !WINAPPSDK
60-
if (e.PrelaunchActivated == false)
65+
if (e.PrelaunchActivated == false)
6166
#endif
62-
rootFrame.Navigate(typeof(AppLoadingView), e.Arguments);
67+
rootFrame.Navigate(typeof(AppLoadingView), e.Arguments);
68+
}
6369

6470
// Ensure the current window is active
65-
currentWindow.Activate();
71+
currentWindow?.Activate();
6672
}
6773

6874
/// <summary>

CommunityToolkit.App.Shared/Pages/Shell.xaml.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ public sealed partial class Shell : Page
2020
public Shell()
2121
{
2222
this.InitializeComponent();
23-
#if WINAPPSDK
24-
appTitleBar.Window = App.currentWindow;
23+
#if WINDOWS_WINAPPSDK
24+
if (App.currentWindow is not null)
25+
appTitleBar.Window = App.currentWindow;
2526
#else
2627
BackdropMaterial.SetApplyToRootOrPageBackground(this, true);
2728
#endif

CommunityToolkit.App.Shared/Pages/TabbedPage.xaml.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,9 @@ public sealed partial class TabbedPage : Page
3434
public TabbedPage()
3535
{
3636
this.InitializeComponent();
37-
#if WINAPPSDK
38-
appTitleBar.Window = App.currentWindow;
37+
#if WINDOWS_WINAPPSDK
38+
if (App.currentWindow is not null)
39+
appTitleBar.Window = App.currentWindow;
3940
#else
4041
BackdropMaterial.SetApplyToRootOrPageBackground(this, true);
4142
#endif

MultiTarget/AvailableTargetFrameworks.props

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,21 @@
33
<UwpTargetFramework>uap10.0.17763</UwpTargetFramework>
44
<WinAppSdkTargetFramework>net8.0-windows10.0.22621.0;net7.0-windows10.0.22621.0;net6.0-windows10.0.22621.0;</WinAppSdkTargetFramework>
55

6-
<WasmHeadTargetFramework>net7.0</WasmHeadTargetFramework>
7-
<LinuxHeadTargetFramework>net7.0</LinuxHeadTargetFramework>
8-
<WpfHeadTargetFramework>net7.0</WpfHeadTargetFramework>
6+
<WasmHeadTargetFramework>net8.0</WasmHeadTargetFramework>
7+
<LinuxHeadTargetFramework>net8.0</LinuxHeadTargetFramework>
8+
<WpfHeadTargetFramework>net8.0</WpfHeadTargetFramework>
99

10-
<AndroidLibTargetFramework>net7.0-android33.0</AndroidLibTargetFramework>
11-
<MacOSLibTargetFramework>net7.0-maccatalyst</MacOSLibTargetFramework>
12-
<iOSLibTargetFramework>net7.0-ios</iOSLibTargetFramework>
10+
<AndroidLibTargetFramework>net8.0-android34.0</AndroidLibTargetFramework>
11+
<MacOSLibTargetFramework>net8.0-maccatalyst</MacOSLibTargetFramework>
12+
<iOSLibTargetFramework>net8.0-ios</iOSLibTargetFramework>
1313

1414
<!-- Used for comparison to current TargetFramework -->
15-
<LinuxLibTargetFramework>net7.0</LinuxLibTargetFramework>
16-
<WasmLibTargetFramework>net7.0</WasmLibTargetFramework>
17-
<WpfLibTargetFramework>net7.0</WpfLibTargetFramework>
15+
<LinuxLibTargetFramework>net8.0</LinuxLibTargetFramework>
16+
<WasmLibTargetFramework>net8.0</WasmLibTargetFramework>
17+
<WpfLibTargetFramework>net8.0</WpfLibTargetFramework>
1818

1919
<!-- Used for defining TargetFramework under platforms that need it -->
2020
<DotnetStandardCommonTargetFramework>netstandard2.0</DotnetStandardCommonTargetFramework>
21-
<DotnetCommonTargetFramework>net7.0</DotnetCommonTargetFramework>
21+
<DotnetCommonTargetFramework>net8.0</DotnetCommonTargetFramework>
2222
</PropertyGroup>
2323
</Project>

MultiTarget/EnabledTargetFrameworks.props

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@
22
<PropertyGroup>
33
<UwpTargetFramework>uap10.0.17763</UwpTargetFramework>
44
<WinAppSdkTargetFramework>net8.0-windows10.0.22621.0;net7.0-windows10.0.22621.0;net6.0-windows10.0.22621.0;</WinAppSdkTargetFramework>
5-
6-
<WasmHeadTargetFramework>net7.0</WasmHeadTargetFramework>
7-
<LinuxHeadTargetFramework>net7.0</LinuxHeadTargetFramework>
8-
<WpfHeadTargetFramework>net7.0</WpfHeadTargetFramework>
5+
6+
<WasmHeadTargetFramework>net8.0</WasmHeadTargetFramework>
7+
<LinuxHeadTargetFramework>net8.0</LinuxHeadTargetFramework>
8+
<WpfHeadTargetFramework>net8.0</WpfHeadTargetFramework>
99

1010
<!-- Used for comparison to current TargetFramework -->
11-
<LinuxLibTargetFramework>net7.0</LinuxLibTargetFramework>
12-
<WasmLibTargetFramework>net7.0</WasmLibTargetFramework>
13-
<WpfLibTargetFramework>net7.0</WpfLibTargetFramework>
11+
<LinuxLibTargetFramework>net8.0</LinuxLibTargetFramework>
12+
<WasmLibTargetFramework>net8.0</WasmLibTargetFramework>
13+
<WpfLibTargetFramework>net8.0</WpfLibTargetFramework>
1414

1515
<!-- Used for defining TargetFramework under platforms that need it -->
1616
<DotnetStandardCommonTargetFramework>netstandard2.0</DotnetStandardCommonTargetFramework>
17-
<DotnetCommonTargetFramework>net7.0</DotnetCommonTargetFramework>
17+
<DotnetCommonTargetFramework>net8.0</DotnetCommonTargetFramework>
1818
</PropertyGroup>
1919
</Project>

MultiTarget/PackageReferences/Uno.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project>
22
<PropertyGroup>
3-
<CommonUnoPackageVersion>5.1.87</CommonUnoPackageVersion>
3+
<CommonUnoPackageVersion>5.2.132</CommonUnoPackageVersion>
44
</PropertyGroup>
55

66
<!-- This file is modified by UseUnoWinUI.ps1 to switch between WinUI 2 and 3 under Uno Platform -->

ProjectHeads/App.Head.Wasm.props

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,12 @@
6060

6161
<ItemGroup>
6262
<PackageReference Include="Markdig" Version="0.31.0" />
63-
<PackageReference Include="Microsoft.Windows.Compatibility" Version="7.0.3" />
64-
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
65-
<PackageReference Include="Uno.Extensions.Logging.WebAssembly.Console" Version="1.6.0-dev.2" />
66-
<PackageReference Include="Uno.UI.Adapter.Microsoft.Extensions.Logging" Version="4.9.45" />
67-
<PackageReference Include="Uno.Wasm.Bootstrap" Version="7.0.29" />
68-
<PackageReference Include="Uno.Wasm.Bootstrap.DevServer" Version="7.0.29" />
63+
<PackageReference Include="Microsoft.Windows.Compatibility" Version="8.0.5" />
64+
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
65+
<PackageReference Include="Uno.Extensions.Logging.WebAssembly.Console" Version="1.8.0-dev.1" />
66+
<PackageReference Include="Uno.UI.Adapter.Microsoft.Extensions.Logging" Version="5.2.132" />
67+
<PackageReference Include="Uno.Wasm.Bootstrap" Version="8.0.14" />
68+
<PackageReference Include="Uno.Wasm.Bootstrap.DevServer" Version="8.0.14" />
6969
</ItemGroup>
7070

7171
<ItemGroup>

ProjectHeads/SingleComponent/WinAppSdk/ProjectTemplate.WinAppSdk.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<IsDeployableHead>true</IsDeployableHead>
66
<IsWinAppSdk>true</IsWinAppSdk>
77
<HasWinUI>true</HasWinUI>
8-
<WinUIMajorVersion>2</WinUIMajorVersion>
8+
<WinUIMajorVersion>3</WinUIMajorVersion>
99

1010
<IsSingleExperimentHead>true</IsSingleExperimentHead>
1111
</PropertyGroup>

0 commit comments

Comments
 (0)