From dafe3a12b893dc032c001c1a1a45149c56f6093b Mon Sep 17 00:00:00 2001 From: Chris Pulman Date: Wed, 20 Aug 2025 22:32:43 +0100 Subject: [PATCH] Refactor WhenAnyValue usage to generic overloads Replaces lambda-based WhenAnyValue calls with explicit generic overloads across multiple platforms and components for improved AOT compatibility and clarity. Adds SuppressMessage attributes to registration classes to address trimming and AOT warnings where dynamic code or reflection is not always used. Also updates project file to suppress IL2026 and IL3050 warnings for AOT tests. --- src/ReactiveUI.AOTTests/ReactiveUI.AOT.Tests.csproj | 1 + src/ReactiveUI.AOTTests/StringBasedObservationTests.cs | 1 + src/ReactiveUI.AndroidX/Registrations.cs | 2 ++ src/ReactiveUI.Blazor/ReactiveComponentBase.cs | 2 +- src/ReactiveUI.Blazor/ReactiveInjectableComponentBase.cs | 2 +- src/ReactiveUI.Blazor/ReactiveLayoutComponentBase.cs | 2 +- src/ReactiveUI.Blazor/Registrations.cs | 2 ++ .../ViewModels/ChatRoomViewModel.cs | 2 +- src/ReactiveUI.Builder.WpfApp/ViewModels/LobbyViewModel.cs | 2 +- src/ReactiveUI.Builder.WpfApp/Views/ChatRoomView.xaml.cs | 3 ++- src/ReactiveUI.Builder.WpfApp/Views/LobbyView.xaml.cs | 2 +- src/ReactiveUI.Drawing/Registrations.cs | 2 ++ src/ReactiveUI.Maui/ActivationForViewFetcher.cs | 2 +- src/ReactiveUI.Maui/Common/ViewModelViewHost.cs | 2 +- src/ReactiveUI.Maui/Registrations.cs | 2 ++ src/ReactiveUI.Maui/ViewModelViewHost.cs | 2 +- src/ReactiveUI.Winforms/Registrations.cs | 2 ++ src/ReactiveUI.Winforms/ViewModelViewHost.cs | 6 +++--- src/ReactiveUI.Wpf/Common/ViewModelViewHost.cs | 2 +- src/ReactiveUI.Wpf/Registrations.cs | 2 ++ src/ReactiveUI/Platforms/android/PlatformRegistrations.cs | 2 ++ src/ReactiveUI/Platforms/mac/PlatformRegistrations.cs | 2 ++ src/ReactiveUI/Platforms/net/PlatformRegistrations.cs | 2 ++ .../Platforms/uikit-common/PlatformRegistrations.cs | 2 ++ src/ReactiveUI/Suspension/SuspensionHostExtensions.cs | 2 +- 25 files changed, 38 insertions(+), 15 deletions(-) diff --git a/src/ReactiveUI.AOTTests/ReactiveUI.AOT.Tests.csproj b/src/ReactiveUI.AOTTests/ReactiveUI.AOT.Tests.csproj index ccca577b52..b8b9f00fec 100644 --- a/src/ReactiveUI.AOTTests/ReactiveUI.AOT.Tests.csproj +++ b/src/ReactiveUI.AOTTests/ReactiveUI.AOT.Tests.csproj @@ -9,6 +9,7 @@ true true full + $(NoWarn);IL2026;IL3050; diff --git a/src/ReactiveUI.AOTTests/StringBasedObservationTests.cs b/src/ReactiveUI.AOTTests/StringBasedObservationTests.cs index 978e7f8ef5..00787e8119 100644 --- a/src/ReactiveUI.AOTTests/StringBasedObservationTests.cs +++ b/src/ReactiveUI.AOTTests/StringBasedObservationTests.cs @@ -3,6 +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. +using System.Diagnostics.CodeAnalysis; using System.Reactive.Concurrency; using System.Reactive.Linq; diff --git a/src/ReactiveUI.AndroidX/Registrations.cs b/src/ReactiveUI.AndroidX/Registrations.cs index 431e5904ea..ba4732f505 100644 --- a/src/ReactiveUI.AndroidX/Registrations.cs +++ b/src/ReactiveUI.AndroidX/Registrations.cs @@ -17,6 +17,8 @@ public class Registrations : IWantsToRegisterStuff #if NET6_0_OR_GREATER [RequiresDynamicCode("Register uses methods that require dynamic code generation")] [RequiresUnreferencedCode("Register uses methods that may require unreferenced code")] + [SuppressMessage("Trimming", "IL2046:'RequiresUnreferencedCodeAttribute' annotations must match across all interface implementations or overrides.", Justification = "Not all paths use reflection")] + [SuppressMessage("AOT", "IL3051:'RequiresDynamicCodeAttribute' annotations must match across all interface implementations or overrides.", Justification = "Not all paths use reflection")] #endif public void Register(Action, Type> registerFunction) { diff --git a/src/ReactiveUI.Blazor/ReactiveComponentBase.cs b/src/ReactiveUI.Blazor/ReactiveComponentBase.cs index a16fbf939d..95953cbf28 100644 --- a/src/ReactiveUI.Blazor/ReactiveComponentBase.cs +++ b/src/ReactiveUI.Blazor/ReactiveComponentBase.cs @@ -92,7 +92,7 @@ protected override void OnAfterRender(bool firstRender) { // The following subscriptions are here because if they are done in OnInitialized, they conflict with certain JavaScript frameworks. var viewModelChanged = - this.WhenAnyValue(x => x.ViewModel) + this.WhenAnyValue, T?>(nameof(ViewModel)) .WhereNotNull() .Publish() .RefCount(2); diff --git a/src/ReactiveUI.Blazor/ReactiveInjectableComponentBase.cs b/src/ReactiveUI.Blazor/ReactiveInjectableComponentBase.cs index 9ddd1d0555..7c6a0a7446 100644 --- a/src/ReactiveUI.Blazor/ReactiveInjectableComponentBase.cs +++ b/src/ReactiveUI.Blazor/ReactiveInjectableComponentBase.cs @@ -94,7 +94,7 @@ protected override void OnAfterRender(bool firstRender) { // The following subscriptions are here because if they are done in OnInitialized, they conflict with certain JavaScript frameworks. var viewModelChanged = - this.WhenAnyValue(x => x.ViewModel) + this.WhenAnyValue, T?>(nameof(ViewModel)) .WhereNotNull() .Publish() .RefCount(2); diff --git a/src/ReactiveUI.Blazor/ReactiveLayoutComponentBase.cs b/src/ReactiveUI.Blazor/ReactiveLayoutComponentBase.cs index 454391c659..42d9cb4b22 100644 --- a/src/ReactiveUI.Blazor/ReactiveLayoutComponentBase.cs +++ b/src/ReactiveUI.Blazor/ReactiveLayoutComponentBase.cs @@ -91,7 +91,7 @@ protected override void OnAfterRender(bool isFirstRender) if (isFirstRender) { var viewModelChanged = - this.WhenAnyValue(x => x.ViewModel) + this.WhenAnyValue, T?>(nameof(ViewModel)) .WhereNotNull() .Publish() .RefCount(2); diff --git a/src/ReactiveUI.Blazor/Registrations.cs b/src/ReactiveUI.Blazor/Registrations.cs index 719a8632cf..e66664fa2d 100644 --- a/src/ReactiveUI.Blazor/Registrations.cs +++ b/src/ReactiveUI.Blazor/Registrations.cs @@ -17,6 +17,8 @@ public class Registrations : IWantsToRegisterStuff #if NET6_0_OR_GREATER [RequiresDynamicCode("Register uses methods that require dynamic code generation")] [RequiresUnreferencedCode("Register uses methods that may require unreferenced code")] + [SuppressMessage("Trimming", "IL2046:'RequiresUnreferencedCodeAttribute' annotations must match across all interface implementations or overrides.", Justification = "Not all paths use reflection")] + [SuppressMessage("AOT", "IL3051:'RequiresDynamicCodeAttribute' annotations must match across all interface implementations or overrides.", Justification = "Not all paths use reflection")] #endif public void Register(Action, Type> registerFunction) { diff --git a/src/ReactiveUI.Builder.WpfApp/ViewModels/ChatRoomViewModel.cs b/src/ReactiveUI.Builder.WpfApp/ViewModels/ChatRoomViewModel.cs index bda432daae..539f2cd9ad 100644 --- a/src/ReactiveUI.Builder.WpfApp/ViewModels/ChatRoomViewModel.cs +++ b/src/ReactiveUI.Builder.WpfApp/ViewModels/ChatRoomViewModel.cs @@ -33,7 +33,7 @@ public ChatRoomViewModel(IScreen hostScreen, ChatRoom room, string user) _room = room; _user = user; - var canSend = this.WhenAnyValue(x => x.MessageText, txt => !string.IsNullOrWhiteSpace(txt)); + var canSend = this.WhenAnyValue(nameof(MessageText), txt => !string.IsNullOrWhiteSpace(txt)); SendMessage = ReactiveCommand.Create(SendMessageImpl, canSend); // Observe new incoming messages via MessageBus using the room name as the contract across instances diff --git a/src/ReactiveUI.Builder.WpfApp/ViewModels/LobbyViewModel.cs b/src/ReactiveUI.Builder.WpfApp/ViewModels/LobbyViewModel.cs index e0ff449653..ba1bbef9d2 100644 --- a/src/ReactiveUI.Builder.WpfApp/ViewModels/LobbyViewModel.cs +++ b/src/ReactiveUI.Builder.WpfApp/ViewModels/LobbyViewModel.cs @@ -29,7 +29,7 @@ public LobbyViewModel(IScreen hostScreen) HostScreen = hostScreen; UrlPathSegment = "lobby"; - var canCreate = this.WhenAnyValue(x => x.RoomName, rn => !string.IsNullOrWhiteSpace(rn)); + var canCreate = this.WhenAnyValue(nameof(RoomName), rn => !string.IsNullOrWhiteSpace(rn)); CreateRoom = ReactiveCommand.Create(CreateRoomImpl, canCreate); DeleteRoom = ReactiveCommand.Create(DeleteRoomImpl); diff --git a/src/ReactiveUI.Builder.WpfApp/Views/ChatRoomView.xaml.cs b/src/ReactiveUI.Builder.WpfApp/Views/ChatRoomView.xaml.cs index 1b585b33b8..dd4b42d551 100644 --- a/src/ReactiveUI.Builder.WpfApp/Views/ChatRoomView.xaml.cs +++ b/src/ReactiveUI.Builder.WpfApp/Views/ChatRoomView.xaml.cs @@ -5,6 +5,7 @@ using System.Reactive.Disposables; using System.Windows; +using ReactiveUI.Builder.WpfApp.ViewModels; namespace ReactiveUI.Builder.WpfApp.Views; @@ -28,7 +29,7 @@ public ChatRoomView() this.WhenActivated(d => { // Map ViewModel to DataContext for XAML bindings like {Binding RoomName} - this.WhenAnyValue(v => v.ViewModel).BindTo(this, v => v.DataContext).DisposeWith(d); + this.WhenAnyValue(nameof(ViewModel)).BindTo(this, v => v.DataContext).DisposeWith(d); this.Bind(ViewModel, vm => vm.MessageText, v => v.MessageBox.Text).DisposeWith(d); this.BindCommand(ViewModel, vm => vm.SendMessage, v => v.SendButton).DisposeWith(d); diff --git a/src/ReactiveUI.Builder.WpfApp/Views/LobbyView.xaml.cs b/src/ReactiveUI.Builder.WpfApp/Views/LobbyView.xaml.cs index 9d99de044b..c1af1208fe 100644 --- a/src/ReactiveUI.Builder.WpfApp/Views/LobbyView.xaml.cs +++ b/src/ReactiveUI.Builder.WpfApp/Views/LobbyView.xaml.cs @@ -43,7 +43,7 @@ public LobbyView() }).DisposeWith(d); // Delete selected room via Delete button only - var selectedRoomStream = this.WhenAnyValue(x => x.RoomsList.SelectedItem) + var selectedRoomStream = this.WhenAnyValue(nameof(RoomsList.SelectedItem)) .Select(x => x as ChatRoom) .WhereNotNull(); this.BindCommand(ViewModel, vm => vm.DeleteRoom, v => v.DeleteRoomButton, selectedRoomStream) diff --git a/src/ReactiveUI.Drawing/Registrations.cs b/src/ReactiveUI.Drawing/Registrations.cs index 859adbe1f9..15048f0112 100644 --- a/src/ReactiveUI.Drawing/Registrations.cs +++ b/src/ReactiveUI.Drawing/Registrations.cs @@ -17,6 +17,8 @@ public class Registrations : IWantsToRegisterStuff #if NET6_0_OR_GREATER [RequiresDynamicCode("Register uses methods that require dynamic code generation")] [RequiresUnreferencedCode("Register uses methods that may require unreferenced code")] + [SuppressMessage("Trimming", "IL2046:'RequiresUnreferencedCodeAttribute' annotations must match across all interface implementations or overrides.", Justification = "Not all paths use reflection")] + [SuppressMessage("AOT", "IL3051:'RequiresDynamicCodeAttribute' annotations must match across all interface implementations or overrides.", Justification = "Not all paths use reflection")] #endif public void Register(Action, Type> registerFunction) { diff --git a/src/ReactiveUI.Maui/ActivationForViewFetcher.cs b/src/ReactiveUI.Maui/ActivationForViewFetcher.cs index 109f47bb1d..d510dc70fe 100644 --- a/src/ReactiveUI.Maui/ActivationForViewFetcher.cs +++ b/src/ReactiveUI.Maui/ActivationForViewFetcher.cs @@ -177,7 +177,7 @@ public IObservable GetActivationForView(IActivatableView view) return viewLoaded .Merge(viewUnloaded) - .Select(b => b ? view.WhenAnyValue(x => x.IsHitTestVisible).SkipWhile(x => !x) : Observables.False) + .Select(b => b ? view.WhenAnyValue(nameof(view.IsHitTestVisible)).SkipWhile(x => !x) : Observables.False) .Switch() .DistinctUntilChanged(); } diff --git a/src/ReactiveUI.Maui/Common/ViewModelViewHost.cs b/src/ReactiveUI.Maui/Common/ViewModelViewHost.cs index 131ceaa5a1..23c718b6c0 100644 --- a/src/ReactiveUI.Maui/Common/ViewModelViewHost.cs +++ b/src/ReactiveUI.Maui/Common/ViewModelViewHost.cs @@ -79,7 +79,7 @@ public ViewModelViewHost() .DistinctUntilChanged(); var contractChanged = this.WhenAnyObservable(x => x.ViewContractObservable).Do(x => _viewContract = x).StartWith(ViewContract); - var viewModelChanged = this.WhenAnyValue(x => x.ViewModel).StartWith(ViewModel); + var viewModelChanged = this.WhenAnyValue(nameof(ViewModel)).StartWith(ViewModel); var vmAndContract = contractChanged .CombineLatest(viewModelChanged, (contract, vm) => (ViewModel: vm, Contract: contract)); diff --git a/src/ReactiveUI.Maui/Registrations.cs b/src/ReactiveUI.Maui/Registrations.cs index e0dcb1bf4f..0454e0b1d3 100644 --- a/src/ReactiveUI.Maui/Registrations.cs +++ b/src/ReactiveUI.Maui/Registrations.cs @@ -25,6 +25,8 @@ public class Registrations : IWantsToRegisterStuff #if NET6_0_OR_GREATER [RequiresDynamicCode("Register uses methods that require dynamic code generation")] [RequiresUnreferencedCode("Register uses methods that may require unreferenced code")] + [SuppressMessage("Trimming", "IL2046:'RequiresUnreferencedCodeAttribute' annotations must match across all interface implementations or overrides.", Justification = "Not all paths use reflection")] + [SuppressMessage("AOT", "IL3051:'RequiresDynamicCodeAttribute' annotations must match across all interface implementations or overrides.", Justification = "Not all paths use reflection")] #endif public void Register(Action, Type> registerFunction) { diff --git a/src/ReactiveUI.Maui/ViewModelViewHost.cs b/src/ReactiveUI.Maui/ViewModelViewHost.cs index ef34db1ebb..90817a54d8 100644 --- a/src/ReactiveUI.Maui/ViewModelViewHost.cs +++ b/src/ReactiveUI.Maui/ViewModelViewHost.cs @@ -69,7 +69,7 @@ public ViewModelViewHost() ViewContractObservable = Observable.Default; - var vmAndContract = this.WhenAnyValue(x => x.ViewModel).CombineLatest( + var vmAndContract = this.WhenAnyValue(nameof(ViewModel)).CombineLatest( this.WhenAnyObservable(x => x.ViewContractObservable), (vm, contract) => new { ViewModel = vm, Contract = contract, }); diff --git a/src/ReactiveUI.Winforms/Registrations.cs b/src/ReactiveUI.Winforms/Registrations.cs index 15d53d2f6f..85664f541e 100644 --- a/src/ReactiveUI.Winforms/Registrations.cs +++ b/src/ReactiveUI.Winforms/Registrations.cs @@ -15,6 +15,8 @@ public class Registrations : IWantsToRegisterStuff #if NET6_0_OR_GREATER [RequiresDynamicCode("Register uses methods that require dynamic code generation")] [RequiresUnreferencedCode("Register uses methods that may require unreferenced code")] + [SuppressMessage("Trimming", "IL2046:'RequiresUnreferencedCodeAttribute' annotations must match across all interface implementations or overrides.", Justification = "Not all paths use reflection")] + [SuppressMessage("AOT", "IL3051:'RequiresDynamicCodeAttribute' annotations must match across all interface implementations or overrides.", Justification = "Not all paths use reflection")] #endif public void Register(Action, Type> registerFunction) { diff --git a/src/ReactiveUI.Winforms/ViewModelViewHost.cs b/src/ReactiveUI.Winforms/ViewModelViewHost.cs index e889658ba3..dcafb619c5 100644 --- a/src/ReactiveUI.Winforms/ViewModelViewHost.cs +++ b/src/ReactiveUI.Winforms/ViewModelViewHost.cs @@ -153,7 +153,7 @@ protected override void Dispose(bool disposing) private IEnumerable SetupBindings() { var viewChanges = - this.WhenAnyValue(x => x!.Content) + this.WhenAnyValue(nameof(Content)) .WhereNotNull() .OfType() .Subscribe(x => @@ -175,7 +175,7 @@ private IEnumerable SetupBindings() yield return viewChanges!; - yield return this.WhenAnyValue(x => x.DefaultContent).Subscribe(x => + yield return this.WhenAnyValue(nameof(DefaultContent)).Subscribe(x => { if (x is not null) { @@ -186,7 +186,7 @@ private IEnumerable SetupBindings() ViewContractObservable = Observable.Return(string.Empty); var vmAndContract = - this.WhenAnyValue(x => x.ViewModel) + this.WhenAnyValue(nameof(ViewModel)) .CombineLatest( this.WhenAnyObservable(x => x.ViewContractObservable!), (vm, contract) => new { ViewModel = vm, Contract = contract }); diff --git a/src/ReactiveUI.Wpf/Common/ViewModelViewHost.cs b/src/ReactiveUI.Wpf/Common/ViewModelViewHost.cs index fd336fe49a..280d199bfe 100644 --- a/src/ReactiveUI.Wpf/Common/ViewModelViewHost.cs +++ b/src/ReactiveUI.Wpf/Common/ViewModelViewHost.cs @@ -106,7 +106,7 @@ public ViewModelViewHost() .DistinctUntilChanged(); var contractChanged = this.WhenAnyObservable(x => x.ViewContractObservable).Do(x => _viewContract = x).StartWith(ViewContract); - var viewModelChanged = this.WhenAnyValue(x => x.ViewModel).StartWith(ViewModel); + var viewModelChanged = this.WhenAnyValue(nameof(ViewModel)).StartWith(ViewModel); var vmAndContract = contractChanged .CombineLatest(viewModelChanged, (contract, vm) => (ViewModel: vm, Contract: contract)); diff --git a/src/ReactiveUI.Wpf/Registrations.cs b/src/ReactiveUI.Wpf/Registrations.cs index 5e873428e8..b443d980d5 100644 --- a/src/ReactiveUI.Wpf/Registrations.cs +++ b/src/ReactiveUI.Wpf/Registrations.cs @@ -14,6 +14,8 @@ public class Registrations : IWantsToRegisterStuff #if NET6_0_OR_GREATER [RequiresDynamicCode("Register uses methods that require dynamic code generation")] [RequiresUnreferencedCode("Register uses methods that may require unreferenced code")] + [SuppressMessage("Trimming", "IL2046:'RequiresUnreferencedCodeAttribute' annotations must match across all interface implementations or overrides.", Justification = "Not all paths use reflection")] + [SuppressMessage("AOT", "IL3051:'RequiresDynamicCodeAttribute' annotations must match across all interface implementations or overrides.", Justification = "Not all paths use reflection")] #endif public void Register(Action, Type> registerFunction) { diff --git a/src/ReactiveUI/Platforms/android/PlatformRegistrations.cs b/src/ReactiveUI/Platforms/android/PlatformRegistrations.cs index dae10d11f2..7ad50d6496 100644 --- a/src/ReactiveUI/Platforms/android/PlatformRegistrations.cs +++ b/src/ReactiveUI/Platforms/android/PlatformRegistrations.cs @@ -15,6 +15,8 @@ public class PlatformRegistrations : IWantsToRegisterStuff #if NET6_0_OR_GREATER [RequiresDynamicCode("Platform registration uses ComponentModelTypeConverter and RxApp which require dynamic code generation")] [RequiresUnreferencedCode("Platform registration uses ComponentModelTypeConverter and RxApp which may require unreferenced code")] + [SuppressMessage("Trimming", "IL2046:'RequiresUnreferencedCodeAttribute' annotations must match across all interface implementations or overrides.", Justification = "Not all paths use reflection")] + [SuppressMessage("AOT", "IL3051:'RequiresDynamicCodeAttribute' annotations must match across all interface implementations or overrides.", Justification = "Not all paths use reflection")] #endif public void Register(Action, Type> registerFunction) // TODO: Create Test { diff --git a/src/ReactiveUI/Platforms/mac/PlatformRegistrations.cs b/src/ReactiveUI/Platforms/mac/PlatformRegistrations.cs index 70c5fdfe85..2e72433a7b 100644 --- a/src/ReactiveUI/Platforms/mac/PlatformRegistrations.cs +++ b/src/ReactiveUI/Platforms/mac/PlatformRegistrations.cs @@ -15,6 +15,8 @@ public class PlatformRegistrations : IWantsToRegisterStuff #if NET6_0_OR_GREATER [RequiresDynamicCode("Platform registration uses ComponentModelTypeConverter and RxApp which require dynamic code generation")] [RequiresUnreferencedCode("Platform registration uses ComponentModelTypeConverter and RxApp which may require unreferenced code")] + [SuppressMessage("Trimming", "IL2046:'RequiresUnreferencedCodeAttribute' annotations must match across all interface implementations or overrides.", Justification = "Not all paths use reflection")] + [SuppressMessage("AOT", "IL3051:'RequiresDynamicCodeAttribute' annotations must match across all interface implementations or overrides.", Justification = "Not all paths use reflection")] #endif public void Register(Action, Type> registerFunction) { diff --git a/src/ReactiveUI/Platforms/net/PlatformRegistrations.cs b/src/ReactiveUI/Platforms/net/PlatformRegistrations.cs index 2d54d35056..cee5e7073b 100644 --- a/src/ReactiveUI/Platforms/net/PlatformRegistrations.cs +++ b/src/ReactiveUI/Platforms/net/PlatformRegistrations.cs @@ -16,6 +16,8 @@ public class PlatformRegistrations : IWantsToRegisterStuff #if NET6_0_OR_GREATER [RequiresDynamicCode("Platform registration uses ComponentModelTypeConverter and RxApp which require dynamic code generation")] [RequiresUnreferencedCode("Platform registration uses ComponentModelTypeConverter and RxApp which may require unreferenced code")] + [SuppressMessage("Trimming", "IL2046:'RequiresUnreferencedCodeAttribute' annotations must match across all interface implementations or overrides.", Justification = "Not all paths use reflection")] + [SuppressMessage("AOT", "IL3051:'RequiresDynamicCodeAttribute' annotations must match across all interface implementations or overrides.", Justification = "Not all paths use reflection")] #endif public void Register(Action, Type> registerFunction) { diff --git a/src/ReactiveUI/Platforms/uikit-common/PlatformRegistrations.cs b/src/ReactiveUI/Platforms/uikit-common/PlatformRegistrations.cs index 5f986d4cbc..d9e1448d96 100644 --- a/src/ReactiveUI/Platforms/uikit-common/PlatformRegistrations.cs +++ b/src/ReactiveUI/Platforms/uikit-common/PlatformRegistrations.cs @@ -15,6 +15,8 @@ public class PlatformRegistrations : IWantsToRegisterStuff #if NET6_0_OR_GREATER [RequiresDynamicCode("Platform registration uses ComponentModelTypeConverter and RxApp which require dynamic code generation")] [RequiresUnreferencedCode("Platform registration uses ComponentModelTypeConverter and RxApp which may require unreferenced code")] + [SuppressMessage("Trimming", "IL2046:'RequiresUnreferencedCodeAttribute' annotations must match across all interface implementations or overrides.", Justification = "Not all paths use reflection")] + [SuppressMessage("AOT", "IL3051:'RequiresDynamicCodeAttribute' annotations must match across all interface implementations or overrides.", Justification = "Not all paths use reflection")] #endif public void Register(Action, Type> registerFunction) { diff --git a/src/ReactiveUI/Suspension/SuspensionHostExtensions.cs b/src/ReactiveUI/Suspension/SuspensionHostExtensions.cs index e72f8bd975..cd07e33073 100644 --- a/src/ReactiveUI/Suspension/SuspensionHostExtensions.cs +++ b/src/ReactiveUI/Suspension/SuspensionHostExtensions.cs @@ -50,7 +50,7 @@ public static IObservable ObserveAppState(this ISuspensionHost item) { item.ArgumentNullExceptionThrowIfNull(nameof(item)); - return item.WhenAny(suspensionHost => suspensionHost.AppState, observedChange => observedChange.Value) + return item.WhenAny(nameof(item.AppState), observedChange => observedChange.Value) .WhereNotNull() .Cast(); }