Skip to content

Commit

Permalink
Fix possible nullref assignments on Wasdk
Browse files Browse the repository at this point in the history
  • Loading branch information
Arlodotexe committed Jun 3, 2024
1 parent 81ebdb1 commit 35189bd
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions CommunityToolkit.App.Shared/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ namespace CommunityToolkit.App.Shared;
public sealed partial class App : Application
{
// MacOS and iOS don't know the correct type without a full namespace declaration, confusing it with NSWindow and UIWindow.
// Using static will not work.
#if WINAPPSDK
public static Microsoft.UI.Xaml.Window currentWindow = Microsoft.UI.Xaml.Window.Current;
#else
// 'using static' will not work.
#if WINUI3
public static Microsoft.UI.Xaml.Window? currentWindow = Microsoft.UI.Xaml.Window.Current;
#elif WINUI2
private static Windows.UI.Xaml.Window? currentWindow = Windows.UI.Xaml.Window.Current;

Check failure on line 19 in CommunityToolkit.App.Shared/App.xaml.cs

View workflow job for this annotation

GitHub Actions / project-template

The type or namespace name 'Window' does not exist in the namespace 'Windows.UI.Xaml' (are you missing an assembly reference?)

Check failure on line 19 in CommunityToolkit.App.Shared/App.xaml.cs

View workflow job for this annotation

GitHub Actions / new-experiment

The type or namespace name 'Window' does not exist in the namespace 'Windows.UI.Xaml' (are you missing an assembly reference?)
#endif

Expand Down
2 changes: 1 addition & 1 deletion CommunityToolkit.App.Shared/Pages/Shell.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public sealed partial class Shell : Page
public Shell()
{
this.InitializeComponent();
#if WINAPPSDK
#if WINDOWS_WINAPPSDK
appTitleBar.Window = App.currentWindow;
#else
BackdropMaterial.SetApplyToRootOrPageBackground(this, true);
Expand Down
2 changes: 1 addition & 1 deletion CommunityToolkit.App.Shared/Pages/TabbedPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public sealed partial class TabbedPage : Page
public TabbedPage()
{
this.InitializeComponent();
#if WINAPPSDK
#if WINDOWS_WINAPPSDK
appTitleBar.Window = App.currentWindow;
#else
BackdropMaterial.SetApplyToRootOrPageBackground(this, true);
Expand Down

0 comments on commit 35189bd

Please sign in to comment.