diff --git a/src/ReactiveUI.Maui/ActivationForViewFetcher.cs b/src/ReactiveUI.Maui/ActivationForViewFetcher.cs
index b0185bc4c0..7b8285fa77 100644
--- a/src/ReactiveUI.Maui/ActivationForViewFetcher.cs
+++ b/src/ReactiveUI.Maui/ActivationForViewFetcher.cs
@@ -6,13 +6,15 @@
using System;
using System.Reactive.Linq;
using System.Reflection;
-#if HAS_WINUI
+#if WINUI_TARGET
using Microsoft.UI.Xaml;
using Windows.Foundation;
+#endif
+#if IS_WINUI
namespace ReactiveUI.WinUI;
#endif
-#if HAS_MAUI
+#if IS_MAUI
using System.ComponentModel;
using Microsoft.Maui.Controls;
@@ -27,13 +29,15 @@ public class ActivationForViewFetcher : IActivationForViewFetcher
{
///
public int GetAffinityForView(Type view) =>
-#if HAS_WINUI
- typeof(FrameworkElement).GetTypeInfo().IsAssignableFrom(view.GetTypeInfo())
+#if WINUI_TARGET
+#if IS_MAUI
+ typeof(Page).GetTypeInfo().IsAssignableFrom(view.GetTypeInfo()) ||
#endif
-#if HAS_MAUI
- typeof(Page).GetTypeInfo().IsAssignableFrom(view.GetTypeInfo()) ||
+ typeof(FrameworkElement).GetTypeInfo().IsAssignableFrom(view.GetTypeInfo())
+#else
+ typeof(Page).GetTypeInfo().IsAssignableFrom(view.GetTypeInfo()) ||
typeof(View).GetTypeInfo().IsAssignableFrom(view.GetTypeInfo()) ||
- typeof(Cell).GetTypeInfo().IsAssignableFrom(view.GetTypeInfo())
+ typeof(Cell).GetTypeInfo().IsAssignableFrom(view.GetTypeInfo())
#endif
? 10 : 0;
@@ -42,10 +46,12 @@ public IObservable GetActivationForView(IActivatableView view)
{
var activation =
GetActivationFor(view as ICanActivate) ??
-#if HAS_WINUI
+#if WINUI_TARGET
GetActivationFor(view as FrameworkElement) ??
+#if IS_MAUI
+ GetActivationFor(view as Page) ??
#endif
-#if HAS_MAUI
+#else
GetActivationFor(view as Page) ??
GetActivationFor(view as View) ??
GetActivationFor(view as Cell) ??
@@ -55,9 +61,10 @@ public IObservable GetActivationForView(IActivatableView view)
return activation.DistinctUntilChanged();
}
- private static IObservable? GetActivationFor(ICanActivate? canActivate) => canActivate?.Activated.Select(_ => true).Merge(canActivate.Deactivated.Select(_ => false));
+ private static IObservable? GetActivationFor(ICanActivate? canActivate) =>
+ canActivate?.Activated.Select(_ => true).Merge(canActivate.Deactivated.Select(_ => false));
-#if HAS_MAUI
+#if !WINUI_TARGET || (WINUI_TARGET && IS_MAUI)
private static IObservable? GetActivationFor(Page? page)
{
if (page is null)
@@ -85,7 +92,9 @@ public IObservable GetActivationForView(IActivatableView view)
return appearing.Merge(disappearing);
}
+#endif
+#if !WINUI_TARGET
private static IObservable? GetActivationFor(View? view)
{
if (view is null)
@@ -135,14 +144,12 @@ public IObservable GetActivationForView(IActivatableView view)
return appearing.Merge(disappearing);
}
-#endif
-
-#if HAS_WINUI
- private static IObservable GetActivationFor(FrameworkElement? view)
+#else
+ private static IObservable? GetActivationFor(FrameworkElement? view)
{
if (view is null)
{
- return Observable.Empty;
+ return null;
}
var viewLoaded = Observable.FromEvent, bool>(
diff --git a/src/ReactiveUI.Maui/Common/AutoDataTemplateBindingHook.cs b/src/ReactiveUI.Maui/Common/AutoDataTemplateBindingHook.cs
index 4f576813c3..db1995f2c3 100644
--- a/src/ReactiveUI.Maui/Common/AutoDataTemplateBindingHook.cs
+++ b/src/ReactiveUI.Maui/Common/AutoDataTemplateBindingHook.cs
@@ -3,7 +3,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.
-#if HAS_WINUI
+#if WINUI_TARGET
using System;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
diff --git a/src/ReactiveUI.Maui/Common/BooleanToVisibilityTypeConverter.cs b/src/ReactiveUI.Maui/Common/BooleanToVisibilityTypeConverter.cs
index c622b42298..f5d3c559cf 100644
--- a/src/ReactiveUI.Maui/Common/BooleanToVisibilityTypeConverter.cs
+++ b/src/ReactiveUI.Maui/Common/BooleanToVisibilityTypeConverter.cs
@@ -4,11 +4,10 @@
// See the LICENSE file in the project root for full license information.
using System;
-#if HAS_MAUI
-using Microsoft.Maui;
-#endif
-#if HAS_WINUI
+#if WINUI_TARGET
using Microsoft.UI.Xaml;
+#else
+using Microsoft.Maui;
#endif
namespace ReactiveUI
@@ -46,7 +45,7 @@ public bool TryConvert(object? from, Type toType, object? conversionHint, out ob
{
var fromAsBool = (hint & BooleanToVisibilityHint.Inverse) != 0 ? !fromBool : fromBool;
-#if !NETFX_CORE && !HAS_UNO && !HAS_WINUI
+#if !WINUI_TARGET
var notVisible = (hint & BooleanToVisibilityHint.UseHidden) != 0 ? Visibility.Hidden : Visibility.Collapsed;
#else
var notVisible = Visibility.Collapsed;
diff --git a/src/ReactiveUI.Maui/Common/ReactivePage.cs b/src/ReactiveUI.Maui/Common/ReactivePage.cs
index 7a257ff899..09d99a20e4 100644
--- a/src/ReactiveUI.Maui/Common/ReactivePage.cs
+++ b/src/ReactiveUI.Maui/Common/ReactivePage.cs
@@ -3,12 +3,11 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.
-#if HAS_MAUI
-using Microsoft.Maui.Controls;
-#endif
-#if HAS_WINUI
+#if WINUI_TARGET
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
+#else
+using Microsoft.Maui.Controls;
#endif
namespace ReactiveUI
@@ -81,7 +80,7 @@ class ReactivePage :
Page, IViewFor
where TViewModel : class
{
-#if HAS_WINUI
+#if WINUI_TARGET
///
/// The view model dependency property.
///
@@ -123,7 +122,7 @@ class ReactivePage :
set => ViewModel = (TViewModel?)value;
}
-#if HAS_MAUI
+#if !WINUI_TARGET
///
protected override void OnBindingContextChanged()
{
diff --git a/src/ReactiveUI.Maui/Common/ReactiveUserControl.cs b/src/ReactiveUI.Maui/Common/ReactiveUserControl.cs
index 0854ed3dc4..ae4d50fae6 100644
--- a/src/ReactiveUI.Maui/Common/ReactiveUserControl.cs
+++ b/src/ReactiveUI.Maui/Common/ReactiveUserControl.cs
@@ -3,7 +3,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.
-#if HAS_WINUI
+#if WINUI_TARGET
using System;
using System.Diagnostics.CodeAnalysis;
using Microsoft.UI.Xaml;
diff --git a/src/ReactiveUI.Maui/Common/RoutedViewHost.cs b/src/ReactiveUI.Maui/Common/RoutedViewHost.cs
index 7faf999d5c..1a2402f9d6 100644
--- a/src/ReactiveUI.Maui/Common/RoutedViewHost.cs
+++ b/src/ReactiveUI.Maui/Common/RoutedViewHost.cs
@@ -3,7 +3,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.
-#if HAS_WINUI
+#if WINUI_TARGET
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
diff --git a/src/ReactiveUI.Maui/Common/ViewModelViewHost.cs b/src/ReactiveUI.Maui/Common/ViewModelViewHost.cs
index 2d92165214..51fd43c0fa 100644
--- a/src/ReactiveUI.Maui/Common/ViewModelViewHost.cs
+++ b/src/ReactiveUI.Maui/Common/ViewModelViewHost.cs
@@ -3,7 +3,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.
-#if HAS_WINUI
+#if WINUI_TARGET
using System;
using System.Diagnostics.CodeAnalysis;
using System.Reactive;
diff --git a/src/ReactiveUI.Maui/ReactiveUI.Maui.csproj b/src/ReactiveUI.Maui/ReactiveUI.Maui.csproj
index be46c0c21b..3c23ea909a 100644
--- a/src/ReactiveUI.Maui/ReactiveUI.Maui.csproj
+++ b/src/ReactiveUI.Maui/ReactiveUI.Maui.csproj
@@ -6,13 +6,11 @@
Contains the ReactiveUI platform specific extensions for Microsoft Maui
mvvm;reactiveui;rx;reactive extensions;observable;LINQ;events;frp;maui;android;ios;mac;forms;net
true
+ IS_MAUI
- HAS_WINUI
-
-
- HAS_MAUI
+ $(DefineConstants);WINUI_TARGET;
@@ -26,8 +24,5 @@
-
-
-
diff --git a/src/ReactiveUI.Maui/Registrations.cs b/src/ReactiveUI.Maui/Registrations.cs
index 4e466557cc..1488c538da 100644
--- a/src/ReactiveUI.Maui/Registrations.cs
+++ b/src/ReactiveUI.Maui/Registrations.cs
@@ -5,13 +5,15 @@
using System;
-#if HAS_WINUI
+#if WINUI_TARGET
using System.Reactive.Concurrency;
using Splat;
+#endif
+#if IS_WINUI
namespace ReactiveUI.WinUI;
#endif
-#if HAS_MAUI
+#if IS_MAUI
namespace ReactiveUI.Maui;
#endif
@@ -37,7 +39,7 @@ public void Register(Action, Type> registerFunction)
registerFunction(() => new ActivationForViewFetcher(), typeof(IActivationForViewFetcher));
registerFunction(() => new BooleanToVisibilityTypeConverter(), typeof(IBindingTypeConverter));
-#if HAS_WINUI
+#if WINUI_TARGET
registerFunction(() => new PlatformOperations(), typeof(IPlatformOperations));
registerFunction(() => new DependencyObjectObservableForProperty(), typeof(ICreatesObservableForProperty));
registerFunction(() => new AutoDataTemplateBindingHook(), typeof(IPropertyBindingHook));
diff --git a/src/ReactiveUI.Maui/WinUI/DependencyObjectObservableForProperty.cs b/src/ReactiveUI.Maui/WinUI/DependencyObjectObservableForProperty.cs
index ba9c6af040..1a10f3f008 100644
--- a/src/ReactiveUI.Maui/WinUI/DependencyObjectObservableForProperty.cs
+++ b/src/ReactiveUI.Maui/WinUI/DependencyObjectObservableForProperty.cs
@@ -3,7 +3,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.
-#if HAS_WINUI
+#if WINUI_TARGET
using System;
using System.Globalization;
using System.Linq.Expressions;
diff --git a/src/ReactiveUI.Maui/WinUI/DispatcherQueueScheduler.cs b/src/ReactiveUI.Maui/WinUI/DispatcherQueueScheduler.cs
index acfde8ad79..805199c0f2 100644
--- a/src/ReactiveUI.Maui/WinUI/DispatcherQueueScheduler.cs
+++ b/src/ReactiveUI.Maui/WinUI/DispatcherQueueScheduler.cs
@@ -3,7 +3,7 @@
// See the LICENSE file in the project root for more information.
//
-#if HAS_WINUI
+#if WINUI_TARGET
using System.Reactive.Disposables;
using System.Threading;
using Microsoft.UI.Dispatching;
diff --git a/src/ReactiveUI.Maui/WinUI/TransitioningContentControl.Empty.cs b/src/ReactiveUI.Maui/WinUI/TransitioningContentControl.Empty.cs
index 7034159adb..0f0ef978b2 100644
--- a/src/ReactiveUI.Maui/WinUI/TransitioningContentControl.Empty.cs
+++ b/src/ReactiveUI.Maui/WinUI/TransitioningContentControl.Empty.cs
@@ -3,7 +3,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.
-#if HAS_WINUI
+#if WINUI_TARGET
using System.Diagnostics.CodeAnalysis;
using Microsoft.UI.Xaml.Controls;
diff --git a/src/ReactiveUI.WinUI/ReactiveUI.WinUI.csproj b/src/ReactiveUI.WinUI/ReactiveUI.WinUI.csproj
index a69bb5d727..292918ffbf 100644
--- a/src/ReactiveUI.WinUI/ReactiveUI.WinUI.csproj
+++ b/src/ReactiveUI.WinUI/ReactiveUI.WinUI.csproj
@@ -4,9 +4,9 @@
10.0.17763.0
Contains the ReactiveUI platform specific extensions for WinUI Desktop
ReactiveUI.WinUI.Desktop
- HAS_WINUI
mvvm;reactiveui;rx;reactive extensions;observable;LINQ;events;winui
true
+ IS_WINUI;WINUI_TARGET;