diff --git a/src/Directory.Packages.props b/src/Directory.Packages.props index c2542f28fa..0cb6e71de3 100644 --- a/src/Directory.Packages.props +++ b/src/Directory.Packages.props @@ -4,7 +4,7 @@ true - 16.0.1 + 16.1.1 1.13.1.4 2.8.4.1 @@ -16,7 +16,8 @@ - + + diff --git a/src/ReactiveUI.AndroidX/Builder/AndroidXReactiveUIBuilderExtensions.cs b/src/ReactiveUI.AndroidX/Builder/AndroidXReactiveUIBuilderExtensions.cs index 4dbcb6aaa8..888d25e65c 100644 --- a/src/ReactiveUI.AndroidX/Builder/AndroidXReactiveUIBuilderExtensions.cs +++ b/src/ReactiveUI.AndroidX/Builder/AndroidXReactiveUIBuilderExtensions.cs @@ -25,7 +25,7 @@ public static class AndroidXReactiveUIBuilderExtensions /// /// The builder instance. /// The builder instance for chaining. - public static ReactiveUIBuilder WithAndroidX(this ReactiveUIBuilder builder) + public static IReactiveUIBuilder WithAndroidX(this IReactiveUIBuilder builder) { if (builder is null) { @@ -42,7 +42,7 @@ public static ReactiveUIBuilder WithAndroidX(this ReactiveUIBuilder builder) /// /// The builder. /// The builder instance for chaining. - public static ReactiveUIBuilder WithAndroidXScheduler(this ReactiveUIBuilder builder) + public static IReactiveUIBuilder WithAndroidXScheduler(this IReactiveUIBuilder builder) { if (builder is null) { diff --git a/src/ReactiveUI.AndroidX/ReactiveUI.AndroidX.csproj b/src/ReactiveUI.AndroidX/ReactiveUI.AndroidX.csproj index 553336a9d8..4b4ab206b6 100644 --- a/src/ReactiveUI.AndroidX/ReactiveUI.AndroidX.csproj +++ b/src/ReactiveUI.AndroidX/ReactiveUI.AndroidX.csproj @@ -12,6 +12,7 @@ + diff --git a/src/ReactiveUI.AndroidX/Registrations.cs b/src/ReactiveUI.AndroidX/Registrations.cs index ba4732f505..c5cc0c6c8a 100644 --- a/src/ReactiveUI.AndroidX/Registrations.cs +++ b/src/ReactiveUI.AndroidX/Registrations.cs @@ -14,12 +14,6 @@ namespace ReactiveUI.AndroidX; 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) { #if NET6_0_OR_GREATER diff --git a/src/ReactiveUI.Blazor/Builder/BlazorReactiveUIBuilderExtensions.cs b/src/ReactiveUI.Blazor/Builder/BlazorReactiveUIBuilderExtensions.cs index 7e417c9ec8..671b3790ed 100644 --- a/src/ReactiveUI.Blazor/Builder/BlazorReactiveUIBuilderExtensions.cs +++ b/src/ReactiveUI.Blazor/Builder/BlazorReactiveUIBuilderExtensions.cs @@ -23,7 +23,7 @@ public static class BlazorReactiveUIBuilderExtensions /// /// The builder instance. /// The builder instance for chaining. - public static ReactiveUIBuilder WithBlazor(this ReactiveUIBuilder builder) + public static IReactiveUIBuilder WithBlazor(this IReactiveUIBuilder builder) { if (builder is null) { @@ -40,7 +40,7 @@ public static ReactiveUIBuilder WithBlazor(this ReactiveUIBuilder builder) /// /// The builder. /// The builder instance for chaining. - public static ReactiveUIBuilder WithBlazorScheduler(this ReactiveUIBuilder builder) + public static IReactiveUIBuilder WithBlazorScheduler(this IReactiveUIBuilder builder) { if (builder is null) { diff --git a/src/ReactiveUI.Blazor/ReactiveUI.Blazor.csproj b/src/ReactiveUI.Blazor/ReactiveUI.Blazor.csproj index fa5fbf69d5..caf115df05 100644 --- a/src/ReactiveUI.Blazor/ReactiveUI.Blazor.csproj +++ b/src/ReactiveUI.Blazor/ReactiveUI.Blazor.csproj @@ -8,6 +8,7 @@ + diff --git a/src/ReactiveUI.Blend/ReactiveUI.Blend.csproj b/src/ReactiveUI.Blend/ReactiveUI.Blend.csproj index f4072508d7..e1f61abf68 100644 --- a/src/ReactiveUI.Blend/ReactiveUI.Blend.csproj +++ b/src/ReactiveUI.Blend/ReactiveUI.Blend.csproj @@ -18,6 +18,7 @@ + diff --git a/src/ReactiveUI.Drawing/Builder/ReactiveUIBuilderDrawingExtensions.cs b/src/ReactiveUI.Drawing/Builder/ReactiveUIBuilderDrawingExtensions.cs index 36fa5df418..6d5f9432d9 100644 --- a/src/ReactiveUI.Drawing/Builder/ReactiveUIBuilderDrawingExtensions.cs +++ b/src/ReactiveUI.Drawing/Builder/ReactiveUIBuilderDrawingExtensions.cs @@ -15,7 +15,7 @@ public static class ReactiveUIBuilderDrawingExtensions /// /// The builder instance. /// The builder instance for method chaining. - public static ReactiveUIBuilder WithDrawing(this ReactiveUIBuilder builder) + public static IReactiveUIBuilder WithDrawing(this IReactiveUIBuilder builder) { if (builder is null) { diff --git a/src/ReactiveUI.Drawing/ReactiveUI.Drawing.csproj b/src/ReactiveUI.Drawing/ReactiveUI.Drawing.csproj index d493a24d9b..416fa50350 100644 --- a/src/ReactiveUI.Drawing/ReactiveUI.Drawing.csproj +++ b/src/ReactiveUI.Drawing/ReactiveUI.Drawing.csproj @@ -24,5 +24,6 @@ + \ No newline at end of file diff --git a/src/ReactiveUI.Maui/Builder/MauiReactiveUIBuilderExtensions.cs b/src/ReactiveUI.Maui/Builder/MauiReactiveUIBuilderExtensions.cs index 7db88f5631..329c6a10f0 100644 --- a/src/ReactiveUI.Maui/Builder/MauiReactiveUIBuilderExtensions.cs +++ b/src/ReactiveUI.Maui/Builder/MauiReactiveUIBuilderExtensions.cs @@ -26,7 +26,7 @@ public static class MauiReactiveUIBuilderExtensions /// The builder instance. /// The MAUI dispatcher to use for the main thread scheduler. /// The builder instance for chaining. - public static ReactiveUIBuilder WithMaui(this ReactiveUIBuilder builder, IDispatcher? dispatcher = null) + public static IReactiveUIBuilder WithMaui(this IReactiveUIBuilder builder, IDispatcher? dispatcher = null) { if (builder is null) { @@ -43,7 +43,7 @@ public static ReactiveUIBuilder WithMaui(this ReactiveUIBuilder builder, IDispat /// /// The builder. /// The builder instance for chaining. - public static ReactiveUIBuilder WithMauiScheduler(this ReactiveUIBuilder builder) + public static IReactiveUIBuilder WithMauiScheduler(this IReactiveUIBuilder builder) { if (builder is null) { diff --git a/src/ReactiveUI.Maui/Common/ReactivePage.cs b/src/ReactiveUI.Maui/Common/ReactivePage.cs index 5254d622ca..2dfda8d0d5 100644 --- a/src/ReactiveUI.Maui/Common/ReactivePage.cs +++ b/src/ReactiveUI.Maui/Common/ReactivePage.cs @@ -83,6 +83,7 @@ namespace ReactiveUI; [RequiresDynamicCode("ReactivePage uses methods that require dynamic code generation")] [RequiresUnreferencedCode("ReactivePage uses methods that may require unreferenced code")] #endif +[SuppressMessage("WinRT", "CsWinRT1029:Types used in signatures should be WinRT types", Justification = "This is a netstandard2.0 library")] public partial class ReactivePage : Page, IViewFor where TViewModel : class diff --git a/src/ReactiveUI.Maui/Common/ReactiveUserControl.cs b/src/ReactiveUI.Maui/Common/ReactiveUserControl.cs index 03a887e7fc..2ffdd8965f 100644 --- a/src/ReactiveUI.Maui/Common/ReactiveUserControl.cs +++ b/src/ReactiveUI.Maui/Common/ReactiveUserControl.cs @@ -76,6 +76,7 @@ namespace ReactiveUI; /// /// The type of the view model backing the view. /// +[SuppressMessage("WinRT", "CsWinRT1029:Types used in signatures should be WinRT types", Justification = "This is a netstandard2.0 library")] public partial class ReactiveUserControl : UserControl, IViewFor where TViewModel : class diff --git a/src/ReactiveUI.Maui/ReactiveUI.Maui.csproj b/src/ReactiveUI.Maui/ReactiveUI.Maui.csproj index 144d1e5241..76bb6cc9fc 100644 --- a/src/ReactiveUI.Maui/ReactiveUI.Maui.csproj +++ b/src/ReactiveUI.Maui/ReactiveUI.Maui.csproj @@ -21,11 +21,12 @@ - + + diff --git a/src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.DotNet8_0.verified.txt b/src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.DotNet8_0.verified.txt index 4badcd8c11..b5c07bd246 100644 --- a/src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.DotNet8_0.verified.txt +++ b/src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.DotNet8_0.verified.txt @@ -85,18 +85,22 @@ namespace ReactiveUI public override System.IObservable> Execute(TParam parameter) { } public override System.IDisposable Subscribe(System.IObserver> observer) { } } - [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("CommandBinder uses RxApp initialization which requires dynamic code generation")] - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("CommandBinder uses RxApp initialization which may require unreferenced code")] public static class CommandBinder { + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("This method uses reflection to access properties by name.")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("This method uses reflection to access properties by name.")] public static ReactiveUI.IReactiveBinding BindCommand(this TView view, TViewModel? viewModel, System.Linq.Expressions.Expression> propertyName, System.Linq.Expressions.Expression> controlName, string? toEvent = null) where TView : class, ReactiveUI.IViewFor where TViewModel : class where TProp : System.Windows.Input.ICommand { } + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("This method uses reflection to access properties by name.")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("This method uses reflection to access properties by name.")] public static ReactiveUI.IReactiveBinding BindCommand(this TView view, TViewModel? viewModel, System.Linq.Expressions.Expression> propertyName, System.Linq.Expressions.Expression> controlName, System.IObservable withParameter, string? toEvent = null) where TView : class, ReactiveUI.IViewFor where TViewModel : class where TProp : System.Windows.Input.ICommand { } + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("This method uses reflection to access properties by name.")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("This method uses reflection to access properties by name.")] public static ReactiveUI.IReactiveBinding BindCommand(this TView view, TViewModel? viewModel, System.Linq.Expressions.Expression> propertyName, System.Linq.Expressions.Expression> controlName, System.Linq.Expressions.Expression> withParameter, string? toEvent = null) where TView : class, ReactiveUI.IViewFor where TViewModel : class @@ -105,16 +109,14 @@ namespace ReactiveUI public class CommandBinderImplementation : Splat.IEnableLogger { public CommandBinderImplementation() { } - [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("BindCommand uses ViewModelWhenAnyValue which requires dynamic code generation")] - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("BindCommand uses ViewModelWhenAnyValue which may reference members that could be " + - "trimmed")] + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("This method uses reflection to access properties by name.")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("This method uses reflection to access properties by name.")] public ReactiveUI.IReactiveBinding BindCommand(TViewModel? viewModel, TView view, System.Linq.Expressions.Expression> vmProperty, System.Linq.Expressions.Expression> controlProperty, System.IObservable withParameter, string? toEvent = null) where TView : class, ReactiveUI.IViewFor where TViewModel : class where TProp : System.Windows.Input.ICommand { } - [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("BindCommand uses ViewModelWhenAnyValue which requires dynamic code generation")] - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("BindCommand uses ViewModelWhenAnyValue which may reference members that could be " + - "trimmed")] + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("This method uses reflection to access properties by name.")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("This method uses reflection to access properties by name.")] public ReactiveUI.IReactiveBinding BindCommand(TViewModel? viewModel, TView view, System.Linq.Expressions.Expression> vmProperty, System.Linq.Expressions.Expression> controlProperty, System.Linq.Expressions.Expression> withParameter, string? toEvent = null) where TView : class, ReactiveUI.IViewFor where TViewModel : class @@ -138,8 +140,8 @@ namespace ReactiveUI public class CreatesCommandBindingViaCommandParameter : ReactiveUI.ICreatesCommandBinding { public CreatesCommandBindingViaCommandParameter() { } - [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Property access requires dynamic code generation")] - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Property access may reference members that could be trimmed")] + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("BindCommandToObject uses methods that require dynamic code generation")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("BindCommandToObject uses methods that may require unreferenced code")] public System.IDisposable? BindCommandToObject(System.Windows.Input.ICommand? command, object? target, System.IObservable commandParameter) { } [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("BindCommandToObject uses methods that require dynamic code generation")] [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("BindCommandToObject uses methods that may require unreferenced code")] @@ -183,8 +185,8 @@ namespace ReactiveUI } public static class DependencyResolverMixins { - [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("The method uses reflection and will not work in AOT environments.")] - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The method uses reflection and will not work in AOT environments.")] + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("InitializeReactiveUI uses reflection to locate types which may be trimmed.")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("InitializeReactiveUI uses reflection to locate types which may be trimmed.")] public static void InitializeReactiveUI(this Splat.IMutableDependencyResolver resolver, params ReactiveUI.RegistrationNamespace[] registrationNamespaces) { } [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("RegisterViewsForViewModels scans the provided assembly and creates instances via " + "reflection; this is not compatible with AOT.")] @@ -434,34 +436,14 @@ namespace ReactiveUI } public static class IReactiveObjectExtensions { - [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Extension state uses RxApp.DefaultExceptionHandler which requires dynamic code ge" + - "neration")] - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Extension state uses RxApp.DefaultExceptionHandler which may require unreferenced" + - " code")] public static TRet RaiseAndSetIfChanged(this TObj reactiveObject, ref TRet backingField, TRet newValue, [System.Runtime.CompilerServices.CallerMemberName] string? propertyName = null) where TObj : ReactiveUI.IReactiveObject { } - [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Extension state uses RxApp.DefaultExceptionHandler which requires dynamic code ge" + - "neration")] - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Extension state uses RxApp.DefaultExceptionHandler which may require unreferenced" + - " code")] public static void RaisePropertyChanged(this TSender reactiveObject, [System.Runtime.CompilerServices.CallerMemberName] string? propertyName = null) where TSender : ReactiveUI.IReactiveObject { } - [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Extension state uses RxApp.DefaultExceptionHandler which requires dynamic code ge" + - "neration")] - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Extension state uses RxApp.DefaultExceptionHandler which may require unreferenced" + - " code")] public static void RaisePropertyChanging(this TSender reactiveObject, [System.Runtime.CompilerServices.CallerMemberName] string? propertyName = null) where TSender : ReactiveUI.IReactiveObject { } - [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Extension state uses RxApp.DefaultExceptionHandler which requires dynamic code ge" + - "neration")] - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Extension state uses RxApp.DefaultExceptionHandler which may require unreferenced" + - " code")] public static void SubscribePropertyChangedEvents(this TSender reactiveObject) where TSender : ReactiveUI.IReactiveObject { } - [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Extension state uses RxApp.DefaultExceptionHandler which requires dynamic code ge" + - "neration")] - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Extension state uses RxApp.DefaultExceptionHandler which may require unreferenced" + - " code")] public static void SubscribePropertyChangingEvents(this TSender reactiveObject) where TSender : ReactiveUI.IReactiveObject { } } @@ -548,24 +530,20 @@ namespace ReactiveUI public int GetAffinityForObjects(System.Type fromType, System.Type toType) { } public bool TryConvert(object? from, System.Type toType, object? conversionHint, out object result) { } } - [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("InteractionBinderImplementation uses reflection and expression evaluation which r" + - "equire dynamic code generation")] - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("InteractionBinderImplementation uses reflection and expression evaluation which m" + - "ay require unreferenced code")] public class InteractionBinderImplementation : ReactiveUI.IInteractionBinderImplementation, Splat.IEnableLogger { public InteractionBinderImplementation() { } + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("The handler may use serialization which requires dynamic code generation")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The handler may use serialization which may require unreferenced code")] public System.IDisposable BindInteraction(TViewModel? viewModel, TView view, System.Linq.Expressions.Expression>> propertyName, System.Func, System.Threading.Tasks.Task> handler) where TViewModel : class where TView : class, ReactiveUI.IViewFor { } + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("The handler may use serialization which requires dynamic code generation")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The handler may use serialization which may require unreferenced code")] public System.IDisposable BindInteraction(TViewModel? viewModel, TView view, System.Linq.Expressions.Expression>> propertyName, System.Func, System.IObservable> handler) where TViewModel : class where TView : class, ReactiveUI.IViewFor { } } - [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("InteractionBindingMixins uses RxApp initialization and expression binding which r" + - "equire dynamic code generation")] - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("InteractionBindingMixins uses RxApp initialization and expression binding which m" + - "ay require unreferenced code")] public static class InteractionBindingMixins { [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("BindInteraction uses expression binding which requires dynamic code generation")] @@ -758,8 +736,8 @@ namespace ReactiveUI } public static class ObservableFuncMixins { - [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("ToObservable uses methods that require dynamic code generation")] - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("ToObservable uses methods that may require unreferenced code")] + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("This method uses reflection to access properties by name.")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("This method uses reflection to access properties by name.")] public static System.IObservable ToObservable(this System.Linq.Expressions.Expression> expression, TSource? source, bool beforeChange = false, bool skipInitial = false) { } } public static class ObservableLoggingMixin @@ -840,67 +818,99 @@ namespace ReactiveUI "e unreferenced code")] public void Register(System.Action, System.Type> registerFunction) { } } - [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Property binding uses reflection and dynamic type conversion")] - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Property binding may reference members that could be trimmed")] public class PropertyBinderImplementation : ReactiveUI.IPropertyBinderImplementation, Splat.IEnableLogger { public PropertyBinderImplementation() { } + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("The handler may use serialization which requires dynamic code generation")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The handler may use serialization which may require unreferenced code")] [return: System.Runtime.CompilerServices.TupleElementNames(new string[] { "view", "isViewModel"})] public ReactiveUI.IReactiveBinding> Bind(TViewModel? viewModel, TView view, System.Linq.Expressions.Expression> vmProperty, System.Linq.Expressions.Expression> viewProperty, System.IObservable? signalViewUpdate, System.Func vmToViewConverter, System.Func viewToVmConverter, ReactiveUI.TriggerUpdate triggerUpdate = 0) where TViewModel : class where TView : class, ReactiveUI.IViewFor { } + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("The handler may use serialization which requires dynamic code generation")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The handler may use serialization which may require unreferenced code")] [return: System.Runtime.CompilerServices.TupleElementNames(new string?[]?[] { "view", "isViewModel"})] public ReactiveUI.IReactiveBinding> Bind(TViewModel? viewModel, TView view, System.Linq.Expressions.Expression> vmProperty, System.Linq.Expressions.Expression> viewProperty, System.IObservable? signalViewUpdate, object? conversionHint, ReactiveUI.IBindingTypeConverter? vmToViewConverterOverride = null, ReactiveUI.IBindingTypeConverter? viewToVMConverterOverride = null, ReactiveUI.TriggerUpdate triggerUpdate = 0) where TViewModel : class where TView : class, ReactiveUI.IViewFor { } + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("The handler may use serialization which requires dynamic code generation")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The handler may use serialization which may require unreferenced code")] public System.IDisposable BindTo(System.IObservable observedChange, TTarget? target, System.Linq.Expressions.Expression> propertyExpression, object? conversionHint = null, ReactiveUI.IBindingTypeConverter? vmToViewConverterOverride = null) where TTarget : class { } + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("The handler may use serialization which requires dynamic code generation")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The handler may use serialization which may require unreferenced code")] public ReactiveUI.IReactiveBinding OneWayBind(TViewModel? viewModel, TView view, System.Linq.Expressions.Expression> vmProperty, System.Linq.Expressions.Expression> viewProperty, System.Func selector) where TViewModel : class where TView : class, ReactiveUI.IViewFor { } + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("The handler may use serialization which requires dynamic code generation")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The handler may use serialization which may require unreferenced code")] public ReactiveUI.IReactiveBinding OneWayBind(TViewModel? viewModel, TView view, System.Linq.Expressions.Expression> vmProperty, System.Linq.Expressions.Expression> viewProperty, object? conversionHint = null, ReactiveUI.IBindingTypeConverter? vmToViewConverterOverride = null) where TViewModel : class where TView : class, ReactiveUI.IViewFor { } } - [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("PropertyBindingMixins uses RxApp initialization and expression binding which requ" + - "ire dynamic code generation")] - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("PropertyBindingMixins uses RxApp initialization and expression binding which may " + - "require unreferenced code")] public static class PropertyBindingMixins { + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("PropertyBindingMixins uses RxApp initialization and expression binding which requ" + + "ire dynamic code generation")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("PropertyBindingMixins uses RxApp initialization and expression binding which may " + + "require unreferenced code")] [return: System.Runtime.CompilerServices.TupleElementNames(new string[] { "view", "isViewModel"})] public static ReactiveUI.IReactiveBinding> Bind(this TView view, TViewModel? viewModel, System.Linq.Expressions.Expression> vmProperty, System.Linq.Expressions.Expression> viewProperty, System.Func vmToViewConverter, System.Func viewToVmConverter) where TViewModel : class where TView : class, ReactiveUI.IViewFor { } + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("PropertyBindingMixins uses RxApp initialization and expression binding which requ" + + "ire dynamic code generation")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("PropertyBindingMixins uses RxApp initialization and expression binding which may " + + "require unreferenced code")] [return: System.Runtime.CompilerServices.TupleElementNames(new string?[]?[] { "view", "isViewModel"})] public static ReactiveUI.IReactiveBinding> Bind(this TView view, TViewModel? viewModel, System.Linq.Expressions.Expression> vmProperty, System.Linq.Expressions.Expression> viewProperty, object? conversionHint = null, ReactiveUI.IBindingTypeConverter? vmToViewConverterOverride = null, ReactiveUI.IBindingTypeConverter? viewToVMConverterOverride = null) where TViewModel : class where TView : class, ReactiveUI.IViewFor { } + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("PropertyBindingMixins uses RxApp initialization and expression binding which requ" + + "ire dynamic code generation")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("PropertyBindingMixins uses RxApp initialization and expression binding which may " + + "require unreferenced code")] [return: System.Runtime.CompilerServices.TupleElementNames(new string[] { "view", "isViewModel"})] public static ReactiveUI.IReactiveBinding> Bind(this TView view, TViewModel? viewModel, System.Linq.Expressions.Expression> vmProperty, System.Linq.Expressions.Expression> viewProperty, System.IObservable? signalViewUpdate, System.Func vmToViewConverter, System.Func viewToVmConverter, ReactiveUI.TriggerUpdate triggerUpdate = 0) where TViewModel : class where TView : class, ReactiveUI.IViewFor { } + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("PropertyBindingMixins uses RxApp initialization and expression binding which requ" + + "ire dynamic code generation")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("PropertyBindingMixins uses RxApp initialization and expression binding which may " + + "require unreferenced code")] [return: System.Runtime.CompilerServices.TupleElementNames(new string?[]?[] { "view", "isViewModel"})] public static ReactiveUI.IReactiveBinding> Bind(this TView view, TViewModel? viewModel, System.Linq.Expressions.Expression> vmProperty, System.Linq.Expressions.Expression> viewProperty, System.IObservable? signalViewUpdate, object? conversionHint = null, ReactiveUI.IBindingTypeConverter? vmToViewConverterOverride = null, ReactiveUI.IBindingTypeConverter? viewToVMConverterOverride = null, ReactiveUI.TriggerUpdate triggerUpdate = 0) where TViewModel : class where TView : class, ReactiveUI.IViewFor { } + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("PropertyBindingMixins uses RxApp initialization and expression binding which requ" + + "ire dynamic code generation")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("PropertyBindingMixins uses RxApp initialization and expression binding which may " + + "require unreferenced code")] public static System.IDisposable BindTo(this System.IObservable @this, TTarget? target, System.Linq.Expressions.Expression> property, object? conversionHint = null, ReactiveUI.IBindingTypeConverter? vmToViewConverterOverride = null) where TTarget : class { } + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("PropertyBindingMixins uses RxApp initialization and expression binding which requ" + + "ire dynamic code generation")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("PropertyBindingMixins uses RxApp initialization and expression binding which may " + + "require unreferenced code")] public static ReactiveUI.IReactiveBinding OneWayBind(this TView view, TViewModel? viewModel, System.Linq.Expressions.Expression> vmProperty, System.Linq.Expressions.Expression> viewProperty, System.Func selector) where TViewModel : class where TView : class, ReactiveUI.IViewFor { } + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("PropertyBindingMixins uses RxApp initialization and expression binding which requ" + + "ire dynamic code generation")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("PropertyBindingMixins uses RxApp initialization and expression binding which may " + + "require unreferenced code")] public static ReactiveUI.IReactiveBinding OneWayBind(this TView view, TViewModel? viewModel, System.Linq.Expressions.Expression> vmProperty, System.Linq.Expressions.Expression> viewProperty, object? conversionHint = null, ReactiveUI.IBindingTypeConverter? vmToViewConverterOverride = null) where TViewModel : class where TView : class, ReactiveUI.IViewFor { } @@ -1016,74 +1026,59 @@ namespace ReactiveUI public override System.IObservable Execute(TParam parameter) { } public override System.IDisposable Subscribe(System.IObserver observer) { } } - [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("ReactiveNotifyPropertyChangedMixin uses RxApp which requires dynamic code generat" + - "ion")] - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("ReactiveNotifyPropertyChangedMixin uses RxApp which may require unreferenced code")] public static class ReactiveNotifyPropertyChangedMixin { - [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("ObservableForProperty uses expression analysis which requires dynamic code genera" + - "tion")] - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("ObservableForProperty may reference properties that could be trimmed")] + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("This method uses reflection to access properties by name.")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("This method uses reflection to access properties by name.")] public static System.IObservable> ObservableForProperty(this TSender? item, System.Linq.Expressions.Expression> property) { } - [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("ObservableForProperty uses expression analysis which requires dynamic code genera" + - "tion")] - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("ObservableForProperty may reference properties that could be trimmed")] + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("This method uses reflection to access properties by name.")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("This method uses reflection to access properties by name.")] public static System.IObservable> ObservableForProperty(this TSender? item, string propertyName) { } - [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("ObservableForProperty uses expression analysis which requires dynamic code genera" + - "tion")] - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("ObservableForProperty may reference properties that could be trimmed")] + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("This method uses reflection to access properties by name.")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("This method uses reflection to access properties by name.")] public static System.IObservable> ObservableForProperty(this TSender? item, System.Linq.Expressions.Expression> property, bool beforeChange) { } - [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("ObservableForProperty uses expression analysis which requires dynamic code genera" + - "tion")] - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("ObservableForProperty may reference properties that could be trimmed")] + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("This method uses reflection to access properties by name.")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("This method uses reflection to access properties by name.")] public static System.IObservable> ObservableForProperty(this TSender? item, string propertyName, bool beforeChange) { } - [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("ObservableForProperty uses expression analysis which requires dynamic code genera" + - "tion")] - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("ObservableForProperty may reference properties that could be trimmed")] + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("This method uses reflection to access properties by name.")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("This method uses reflection to access properties by name.")] public static System.IObservable> ObservableForProperty(this TSender? item, System.Linq.Expressions.Expression> property, bool beforeChange, bool skipInitial) { } - [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("ObservableForProperty uses expression analysis which requires dynamic code genera" + - "tion")] - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("ObservableForProperty may reference properties that could be trimmed")] + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("This method uses reflection to access properties by name.")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("This method uses reflection to access properties by name.")] public static System.IObservable> ObservableForProperty(this TSender? item, string propertyName, bool beforeChange, bool skipInitial) { } - [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("ObservableForProperty uses expression analysis which requires dynamic code genera" + - "tion")] - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("ObservableForProperty may reference properties that could be trimmed")] + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("This method uses reflection to access properties by name.")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("This method uses reflection to access properties by name.")] public static System.IObservable> ObservableForProperty(this TSender? item, System.Linq.Expressions.Expression> property, bool beforeChange, bool skipInitial, bool isDistinct) { } - [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("ObservableForProperty uses expression analysis which requires dynamic code genera" + - "tion")] - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("ObservableForProperty may reference properties that could be trimmed")] + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("This method uses reflection to access properties by name.")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("This method uses reflection to access properties by name.")] public static System.IObservable> ObservableForProperty(this TSender? item, string propertyName, bool beforeChange, bool skipInitial, bool isDistinct) { } - [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("NotifyForProperty uses expression analysis which requires dynamic code generation")] - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("NotifyForProperty may reference properties that could be trimmed")] + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("This method uses reflection to access properties by name.")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("This method uses reflection to access properties by name.")] public static System.IObservable ObservableForProperty(this TSender? item, System.Linq.Expressions.Expression> property, System.Func selector) where TSender : class { } - [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("NotifyForProperty uses expression analysis which requires dynamic code generation")] - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("NotifyForProperty may reference properties that could be trimmed")] + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("This method uses reflection to access properties by name.")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("This method uses reflection to access properties by name.")] public static System.IObservable ObservableForProperty(this TSender? item, System.Linq.Expressions.Expression> property, System.Func selector, bool beforeChange) where TSender : class { } - [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("NotifyForProperty uses expression analysis which requires dynamic code generation")] - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("NotifyForProperty may reference properties that could be trimmed")] + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("This method uses reflection to access properties by name.")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("This method uses reflection to access properties by name.")] public static System.IObservable> SubscribeToExpressionChain(this TSender? source, System.Linq.Expressions.Expression? expression) { } - [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("NotifyForProperty uses expression analysis which requires dynamic code generation")] - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("NotifyForProperty may reference properties that could be trimmed")] + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("This method uses reflection to access properties by name.")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("This method uses reflection to access properties by name.")] public static System.IObservable> SubscribeToExpressionChain(this TSender? source, System.Linq.Expressions.Expression? expression, bool beforeChange) { } - [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("NotifyForProperty uses expression analysis which requires dynamic code generation")] - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("NotifyForProperty may reference properties that could be trimmed")] + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("This method uses reflection to access properties by name.")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("This method uses reflection to access properties by name.")] public static System.IObservable> SubscribeToExpressionChain(this TSender? source, System.Linq.Expressions.Expression? expression, bool beforeChange, bool skipInitial) { } - [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("SubscribeToExpressionChain uses expression analysis which requires dynamic code g" + - "eneration")] - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("SubscribeToExpressionChain may reference properties that could be trimmed")] + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("This method uses reflection to access properties by name.")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("This method uses reflection to access properties by name.")] public static System.IObservable> SubscribeToExpressionChain(this TSender? source, System.Linq.Expressions.Expression? expression, bool beforeChange, bool skipInitial, bool suppressWarnings) { } - [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("SubscribeToExpressionChain uses expression analysis which requires dynamic code g" + - "eneration")] - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("SubscribeToExpressionChain may reference properties that could be trimmed")] + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("This method uses reflection to access properties by name.")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("This method uses reflection to access properties by name.")] public static System.IObservable> SubscribeToExpressionChain(this TSender? source, System.Linq.Expressions.Expression? expression, bool beforeChange, bool skipInitial, bool suppressWarnings, bool isDistinct) { } } [System.Runtime.Serialization.DataContract] public class ReactiveObject : ReactiveUI.IHandleObservableErrors, ReactiveUI.IReactiveNotifyPropertyChanged, ReactiveUI.IReactiveObject, Splat.IEnableLogger, System.ComponentModel.INotifyPropertyChanged, System.ComponentModel.INotifyPropertyChanging { - [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("ReactiveObject uses extension methods that require dynamic code generation")] - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("ReactiveObject uses extension methods that may require unreferenced code")] public ReactiveObject() { } [System.ComponentModel.Browsable(false)] [System.ComponentModel.DataAnnotations.Display(AutoGenerateField=false, AutoGenerateFilter=false, Order=-1)] @@ -1102,20 +1097,10 @@ namespace ReactiveUI public System.IObservable ThrownExceptions { get; } public event System.ComponentModel.PropertyChangedEventHandler? PropertyChanged; public event System.ComponentModel.PropertyChangingEventHandler? PropertyChanging; - [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("AreChangeNotificationsEnabled uses extension methods that require dynamic code ge" + - "neration")] - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("AreChangeNotificationsEnabled uses extension methods that may require unreference" + - "d code")] public bool AreChangeNotificationsEnabled() { } - [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("DelayChangeNotifications uses extension methods that require dynamic code generat" + - "ion")] - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("DelayChangeNotifications uses extension methods that may require unreferenced cod" + - "e")] public System.IDisposable DelayChangeNotifications() { } - [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("SuppressChangeNotifications uses extension methods that require dynamic code gene" + - "ration")] - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("SuppressChangeNotifications uses extension methods that may require unreferenced " + - "code")] + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("This method uses reflection to access properties by name.")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("This method uses reflection to access properties by name.")] public System.IDisposable SuppressChangeNotifications() { } } public class ReactivePropertyChangedEventArgs : System.ComponentModel.PropertyChangedEventArgs, ReactiveUI.IReactivePropertyChangedEventArgs @@ -1233,37 +1218,27 @@ namespace ReactiveUI "code")] public System.IDisposable SuppressChangeNotifications() { } } - [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Expression rewriting requires dynamic code generation")] - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Expression rewriting may reference members that could be trimmed")] public static class Reflection { [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Expression tree analysis requires dynamic code generation")] [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Expression tree analysis may reference members that could be trimmed")] public static string ExpressionToPropertyNames(System.Linq.Expressions.Expression? expression) { } - [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Event reflection requires dynamic code generation")] - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Event reflection may reference members that could be trimmed")] - public static System.Type GetEventArgsTypeForEvent(System.Type type, string? eventName) { } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Event access may reference members that could be trimmed")] + public static System.Type GetEventArgsTypeForEvent([System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All)] System.Type type, string? eventName) { } [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Member access requires dynamic code generation")] [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Member access may reference members that could be trimmed")] public static System.Func? GetValueFetcherForProperty(System.Reflection.MemberInfo? member) { } [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Member access requires dynamic code generation")] [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Member access may reference members that could be trimmed")] public static System.Func GetValueFetcherOrThrow(System.Reflection.MemberInfo? member) { } - [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Member access requires dynamic code generation")] - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Member access may reference members that could be trimmed")] public static System.Action GetValueSetterForProperty(System.Reflection.MemberInfo? member) { } [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Member access requires dynamic code generation")] [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Member access may reference members that could be trimmed")] public static System.Action? GetValueSetterOrThrow(System.Reflection.MemberInfo? member) { } public static bool IsStatic(this System.Reflection.PropertyInfo item) { } - [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Type resolution requires dynamic code generation")] - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Type resolution may reference types that could be trimmed")] public static System.Type? ReallyFindType(string? type, bool throwOnFailure) { } - [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Expression rewriting requires dynamic code generation")] - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Expression rewriting may reference members that could be trimmed")] public static System.Linq.Expressions.Expression Rewrite(System.Linq.Expressions.Expression? expression) { } - [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Method reflection requires dynamic code generation")] - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Method reflection may reference members that could be trimmed")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Method access may reference members that could be trimmed")] public static void ThrowIfMethodsNotOverloaded(string callingTypeName, object targetObject, params string[] methodsToCheck) { } [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Expression evaluation requires dynamic code generation")] [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Expression evaluation may reference members that could be trimmed")] @@ -1334,10 +1309,6 @@ namespace ReactiveUI where T : ReactiveUI.IRoutableViewModel { } public static ReactiveUI.IRoutableViewModel? GetCurrentViewModel(this ReactiveUI.RoutingState item) { } } - [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("RxApp initialization uses reflection-based registration which requires dynamic co" + - "de generation.")] - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("RxApp initialization uses reflection-based registration which may require unrefer" + - "enced code.")] public static class RxApp { public const int BigCacheLimit = 256; @@ -1421,17 +1392,25 @@ namespace ReactiveUI public ViewContractAttribute(string contract) { } public string Contract { get; } } - [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("ViewForMixins uses methods that require dynamic code generation")] - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("ViewForMixins uses methods that may require unreferenced code")] public static class ViewForMixins { + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("WhenActivated uses reflection which requires dynamic code generation")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("WhenActivated may reference types that could be trimmed")] public static System.IDisposable WhenActivated(this ReactiveUI.IActivatableView item, System.Action> block) { } + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("WhenActivated uses reflection which requires dynamic code generation")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("WhenActivated may reference types that could be trimmed")] public static System.IDisposable WhenActivated(this ReactiveUI.IActivatableView item, System.Func> block) { } public static void WhenActivated(this ReactiveUI.IActivatableViewModel item, System.Action> block) { } public static void WhenActivated(this ReactiveUI.IActivatableViewModel item, System.Action block) { } public static void WhenActivated(this ReactiveUI.IActivatableViewModel item, System.Func> block) { } + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("WhenActivated uses reflection which requires dynamic code generation")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("WhenActivated may reference types that could be trimmed")] public static System.IDisposable WhenActivated(this ReactiveUI.IActivatableView item, System.Action> block, ReactiveUI.IViewFor view) { } + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("WhenActivated uses reflection which requires dynamic code generation")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("WhenActivated may reference types that could be trimmed")] public static System.IDisposable WhenActivated(this ReactiveUI.IActivatableView item, System.Action block, ReactiveUI.IViewFor? view = null) { } + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("WhenActivated uses reflection which requires dynamic code generation")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("WhenActivated may reference types that could be trimmed")] public static System.IDisposable WhenActivated(this ReactiveUI.IActivatableView item, System.Func> block, ReactiveUI.IViewFor? view) { } } public static class ViewLocator @@ -2177,48 +2156,78 @@ namespace ReactiveUI } namespace ReactiveUI.Builder { - public static class MultiPlatformReactiveUIBuilderExtensions + public interface IReactiveUIBuilder : Splat.Builder.IAppBuilder + { + ReactiveUI.Builder.IReactiveUIBuilder ConfigureMessageBus(System.Action configure); + ReactiveUI.Builder.IReactiveUIBuilder ConfigureSuspensionDriver(System.Action configure); + ReactiveUI.Builder.IReactiveUIBuilder ConfigureViewLocator(System.Action configure); + ReactiveUI.Builder.IReactiveUIBuilder ForCustomPlatform(System.Reactive.Concurrency.IScheduler mainThreadScheduler, System.Action platformServices); + ReactiveUI.Builder.IReactiveUIBuilder ForPlatforms(params System.Action[] platformConfigurations); + ReactiveUI.Builder.IReactiveUIBuilder RegisterSingletonView() + where TView : class, ReactiveUI.IViewFor, new () + where TViewModel : class, ReactiveUI.IReactiveObject; + ReactiveUI.Builder.IReactiveUIBuilder RegisterSingletonViewModel<[System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All)] TViewModel>() + where TViewModel : class, ReactiveUI.IReactiveObject, new (); + ReactiveUI.Builder.IReactiveUIBuilder RegisterView() + where TView : class, ReactiveUI.IViewFor, new () + where TViewModel : class, ReactiveUI.IReactiveObject; + ReactiveUI.Builder.IReactiveUIBuilder RegisterViewModel() + where TViewModel : class, ReactiveUI.IReactiveObject, new (); + ReactiveUI.Builder.IReactiveUIBuilder UsingSplatModule(T registrationModule) + where T : Splat.Builder.IModule; + ReactiveUI.Builder.IReactiveUIBuilder WithMainThreadScheduler(System.Reactive.Concurrency.IScheduler scheduler, bool setRxApp = true); + ReactiveUI.Builder.IReactiveUIBuilder WithPlatformModule() + where T : ReactiveUI.IWantsToRegisterStuff, new (); + ReactiveUI.Builder.IReactiveUIBuilder WithPlatformServices(); + ReactiveUI.Builder.IReactiveUIBuilder WithRegistration(System.Action configureAction); + ReactiveUI.Builder.IReactiveUIBuilder WithRegistrationOnBuild(System.Action configureAction); + ReactiveUI.Builder.IReactiveUIBuilder WithTaskPoolScheduler(System.Reactive.Concurrency.IScheduler scheduler, bool setRxApp = true); + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("The method uses reflection and will not work in AOT environments.")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The method uses reflection and will not work in AOT environments.")] + ReactiveUI.Builder.IReactiveUIBuilder WithViewsFromAssembly(System.Reflection.Assembly assembly); + } + public interface IReactiveUIInstance : Splat.Builder.IAppInstance { - public static ReactiveUI.Builder.ReactiveUIBuilder ForCustomPlatform(this ReactiveUI.Builder.ReactiveUIBuilder builder, System.Reactive.Concurrency.IScheduler mainThreadScheduler, System.Action platformServices) { } - public static ReactiveUI.Builder.ReactiveUIBuilder ForPlatforms(this ReactiveUI.Builder.ReactiveUIBuilder builder, params System.Action[] platformConfigurations) { } + System.Reactive.Concurrency.IScheduler? MainThreadScheduler { get; } + System.Reactive.Concurrency.IScheduler? TaskpoolScheduler { get; } } - public sealed class ReactiveUIBuilder : Splat.Builder.AppBuilder + public sealed class ReactiveUIBuilder : Splat.Builder.AppBuilder, ReactiveUI.Builder.IReactiveUIBuilder, ReactiveUI.Builder.IReactiveUIInstance, Splat.Builder.IAppBuilder, Splat.Builder.IAppInstance { - public ReactiveUIBuilder(Splat.IMutableDependencyResolver resolver) { } - [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("ReactiveUI uses reflection to register some services. Ensure that the necessary t" + - "ypes are preserved.")] - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("ReactiveUI uses reflection to register some services. Ensure that the necessary t" + - "ypes are preserved.")] - public override Splat.Builder.AppBuilder WithCoreServices() { } - public ReactiveUI.Builder.ReactiveUIBuilder WithMainThreadScheduler(System.Reactive.Concurrency.IScheduler scheduler) { } - public ReactiveUI.Builder.ReactiveUIBuilder WithPlatformModule() + public ReactiveUIBuilder(Splat.IMutableDependencyResolver resolver, Splat.IReadonlyDependencyResolver? current) { } + public System.Reactive.Concurrency.IScheduler? MainThreadScheduler { get; } + public System.Reactive.Concurrency.IScheduler? TaskpoolScheduler { get; } + public ReactiveUI.Builder.IReactiveUIBuilder ConfigureMessageBus(System.Action configure) { } + public ReactiveUI.Builder.IReactiveUIBuilder ConfigureSuspensionDriver(System.Action configure) { } + public ReactiveUI.Builder.IReactiveUIBuilder ConfigureViewLocator(System.Action configure) { } + public ReactiveUI.Builder.IReactiveUIBuilder ForCustomPlatform(System.Reactive.Concurrency.IScheduler mainThreadScheduler, System.Action platformServices) { } + public ReactiveUI.Builder.IReactiveUIBuilder ForPlatforms(params System.Action[] platformConfigurations) { } + public ReactiveUI.Builder.IReactiveUIBuilder RegisterSingletonView() + where TView : class, ReactiveUI.IViewFor, new () + where TViewModel : class, ReactiveUI.IReactiveObject { } + public ReactiveUI.Builder.IReactiveUIBuilder RegisterSingletonViewModel<[System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All)] TViewModel>() + where TViewModel : class, ReactiveUI.IReactiveObject, new () { } + public ReactiveUI.Builder.IReactiveUIBuilder RegisterView() + where TView : class, ReactiveUI.IViewFor, new () + where TViewModel : class, ReactiveUI.IReactiveObject { } + public ReactiveUI.Builder.IReactiveUIBuilder RegisterViewModel() + where TViewModel : class, ReactiveUI.IReactiveObject, new () { } + public ReactiveUI.Builder.IReactiveUIBuilder UsingSplatModule(T registrationModule) + where T : Splat.Builder.IModule { } + public override Splat.Builder.IAppBuilder WithCoreServices() { } + public ReactiveUI.Builder.IReactiveUIBuilder WithMainThreadScheduler(System.Reactive.Concurrency.IScheduler scheduler, bool setRxApp = true) { } + public ReactiveUI.Builder.IReactiveUIBuilder WithPlatformModule() where T : ReactiveUI.IWantsToRegisterStuff, new () { } - public ReactiveUI.Builder.ReactiveUIBuilder WithPlatformServices() { } - public ReactiveUI.Builder.ReactiveUIBuilder WithRegistration(System.Action configureAction) { } - public ReactiveUI.Builder.ReactiveUIBuilder WithRegistrationOnBuild(System.Action configureAction) { } - public ReactiveUI.Builder.ReactiveUIBuilder WithTaskPoolScheduler(System.Reactive.Concurrency.IScheduler scheduler) { } + public ReactiveUI.Builder.IReactiveUIBuilder WithPlatformServices() { } + public ReactiveUI.Builder.IReactiveUIBuilder WithRegistration(System.Action configureAction) { } + public ReactiveUI.Builder.IReactiveUIBuilder WithRegistrationOnBuild(System.Action configureAction) { } + public ReactiveUI.Builder.IReactiveUIBuilder WithTaskPoolScheduler(System.Reactive.Concurrency.IScheduler scheduler, bool setRxApp = true) { } [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("The method uses reflection and will not work in AOT environments.")] [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The method uses reflection and will not work in AOT environments.")] - public ReactiveUI.Builder.ReactiveUIBuilder WithViewsFromAssembly(System.Reflection.Assembly assembly) { } + public ReactiveUI.Builder.IReactiveUIBuilder WithViewsFromAssembly(System.Reflection.Assembly assembly) { } } public static class RxAppBuilder { - public static ReactiveUI.Builder.ReactiveUIBuilder ConfigureMessageBus(this ReactiveUI.Builder.ReactiveUIBuilder builder, System.Action configure) { } - public static ReactiveUI.Builder.ReactiveUIBuilder ConfigureSuspensionDriver(this ReactiveUI.Builder.ReactiveUIBuilder builder, System.Action configure) { } - public static ReactiveUI.Builder.ReactiveUIBuilder ConfigureViewLocator(this ReactiveUI.Builder.ReactiveUIBuilder builder, System.Action configure) { } public static ReactiveUI.Builder.ReactiveUIBuilder CreateReactiveUIBuilder() { } public static ReactiveUI.Builder.ReactiveUIBuilder CreateReactiveUIBuilder(this Splat.IMutableDependencyResolver resolver) { } - public static ReactiveUI.Builder.ReactiveUIBuilder RegisterSingletonView(this ReactiveUI.Builder.ReactiveUIBuilder builder) - where TView : class, ReactiveUI.IViewFor, new () - where TViewModel : class, ReactiveUI.IReactiveObject { } - [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("This method uses \'new()\' constraint which may require dynamic code generation.")] - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("This method uses \'new()\' constraint which may require dynamic code generation.")] - public static ReactiveUI.Builder.ReactiveUIBuilder RegisterSingletonViewModel(this ReactiveUI.Builder.ReactiveUIBuilder builder) - where TViewModel : class, ReactiveUI.IReactiveObject, new () { } - public static ReactiveUI.Builder.ReactiveUIBuilder RegisterView(this ReactiveUI.Builder.ReactiveUIBuilder builder) - where TView : class, ReactiveUI.IViewFor, new () - where TViewModel : class, ReactiveUI.IReactiveObject { } - public static ReactiveUI.Builder.ReactiveUIBuilder RegisterViewModel(this ReactiveUI.Builder.ReactiveUIBuilder builder) - where TViewModel : class, ReactiveUI.IReactiveObject, new () { } } } \ No newline at end of file diff --git a/src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.DotNet9_0.verified.txt b/src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.DotNet9_0.verified.txt index 5b28b8c733..5a6b86ac16 100644 --- a/src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.DotNet9_0.verified.txt +++ b/src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.DotNet9_0.verified.txt @@ -85,18 +85,22 @@ namespace ReactiveUI public override System.IObservable> Execute(TParam parameter) { } public override System.IDisposable Subscribe(System.IObserver> observer) { } } - [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("CommandBinder uses RxApp initialization which requires dynamic code generation")] - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("CommandBinder uses RxApp initialization which may require unreferenced code")] public static class CommandBinder { + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("This method uses reflection to access properties by name.")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("This method uses reflection to access properties by name.")] public static ReactiveUI.IReactiveBinding BindCommand(this TView view, TViewModel? viewModel, System.Linq.Expressions.Expression> propertyName, System.Linq.Expressions.Expression> controlName, string? toEvent = null) where TView : class, ReactiveUI.IViewFor where TViewModel : class where TProp : System.Windows.Input.ICommand { } + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("This method uses reflection to access properties by name.")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("This method uses reflection to access properties by name.")] public static ReactiveUI.IReactiveBinding BindCommand(this TView view, TViewModel? viewModel, System.Linq.Expressions.Expression> propertyName, System.Linq.Expressions.Expression> controlName, System.IObservable withParameter, string? toEvent = null) where TView : class, ReactiveUI.IViewFor where TViewModel : class where TProp : System.Windows.Input.ICommand { } + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("This method uses reflection to access properties by name.")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("This method uses reflection to access properties by name.")] public static ReactiveUI.IReactiveBinding BindCommand(this TView view, TViewModel? viewModel, System.Linq.Expressions.Expression> propertyName, System.Linq.Expressions.Expression> controlName, System.Linq.Expressions.Expression> withParameter, string? toEvent = null) where TView : class, ReactiveUI.IViewFor where TViewModel : class @@ -105,16 +109,14 @@ namespace ReactiveUI public class CommandBinderImplementation : Splat.IEnableLogger { public CommandBinderImplementation() { } - [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("BindCommand uses ViewModelWhenAnyValue which requires dynamic code generation")] - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("BindCommand uses ViewModelWhenAnyValue which may reference members that could be " + - "trimmed")] + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("This method uses reflection to access properties by name.")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("This method uses reflection to access properties by name.")] public ReactiveUI.IReactiveBinding BindCommand(TViewModel? viewModel, TView view, System.Linq.Expressions.Expression> vmProperty, System.Linq.Expressions.Expression> controlProperty, System.IObservable withParameter, string? toEvent = null) where TView : class, ReactiveUI.IViewFor where TViewModel : class where TProp : System.Windows.Input.ICommand { } - [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("BindCommand uses ViewModelWhenAnyValue which requires dynamic code generation")] - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("BindCommand uses ViewModelWhenAnyValue which may reference members that could be " + - "trimmed")] + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("This method uses reflection to access properties by name.")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("This method uses reflection to access properties by name.")] public ReactiveUI.IReactiveBinding BindCommand(TViewModel? viewModel, TView view, System.Linq.Expressions.Expression> vmProperty, System.Linq.Expressions.Expression> controlProperty, System.Linq.Expressions.Expression> withParameter, string? toEvent = null) where TView : class, ReactiveUI.IViewFor where TViewModel : class @@ -138,8 +140,8 @@ namespace ReactiveUI public class CreatesCommandBindingViaCommandParameter : ReactiveUI.ICreatesCommandBinding { public CreatesCommandBindingViaCommandParameter() { } - [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Property access requires dynamic code generation")] - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Property access may reference members that could be trimmed")] + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("BindCommandToObject uses methods that require dynamic code generation")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("BindCommandToObject uses methods that may require unreferenced code")] public System.IDisposable? BindCommandToObject(System.Windows.Input.ICommand? command, object? target, System.IObservable commandParameter) { } [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("BindCommandToObject uses methods that require dynamic code generation")] [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("BindCommandToObject uses methods that may require unreferenced code")] @@ -183,8 +185,8 @@ namespace ReactiveUI } public static class DependencyResolverMixins { - [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("The method uses reflection and will not work in AOT environments.")] - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The method uses reflection and will not work in AOT environments.")] + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("InitializeReactiveUI uses reflection to locate types which may be trimmed.")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("InitializeReactiveUI uses reflection to locate types which may be trimmed.")] public static void InitializeReactiveUI(this Splat.IMutableDependencyResolver resolver, params ReactiveUI.RegistrationNamespace[] registrationNamespaces) { } [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("RegisterViewsForViewModels scans the provided assembly and creates instances via " + "reflection; this is not compatible with AOT.")] @@ -434,34 +436,14 @@ namespace ReactiveUI } public static class IReactiveObjectExtensions { - [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Extension state uses RxApp.DefaultExceptionHandler which requires dynamic code ge" + - "neration")] - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Extension state uses RxApp.DefaultExceptionHandler which may require unreferenced" + - " code")] public static TRet RaiseAndSetIfChanged(this TObj reactiveObject, ref TRet backingField, TRet newValue, [System.Runtime.CompilerServices.CallerMemberName] string? propertyName = null) where TObj : ReactiveUI.IReactiveObject { } - [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Extension state uses RxApp.DefaultExceptionHandler which requires dynamic code ge" + - "neration")] - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Extension state uses RxApp.DefaultExceptionHandler which may require unreferenced" + - " code")] public static void RaisePropertyChanged(this TSender reactiveObject, [System.Runtime.CompilerServices.CallerMemberName] string? propertyName = null) where TSender : ReactiveUI.IReactiveObject { } - [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Extension state uses RxApp.DefaultExceptionHandler which requires dynamic code ge" + - "neration")] - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Extension state uses RxApp.DefaultExceptionHandler which may require unreferenced" + - " code")] public static void RaisePropertyChanging(this TSender reactiveObject, [System.Runtime.CompilerServices.CallerMemberName] string? propertyName = null) where TSender : ReactiveUI.IReactiveObject { } - [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Extension state uses RxApp.DefaultExceptionHandler which requires dynamic code ge" + - "neration")] - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Extension state uses RxApp.DefaultExceptionHandler which may require unreferenced" + - " code")] public static void SubscribePropertyChangedEvents(this TSender reactiveObject) where TSender : ReactiveUI.IReactiveObject { } - [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Extension state uses RxApp.DefaultExceptionHandler which requires dynamic code ge" + - "neration")] - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Extension state uses RxApp.DefaultExceptionHandler which may require unreferenced" + - " code")] public static void SubscribePropertyChangingEvents(this TSender reactiveObject) where TSender : ReactiveUI.IReactiveObject { } } @@ -548,24 +530,20 @@ namespace ReactiveUI public int GetAffinityForObjects(System.Type fromType, System.Type toType) { } public bool TryConvert(object? from, System.Type toType, object? conversionHint, out object result) { } } - [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("InteractionBinderImplementation uses reflection and expression evaluation which r" + - "equire dynamic code generation")] - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("InteractionBinderImplementation uses reflection and expression evaluation which m" + - "ay require unreferenced code")] public class InteractionBinderImplementation : ReactiveUI.IInteractionBinderImplementation, Splat.IEnableLogger { public InteractionBinderImplementation() { } + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("The handler may use serialization which requires dynamic code generation")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The handler may use serialization which may require unreferenced code")] public System.IDisposable BindInteraction(TViewModel? viewModel, TView view, System.Linq.Expressions.Expression>> propertyName, System.Func, System.Threading.Tasks.Task> handler) where TViewModel : class where TView : class, ReactiveUI.IViewFor { } + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("The handler may use serialization which requires dynamic code generation")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The handler may use serialization which may require unreferenced code")] public System.IDisposable BindInteraction(TViewModel? viewModel, TView view, System.Linq.Expressions.Expression>> propertyName, System.Func, System.IObservable> handler) where TViewModel : class where TView : class, ReactiveUI.IViewFor { } } - [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("InteractionBindingMixins uses RxApp initialization and expression binding which r" + - "equire dynamic code generation")] - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("InteractionBindingMixins uses RxApp initialization and expression binding which m" + - "ay require unreferenced code")] public static class InteractionBindingMixins { [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("BindInteraction uses expression binding which requires dynamic code generation")] @@ -758,8 +736,8 @@ namespace ReactiveUI } public static class ObservableFuncMixins { - [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("ToObservable uses methods that require dynamic code generation")] - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("ToObservable uses methods that may require unreferenced code")] + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("This method uses reflection to access properties by name.")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("This method uses reflection to access properties by name.")] public static System.IObservable ToObservable(this System.Linq.Expressions.Expression> expression, TSource? source, bool beforeChange = false, bool skipInitial = false) { } } public static class ObservableLoggingMixin @@ -840,67 +818,99 @@ namespace ReactiveUI "e unreferenced code")] public void Register(System.Action, System.Type> registerFunction) { } } - [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Property binding uses reflection and dynamic type conversion")] - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Property binding may reference members that could be trimmed")] public class PropertyBinderImplementation : ReactiveUI.IPropertyBinderImplementation, Splat.IEnableLogger { public PropertyBinderImplementation() { } + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("The handler may use serialization which requires dynamic code generation")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The handler may use serialization which may require unreferenced code")] [return: System.Runtime.CompilerServices.TupleElementNames(new string[] { "view", "isViewModel"})] public ReactiveUI.IReactiveBinding> Bind(TViewModel? viewModel, TView view, System.Linq.Expressions.Expression> vmProperty, System.Linq.Expressions.Expression> viewProperty, System.IObservable? signalViewUpdate, System.Func vmToViewConverter, System.Func viewToVmConverter, ReactiveUI.TriggerUpdate triggerUpdate = 0) where TViewModel : class where TView : class, ReactiveUI.IViewFor { } + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("The handler may use serialization which requires dynamic code generation")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The handler may use serialization which may require unreferenced code")] [return: System.Runtime.CompilerServices.TupleElementNames(new string?[]?[] { "view", "isViewModel"})] public ReactiveUI.IReactiveBinding> Bind(TViewModel? viewModel, TView view, System.Linq.Expressions.Expression> vmProperty, System.Linq.Expressions.Expression> viewProperty, System.IObservable? signalViewUpdate, object? conversionHint, ReactiveUI.IBindingTypeConverter? vmToViewConverterOverride = null, ReactiveUI.IBindingTypeConverter? viewToVMConverterOverride = null, ReactiveUI.TriggerUpdate triggerUpdate = 0) where TViewModel : class where TView : class, ReactiveUI.IViewFor { } + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("The handler may use serialization which requires dynamic code generation")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The handler may use serialization which may require unreferenced code")] public System.IDisposable BindTo(System.IObservable observedChange, TTarget? target, System.Linq.Expressions.Expression> propertyExpression, object? conversionHint = null, ReactiveUI.IBindingTypeConverter? vmToViewConverterOverride = null) where TTarget : class { } + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("The handler may use serialization which requires dynamic code generation")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The handler may use serialization which may require unreferenced code")] public ReactiveUI.IReactiveBinding OneWayBind(TViewModel? viewModel, TView view, System.Linq.Expressions.Expression> vmProperty, System.Linq.Expressions.Expression> viewProperty, System.Func selector) where TViewModel : class where TView : class, ReactiveUI.IViewFor { } + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("The handler may use serialization which requires dynamic code generation")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The handler may use serialization which may require unreferenced code")] public ReactiveUI.IReactiveBinding OneWayBind(TViewModel? viewModel, TView view, System.Linq.Expressions.Expression> vmProperty, System.Linq.Expressions.Expression> viewProperty, object? conversionHint = null, ReactiveUI.IBindingTypeConverter? vmToViewConverterOverride = null) where TViewModel : class where TView : class, ReactiveUI.IViewFor { } } - [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("PropertyBindingMixins uses RxApp initialization and expression binding which requ" + - "ire dynamic code generation")] - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("PropertyBindingMixins uses RxApp initialization and expression binding which may " + - "require unreferenced code")] public static class PropertyBindingMixins { + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("PropertyBindingMixins uses RxApp initialization and expression binding which requ" + + "ire dynamic code generation")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("PropertyBindingMixins uses RxApp initialization and expression binding which may " + + "require unreferenced code")] [return: System.Runtime.CompilerServices.TupleElementNames(new string[] { "view", "isViewModel"})] public static ReactiveUI.IReactiveBinding> Bind(this TView view, TViewModel? viewModel, System.Linq.Expressions.Expression> vmProperty, System.Linq.Expressions.Expression> viewProperty, System.Func vmToViewConverter, System.Func viewToVmConverter) where TViewModel : class where TView : class, ReactiveUI.IViewFor { } + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("PropertyBindingMixins uses RxApp initialization and expression binding which requ" + + "ire dynamic code generation")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("PropertyBindingMixins uses RxApp initialization and expression binding which may " + + "require unreferenced code")] [return: System.Runtime.CompilerServices.TupleElementNames(new string?[]?[] { "view", "isViewModel"})] public static ReactiveUI.IReactiveBinding> Bind(this TView view, TViewModel? viewModel, System.Linq.Expressions.Expression> vmProperty, System.Linq.Expressions.Expression> viewProperty, object? conversionHint = null, ReactiveUI.IBindingTypeConverter? vmToViewConverterOverride = null, ReactiveUI.IBindingTypeConverter? viewToVMConverterOverride = null) where TViewModel : class where TView : class, ReactiveUI.IViewFor { } + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("PropertyBindingMixins uses RxApp initialization and expression binding which requ" + + "ire dynamic code generation")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("PropertyBindingMixins uses RxApp initialization and expression binding which may " + + "require unreferenced code")] [return: System.Runtime.CompilerServices.TupleElementNames(new string[] { "view", "isViewModel"})] public static ReactiveUI.IReactiveBinding> Bind(this TView view, TViewModel? viewModel, System.Linq.Expressions.Expression> vmProperty, System.Linq.Expressions.Expression> viewProperty, System.IObservable? signalViewUpdate, System.Func vmToViewConverter, System.Func viewToVmConverter, ReactiveUI.TriggerUpdate triggerUpdate = 0) where TViewModel : class where TView : class, ReactiveUI.IViewFor { } + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("PropertyBindingMixins uses RxApp initialization and expression binding which requ" + + "ire dynamic code generation")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("PropertyBindingMixins uses RxApp initialization and expression binding which may " + + "require unreferenced code")] [return: System.Runtime.CompilerServices.TupleElementNames(new string?[]?[] { "view", "isViewModel"})] public static ReactiveUI.IReactiveBinding> Bind(this TView view, TViewModel? viewModel, System.Linq.Expressions.Expression> vmProperty, System.Linq.Expressions.Expression> viewProperty, System.IObservable? signalViewUpdate, object? conversionHint = null, ReactiveUI.IBindingTypeConverter? vmToViewConverterOverride = null, ReactiveUI.IBindingTypeConverter? viewToVMConverterOverride = null, ReactiveUI.TriggerUpdate triggerUpdate = 0) where TViewModel : class where TView : class, ReactiveUI.IViewFor { } + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("PropertyBindingMixins uses RxApp initialization and expression binding which requ" + + "ire dynamic code generation")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("PropertyBindingMixins uses RxApp initialization and expression binding which may " + + "require unreferenced code")] public static System.IDisposable BindTo(this System.IObservable @this, TTarget? target, System.Linq.Expressions.Expression> property, object? conversionHint = null, ReactiveUI.IBindingTypeConverter? vmToViewConverterOverride = null) where TTarget : class { } + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("PropertyBindingMixins uses RxApp initialization and expression binding which requ" + + "ire dynamic code generation")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("PropertyBindingMixins uses RxApp initialization and expression binding which may " + + "require unreferenced code")] public static ReactiveUI.IReactiveBinding OneWayBind(this TView view, TViewModel? viewModel, System.Linq.Expressions.Expression> vmProperty, System.Linq.Expressions.Expression> viewProperty, System.Func selector) where TViewModel : class where TView : class, ReactiveUI.IViewFor { } + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("PropertyBindingMixins uses RxApp initialization and expression binding which requ" + + "ire dynamic code generation")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("PropertyBindingMixins uses RxApp initialization and expression binding which may " + + "require unreferenced code")] public static ReactiveUI.IReactiveBinding OneWayBind(this TView view, TViewModel? viewModel, System.Linq.Expressions.Expression> vmProperty, System.Linq.Expressions.Expression> viewProperty, object? conversionHint = null, ReactiveUI.IBindingTypeConverter? vmToViewConverterOverride = null) where TViewModel : class where TView : class, ReactiveUI.IViewFor { } @@ -1016,74 +1026,59 @@ namespace ReactiveUI public override System.IObservable Execute(TParam parameter) { } public override System.IDisposable Subscribe(System.IObserver observer) { } } - [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("ReactiveNotifyPropertyChangedMixin uses RxApp which requires dynamic code generat" + - "ion")] - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("ReactiveNotifyPropertyChangedMixin uses RxApp which may require unreferenced code")] public static class ReactiveNotifyPropertyChangedMixin { - [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("ObservableForProperty uses expression analysis which requires dynamic code genera" + - "tion")] - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("ObservableForProperty may reference properties that could be trimmed")] + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("This method uses reflection to access properties by name.")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("This method uses reflection to access properties by name.")] public static System.IObservable> ObservableForProperty(this TSender? item, System.Linq.Expressions.Expression> property) { } - [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("ObservableForProperty uses expression analysis which requires dynamic code genera" + - "tion")] - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("ObservableForProperty may reference properties that could be trimmed")] + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("This method uses reflection to access properties by name.")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("This method uses reflection to access properties by name.")] public static System.IObservable> ObservableForProperty(this TSender? item, string propertyName) { } - [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("ObservableForProperty uses expression analysis which requires dynamic code genera" + - "tion")] - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("ObservableForProperty may reference properties that could be trimmed")] + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("This method uses reflection to access properties by name.")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("This method uses reflection to access properties by name.")] public static System.IObservable> ObservableForProperty(this TSender? item, System.Linq.Expressions.Expression> property, bool beforeChange) { } - [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("ObservableForProperty uses expression analysis which requires dynamic code genera" + - "tion")] - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("ObservableForProperty may reference properties that could be trimmed")] + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("This method uses reflection to access properties by name.")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("This method uses reflection to access properties by name.")] public static System.IObservable> ObservableForProperty(this TSender? item, string propertyName, bool beforeChange) { } - [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("ObservableForProperty uses expression analysis which requires dynamic code genera" + - "tion")] - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("ObservableForProperty may reference properties that could be trimmed")] + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("This method uses reflection to access properties by name.")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("This method uses reflection to access properties by name.")] public static System.IObservable> ObservableForProperty(this TSender? item, System.Linq.Expressions.Expression> property, bool beforeChange, bool skipInitial) { } - [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("ObservableForProperty uses expression analysis which requires dynamic code genera" + - "tion")] - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("ObservableForProperty may reference properties that could be trimmed")] + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("This method uses reflection to access properties by name.")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("This method uses reflection to access properties by name.")] public static System.IObservable> ObservableForProperty(this TSender? item, string propertyName, bool beforeChange, bool skipInitial) { } - [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("ObservableForProperty uses expression analysis which requires dynamic code genera" + - "tion")] - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("ObservableForProperty may reference properties that could be trimmed")] + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("This method uses reflection to access properties by name.")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("This method uses reflection to access properties by name.")] public static System.IObservable> ObservableForProperty(this TSender? item, System.Linq.Expressions.Expression> property, bool beforeChange, bool skipInitial, bool isDistinct) { } - [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("ObservableForProperty uses expression analysis which requires dynamic code genera" + - "tion")] - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("ObservableForProperty may reference properties that could be trimmed")] + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("This method uses reflection to access properties by name.")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("This method uses reflection to access properties by name.")] public static System.IObservable> ObservableForProperty(this TSender? item, string propertyName, bool beforeChange, bool skipInitial, bool isDistinct) { } - [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("NotifyForProperty uses expression analysis which requires dynamic code generation")] - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("NotifyForProperty may reference properties that could be trimmed")] + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("This method uses reflection to access properties by name.")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("This method uses reflection to access properties by name.")] public static System.IObservable ObservableForProperty(this TSender? item, System.Linq.Expressions.Expression> property, System.Func selector) where TSender : class { } - [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("NotifyForProperty uses expression analysis which requires dynamic code generation")] - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("NotifyForProperty may reference properties that could be trimmed")] + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("This method uses reflection to access properties by name.")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("This method uses reflection to access properties by name.")] public static System.IObservable ObservableForProperty(this TSender? item, System.Linq.Expressions.Expression> property, System.Func selector, bool beforeChange) where TSender : class { } - [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("NotifyForProperty uses expression analysis which requires dynamic code generation")] - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("NotifyForProperty may reference properties that could be trimmed")] + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("This method uses reflection to access properties by name.")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("This method uses reflection to access properties by name.")] public static System.IObservable> SubscribeToExpressionChain(this TSender? source, System.Linq.Expressions.Expression? expression) { } - [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("NotifyForProperty uses expression analysis which requires dynamic code generation")] - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("NotifyForProperty may reference properties that could be trimmed")] + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("This method uses reflection to access properties by name.")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("This method uses reflection to access properties by name.")] public static System.IObservable> SubscribeToExpressionChain(this TSender? source, System.Linq.Expressions.Expression? expression, bool beforeChange) { } - [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("NotifyForProperty uses expression analysis which requires dynamic code generation")] - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("NotifyForProperty may reference properties that could be trimmed")] + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("This method uses reflection to access properties by name.")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("This method uses reflection to access properties by name.")] public static System.IObservable> SubscribeToExpressionChain(this TSender? source, System.Linq.Expressions.Expression? expression, bool beforeChange, bool skipInitial) { } - [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("SubscribeToExpressionChain uses expression analysis which requires dynamic code g" + - "eneration")] - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("SubscribeToExpressionChain may reference properties that could be trimmed")] + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("This method uses reflection to access properties by name.")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("This method uses reflection to access properties by name.")] public static System.IObservable> SubscribeToExpressionChain(this TSender? source, System.Linq.Expressions.Expression? expression, bool beforeChange, bool skipInitial, bool suppressWarnings) { } - [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("SubscribeToExpressionChain uses expression analysis which requires dynamic code g" + - "eneration")] - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("SubscribeToExpressionChain may reference properties that could be trimmed")] + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("This method uses reflection to access properties by name.")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("This method uses reflection to access properties by name.")] public static System.IObservable> SubscribeToExpressionChain(this TSender? source, System.Linq.Expressions.Expression? expression, bool beforeChange, bool skipInitial, bool suppressWarnings, bool isDistinct) { } } [System.Runtime.Serialization.DataContract] public class ReactiveObject : ReactiveUI.IHandleObservableErrors, ReactiveUI.IReactiveNotifyPropertyChanged, ReactiveUI.IReactiveObject, Splat.IEnableLogger, System.ComponentModel.INotifyPropertyChanged, System.ComponentModel.INotifyPropertyChanging { - [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("ReactiveObject uses extension methods that require dynamic code generation")] - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("ReactiveObject uses extension methods that may require unreferenced code")] public ReactiveObject() { } [System.ComponentModel.Browsable(false)] [System.ComponentModel.DataAnnotations.Display(AutoGenerateField=false, AutoGenerateFilter=false, Order=-1)] @@ -1102,20 +1097,10 @@ namespace ReactiveUI public System.IObservable ThrownExceptions { get; } public event System.ComponentModel.PropertyChangedEventHandler? PropertyChanged; public event System.ComponentModel.PropertyChangingEventHandler? PropertyChanging; - [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("AreChangeNotificationsEnabled uses extension methods that require dynamic code ge" + - "neration")] - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("AreChangeNotificationsEnabled uses extension methods that may require unreference" + - "d code")] public bool AreChangeNotificationsEnabled() { } - [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("DelayChangeNotifications uses extension methods that require dynamic code generat" + - "ion")] - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("DelayChangeNotifications uses extension methods that may require unreferenced cod" + - "e")] public System.IDisposable DelayChangeNotifications() { } - [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("SuppressChangeNotifications uses extension methods that require dynamic code gene" + - "ration")] - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("SuppressChangeNotifications uses extension methods that may require unreferenced " + - "code")] + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("This method uses reflection to access properties by name.")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("This method uses reflection to access properties by name.")] public System.IDisposable SuppressChangeNotifications() { } } public class ReactivePropertyChangedEventArgs : System.ComponentModel.PropertyChangedEventArgs, ReactiveUI.IReactivePropertyChangedEventArgs @@ -1233,37 +1218,27 @@ namespace ReactiveUI "code")] public System.IDisposable SuppressChangeNotifications() { } } - [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Expression rewriting requires dynamic code generation")] - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Expression rewriting may reference members that could be trimmed")] public static class Reflection { [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Expression tree analysis requires dynamic code generation")] [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Expression tree analysis may reference members that could be trimmed")] public static string ExpressionToPropertyNames(System.Linq.Expressions.Expression? expression) { } - [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Event reflection requires dynamic code generation")] - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Event reflection may reference members that could be trimmed")] - public static System.Type GetEventArgsTypeForEvent(System.Type type, string? eventName) { } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Event access may reference members that could be trimmed")] + public static System.Type GetEventArgsTypeForEvent([System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All)] System.Type type, string? eventName) { } [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Member access requires dynamic code generation")] [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Member access may reference members that could be trimmed")] public static System.Func? GetValueFetcherForProperty(System.Reflection.MemberInfo? member) { } [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Member access requires dynamic code generation")] [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Member access may reference members that could be trimmed")] public static System.Func GetValueFetcherOrThrow(System.Reflection.MemberInfo? member) { } - [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Member access requires dynamic code generation")] - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Member access may reference members that could be trimmed")] public static System.Action GetValueSetterForProperty(System.Reflection.MemberInfo? member) { } [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Member access requires dynamic code generation")] [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Member access may reference members that could be trimmed")] public static System.Action? GetValueSetterOrThrow(System.Reflection.MemberInfo? member) { } public static bool IsStatic(this System.Reflection.PropertyInfo item) { } - [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Type resolution requires dynamic code generation")] - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Type resolution may reference types that could be trimmed")] public static System.Type? ReallyFindType(string? type, bool throwOnFailure) { } - [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Expression rewriting requires dynamic code generation")] - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Expression rewriting may reference members that could be trimmed")] public static System.Linq.Expressions.Expression Rewrite(System.Linq.Expressions.Expression? expression) { } - [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Method reflection requires dynamic code generation")] - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Method reflection may reference members that could be trimmed")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Method access may reference members that could be trimmed")] public static void ThrowIfMethodsNotOverloaded(string callingTypeName, object targetObject, params string[] methodsToCheck) { } [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Expression evaluation requires dynamic code generation")] [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Expression evaluation may reference members that could be trimmed")] @@ -1334,10 +1309,6 @@ namespace ReactiveUI where T : ReactiveUI.IRoutableViewModel { } public static ReactiveUI.IRoutableViewModel? GetCurrentViewModel(this ReactiveUI.RoutingState item) { } } - [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("RxApp initialization uses reflection-based registration which requires dynamic co" + - "de generation.")] - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("RxApp initialization uses reflection-based registration which may require unrefer" + - "enced code.")] public static class RxApp { public const int BigCacheLimit = 256; @@ -1421,17 +1392,25 @@ namespace ReactiveUI public ViewContractAttribute(string contract) { } public string Contract { get; } } - [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("ViewForMixins uses methods that require dynamic code generation")] - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("ViewForMixins uses methods that may require unreferenced code")] public static class ViewForMixins { + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("WhenActivated uses reflection which requires dynamic code generation")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("WhenActivated may reference types that could be trimmed")] public static System.IDisposable WhenActivated(this ReactiveUI.IActivatableView item, System.Action> block) { } + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("WhenActivated uses reflection which requires dynamic code generation")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("WhenActivated may reference types that could be trimmed")] public static System.IDisposable WhenActivated(this ReactiveUI.IActivatableView item, System.Func> block) { } public static void WhenActivated(this ReactiveUI.IActivatableViewModel item, System.Action> block) { } public static void WhenActivated(this ReactiveUI.IActivatableViewModel item, System.Action block) { } public static void WhenActivated(this ReactiveUI.IActivatableViewModel item, System.Func> block) { } + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("WhenActivated uses reflection which requires dynamic code generation")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("WhenActivated may reference types that could be trimmed")] public static System.IDisposable WhenActivated(this ReactiveUI.IActivatableView item, System.Action> block, ReactiveUI.IViewFor view) { } + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("WhenActivated uses reflection which requires dynamic code generation")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("WhenActivated may reference types that could be trimmed")] public static System.IDisposable WhenActivated(this ReactiveUI.IActivatableView item, System.Action block, ReactiveUI.IViewFor? view = null) { } + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("WhenActivated uses reflection which requires dynamic code generation")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("WhenActivated may reference types that could be trimmed")] public static System.IDisposable WhenActivated(this ReactiveUI.IActivatableView item, System.Func> block, ReactiveUI.IViewFor? view) { } } public static class ViewLocator @@ -2177,48 +2156,78 @@ namespace ReactiveUI } namespace ReactiveUI.Builder { - public static class MultiPlatformReactiveUIBuilderExtensions + public interface IReactiveUIBuilder : Splat.Builder.IAppBuilder + { + ReactiveUI.Builder.IReactiveUIBuilder ConfigureMessageBus(System.Action configure); + ReactiveUI.Builder.IReactiveUIBuilder ConfigureSuspensionDriver(System.Action configure); + ReactiveUI.Builder.IReactiveUIBuilder ConfigureViewLocator(System.Action configure); + ReactiveUI.Builder.IReactiveUIBuilder ForCustomPlatform(System.Reactive.Concurrency.IScheduler mainThreadScheduler, System.Action platformServices); + ReactiveUI.Builder.IReactiveUIBuilder ForPlatforms(params System.Action[] platformConfigurations); + ReactiveUI.Builder.IReactiveUIBuilder RegisterSingletonView() + where TView : class, ReactiveUI.IViewFor, new () + where TViewModel : class, ReactiveUI.IReactiveObject; + ReactiveUI.Builder.IReactiveUIBuilder RegisterSingletonViewModel<[System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All)] TViewModel>() + where TViewModel : class, ReactiveUI.IReactiveObject, new (); + ReactiveUI.Builder.IReactiveUIBuilder RegisterView() + where TView : class, ReactiveUI.IViewFor, new () + where TViewModel : class, ReactiveUI.IReactiveObject; + ReactiveUI.Builder.IReactiveUIBuilder RegisterViewModel() + where TViewModel : class, ReactiveUI.IReactiveObject, new (); + ReactiveUI.Builder.IReactiveUIBuilder UsingSplatModule(T registrationModule) + where T : Splat.Builder.IModule; + ReactiveUI.Builder.IReactiveUIBuilder WithMainThreadScheduler(System.Reactive.Concurrency.IScheduler scheduler, bool setRxApp = true); + ReactiveUI.Builder.IReactiveUIBuilder WithPlatformModule() + where T : ReactiveUI.IWantsToRegisterStuff, new (); + ReactiveUI.Builder.IReactiveUIBuilder WithPlatformServices(); + ReactiveUI.Builder.IReactiveUIBuilder WithRegistration(System.Action configureAction); + ReactiveUI.Builder.IReactiveUIBuilder WithRegistrationOnBuild(System.Action configureAction); + ReactiveUI.Builder.IReactiveUIBuilder WithTaskPoolScheduler(System.Reactive.Concurrency.IScheduler scheduler, bool setRxApp = true); + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("The method uses reflection and will not work in AOT environments.")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The method uses reflection and will not work in AOT environments.")] + ReactiveUI.Builder.IReactiveUIBuilder WithViewsFromAssembly(System.Reflection.Assembly assembly); + } + public interface IReactiveUIInstance : Splat.Builder.IAppInstance { - public static ReactiveUI.Builder.ReactiveUIBuilder ForCustomPlatform(this ReactiveUI.Builder.ReactiveUIBuilder builder, System.Reactive.Concurrency.IScheduler mainThreadScheduler, System.Action platformServices) { } - public static ReactiveUI.Builder.ReactiveUIBuilder ForPlatforms(this ReactiveUI.Builder.ReactiveUIBuilder builder, params System.Action[] platformConfigurations) { } + System.Reactive.Concurrency.IScheduler? MainThreadScheduler { get; } + System.Reactive.Concurrency.IScheduler? TaskpoolScheduler { get; } } - public sealed class ReactiveUIBuilder : Splat.Builder.AppBuilder + public sealed class ReactiveUIBuilder : Splat.Builder.AppBuilder, ReactiveUI.Builder.IReactiveUIBuilder, ReactiveUI.Builder.IReactiveUIInstance, Splat.Builder.IAppBuilder, Splat.Builder.IAppInstance { - public ReactiveUIBuilder(Splat.IMutableDependencyResolver resolver) { } - [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("ReactiveUI uses reflection to register some services. Ensure that the necessary t" + - "ypes are preserved.")] - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("ReactiveUI uses reflection to register some services. Ensure that the necessary t" + - "ypes are preserved.")] - public override Splat.Builder.AppBuilder WithCoreServices() { } - public ReactiveUI.Builder.ReactiveUIBuilder WithMainThreadScheduler(System.Reactive.Concurrency.IScheduler scheduler) { } - public ReactiveUI.Builder.ReactiveUIBuilder WithPlatformModule() + public ReactiveUIBuilder(Splat.IMutableDependencyResolver resolver, Splat.IReadonlyDependencyResolver? current) { } + public System.Reactive.Concurrency.IScheduler? MainThreadScheduler { get; } + public System.Reactive.Concurrency.IScheduler? TaskpoolScheduler { get; } + public ReactiveUI.Builder.IReactiveUIBuilder ConfigureMessageBus(System.Action configure) { } + public ReactiveUI.Builder.IReactiveUIBuilder ConfigureSuspensionDriver(System.Action configure) { } + public ReactiveUI.Builder.IReactiveUIBuilder ConfigureViewLocator(System.Action configure) { } + public ReactiveUI.Builder.IReactiveUIBuilder ForCustomPlatform(System.Reactive.Concurrency.IScheduler mainThreadScheduler, System.Action platformServices) { } + public ReactiveUI.Builder.IReactiveUIBuilder ForPlatforms(params System.Action[] platformConfigurations) { } + public ReactiveUI.Builder.IReactiveUIBuilder RegisterSingletonView() + where TView : class, ReactiveUI.IViewFor, new () + where TViewModel : class, ReactiveUI.IReactiveObject { } + public ReactiveUI.Builder.IReactiveUIBuilder RegisterSingletonViewModel<[System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All)] TViewModel>() + where TViewModel : class, ReactiveUI.IReactiveObject, new () { } + public ReactiveUI.Builder.IReactiveUIBuilder RegisterView() + where TView : class, ReactiveUI.IViewFor, new () + where TViewModel : class, ReactiveUI.IReactiveObject { } + public ReactiveUI.Builder.IReactiveUIBuilder RegisterViewModel() + where TViewModel : class, ReactiveUI.IReactiveObject, new () { } + public ReactiveUI.Builder.IReactiveUIBuilder UsingSplatModule(T registrationModule) + where T : Splat.Builder.IModule { } + public override Splat.Builder.IAppBuilder WithCoreServices() { } + public ReactiveUI.Builder.IReactiveUIBuilder WithMainThreadScheduler(System.Reactive.Concurrency.IScheduler scheduler, bool setRxApp = true) { } + public ReactiveUI.Builder.IReactiveUIBuilder WithPlatformModule() where T : ReactiveUI.IWantsToRegisterStuff, new () { } - public ReactiveUI.Builder.ReactiveUIBuilder WithPlatformServices() { } - public ReactiveUI.Builder.ReactiveUIBuilder WithRegistration(System.Action configureAction) { } - public ReactiveUI.Builder.ReactiveUIBuilder WithRegistrationOnBuild(System.Action configureAction) { } - public ReactiveUI.Builder.ReactiveUIBuilder WithTaskPoolScheduler(System.Reactive.Concurrency.IScheduler scheduler) { } + public ReactiveUI.Builder.IReactiveUIBuilder WithPlatformServices() { } + public ReactiveUI.Builder.IReactiveUIBuilder WithRegistration(System.Action configureAction) { } + public ReactiveUI.Builder.IReactiveUIBuilder WithRegistrationOnBuild(System.Action configureAction) { } + public ReactiveUI.Builder.IReactiveUIBuilder WithTaskPoolScheduler(System.Reactive.Concurrency.IScheduler scheduler, bool setRxApp = true) { } [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("The method uses reflection and will not work in AOT environments.")] [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The method uses reflection and will not work in AOT environments.")] - public ReactiveUI.Builder.ReactiveUIBuilder WithViewsFromAssembly(System.Reflection.Assembly assembly) { } + public ReactiveUI.Builder.IReactiveUIBuilder WithViewsFromAssembly(System.Reflection.Assembly assembly) { } } public static class RxAppBuilder { - public static ReactiveUI.Builder.ReactiveUIBuilder ConfigureMessageBus(this ReactiveUI.Builder.ReactiveUIBuilder builder, System.Action configure) { } - public static ReactiveUI.Builder.ReactiveUIBuilder ConfigureSuspensionDriver(this ReactiveUI.Builder.ReactiveUIBuilder builder, System.Action configure) { } - public static ReactiveUI.Builder.ReactiveUIBuilder ConfigureViewLocator(this ReactiveUI.Builder.ReactiveUIBuilder builder, System.Action configure) { } public static ReactiveUI.Builder.ReactiveUIBuilder CreateReactiveUIBuilder() { } public static ReactiveUI.Builder.ReactiveUIBuilder CreateReactiveUIBuilder(this Splat.IMutableDependencyResolver resolver) { } - public static ReactiveUI.Builder.ReactiveUIBuilder RegisterSingletonView(this ReactiveUI.Builder.ReactiveUIBuilder builder) - where TView : class, ReactiveUI.IViewFor, new () - where TViewModel : class, ReactiveUI.IReactiveObject { } - [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("This method uses \'new()\' constraint which may require dynamic code generation.")] - [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("This method uses \'new()\' constraint which may require dynamic code generation.")] - public static ReactiveUI.Builder.ReactiveUIBuilder RegisterSingletonViewModel(this ReactiveUI.Builder.ReactiveUIBuilder builder) - where TViewModel : class, ReactiveUI.IReactiveObject, new () { } - public static ReactiveUI.Builder.ReactiveUIBuilder RegisterView(this ReactiveUI.Builder.ReactiveUIBuilder builder) - where TView : class, ReactiveUI.IViewFor, new () - where TViewModel : class, ReactiveUI.IReactiveObject { } - public static ReactiveUI.Builder.ReactiveUIBuilder RegisterViewModel(this ReactiveUI.Builder.ReactiveUIBuilder builder) - where TViewModel : class, ReactiveUI.IReactiveObject, new () { } } } \ No newline at end of file diff --git a/src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.Net4_7.verified.txt b/src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.Net4_7.verified.txt index 787d5875d8..3bc843cd19 100644 --- a/src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.Net4_7.verified.txt +++ b/src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.Net4_7.verified.txt @@ -1242,40 +1242,74 @@ namespace ReactiveUI } namespace ReactiveUI.Builder { - public static class MultiPlatformReactiveUIBuilderExtensions - { - public static ReactiveUI.Builder.ReactiveUIBuilder ForCustomPlatform(this ReactiveUI.Builder.ReactiveUIBuilder builder, System.Reactive.Concurrency.IScheduler mainThreadScheduler, System.Action platformServices) { } - public static ReactiveUI.Builder.ReactiveUIBuilder ForPlatforms(this ReactiveUI.Builder.ReactiveUIBuilder builder, params System.Action[] platformConfigurations) { } - } - public sealed class ReactiveUIBuilder : Splat.Builder.AppBuilder - { - public ReactiveUIBuilder(Splat.IMutableDependencyResolver resolver) { } - public override Splat.Builder.AppBuilder WithCoreServices() { } - public ReactiveUI.Builder.ReactiveUIBuilder WithMainThreadScheduler(System.Reactive.Concurrency.IScheduler scheduler) { } - public ReactiveUI.Builder.ReactiveUIBuilder WithPlatformModule() - where T : ReactiveUI.IWantsToRegisterStuff, new () { } - public ReactiveUI.Builder.ReactiveUIBuilder WithPlatformServices() { } - public ReactiveUI.Builder.ReactiveUIBuilder WithRegistration(System.Action configureAction) { } - public ReactiveUI.Builder.ReactiveUIBuilder WithRegistrationOnBuild(System.Action configureAction) { } - public ReactiveUI.Builder.ReactiveUIBuilder WithTaskPoolScheduler(System.Reactive.Concurrency.IScheduler scheduler) { } - public ReactiveUI.Builder.ReactiveUIBuilder WithViewsFromAssembly(System.Reflection.Assembly assembly) { } - } - public static class RxAppBuilder - { - public static ReactiveUI.Builder.ReactiveUIBuilder ConfigureMessageBus(this ReactiveUI.Builder.ReactiveUIBuilder builder, System.Action configure) { } - public static ReactiveUI.Builder.ReactiveUIBuilder ConfigureSuspensionDriver(this ReactiveUI.Builder.ReactiveUIBuilder builder, System.Action configure) { } - public static ReactiveUI.Builder.ReactiveUIBuilder ConfigureViewLocator(this ReactiveUI.Builder.ReactiveUIBuilder builder, System.Action configure) { } - public static ReactiveUI.Builder.ReactiveUIBuilder CreateReactiveUIBuilder() { } - public static ReactiveUI.Builder.ReactiveUIBuilder CreateReactiveUIBuilder(this Splat.IMutableDependencyResolver resolver) { } - public static ReactiveUI.Builder.ReactiveUIBuilder RegisterSingletonView(this ReactiveUI.Builder.ReactiveUIBuilder builder) + public interface IReactiveUIBuilder : Splat.Builder.IAppBuilder + { + ReactiveUI.Builder.IReactiveUIBuilder ConfigureMessageBus(System.Action configure); + ReactiveUI.Builder.IReactiveUIBuilder ConfigureSuspensionDriver(System.Action configure); + ReactiveUI.Builder.IReactiveUIBuilder ConfigureViewLocator(System.Action configure); + ReactiveUI.Builder.IReactiveUIBuilder ForCustomPlatform(System.Reactive.Concurrency.IScheduler mainThreadScheduler, System.Action platformServices); + ReactiveUI.Builder.IReactiveUIBuilder ForPlatforms(params System.Action[] platformConfigurations); + ReactiveUI.Builder.IReactiveUIBuilder RegisterSingletonView() + where TView : class, ReactiveUI.IViewFor, new () + where TViewModel : class, ReactiveUI.IReactiveObject; + ReactiveUI.Builder.IReactiveUIBuilder RegisterSingletonViewModel() + where TViewModel : class, ReactiveUI.IReactiveObject, new (); + ReactiveUI.Builder.IReactiveUIBuilder RegisterView() + where TView : class, ReactiveUI.IViewFor, new () + where TViewModel : class, ReactiveUI.IReactiveObject; + ReactiveUI.Builder.IReactiveUIBuilder RegisterViewModel() + where TViewModel : class, ReactiveUI.IReactiveObject, new (); + ReactiveUI.Builder.IReactiveUIBuilder UsingSplatModule(T registrationModule) + where T : Splat.Builder.IModule; + ReactiveUI.Builder.IReactiveUIBuilder WithMainThreadScheduler(System.Reactive.Concurrency.IScheduler scheduler, bool setRxApp = true); + ReactiveUI.Builder.IReactiveUIBuilder WithPlatformModule() + where T : ReactiveUI.IWantsToRegisterStuff, new (); + ReactiveUI.Builder.IReactiveUIBuilder WithPlatformServices(); + ReactiveUI.Builder.IReactiveUIBuilder WithRegistration(System.Action configureAction); + ReactiveUI.Builder.IReactiveUIBuilder WithRegistrationOnBuild(System.Action configureAction); + ReactiveUI.Builder.IReactiveUIBuilder WithTaskPoolScheduler(System.Reactive.Concurrency.IScheduler scheduler, bool setRxApp = true); + ReactiveUI.Builder.IReactiveUIBuilder WithViewsFromAssembly(System.Reflection.Assembly assembly); + } + public interface IReactiveUIInstance : Splat.Builder.IAppInstance + { + System.Reactive.Concurrency.IScheduler? MainThreadScheduler { get; } + System.Reactive.Concurrency.IScheduler? TaskpoolScheduler { get; } + } + public sealed class ReactiveUIBuilder : Splat.Builder.AppBuilder, ReactiveUI.Builder.IReactiveUIBuilder, ReactiveUI.Builder.IReactiveUIInstance, Splat.Builder.IAppBuilder, Splat.Builder.IAppInstance + { + public ReactiveUIBuilder(Splat.IMutableDependencyResolver resolver, Splat.IReadonlyDependencyResolver? current) { } + public System.Reactive.Concurrency.IScheduler? MainThreadScheduler { get; } + public System.Reactive.Concurrency.IScheduler? TaskpoolScheduler { get; } + public ReactiveUI.Builder.IReactiveUIBuilder ConfigureMessageBus(System.Action configure) { } + public ReactiveUI.Builder.IReactiveUIBuilder ConfigureSuspensionDriver(System.Action configure) { } + public ReactiveUI.Builder.IReactiveUIBuilder ConfigureViewLocator(System.Action configure) { } + public ReactiveUI.Builder.IReactiveUIBuilder ForCustomPlatform(System.Reactive.Concurrency.IScheduler mainThreadScheduler, System.Action platformServices) { } + public ReactiveUI.Builder.IReactiveUIBuilder ForPlatforms(params System.Action[] platformConfigurations) { } + public ReactiveUI.Builder.IReactiveUIBuilder RegisterSingletonView() where TView : class, ReactiveUI.IViewFor, new () where TViewModel : class, ReactiveUI.IReactiveObject { } - public static ReactiveUI.Builder.ReactiveUIBuilder RegisterSingletonViewModel(this ReactiveUI.Builder.ReactiveUIBuilder builder) + public ReactiveUI.Builder.IReactiveUIBuilder RegisterSingletonViewModel() where TViewModel : class, ReactiveUI.IReactiveObject, new () { } - public static ReactiveUI.Builder.ReactiveUIBuilder RegisterView(this ReactiveUI.Builder.ReactiveUIBuilder builder) + public ReactiveUI.Builder.IReactiveUIBuilder RegisterView() where TView : class, ReactiveUI.IViewFor, new () where TViewModel : class, ReactiveUI.IReactiveObject { } - public static ReactiveUI.Builder.ReactiveUIBuilder RegisterViewModel(this ReactiveUI.Builder.ReactiveUIBuilder builder) + public ReactiveUI.Builder.IReactiveUIBuilder RegisterViewModel() where TViewModel : class, ReactiveUI.IReactiveObject, new () { } + public ReactiveUI.Builder.IReactiveUIBuilder UsingSplatModule(T registrationModule) + where T : Splat.Builder.IModule { } + public override Splat.Builder.IAppBuilder WithCoreServices() { } + public ReactiveUI.Builder.IReactiveUIBuilder WithMainThreadScheduler(System.Reactive.Concurrency.IScheduler scheduler, bool setRxApp = true) { } + public ReactiveUI.Builder.IReactiveUIBuilder WithPlatformModule() + where T : ReactiveUI.IWantsToRegisterStuff, new () { } + public ReactiveUI.Builder.IReactiveUIBuilder WithPlatformServices() { } + public ReactiveUI.Builder.IReactiveUIBuilder WithRegistration(System.Action configureAction) { } + public ReactiveUI.Builder.IReactiveUIBuilder WithRegistrationOnBuild(System.Action configureAction) { } + public ReactiveUI.Builder.IReactiveUIBuilder WithTaskPoolScheduler(System.Reactive.Concurrency.IScheduler scheduler, bool setRxApp = true) { } + public ReactiveUI.Builder.IReactiveUIBuilder WithViewsFromAssembly(System.Reflection.Assembly assembly) { } + } + public static class RxAppBuilder + { + public static ReactiveUI.Builder.ReactiveUIBuilder CreateReactiveUIBuilder() { } + public static ReactiveUI.Builder.ReactiveUIBuilder CreateReactiveUIBuilder(this Splat.IMutableDependencyResolver resolver) { } } } \ No newline at end of file diff --git a/src/ReactiveUI.Tests/MessageBusTest.cs b/src/ReactiveUI.Tests/MessageBusTest.cs index 8badadb0c8..1c5f053189 100644 --- a/src/ReactiveUI.Tests/MessageBusTest.cs +++ b/src/ReactiveUI.Tests/MessageBusTest.cs @@ -50,6 +50,8 @@ public void MessageBusSmokeTest() [Fact] public void ExplicitSendMessageShouldWorkEvenAfterRegisteringSource() { + Locator.CurrentMutable.InitializeSplat(); + Locator.CurrentMutable.InitializeReactiveUI(); var fixture = new MessageBus(); fixture.RegisterMessageSource(Observable.Never); @@ -135,6 +137,8 @@ public void RegisteringSecondMessageSourceShouldMergeBothSources() [Fact] public void MessageBusThreadingTest() { + Locator.CurrentMutable.InitializeSplat(); + Locator.CurrentMutable.InitializeReactiveUI(); var mb = new MessageBus(); int? listenedThreadId = null; int? otherThreadId = null; diff --git a/src/ReactiveUI.Tests/Platforms/winforms/API/WinformsApiApprovalTests.Winforms.DotNet8_0.verified.txt b/src/ReactiveUI.Tests/Platforms/winforms/API/WinformsApiApprovalTests.Winforms.DotNet8_0.verified.txt index 73e6bba19d..b612feb8c9 100644 --- a/src/ReactiveUI.Tests/Platforms/winforms/API/WinformsApiApprovalTests.Winforms.DotNet8_0.verified.txt +++ b/src/ReactiveUI.Tests/Platforms/winforms/API/WinformsApiApprovalTests.Winforms.DotNet8_0.verified.txt @@ -6,8 +6,8 @@ namespace ReactiveUI.Builder public static class WinFormsReactiveUIBuilderExtensions { public static System.Reactive.Concurrency.IScheduler WinFormsMainThreadScheduler { get; } - public static ReactiveUI.Builder.ReactiveUIBuilder WithWinForms(this ReactiveUI.Builder.ReactiveUIBuilder builder) { } - public static ReactiveUI.Builder.ReactiveUIBuilder WithWinFormsScheduler(this ReactiveUI.Builder.ReactiveUIBuilder builder) { } + public static ReactiveUI.Builder.IReactiveUIBuilder WithWinForms(this ReactiveUI.Builder.IReactiveUIBuilder builder) { } + public static ReactiveUI.Builder.IReactiveUIBuilder WithWinFormsScheduler(this ReactiveUI.Builder.IReactiveUIBuilder builder) { } } } namespace ReactiveUI.Winforms diff --git a/src/ReactiveUI.Tests/Platforms/winforms/API/WinformsApiApprovalTests.Winforms.DotNet9_0.verified.txt b/src/ReactiveUI.Tests/Platforms/winforms/API/WinformsApiApprovalTests.Winforms.DotNet9_0.verified.txt index 36e6f94b61..b3628e10da 100644 --- a/src/ReactiveUI.Tests/Platforms/winforms/API/WinformsApiApprovalTests.Winforms.DotNet9_0.verified.txt +++ b/src/ReactiveUI.Tests/Platforms/winforms/API/WinformsApiApprovalTests.Winforms.DotNet9_0.verified.txt @@ -6,8 +6,8 @@ namespace ReactiveUI.Builder public static class WinFormsReactiveUIBuilderExtensions { public static System.Reactive.Concurrency.IScheduler WinFormsMainThreadScheduler { get; } - public static ReactiveUI.Builder.ReactiveUIBuilder WithWinForms(this ReactiveUI.Builder.ReactiveUIBuilder builder) { } - public static ReactiveUI.Builder.ReactiveUIBuilder WithWinFormsScheduler(this ReactiveUI.Builder.ReactiveUIBuilder builder) { } + public static ReactiveUI.Builder.IReactiveUIBuilder WithWinForms(this ReactiveUI.Builder.IReactiveUIBuilder builder) { } + public static ReactiveUI.Builder.IReactiveUIBuilder WithWinFormsScheduler(this ReactiveUI.Builder.IReactiveUIBuilder builder) { } } } namespace ReactiveUI.Winforms diff --git a/src/ReactiveUI.Tests/Platforms/winforms/API/WinformsApiApprovalTests.Winforms.Net4_7.verified.txt b/src/ReactiveUI.Tests/Platforms/winforms/API/WinformsApiApprovalTests.Winforms.Net4_7.verified.txt index 9ad8265cca..07a25cafc1 100644 --- a/src/ReactiveUI.Tests/Platforms/winforms/API/WinformsApiApprovalTests.Winforms.Net4_7.verified.txt +++ b/src/ReactiveUI.Tests/Platforms/winforms/API/WinformsApiApprovalTests.Winforms.Net4_7.verified.txt @@ -4,8 +4,8 @@ namespace ReactiveUI.Builder public static class WinFormsReactiveUIBuilderExtensions { public static System.Reactive.Concurrency.IScheduler WinFormsMainThreadScheduler { get; } - public static ReactiveUI.Builder.ReactiveUIBuilder WithWinForms(this ReactiveUI.Builder.ReactiveUIBuilder builder) { } - public static ReactiveUI.Builder.ReactiveUIBuilder WithWinFormsScheduler(this ReactiveUI.Builder.ReactiveUIBuilder builder) { } + public static ReactiveUI.Builder.IReactiveUIBuilder WithWinForms(this ReactiveUI.Builder.IReactiveUIBuilder builder) { } + public static ReactiveUI.Builder.IReactiveUIBuilder WithWinFormsScheduler(this ReactiveUI.Builder.IReactiveUIBuilder builder) { } } } namespace ReactiveUI.Winforms diff --git a/src/ReactiveUI.Tests/Platforms/wpf/API/WpfApiApprovalTests.Wpf.DotNet8_0.verified.txt b/src/ReactiveUI.Tests/Platforms/wpf/API/WpfApiApprovalTests.Wpf.DotNet8_0.verified.txt index 05e43e887c..6b2b4a4c37 100644 --- a/src/ReactiveUI.Tests/Platforms/wpf/API/WpfApiApprovalTests.Wpf.DotNet8_0.verified.txt +++ b/src/ReactiveUI.Tests/Platforms/wpf/API/WpfApiApprovalTests.Wpf.DotNet8_0.verified.txt @@ -163,8 +163,8 @@ namespace ReactiveUI.Builder public static class WpfReactiveUIBuilderExtensions { public static System.Reactive.Concurrency.IScheduler WpfMainThreadScheduler { get; } - public static ReactiveUI.Builder.ReactiveUIBuilder WithWpf(this ReactiveUI.Builder.ReactiveUIBuilder builder) { } - public static ReactiveUI.Builder.ReactiveUIBuilder WithWpfScheduler(this ReactiveUI.Builder.ReactiveUIBuilder builder) { } + public static ReactiveUI.Builder.IReactiveUIBuilder WithWpf(this ReactiveUI.Builder.IReactiveUIBuilder builder) { } + public static ReactiveUI.Builder.IReactiveUIBuilder WithWpfScheduler(this ReactiveUI.Builder.IReactiveUIBuilder builder) { } } } namespace ReactiveUI.Wpf diff --git a/src/ReactiveUI.Tests/Platforms/wpf/API/WpfApiApprovalTests.Wpf.DotNet9_0.verified.txt b/src/ReactiveUI.Tests/Platforms/wpf/API/WpfApiApprovalTests.Wpf.DotNet9_0.verified.txt index 871af41e14..67bb556200 100644 --- a/src/ReactiveUI.Tests/Platforms/wpf/API/WpfApiApprovalTests.Wpf.DotNet9_0.verified.txt +++ b/src/ReactiveUI.Tests/Platforms/wpf/API/WpfApiApprovalTests.Wpf.DotNet9_0.verified.txt @@ -163,8 +163,8 @@ namespace ReactiveUI.Builder public static class WpfReactiveUIBuilderExtensions { public static System.Reactive.Concurrency.IScheduler WpfMainThreadScheduler { get; } - public static ReactiveUI.Builder.ReactiveUIBuilder WithWpf(this ReactiveUI.Builder.ReactiveUIBuilder builder) { } - public static ReactiveUI.Builder.ReactiveUIBuilder WithWpfScheduler(this ReactiveUI.Builder.ReactiveUIBuilder builder) { } + public static ReactiveUI.Builder.IReactiveUIBuilder WithWpf(this ReactiveUI.Builder.IReactiveUIBuilder builder) { } + public static ReactiveUI.Builder.IReactiveUIBuilder WithWpfScheduler(this ReactiveUI.Builder.IReactiveUIBuilder builder) { } } } namespace ReactiveUI.Wpf diff --git a/src/ReactiveUI.Tests/Platforms/wpf/API/WpfApiApprovalTests.Wpf.Net4_7.verified.txt b/src/ReactiveUI.Tests/Platforms/wpf/API/WpfApiApprovalTests.Wpf.Net4_7.verified.txt index 7583f7bb45..21db112e38 100644 --- a/src/ReactiveUI.Tests/Platforms/wpf/API/WpfApiApprovalTests.Wpf.Net4_7.verified.txt +++ b/src/ReactiveUI.Tests/Platforms/wpf/API/WpfApiApprovalTests.Wpf.Net4_7.verified.txt @@ -141,8 +141,8 @@ namespace ReactiveUI.Builder public static class WpfReactiveUIBuilderExtensions { public static System.Reactive.Concurrency.IScheduler WpfMainThreadScheduler { get; } - public static ReactiveUI.Builder.ReactiveUIBuilder WithWpf(this ReactiveUI.Builder.ReactiveUIBuilder builder) { } - public static ReactiveUI.Builder.ReactiveUIBuilder WithWpfScheduler(this ReactiveUI.Builder.ReactiveUIBuilder builder) { } + public static ReactiveUI.Builder.IReactiveUIBuilder WithWpf(this ReactiveUI.Builder.IReactiveUIBuilder builder) { } + public static ReactiveUI.Builder.IReactiveUIBuilder WithWpfScheduler(this ReactiveUI.Builder.IReactiveUIBuilder builder) { } } } namespace ReactiveUI.Wpf diff --git a/src/ReactiveUI.Tests/Routing/RoutedViewHostTests.cs b/src/ReactiveUI.Tests/Routing/RoutedViewHostTests.cs index c5e611aa6e..b558efa4c3 100644 --- a/src/ReactiveUI.Tests/Routing/RoutedViewHostTests.cs +++ b/src/ReactiveUI.Tests/Routing/RoutedViewHostTests.cs @@ -16,6 +16,8 @@ public class RoutedViewHostTests [StaFact] public void RoutedViewHostDefaultContentNotNull() { + Locator.CurrentMutable.InitializeSplat(); + Locator.CurrentMutable.InitializeReactiveUI(); var uc = new RoutedViewHost { DefaultContent = new System.Windows.Controls.Label() @@ -48,6 +50,8 @@ public void RoutedViewHostDefaultContentNotNull() [StaFact] public void RoutedViewHostDefaultContentNotNullWithViewModelAndActivated() { + Locator.CurrentMutable.InitializeSplat(); + Locator.CurrentMutable.InitializeReactiveUI(); Locator.CurrentMutable.Register(() => new()); Locator.CurrentMutable.Register(() => new()); Locator.CurrentMutable.Register>(() => new TestView()); @@ -90,6 +94,8 @@ public void RoutedViewHostDefaultContentNotNullWithViewModelAndActivated() [StaFact] public void RoutedViewHostDefaultContentNotNullWithViewModelAndNotActivated() { + Locator.CurrentMutable.InitializeSplat(); + Locator.CurrentMutable.InitializeReactiveUI(); Locator.CurrentMutable.Register(() => new()); Locator.CurrentMutable.Register(() => new()); Locator.CurrentMutable.Register>(() => new TestView()); diff --git a/src/ReactiveUI.WinUI/Builder/WinUIReactiveUIBuilderExtensions.cs b/src/ReactiveUI.WinUI/Builder/WinUIReactiveUIBuilderExtensions.cs index 5b9a306ea1..680a1c3eb2 100644 --- a/src/ReactiveUI.WinUI/Builder/WinUIReactiveUIBuilderExtensions.cs +++ b/src/ReactiveUI.WinUI/Builder/WinUIReactiveUIBuilderExtensions.cs @@ -23,7 +23,7 @@ public static class WinUIReactiveUIBuilderExtensions /// /// The builder instance. /// The builder instance for chaining. - public static ReactiveUIBuilder WithWinUI(this ReactiveUIBuilder builder) + public static IReactiveUIBuilder WithWinUI(this IReactiveUIBuilder builder) { if (builder is null) { @@ -40,7 +40,7 @@ public static ReactiveUIBuilder WithWinUI(this ReactiveUIBuilder builder) /// /// The builder. /// The builder instance for chaining. - public static ReactiveUIBuilder WithWinUIScheduler(this ReactiveUIBuilder builder) + public static IReactiveUIBuilder WithWinUIScheduler(this IReactiveUIBuilder builder) { if (builder is null) { diff --git a/src/ReactiveUI.WinUI/ReactiveUI.WinUI.csproj b/src/ReactiveUI.WinUI/ReactiveUI.WinUI.csproj index 0e0fd0528e..f63c0c7da3 100644 --- a/src/ReactiveUI.WinUI/ReactiveUI.WinUI.csproj +++ b/src/ReactiveUI.WinUI/ReactiveUI.WinUI.csproj @@ -18,6 +18,7 @@ + diff --git a/src/ReactiveUI.Winforms/Builder/WinFormsReactiveUIBuilderExtensions.cs b/src/ReactiveUI.Winforms/Builder/WinFormsReactiveUIBuilderExtensions.cs index ce675c96f0..139faeceae 100644 --- a/src/ReactiveUI.Winforms/Builder/WinFormsReactiveUIBuilderExtensions.cs +++ b/src/ReactiveUI.Winforms/Builder/WinFormsReactiveUIBuilderExtensions.cs @@ -23,7 +23,7 @@ public static class WinFormsReactiveUIBuilderExtensions /// /// The builder instance. /// The builder instance for chaining. - public static ReactiveUIBuilder WithWinForms(this ReactiveUIBuilder builder) + public static IReactiveUIBuilder WithWinForms(this IReactiveUIBuilder builder) { if (builder is null) { @@ -40,7 +40,7 @@ public static ReactiveUIBuilder WithWinForms(this ReactiveUIBuilder builder) /// /// The builder. /// The builder instance for chaining. - public static ReactiveUIBuilder WithWinFormsScheduler(this ReactiveUIBuilder builder) + public static IReactiveUIBuilder WithWinFormsScheduler(this IReactiveUIBuilder builder) { if (builder is null) { diff --git a/src/ReactiveUI.Winforms/ReactiveUI.Winforms.csproj b/src/ReactiveUI.Winforms/ReactiveUI.Winforms.csproj index 8a2160ba4a..7ade4470e4 100644 --- a/src/ReactiveUI.Winforms/ReactiveUI.Winforms.csproj +++ b/src/ReactiveUI.Winforms/ReactiveUI.Winforms.csproj @@ -17,6 +17,7 @@ + diff --git a/src/ReactiveUI.Wpf/Builder/WpfReactiveUIBuilderExtensions.cs b/src/ReactiveUI.Wpf/Builder/WpfReactiveUIBuilderExtensions.cs index 1b0dc6142f..d33b70ab87 100644 --- a/src/ReactiveUI.Wpf/Builder/WpfReactiveUIBuilderExtensions.cs +++ b/src/ReactiveUI.Wpf/Builder/WpfReactiveUIBuilderExtensions.cs @@ -23,7 +23,7 @@ public static class WpfReactiveUIBuilderExtensions /// /// The builder instance. /// The builder instance for chaining. - public static ReactiveUIBuilder WithWpf(this ReactiveUIBuilder builder) + public static IReactiveUIBuilder WithWpf(this IReactiveUIBuilder builder) { if (builder is null) { @@ -41,7 +41,7 @@ public static ReactiveUIBuilder WithWpf(this ReactiveUIBuilder builder) /// /// The builder. /// The builder instance for chaining. - public static ReactiveUIBuilder WithWpfScheduler(this ReactiveUIBuilder builder) + public static IReactiveUIBuilder WithWpfScheduler(this IReactiveUIBuilder builder) { if (builder is null) { diff --git a/src/ReactiveUI.Wpf/ReactiveUI.Wpf.csproj b/src/ReactiveUI.Wpf/ReactiveUI.Wpf.csproj index 97f5dcfeb4..a155a4a2ff 100644 --- a/src/ReactiveUI.Wpf/ReactiveUI.Wpf.csproj +++ b/src/ReactiveUI.Wpf/ReactiveUI.Wpf.csproj @@ -13,6 +13,7 @@ + diff --git a/src/ReactiveUI.sln b/src/ReactiveUI.sln index 2340397a77..d7defa261f 100644 --- a/src/ReactiveUI.sln +++ b/src/ReactiveUI.sln @@ -11,6 +11,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Directory.Packages.props = Directory.Packages.props global.json = global.json stylecop.json = stylecop.json + tests.runsettings = tests.runsettings ..\version.json = ..\version.json EndProjectSection EndProject diff --git a/src/ReactiveUI/Activation/ViewForMixins.cs b/src/ReactiveUI/Activation/ViewForMixins.cs index c466e7b32d..6094bec6c6 100644 --- a/src/ReactiveUI/Activation/ViewForMixins.cs +++ b/src/ReactiveUI/Activation/ViewForMixins.cs @@ -10,10 +10,6 @@ namespace ReactiveUI; /// /// A set of extension methods to help wire up View and ViewModel activation. /// -#if NET6_0_OR_GREATER -[RequiresDynamicCode("ViewForMixins uses methods that require dynamic code generation")] -[RequiresUnreferencedCode("ViewForMixins uses methods that may require unreferenced code")] -#endif public static class ViewForMixins { private static readonly MemoizingMRUCache _activationFetcherCache = @@ -88,7 +84,7 @@ public static void WhenActivated(this IActivatableViewModel item, Action /// A Disposable that deactivates this registration. +#if NET6_0_OR_GREATER + [RequiresUnreferencedCode("WhenActivated may reference types that could be trimmed")] + [RequiresDynamicCode("WhenActivated uses reflection which requires dynamic code generation")] +#endif public static IDisposable WhenActivated(this IActivatableView item, Func> block) // TODO: Create Test { item.ArgumentNullExceptionThrowIfNull(nameof(item)); @@ -126,6 +126,10 @@ public static IDisposable WhenActivated(this IActivatableView item, Func /// A Disposable that deactivates this registration. +#if NET6_0_OR_GREATER + [RequiresUnreferencedCode("WhenActivated may reference types that could be trimmed")] + [RequiresDynamicCode("WhenActivated uses reflection which requires dynamic code generation")] +#endif public static IDisposable WhenActivated(this IActivatableView item, Func> block, IViewFor? view) // TODO: Create Test { item.ArgumentNullExceptionThrowIfNull(nameof(item)); @@ -161,7 +165,12 @@ public static IDisposable WhenActivated(this IActivatableView item, Func /// A Disposable that deactivates this registration. - public static IDisposable WhenActivated(this IActivatableView item, Action> block) => item.WhenActivated(block, null!); +#if NET6_0_OR_GREATER + [RequiresUnreferencedCode("WhenActivated may reference types that could be trimmed")] + [RequiresDynamicCode("WhenActivated uses reflection which requires dynamic code generation")] +#endif + public static IDisposable WhenActivated(this IActivatableView item, Action> block) => + item.WhenActivated(block, null!); /// /// WhenActivated allows you to register a Func to be called when a @@ -180,6 +189,10 @@ public static IDisposable WhenActivated(this IActivatableView item, Func /// A Disposable that deactivates this registration. +#if NET6_0_OR_GREATER + [RequiresUnreferencedCode("WhenActivated may reference types that could be trimmed")] + [RequiresDynamicCode("WhenActivated uses reflection which requires dynamic code generation")] +#endif public static IDisposable WhenActivated(this IActivatableView item, Action> block, IViewFor view) => // TODO: Create Test item.WhenActivated( () => @@ -206,6 +219,10 @@ public static IDisposable WhenActivated(this IActivatableView item, Action /// A Disposable that deactivates this registration. +#if NET6_0_OR_GREATER + [RequiresUnreferencedCode("WhenActivated may reference types that could be trimmed")] + [RequiresDynamicCode("WhenActivated uses reflection which requires dynamic code generation")] +#endif public static IDisposable WhenActivated(this IActivatableView item, Action block, IViewFor? view = null) => item.WhenActivated( () => @@ -234,6 +251,10 @@ private static CompositeDisposable HandleViewActivation(Func activation) { var vmDisposable = new SerialDisposable(); diff --git a/src/ReactiveUI/Bindings/Command/CommandBinder.cs b/src/ReactiveUI/Bindings/Command/CommandBinder.cs index d12cace91b..a668556dab 100644 --- a/src/ReactiveUI/Bindings/Command/CommandBinder.cs +++ b/src/ReactiveUI/Bindings/Command/CommandBinder.cs @@ -10,10 +10,6 @@ namespace ReactiveUI; /// /// Various helpers to bind View controls and ViewModel commands together. /// -#if NET6_0_OR_GREATER -[RequiresDynamicCode("CommandBinder uses RxApp initialization which requires dynamic code generation")] -[RequiresUnreferencedCode("CommandBinder uses RxApp initialization which may require unreferenced code")] -#endif public static class CommandBinder { private static readonly ICommandBinderImplementation _binderImplementation; @@ -47,6 +43,10 @@ static CommandBinder() /// instead of the default. /// NOTE: If this parameter is used inside WhenActivated, it's /// important to dispose the binding when the view is deactivated. +#if NET6_0_OR_GREATER + [RequiresUnreferencedCode("This method uses reflection to access properties by name.")] + [RequiresDynamicCode("This method uses reflection to access properties by name.")] +#endif public static IReactiveBinding BindCommand( this TView view, TViewModel? viewModel, @@ -77,6 +77,10 @@ public static IReactiveBinding BindCommand +#if NET6_0_OR_GREATER + [RequiresUnreferencedCode("This method uses reflection to access properties by name.")] + [RequiresDynamicCode("This method uses reflection to access properties by name.")] +#endif public static IReactiveBinding BindCommand( this TView view, TViewModel? viewModel, @@ -109,6 +113,10 @@ public static IReactiveBinding BindCommand +#if NET6_0_OR_GREATER + [RequiresUnreferencedCode("This method uses reflection to access properties by name.")] + [RequiresDynamicCode("This method uses reflection to access properties by name.")] +#endif public static IReactiveBinding BindCommand( this TView view, TViewModel? viewModel, diff --git a/src/ReactiveUI/Bindings/Command/CommandBinderImplementation.cs b/src/ReactiveUI/Bindings/Command/CommandBinderImplementation.cs index 83148c4321..8c69a97d89 100644 --- a/src/ReactiveUI/Bindings/Command/CommandBinderImplementation.cs +++ b/src/ReactiveUI/Bindings/Command/CommandBinderImplementation.cs @@ -39,8 +39,8 @@ public class CommandBinderImplementation : ICommandBinderImplementation /// or /// nameof(vmProperty). #if NET6_0_OR_GREATER - [RequiresDynamicCode("BindCommand uses ViewModelWhenAnyValue which requires dynamic code generation")] - [RequiresUnreferencedCode("BindCommand uses ViewModelWhenAnyValue which may reference members that could be trimmed")] + [RequiresUnreferencedCode("This method uses reflection to access properties by name.")] + [RequiresDynamicCode("This method uses reflection to access properties by name.")] #endif public IReactiveBinding BindCommand( TViewModel? viewModel, @@ -94,8 +94,8 @@ public IReactiveBinding BindCommand #if NET6_0_OR_GREATER - [RequiresDynamicCode("BindCommand uses ViewModelWhenAnyValue which requires dynamic code generation")] - [RequiresUnreferencedCode("BindCommand uses ViewModelWhenAnyValue which may reference members that could be trimmed")] + [RequiresUnreferencedCode("This method uses reflection to access properties by name.")] + [RequiresDynamicCode("This method uses reflection to access properties by name.")] #endif public IReactiveBinding BindCommand( TViewModel? viewModel, @@ -128,8 +128,8 @@ public IReactiveBinding BindCommand( IObservable source, diff --git a/src/ReactiveUI/Bindings/Command/CommandBinderImplementationMixins.cs b/src/ReactiveUI/Bindings/Command/CommandBinderImplementationMixins.cs index b4b6bda5f2..013e364a62 100644 --- a/src/ReactiveUI/Bindings/Command/CommandBinderImplementationMixins.cs +++ b/src/ReactiveUI/Bindings/Command/CommandBinderImplementationMixins.cs @@ -13,8 +13,8 @@ namespace ReactiveUI; internal static class CommandBinderImplementationMixins { #if NET6_0_OR_GREATER - [RequiresDynamicCode("BindCommand uses ViewModelWhenAnyValue which requires dynamic code generation")] - [RequiresUnreferencedCode("BindCommand uses ViewModelWhenAnyValue which may reference members that could be trimmed")] + [RequiresUnreferencedCode("BindCommand may reference types that could be trimmed")] + [RequiresDynamicCode("BindCommand uses reflection which requires dynamic code generation")] #endif public static IReactiveBinding BindCommand( this ICommandBinderImplementation @this, @@ -29,8 +29,8 @@ public static IReactiveBinding BindCommand.Empty, toEvent); #if NET6_0_OR_GREATER - [RequiresDynamicCode("BindCommand uses ViewModelWhenAnyValue which requires dynamic code generation")] - [RequiresUnreferencedCode("BindCommand uses ViewModelWhenAnyValue which may reference members that could be trimmed")] + [RequiresUnreferencedCode("BindCommand may reference types that could be trimmed")] + [RequiresDynamicCode("BindCommand uses reflection which requires dynamic code generation")] #endif public static IReactiveBinding BindCommand( this ICommandBinderImplementation @this, diff --git a/src/ReactiveUI/Bindings/Command/CreatesCommandBinding.cs b/src/ReactiveUI/Bindings/Command/CreatesCommandBinding.cs index 5b8f40029f..a4590b7a75 100644 --- a/src/ReactiveUI/Bindings/Command/CreatesCommandBinding.cs +++ b/src/ReactiveUI/Bindings/Command/CreatesCommandBinding.cs @@ -7,14 +7,12 @@ using System.Windows.Input; namespace ReactiveUI; -#pragma warning disable RCS1102 // Make class static. Used as base class. #if NET6_0_OR_GREATER [RequiresDynamicCode("CreatesCommandBinding uses reflection and generic method instantiation")] [RequiresUnreferencedCode("CreatesCommandBinding may reference members that could be trimmed")] #endif -internal class CreatesCommandBinding -#pragma warning restore RCS1102 // Make class static. Used as base class. +internal static class CreatesCommandBinding { private static readonly MemoizingMRUCache _bindCommandCache = new( diff --git a/src/ReactiveUI/Bindings/Command/CreatesCommandBindingViaCommandParameter.cs b/src/ReactiveUI/Bindings/Command/CreatesCommandBindingViaCommandParameter.cs index a365c11c97..268f3b68e8 100644 --- a/src/ReactiveUI/Bindings/Command/CreatesCommandBindingViaCommandParameter.cs +++ b/src/ReactiveUI/Bindings/Command/CreatesCommandBindingViaCommandParameter.cs @@ -40,8 +40,8 @@ public int GetAffinityForObject(Type type, bool hasEventTarget) /// #if NET6_0_OR_GREATER - [RequiresDynamicCode("Property access requires dynamic code generation")] - [RequiresUnreferencedCode("Property access may reference members that could be trimmed")] + [RequiresDynamicCode("BindCommandToObject uses methods that require dynamic code generation")] + [RequiresUnreferencedCode("BindCommandToObject uses methods that may require unreferenced code")] #endif public IDisposable? BindCommandToObject(ICommand? command, object? target, IObservable commandParameter) { diff --git a/src/ReactiveUI/Bindings/Command/ICommandBinderImplementation.cs b/src/ReactiveUI/Bindings/Command/ICommandBinderImplementation.cs index cc19a908f8..232735e000 100644 --- a/src/ReactiveUI/Bindings/Command/ICommandBinderImplementation.cs +++ b/src/ReactiveUI/Bindings/Command/ICommandBinderImplementation.cs @@ -28,8 +28,8 @@ internal interface ICommandBinderImplementation : IEnableLogger /// The type of the parameter to pass to the ICommand. /// A reactive binding. Often only used for disposing the binding. #if NET6_0_OR_GREATER - [RequiresDynamicCode("BindCommand uses ViewModelWhenAnyValue which requires dynamic code generation")] - [RequiresUnreferencedCode("BindCommand uses ViewModelWhenAnyValue which may reference members that could be trimmed")] + [RequiresUnreferencedCode("This method uses reflection to access properties by name.")] + [RequiresDynamicCode("This method uses reflection to access properties by name.")] #endif IReactiveBinding BindCommand( TViewModel? viewModel, @@ -58,8 +58,8 @@ IReactiveBinding BindCommandThe type of the parameter to pass to the ICommand. /// A reactive binding. Often only used for disposing the binding. #if NET6_0_OR_GREATER - [RequiresDynamicCode("BindCommand uses ViewModelWhenAnyValue which requires dynamic code generation")] - [RequiresUnreferencedCode("BindCommand uses ViewModelWhenAnyValue which may reference members that could be trimmed")] + [RequiresUnreferencedCode("This method uses reflection to access properties by name.")] + [RequiresDynamicCode("This method uses reflection to access properties by name.")] #endif IReactiveBinding BindCommand( TViewModel? viewModel, diff --git a/src/ReactiveUI/Bindings/Interaction/InteractionBinderImplementation.cs b/src/ReactiveUI/Bindings/Interaction/InteractionBinderImplementation.cs index a091b0f07d..13ee75b9be 100644 --- a/src/ReactiveUI/Bindings/Interaction/InteractionBinderImplementation.cs +++ b/src/ReactiveUI/Bindings/Interaction/InteractionBinderImplementation.cs @@ -8,13 +8,13 @@ namespace ReactiveUI; /// /// Provides methods to bind s to handlers. /// -#if NET6_0_OR_GREATER -[RequiresDynamicCode("InteractionBinderImplementation uses reflection and expression evaluation which require dynamic code generation")] -[RequiresUnreferencedCode("InteractionBinderImplementation uses reflection and expression evaluation which may require unreferenced code")] -#endif public class InteractionBinderImplementation : IInteractionBinderImplementation { /// +#if NET6_0_OR_GREATER + [RequiresDynamicCode("The handler may use serialization which requires dynamic code generation")] + [RequiresUnreferencedCode("The handler may use serialization which may require unreferenced code")] +#endif public IDisposable BindInteraction( TViewModel? viewModel, TView view, @@ -40,6 +40,10 @@ public IDisposable BindInteraction( } /// +#if NET6_0_OR_GREATER + [RequiresDynamicCode("The handler may use serialization which requires dynamic code generation")] + [RequiresUnreferencedCode("The handler may use serialization which may require unreferenced code")] +#endif public IDisposable BindInteraction( TViewModel? viewModel, TView view, diff --git a/src/ReactiveUI/Bindings/Interaction/InteractionBindingMixins.cs b/src/ReactiveUI/Bindings/Interaction/InteractionBindingMixins.cs index 3f83206e4e..22993c0ab8 100644 --- a/src/ReactiveUI/Bindings/Interaction/InteractionBindingMixins.cs +++ b/src/ReactiveUI/Bindings/Interaction/InteractionBindingMixins.cs @@ -8,10 +8,6 @@ namespace ReactiveUI; /// /// This class provides extension methods for the ReactiveUI view binding mechanism. /// -#if NET6_0_OR_GREATER -[RequiresDynamicCode("InteractionBindingMixins uses RxApp initialization and expression binding which require dynamic code generation")] -[RequiresUnreferencedCode("InteractionBindingMixins uses RxApp initialization and expression binding which may require unreferenced code")] -#endif public static class InteractionBindingMixins { private static readonly InteractionBinderImplementation _binderImplementation = new(); diff --git a/src/ReactiveUI/Bindings/Property/PropertyBinderImplementation.cs b/src/ReactiveUI/Bindings/Property/PropertyBinderImplementation.cs index a3c14b8130..8eaee88ddc 100644 --- a/src/ReactiveUI/Bindings/Property/PropertyBinderImplementation.cs +++ b/src/ReactiveUI/Bindings/Property/PropertyBinderImplementation.cs @@ -11,10 +11,6 @@ namespace ReactiveUI; /// /// Provides methods to bind properties to observables. /// -#if NET6_0_OR_GREATER -[RequiresDynamicCode("Property binding uses reflection and dynamic type conversion")] -[RequiresUnreferencedCode("Property binding may reference members that could be trimmed")] -#endif public class PropertyBinderImplementation : IPropertyBinderImplementation { private static readonly MemoizingMRUCache<(Type fromType, Type toType), IBindingTypeConverter?> _typeConverterCache = new( @@ -26,6 +22,8 @@ public class PropertyBinderImplementation : IPropertyBinderImplementation }).currentBinding, RxApp.SmallCacheLimit); + [SuppressMessage("AOT", "IL3050:Calling members annotated with 'RequiresDynamicCodeAttribute' may break functionality when AOT compiling.", Justification = "Marked as Preserve")] + [SuppressMessage("Trimming", "IL2026:Calling members annotated with 'RequiresUnreferencedCodeAttribute' may break functionality when trimming application code.", Justification = "Marked as Preserve")] private static readonly MemoizingMRUCache<(Type? fromType, Type? toType), ISetMethodBindingConverter?> _setMethodCache = new( (type, _) => Locator.Current.GetServices() .Aggregate((currentAffinity: -1, currentBinding: default(ISetMethodBindingConverter)), (acc, x) => @@ -40,6 +38,10 @@ public class PropertyBinderImplementation : IPropertyBinderImplementation private delegate bool OutFunc(T1 t1, out T2 t2); /// +#if NET6_0_OR_GREATER + [RequiresDynamicCode("The handler may use serialization which requires dynamic code generation")] + [RequiresUnreferencedCode("The handler may use serialization which may require unreferenced code")] +#endif public IReactiveBinding Bind( TViewModel? viewModel, TView view, @@ -84,6 +86,10 @@ bool ViewToVmFunc(TVProp vValue, out TVMProp? vmValue) } /// +#if NET6_0_OR_GREATER + [RequiresDynamicCode("The handler may use serialization which requires dynamic code generation")] + [RequiresUnreferencedCode("The handler may use serialization which may require unreferenced code")] +#endif public IReactiveBinding Bind( TViewModel? viewModel, TView view, @@ -117,6 +123,10 @@ bool ViewToVmFunc(TVProp vValue, out TVMProp? vmValue) } /// +#if NET6_0_OR_GREATER + [RequiresDynamicCode("The handler may use serialization which requires dynamic code generation")] + [RequiresUnreferencedCode("The handler may use serialization which may require unreferenced code")] +#endif public IReactiveBinding OneWayBind( TViewModel? viewModel, TView view, @@ -149,6 +159,10 @@ public IReactiveBinding OneWayBind +#if NET6_0_OR_GREATER + [RequiresDynamicCode("The handler may use serialization which requires dynamic code generation")] + [RequiresUnreferencedCode("The handler may use serialization which may require unreferenced code")] +#endif public IReactiveBinding OneWayBind( TViewModel? viewModel, TView view, @@ -177,6 +191,10 @@ public IReactiveBinding OneWayBind( } /// +#if NET6_0_OR_GREATER + [RequiresDynamicCode("The handler may use serialization which requires dynamic code generation")] + [RequiresUnreferencedCode("The handler may use serialization which may require unreferenced code")] +#endif public IDisposable BindTo( IObservable observedChange, TTarget? target, diff --git a/src/ReactiveUI/Bindings/Property/PropertyBindingMixins.cs b/src/ReactiveUI/Bindings/Property/PropertyBindingMixins.cs index 95b63a0e98..28bf1aea49 100644 --- a/src/ReactiveUI/Bindings/Property/PropertyBindingMixins.cs +++ b/src/ReactiveUI/Bindings/Property/PropertyBindingMixins.cs @@ -8,10 +8,6 @@ namespace ReactiveUI; /// /// This class provides extension methods for the ReactiveUI view binding mechanism. /// -#if NET6_0_OR_GREATER -[RequiresDynamicCode("PropertyBindingMixins uses RxApp initialization and expression binding which require dynamic code generation")] -[RequiresUnreferencedCode("PropertyBindingMixins uses RxApp initialization and expression binding which may require unreferenced code")] -#endif public static class PropertyBindingMixins { private static readonly PropertyBinderImplementation _binderImplementation; @@ -57,6 +53,10 @@ static PropertyBindingMixins() /// An instance of that, when disposed, /// disconnects the binding. /// +#if NET6_0_OR_GREATER + [RequiresDynamicCode("PropertyBindingMixins uses RxApp initialization and expression binding which require dynamic code generation")] + [RequiresUnreferencedCode("PropertyBindingMixins uses RxApp initialization and expression binding which may require unreferenced code")] +#endif public static IReactiveBinding Bind( this TView view, TViewModel? viewModel, @@ -109,6 +109,10 @@ static PropertyBindingMixins() /// An instance of that, when disposed, /// disconnects the binding. /// +#if NET6_0_OR_GREATER + [RequiresDynamicCode("PropertyBindingMixins uses RxApp initialization and expression binding which require dynamic code generation")] + [RequiresUnreferencedCode("PropertyBindingMixins uses RxApp initialization and expression binding which may require unreferenced code")] +#endif public static IReactiveBinding Bind( this TView view, TViewModel? viewModel, @@ -154,6 +158,10 @@ static PropertyBindingMixins() /// An instance of that, when disposed, /// disconnects the binding. /// +#if NET6_0_OR_GREATER + [RequiresDynamicCode("PropertyBindingMixins uses RxApp initialization and expression binding which require dynamic code generation")] + [RequiresUnreferencedCode("PropertyBindingMixins uses RxApp initialization and expression binding which may require unreferenced code")] +#endif public static IReactiveBinding Bind( this TView view, TViewModel? viewModel, @@ -193,6 +201,10 @@ static PropertyBindingMixins() /// An instance of that, when disposed, /// disconnects the binding. /// +#if NET6_0_OR_GREATER + [RequiresDynamicCode("PropertyBindingMixins uses RxApp initialization and expression binding which require dynamic code generation")] + [RequiresUnreferencedCode("PropertyBindingMixins uses RxApp initialization and expression binding which may require unreferenced code")] +#endif public static IReactiveBinding Bind( this TView view, TViewModel? viewModel, @@ -242,6 +254,10 @@ static PropertyBindingMixins() /// An instance of that, when disposed, /// disconnects the binding. /// +#if NET6_0_OR_GREATER + [RequiresDynamicCode("PropertyBindingMixins uses RxApp initialization and expression binding which require dynamic code generation")] + [RequiresUnreferencedCode("PropertyBindingMixins uses RxApp initialization and expression binding which may require unreferenced code")] +#endif public static IReactiveBinding OneWayBind( this TView view, TViewModel? viewModel, @@ -289,6 +305,10 @@ public static IReactiveBinding OneWayBind that, when disposed, /// disconnects the binding. /// +#if NET6_0_OR_GREATER + [RequiresDynamicCode("PropertyBindingMixins uses RxApp initialization and expression binding which require dynamic code generation")] + [RequiresUnreferencedCode("PropertyBindingMixins uses RxApp initialization and expression binding which may require unreferenced code")] +#endif public static IReactiveBinding OneWayBind( this TView view, TViewModel? viewModel, @@ -323,6 +343,10 @@ public static IReactiveBinding OneWayBind /// An object that when disposed, disconnects the binding. +#if NET6_0_OR_GREATER + [RequiresDynamicCode("PropertyBindingMixins uses RxApp initialization and expression binding which require dynamic code generation")] + [RequiresUnreferencedCode("PropertyBindingMixins uses RxApp initialization and expression binding which may require unreferenced code")] +#endif public static IDisposable BindTo( this IObservable @this, TTarget? target, diff --git a/src/ReactiveUI/Builder/IReactiveUIBuilder.cs b/src/ReactiveUI/Builder/IReactiveUIBuilder.cs new file mode 100644 index 0000000000..3251ca8b48 --- /dev/null +++ b/src/ReactiveUI/Builder/IReactiveUIBuilder.cs @@ -0,0 +1,164 @@ +// Copyright (c) 2025 .NET Foundation and Contributors. All rights reserved. +// Licensed to the .NET Foundation under one or more agreements. +// 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.Reflection; +using Splat.Builder; + +namespace ReactiveUI.Builder +{ + /// + /// IReactiveUIBuilder. + /// + /// + public interface IReactiveUIBuilder : IAppBuilder + { + /// + /// Configures the message bus. + /// + /// The configure. + /// The builder instance for chaining. + IReactiveUIBuilder ConfigureMessageBus(Action configure); + + /// + /// Configures the suspension driver. + /// + /// The configure. + /// The builder instance for chaining. + IReactiveUIBuilder ConfigureSuspensionDriver(Action configure); + + /// + /// Configures the view locator. + /// + /// The configure. + /// The builder instance for chaining. + IReactiveUIBuilder ConfigureViewLocator(Action configure); + + /// + /// Fors the custom platform. + /// + /// The main thread scheduler. + /// The platform services. + /// The builder instance for chaining. + IReactiveUIBuilder ForCustomPlatform(IScheduler mainThreadScheduler, Action platformServices); + + /// + /// Fors the platforms. + /// + /// The platform configurations. + /// The builder instance for chaining. + IReactiveUIBuilder ForPlatforms(params Action[] platformConfigurations); + + /// + /// Registers the singleton view. + /// + /// The type of the view. + /// The type of the view model. + /// The builder instance for chaining. + IReactiveUIBuilder RegisterSingletonView() + where TView : class, IViewFor, new() + where TViewModel : class, IReactiveObject; + + /// + /// Registers the singleton view model. + /// + /// The type of the view model. + /// The builder instance for chaining. +#if NET6_0_OR_GREATER + IReactiveUIBuilder RegisterSingletonViewModel<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] TViewModel>() +#else + IReactiveUIBuilder RegisterSingletonViewModel() +#endif + where TViewModel : class, IReactiveObject, new(); + + /// + /// Registers the view. + /// + /// The type of the view. + /// The type of the view model. + /// The builder instance for chaining. + IReactiveUIBuilder RegisterView() + where TView : class, IViewFor, new() + where TViewModel : class, IReactiveObject; + + /// + /// Registers the view model. + /// + /// The type of the view model. + /// The builder instance for chaining. + IReactiveUIBuilder RegisterViewModel() + where TViewModel : class, IReactiveObject, new(); + + /// + /// Withes the main thread scheduler. + /// + /// The scheduler. + /// if set to true [set rx application]. + /// + /// The builder instance for chaining. + /// + IReactiveUIBuilder WithMainThreadScheduler(IScheduler scheduler, bool setRxApp = true); + + /// + /// Withes the platform module. + /// + /// The type of the registration module that implements IWantsToRegisterStuff. + /// The builder instance for chaining. + IReactiveUIBuilder WithPlatformModule() + where T : IWantsToRegisterStuff, new(); + + /// + /// Withes the platform services. + /// + /// The builder instance for chaining. + IReactiveUIBuilder WithPlatformServices(); + + /// + /// Withes the registration. + /// + /// The configure action. + /// The builder instance for chaining. + IReactiveUIBuilder WithRegistration(Action configureAction); + + /// + /// Withes the registration on build. + /// + /// The configure action. + /// The builder instance for chaining. + IReactiveUIBuilder WithRegistrationOnBuild(Action configureAction); + + /// + /// Withes the task pool scheduler. + /// + /// The scheduler. + /// if set to true [set rx application]. + /// + /// The builder instance for chaining. + /// + IReactiveUIBuilder WithTaskPoolScheduler(IScheduler scheduler, bool setRxApp = true); + + /// + /// Withes the views from assembly. + /// + /// The assembly. + /// The builder instance for chaining. + +#if NET6_0_OR_GREATER + [RequiresDynamicCode("The method uses reflection and will not work in AOT environments.")] + [RequiresUnreferencedCode("The method uses reflection and will not work in AOT environments.")] +#endif + IReactiveUIBuilder WithViewsFromAssembly(Assembly assembly); + + /// + /// Using the splat module. + /// + /// The Splat Module Type. + /// The registration module to add. + /// + /// The builder instance for method chaining. + /// + IReactiveUIBuilder UsingSplatModule(T registrationModule) + where T : IModule; + } +} diff --git a/src/ReactiveUI/Builder/IReactiveUIInstance.cs b/src/ReactiveUI/Builder/IReactiveUIInstance.cs new file mode 100644 index 0000000000..1554fc2d2b --- /dev/null +++ b/src/ReactiveUI/Builder/IReactiveUIInstance.cs @@ -0,0 +1,31 @@ +// Copyright (c) 2025 .NET Foundation and Contributors. All rights reserved. +// Licensed to the .NET Foundation under one or more agreements. +// 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 Splat.Builder; + +namespace ReactiveUI.Builder +{ + /// + /// IReactiveUIInstance. + /// + /// + public interface IReactiveUIInstance : IAppInstance + { + /// + /// Gets a scheduler used to schedule work items that + /// should be run "on the UI thread". In normal mode, this will be + /// DispatcherScheduler, and in Unit Test mode this will be Immediate, + /// to simplify writing common unit tests. + /// + IScheduler? MainThreadScheduler { get; } + + /// + /// Gets the a the scheduler used to schedule work items to + /// run in a background thread. In both modes, this will run on the TPL + /// Task Pool. + /// + IScheduler? TaskpoolScheduler { get; } + } +} diff --git a/src/ReactiveUI/Builder/MultiPlatformReactiveUIBuilderExtensions.cs b/src/ReactiveUI/Builder/MultiPlatformReactiveUIBuilderExtensions.cs deleted file mode 100644 index c1a2c7940e..0000000000 --- a/src/ReactiveUI/Builder/MultiPlatformReactiveUIBuilderExtensions.cs +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright (c) 2025 .NET Foundation and Contributors. All rights reserved. -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for full license information. - -namespace ReactiveUI.Builder; - -/// -/// Extensions for configuring multiple platforms with ReactiveUI. -/// -public static class MultiPlatformReactiveUIBuilderExtensions -{ - /// - /// Configures ReactiveUI for multiple platforms simultaneously. - /// - /// The builder instance. - /// The platform configuration actions. - /// The builder instance for chaining. - public static ReactiveUIBuilder ForPlatforms(this ReactiveUIBuilder builder, params Action[] platformConfigurations) - { - if (platformConfigurations is null) - { - throw new ArgumentNullException(nameof(platformConfigurations)); - } - - foreach (var configurePlatform in platformConfigurations) - { - configurePlatform(builder); - } - - return builder; - } - - /// - /// Configures a custom platform implementation for ReactiveUI. - /// - /// The builder instance. - /// The main thread scheduler for the platform. - /// The platform-specific service registrations. - /// The builder instance for chaining. - public static ReactiveUIBuilder ForCustomPlatform( - this ReactiveUIBuilder builder, - IScheduler mainThreadScheduler, - Action platformServices) - { - if (builder is null) - { - throw new ArgumentNullException(nameof(builder)); - } - - return builder - .WithMainThreadScheduler(mainThreadScheduler) - .WithRegistrationOnBuild(platformServices); - } -} diff --git a/src/ReactiveUI/Builder/ReactiveUIBuilder.cs b/src/ReactiveUI/Builder/ReactiveUIBuilder.cs index ca9ade9a83..e42e3e2961 100644 --- a/src/ReactiveUI/Builder/ReactiveUIBuilder.cs +++ b/src/ReactiveUI/Builder/ReactiveUIBuilder.cs @@ -12,34 +12,49 @@ namespace ReactiveUI.Builder; /// A builder class for configuring ReactiveUI services with AOT compatibility. /// Extends the Splat AppBuilder to provide ReactiveUI-specific configuration. /// -public sealed class ReactiveUIBuilder : AppBuilder +public sealed class ReactiveUIBuilder : AppBuilder, IReactiveUIBuilder, IReactiveUIInstance { - private readonly IMutableDependencyResolver _resolver; - private IScheduler? _mainThreadScheduler; - private IScheduler? _taskPoolScheduler; private bool _platformRegistered; private bool _coreRegistered; + private bool _setRxAppMainScheduler; + private bool _setRxAppTaskpoolScheduler; /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The dependency resolver to configure. - public ReactiveUIBuilder(IMutableDependencyResolver resolver) - : base(resolver) - { - _resolver = resolver ?? throw new ArgumentNullException(nameof(resolver)); + /// The configured services. + /// resolver. + public ReactiveUIBuilder(IMutableDependencyResolver resolver, IReadonlyDependencyResolver? current) + : base(resolver, current) => CurrentMutable.InitializeSplat(); - _resolver.InitializeSplat(); - } + /// + /// Gets a scheduler used to schedule work items that + /// should be run "on the UI thread". In normal mode, this will be + /// DispatcherScheduler, and in Unit Test mode this will be Immediate, + /// to simplify writing common unit tests. + /// + public IScheduler? MainThreadScheduler { get; private set; } + + /// + /// Gets the a the scheduler used to schedule work items to + /// run in a background thread. In both modes, this will run on the TPL + /// Task Pool. + /// + public IScheduler? TaskpoolScheduler { get; private set; } /// /// Configures the main thread scheduler for ReactiveUI. /// /// The main thread scheduler to use. - /// The builder instance for chaining. - public ReactiveUIBuilder WithMainThreadScheduler(IScheduler scheduler) + /// if set to true [set rx application]. + /// + /// The builder instance for chaining. + /// + public IReactiveUIBuilder WithMainThreadScheduler(IScheduler scheduler, bool setRxApp = true) { - _mainThreadScheduler = scheduler; + _setRxAppMainScheduler = setRxApp; + MainThreadScheduler = scheduler; return this; } @@ -47,10 +62,14 @@ public ReactiveUIBuilder WithMainThreadScheduler(IScheduler scheduler) /// Configures the task pool scheduler for ReactiveUI. /// /// The task pool scheduler to use. - /// The builder instance for chaining. - public ReactiveUIBuilder WithTaskPoolScheduler(IScheduler scheduler) + /// if set to true [set rx application]. + /// + /// The builder instance for chaining. + /// + public IReactiveUIBuilder WithTaskPoolScheduler(IScheduler scheduler, bool setRxApp = true) { - _taskPoolScheduler = scheduler; + _setRxAppTaskpoolScheduler = setRxApp; + TaskpoolScheduler = scheduler; return this; } @@ -59,7 +78,7 @@ public ReactiveUIBuilder WithTaskPoolScheduler(IScheduler scheduler) /// /// The configuration action. /// The builder instance for chaining. - public ReactiveUIBuilder WithRegistrationOnBuild(Action configureAction) + public IReactiveUIBuilder WithRegistrationOnBuild(Action configureAction) { WithCustomRegistration(configureAction); return this; @@ -70,14 +89,14 @@ public ReactiveUIBuilder WithRegistrationOnBuild(Action /// The configuration action. /// The builder instance for chaining. - public ReactiveUIBuilder WithRegistration(Action configureAction) + public IReactiveUIBuilder WithRegistration(Action configureAction) { if (configureAction is null) { throw new ArgumentNullException(nameof(configureAction)); } - configureAction(_resolver); + configureAction(CurrentMutable); return this; } @@ -85,7 +104,7 @@ public ReactiveUIBuilder WithRegistration(Action con /// Registers the platform-specific ReactiveUI services. /// /// The builder instance for method chaining. - public ReactiveUIBuilder WithPlatformServices() + public IReactiveUIBuilder WithPlatformServices() { if (_platformRegistered) { @@ -103,11 +122,7 @@ public ReactiveUIBuilder WithPlatformServices() /// Registers the core ReactiveUI services in an AOT-compatible manner. /// /// The builder instance for chaining. -#if NET6_0_OR_GREATER - [RequiresUnreferencedCode("ReactiveUI uses reflection to register some services. Ensure that the necessary types are preserved.")] - [RequiresDynamicCode("ReactiveUI uses reflection to register some services. Ensure that the necessary types are preserved.")] -#endif - public override AppBuilder WithCoreServices() + public override IAppBuilder WithCoreServices() { if (!_coreRegistered) { @@ -131,12 +146,12 @@ public override AppBuilder WithCoreServices() [RequiresDynamicCode("The method uses reflection and will not work in AOT environments.")] [RequiresUnreferencedCode("The method uses reflection and will not work in AOT environments.")] #endif - public ReactiveUIBuilder WithViewsFromAssembly(Assembly assembly) + public IReactiveUIBuilder WithViewsFromAssembly(Assembly assembly) { assembly.ArgumentNullExceptionThrowIfNull(nameof(assembly)); // Register views immediately against the builder's resolver - _resolver.RegisterViewsForViewModels(assembly); + CurrentMutable.RegisterViewsForViewModels(assembly); return this; } @@ -146,33 +161,163 @@ public ReactiveUIBuilder WithViewsFromAssembly(Assembly assembly) /// The type of the registration module that implements IWantsToRegisterStuff. /// The builder instance for method chaining. [SuppressMessage("Trimming", "IL2111:Method with parameters or return value with `DynamicallyAccessedMembersAttribute` is accessed via reflection. Trimmer can't guarantee availability of the requirements of the method.", Justification = "Does not use reflection")] - public ReactiveUIBuilder WithPlatformModule() + public IReactiveUIBuilder WithPlatformModule() where T : IWantsToRegisterStuff, new() { var registration = new T(); #if NET6_0_OR_GREATER - registration.Register((f, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] t) => _resolver.RegisterConstant(f(), t)); + registration.Register((f, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] t) => CurrentMutable.RegisterConstant(f(), t)); #else - registration.Register((f, t) => _resolver.RegisterConstant(f(), t)); + registration.Register((f, t) => CurrentMutable.RegisterConstant(f(), t)); #endif return this; } -#if NET6_0_OR_GREATER - [RequiresUnreferencedCode("ReactiveUI uses reflection to register some services. Ensure that the necessary types are preserved.")] - [RequiresDynamicCode("ReactiveUI uses reflection to register some services. Ensure that the necessary types are preserved.")] -#endif - private void ConfigureSchedulers() => - WithCustomRegistration(_ => + /// + /// Using the splat module. + /// + /// The Splat Module Type. + /// The registration module to add. + /// + /// The builder instance for method chaining. + /// + public IReactiveUIBuilder UsingSplatModule(T registrationModule) + where T : IModule + { + UsingModule(registrationModule); + return this; + } + + /// + /// Configures a custom platform implementation for ReactiveUI. + /// + /// The main thread scheduler for the platform. + /// The platform-specific service registrations. + /// The builder instance for chaining. + public IReactiveUIBuilder ForCustomPlatform( + IScheduler mainThreadScheduler, + Action platformServices) => + WithMainThreadScheduler(mainThreadScheduler) + .WithRegistrationOnBuild(platformServices); + + /// + /// Configures ReactiveUI for multiple platforms simultaneously. + /// + /// The platform configuration actions. + /// The builder instance for chaining. + public IReactiveUIBuilder ForPlatforms(params Action[] platformConfigurations) + { + if (platformConfigurations is null) { - if (_mainThreadScheduler != null) + throw new ArgumentNullException(nameof(platformConfigurations)); + } + + foreach (var configurePlatform in platformConfigurations) + { + configurePlatform(this); + } + + return this; + } + + /// + /// Configures the ReactiveUI message bus. + /// + /// The configuration action. + /// The builder instance for chaining. + public IReactiveUIBuilder ConfigureMessageBus(Action configure) => + WithRegistrationOnBuild(resolver => + resolver.Register(() => { - RxApp.MainThreadScheduler = _mainThreadScheduler; - } + var messageBus = new MessageBus(); + configure(messageBus); + return messageBus; + })); + + /// + /// Configures the ReactiveUI view locator. + /// + /// The configuration action. + /// The builder instance for chaining. + public IReactiveUIBuilder ConfigureViewLocator(Action configure) => + WithRegistrationOnBuild(resolver => + resolver.Register(() => + { + var viewLocator = new DefaultViewLocator(); + configure(viewLocator); + return viewLocator; + })); - if (_taskPoolScheduler != null) + /// + /// Configures the ReactiveUI suspension driver. + /// + /// The configuration action. + /// The builder instance for chaining. + public IReactiveUIBuilder ConfigureSuspensionDriver(Action configure) => + WithRegistrationOnBuild(resolver => + { + var currentDriver = Current?.GetService(); + if (currentDriver != null) { - RxApp.TaskpoolScheduler = _taskPoolScheduler; + configure(currentDriver); } }); + + /// + /// Registers a custom view model with the dependency resolver. + /// + /// The view model type. + /// The builder instance for chaining. + public IReactiveUIBuilder RegisterViewModel() + where TViewModel : class, IReactiveObject, new() => + WithRegistration(resolver => resolver.Register(() => new())); + + /// + /// Registers a custom view model with the dependency resolver. + /// + /// The view model type. + /// The builder instance for chaining. +#if NET6_0_OR_GREATER + public IReactiveUIBuilder RegisterSingletonViewModel<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] TViewModel>() +#else + public IReactiveUIBuilder RegisterSingletonViewModel() +#endif + where TViewModel : class, IReactiveObject, new() => + WithRegistration(resolver => resolver.RegisterLazySingleton(() => new())); + + /// + /// Registers a custom view for a specific view model. + /// + /// The view type. + /// The view model type. + /// The builder instance for chaining. + public IReactiveUIBuilder RegisterView() + where TView : class, IViewFor, new() + where TViewModel : class, IReactiveObject => + WithRegistration(resolver => resolver.Register>(() => new TView())); + + /// + /// Registers a custom view for a specific view model. + /// + /// The view type. + /// The view model type. + /// The builder instance for chaining. + public IReactiveUIBuilder RegisterSingletonView() + where TView : class, IViewFor, new() + where TViewModel : class, IReactiveObject => + WithRegistration(resolver => resolver.RegisterLazySingleton>(() => new TView())); + + private void ConfigureSchedulers() => + WithCustomRegistration(_ => + { + if (MainThreadScheduler != null && _setRxAppMainScheduler) + { + RxApp.MainThreadScheduler = MainThreadScheduler; + } + + if (TaskpoolScheduler != null && _setRxAppTaskpoolScheduler) + { + RxApp.TaskpoolScheduler = TaskpoolScheduler; + } + }); } diff --git a/src/ReactiveUI/Builder/RxAppBuilder.cs b/src/ReactiveUI/Builder/RxAppBuilder.cs index f6c632f4c3..591261ceaf 100644 --- a/src/ReactiveUI/Builder/RxAppBuilder.cs +++ b/src/ReactiveUI/Builder/RxAppBuilder.cs @@ -15,7 +15,7 @@ public static class RxAppBuilder /// /// The ReactiveUI builder instance. public static ReactiveUIBuilder CreateReactiveUIBuilder() => - new(AppLocator.CurrentMutable); + new(AppLocator.CurrentMutable, AppLocator.Current); /// /// Creates a ReactiveUI builder with the specified dependency resolver. @@ -23,148 +23,5 @@ public static ReactiveUIBuilder CreateReactiveUIBuilder() => /// The dependency resolver to use. /// The ReactiveUI builder instance. public static ReactiveUIBuilder CreateReactiveUIBuilder(this IMutableDependencyResolver resolver) => - new(resolver); - - /// - /// Configures the ReactiveUI message bus. - /// - /// The builder instance. - /// The configuration action. - /// The builder instance for chaining. - public static ReactiveUIBuilder ConfigureMessageBus(this ReactiveUIBuilder builder, Action configure) - { - if (builder is null) - { - throw new ArgumentNullException(nameof(builder)); - } - - return builder.WithRegistrationOnBuild(resolver => - resolver.Register(() => - { - var messageBus = new MessageBus(); - configure(messageBus); - return messageBus; - })); - } - - /// - /// Configures the ReactiveUI view locator. - /// - /// The builder instance. - /// The configuration action. - /// The builder instance for chaining. - public static ReactiveUIBuilder ConfigureViewLocator(this ReactiveUIBuilder builder, Action configure) - { - if (builder is null) - { - throw new ArgumentNullException(nameof(builder)); - } - - return builder.WithRegistrationOnBuild(resolver => - resolver.Register(() => - { - var viewLocator = new DefaultViewLocator(); - configure(viewLocator); - return viewLocator; - })); - } - - /// - /// Configures the ReactiveUI suspension driver. - /// - /// The builder instance. - /// The configuration action. - /// The builder instance for chaining. - public static ReactiveUIBuilder ConfigureSuspensionDriver(this ReactiveUIBuilder builder, Action configure) - { - if (builder is null) - { - throw new ArgumentNullException(nameof(builder)); - } - - return builder.WithRegistrationOnBuild(resolver => - { - var currentDriver = AppLocator.Current.GetService(); - if (currentDriver != null) - { - configure(currentDriver); - } - }); - } - - /// - /// Registers a custom view model with the dependency resolver. - /// - /// The view model type. - /// The builder instance. - /// The builder instance for chaining. - public static ReactiveUIBuilder RegisterViewModel(this ReactiveUIBuilder builder) - where TViewModel : class, IReactiveObject, new() - { - if (builder is null) - { - throw new ArgumentNullException(nameof(builder)); - } - - return builder.WithRegistration(resolver => resolver.Register(() => new())); - } - - /// - /// Registers a custom view model with the dependency resolver. - /// - /// The view model type. - /// The builder instance. - /// The builder instance for chaining. -#if NET6_0_OR_GREATER - [RequiresDynamicCode("This method uses 'new()' constraint which may require dynamic code generation.")] - [RequiresUnreferencedCode("This method uses 'new()' constraint which may require dynamic code generation.")] -#endif - public static ReactiveUIBuilder RegisterSingletonViewModel(this ReactiveUIBuilder builder) - where TViewModel : class, IReactiveObject, new() - { - if (builder is null) - { - throw new ArgumentNullException(nameof(builder)); - } - - return builder.WithRegistration(resolver => resolver.RegisterLazySingleton(() => new())); - } - - /// - /// Registers a custom view for a specific view model. - /// - /// The view type. - /// The view model type. - /// The builder instance. - /// The builder instance for chaining. - public static ReactiveUIBuilder RegisterView(this ReactiveUIBuilder builder) - where TView : class, IViewFor, new() - where TViewModel : class, IReactiveObject - { - if (builder is null) - { - throw new ArgumentNullException(nameof(builder)); - } - - return builder.WithRegistration(resolver => resolver.Register>(() => new TView())); - } - - /// - /// Registers a custom view for a specific view model. - /// - /// The view type. - /// The view model type. - /// The builder instance. - /// The builder instance for chaining. - public static ReactiveUIBuilder RegisterSingletonView(this ReactiveUIBuilder builder) - where TView : class, IViewFor, new() - where TViewModel : class, IReactiveObject - { - if (builder is null) - { - throw new ArgumentNullException(nameof(builder)); - } - - return builder.WithRegistration(resolver => resolver.RegisterLazySingleton>(() => new TView())); - } + new(resolver, AppLocator.Current); } diff --git a/src/ReactiveUI/EventHandlers/LocalizableAttribute.cs b/src/ReactiveUI/EventHandlers/LocalizableAttribute.cs index 9d43042eb9..29e5630cad 100644 --- a/src/ReactiveUI/EventHandlers/LocalizableAttribute.cs +++ b/src/ReactiveUI/EventHandlers/LocalizableAttribute.cs @@ -22,5 +22,3 @@ public sealed class LocalizableAttribute(bool isLocalizable) : Attribute public bool IsLocalizable { get; } = isLocalizable; } #endif - -// vim: tw=120 ts=4 sw=4 et : diff --git a/src/ReactiveUI/Expression/ExpressionRewriter.cs b/src/ReactiveUI/Expression/ExpressionRewriter.cs index 6cf3f07871..bad0fb5faf 100644 --- a/src/ReactiveUI/Expression/ExpressionRewriter.cs +++ b/src/ReactiveUI/Expression/ExpressionRewriter.cs @@ -11,10 +11,6 @@ namespace ReactiveUI; /// /// Class for simplifying and validating expressions. /// -#if NET6_0_OR_GREATER -[RequiresDynamicCode("ExpressionRewriter uses reflection to access type properties which requires dynamic code generation")] -[RequiresUnreferencedCode("ExpressionRewriter uses reflection to access type properties which may require unreferenced code")] -#endif internal class ExpressionRewriter : ExpressionVisitor { public override Expression Visit(Expression? node) @@ -55,6 +51,12 @@ public override Expression Visit(Expression? node) } } +#if NET6_0_OR_GREATER + [RequiresDynamicCode("ExpressionRewriter uses reflection to access type properties which requires dynamic code generation")] + [RequiresUnreferencedCode("ExpressionRewriter uses reflection to access type properties which may require unreferenced code")] + [SuppressMessage("AOT", "IL3051:'RequiresDynamicCodeAttribute' annotations must match across all interface implementations or overrides.", Justification = "Third Party Code")] + [SuppressMessage("Trimming", "IL2046:'RequiresUnreferencedCodeAttribute' annotations must match across all interface implementations or overrides.", Justification = "Third Party Code")] +#endif protected override Expression VisitBinary(BinaryExpression node) { if (node.Right is not ConstantExpression) @@ -69,6 +71,12 @@ protected override Expression VisitBinary(BinaryExpression node) return Expression.MakeIndex(left, GetItemProperty(left.Type), [right]); } +#if NET6_0_OR_GREATER + [RequiresDynamicCode("ExpressionRewriter uses reflection to access type properties which requires dynamic code generation")] + [RequiresUnreferencedCode("ExpressionRewriter uses reflection to access type properties which may require unreferenced code")] + [SuppressMessage("AOT", "IL3051:'RequiresDynamicCodeAttribute' annotations must match across all interface implementations or overrides.", Justification = "Third Party Code")] + [SuppressMessage("Trimming", "IL2046:'RequiresUnreferencedCodeAttribute' annotations must match across all interface implementations or overrides.", Justification = "Third Party Code")] +#endif protected override Expression VisitUnary(UnaryExpression node) { if (node.NodeType == ExpressionType.ArrayLength && node.Operand is not null) @@ -97,6 +105,12 @@ protected override Expression VisitUnary(UnaryExpression node) } } +#if NET6_0_OR_GREATER + [RequiresDynamicCode("ExpressionRewriter uses reflection to access type properties which requires dynamic code generation")] + [RequiresUnreferencedCode("ExpressionRewriter uses reflection to access type properties which may require unreferenced code")] + [SuppressMessage("AOT", "IL3051:'RequiresDynamicCodeAttribute' annotations must match across all interface implementations or overrides.", Justification = "Third Party Code")] + [SuppressMessage("Trimming", "IL2046:'RequiresUnreferencedCodeAttribute' annotations must match across all interface implementations or overrides.", Justification = "Third Party Code")] +#endif protected override Expression VisitMethodCall(MethodCallExpression node) { // Rewrite a method call to an indexer as an index expression diff --git a/src/ReactiveUI/Expression/Reflection.cs b/src/ReactiveUI/Expression/Reflection.cs index 38f9b5f272..134cedb565 100644 --- a/src/ReactiveUI/Expression/Reflection.cs +++ b/src/ReactiveUI/Expression/Reflection.cs @@ -11,14 +11,15 @@ namespace ReactiveUI; /// /// Helper class for handling Reflection amd Expression tree related items. /// -#if NET6_0_OR_GREATER -[RequiresDynamicCode("Expression rewriting requires dynamic code generation")] -[RequiresUnreferencedCode("Expression rewriting may reference members that could be trimmed")] -#endif +[Preserve(AllMembers = true)] public static class Reflection { + [SuppressMessage("AOT", "IL3050:Calling members annotated with 'RequiresDynamicCodeAttribute' may break functionality when AOT compiling.", Justification = "Marked as Preserve")] + [SuppressMessage("Trimming", "IL2026:Calling members annotated with 'RequiresUnreferencedCodeAttribute' may break functionality when trimming application code.", Justification = "Marked as Preserve")] private static readonly ExpressionRewriter _expressionRewriter = new(); + [SuppressMessage("AOT", "IL3050:Calling members annotated with 'RequiresDynamicCodeAttribute' may break functionality when AOT compiling.", Justification = "Marked as Preserve")] + [SuppressMessage("Trimming", "IL2026:Calling members annotated with 'RequiresUnreferencedCodeAttribute' may break functionality when trimming application code.", Justification = "Marked as Preserve")] private static readonly MemoizingMRUCache _typeCache = new( (type, _) => GetTypeHelper(type), 20); @@ -28,10 +29,6 @@ public static class Reflection /// /// The expression to rewrite. /// The rewritten expression. -#if NET6_0_OR_GREATER - [RequiresDynamicCode("Expression rewriting requires dynamic code generation")] - [RequiresUnreferencedCode("Expression rewriting may reference members that could be trimmed")] -#endif public static Expression Rewrite(Expression? expression) => _expressionRewriter.Visit(expression); /// @@ -137,10 +134,6 @@ public static string ExpressionToPropertyNames(Expression? expression) // TODO: /// /// The member info to convert. /// A Func that takes in the object/indexes and sets the value. -#if NET6_0_OR_GREATER - [RequiresDynamicCode("Member access requires dynamic code generation")] - [RequiresUnreferencedCode("Member access may reference members that could be trimmed")] -#endif public static Action GetValueSetterForProperty(MemberInfo? member) // TODO: Create Test { member.ArgumentNullExceptionThrowIfNull(nameof(member)); @@ -338,10 +331,6 @@ public static bool TrySetValueToPropertyChain(object? target, IEnumerabl /// If we should throw an exception if the type can't be found. /// The type that was found or null. /// If we were unable to find the type. -#if NET6_0_OR_GREATER - [RequiresDynamicCode("Type resolution requires dynamic code generation")] - [RequiresUnreferencedCode("Type resolution may reference types that could be trimmed")] -#endif public static Type? ReallyFindType(string? type, bool throwOnFailure) // TODO: Create Test { var ret = _typeCache.Get(type ?? string.Empty); @@ -356,10 +345,14 @@ public static bool TrySetValueToPropertyChain(object? target, IEnumerabl /// The Type of the EventArgs to use. /// If there is no event matching the name on the target type. #if NET6_0_OR_GREATER - [RequiresDynamicCode("Event reflection requires dynamic code generation")] - [RequiresUnreferencedCode("Event reflection may reference members that could be trimmed")] + [RequiresUnreferencedCode("Event access may reference members that could be trimmed")] +#endif + public static Type GetEventArgsTypeForEvent( +#if NET6_0_OR_GREATER + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] #endif - public static Type GetEventArgsTypeForEvent(Type type, string? eventName) // TODO: Create Test + Type type, + string? eventName) // TODO: Create Test { type.ArgumentNullExceptionThrowIfNull(nameof(type)); @@ -383,8 +376,7 @@ public static Type GetEventArgsTypeForEvent(Type type, string? eventName) // TOD /// The name of the methods to check. /// Thrown if the methods aren't overriden on the target object. #if NET6_0_OR_GREATER - [RequiresDynamicCode("Method reflection requires dynamic code generation")] - [RequiresUnreferencedCode("Method reflection may reference members that could be trimmed")] + [RequiresUnreferencedCode("Method access may reference members that could be trimmed")] #endif public static void ThrowIfMethodsNotOverloaded(string callingTypeName, object targetObject, params string[] methodsToCheck) // TODO: Create Test { @@ -416,8 +408,8 @@ public static bool IsStatic(this PropertyInfo item) // TODO: Create Test } #if NET6_0_OR_GREATER - [RequiresDynamicCode("Expression evaluation requires dynamic code generation")] - [RequiresUnreferencedCode("Expression evaluation may reference members that could be trimmed")] + [RequiresUnreferencedCode("ViewModelWhenAnyValue may reference types that could be trimmed")] + [RequiresDynamicCode("ViewModelWhenAnyValue uses reflection which requires dynamic code generation")] #endif internal static IObservable ViewModelWhenAnyValue(TViewModel? viewModel, TView view, Expression? expression) where TView : class, IViewFor @@ -427,6 +419,9 @@ internal static IObservable ViewModelWhenAnyValue(TVi .Select(x => ((TViewModel?)x).WhenAnyDynamic(expression, y => y.Value)) .Switch()!; +#if NET6_0_OR_GREATER + [RequiresUnreferencedCode("Method access may reference members that could be trimmed")] +#endif private static Type? GetTypeHelper(string type) => Type.GetType( type, assemblyName => diff --git a/src/ReactiveUI/Mixins/DependencyResolverMixins.cs b/src/ReactiveUI/Mixins/DependencyResolverMixins.cs index 4641c46d33..f1359e7273 100644 --- a/src/ReactiveUI/Mixins/DependencyResolverMixins.cs +++ b/src/ReactiveUI/Mixins/DependencyResolverMixins.cs @@ -11,6 +11,7 @@ namespace ReactiveUI; /// /// Extension methods associated with the IMutableDependencyResolver interface. /// +[Preserve(AllMembers = true)] public static class DependencyResolverMixins { /// @@ -22,8 +23,8 @@ public static class DependencyResolverMixins /// The resolver to initialize. /// Which platforms to use. #if NET6_0_OR_GREATER - [RequiresDynamicCode("The method uses reflection and will not work in AOT environments.")] - [RequiresUnreferencedCode("The method uses reflection and will not work in AOT environments.")] + [RequiresDynamicCode("InitializeReactiveUI uses reflection to locate types which may be trimmed.")] + [RequiresUnreferencedCode("InitializeReactiveUI uses reflection to locate types which may be trimmed.")] #endif public static void InitializeReactiveUI(this IMutableDependencyResolver resolver, params RegistrationNamespace[] registrationNamespaces) { @@ -64,7 +65,11 @@ public static void InitializeReactiveUI(this IMutableDependencyResolver resolver // Set up the built-in registration new Registrations().Register((f, t) => resolver.RegisterConstant(f(), t)); +#if NET6_0_OR_GREATER + new PlatformRegistrations().Register((f, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] t) => resolver.RegisterConstant(f(), t)); +#else new PlatformRegistrations().Register((f, t) => resolver.RegisterConstant(f(), t)); +#endif var fdr = typeof(DependencyResolverMixins); @@ -151,8 +156,7 @@ private static Func TypeFactory( } #if NET6_0_OR_GREATER - [RequiresDynamicCode("The method uses reflection and will not work in AOT environments.")] - [RequiresUnreferencedCode("The method uses reflection and will not work in AOT environments.")] + [RequiresUnreferencedCode("ProcessRegistrationForNamespace uses reflection to locate types which may be trimmed.")] #endif private static void ProcessRegistrationForNamespace(string namespaceName, AssemblyName assemblyName, IMutableDependencyResolver resolver) { @@ -188,7 +192,11 @@ private static void ProcessRegistrationForNamespace(string namespaceName, Assemb if (registerTypeClass is not null) { var registerer = (IWantsToRegisterStuff)Activator.CreateInstance(registerTypeClass)!; +#if NET6_0_OR_GREATER + registerer.Register((f, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] t) => resolver.RegisterConstant(f(), t)); +#else registerer.Register((f, t) => resolver.RegisterConstant(f(), t)); +#endif } } } diff --git a/src/ReactiveUI/Mixins/ReactiveNotifyPropertyChangedMixin.cs b/src/ReactiveUI/Mixins/ReactiveNotifyPropertyChangedMixin.cs index 6ef68a6144..9a58c028b0 100644 --- a/src/ReactiveUI/Mixins/ReactiveNotifyPropertyChangedMixin.cs +++ b/src/ReactiveUI/Mixins/ReactiveNotifyPropertyChangedMixin.cs @@ -9,12 +9,11 @@ namespace ReactiveUI; /// Extension methods associated with the Observable Changes and the /// Reactive Notify Property Changed based events. /// -#if NET6_0_OR_GREATER -[RequiresDynamicCode("ReactiveNotifyPropertyChangedMixin uses RxApp which requires dynamic code generation")] -[RequiresUnreferencedCode("ReactiveNotifyPropertyChangedMixin uses RxApp which may require unreferenced code")] -#endif +[Preserve(AllMembers = true)] public static class ReactiveNotifyPropertyChangedMixin { + [SuppressMessage("AOT", "IL3050:Calling members annotated with 'RequiresDynamicCodeAttribute' may break functionality when AOT compiling.", Justification = "Marked as Preserve")] + [SuppressMessage("Trimming", "IL2026:Calling members annotated with 'RequiresUnreferencedCodeAttribute' may break functionality when trimming application code.", Justification = "Marked as Preserve")] private static readonly MemoizingMRUCache<(Type senderType, string propertyName, bool beforeChange), ICreatesObservableForProperty?> _notifyFactoryCache = new( (t, _) => Locator.Current.GetServices() @@ -43,8 +42,8 @@ public static class ReactiveNotifyPropertyChangedMixin /// If set to true, values are filtered with DistinctUntilChanged. /// An Observable representing the property change notifications for the given property name. #if NET6_0_OR_GREATER - [RequiresDynamicCode("ObservableForProperty uses expression analysis which requires dynamic code generation")] - [RequiresUnreferencedCode("ObservableForProperty may reference properties that could be trimmed")] + [RequiresUnreferencedCode("This method uses reflection to access properties by name.")] + [RequiresDynamicCode("This method uses reflection to access properties by name.")] #endif public static IObservable> ObservableForProperty( this TSender? item, @@ -149,8 +148,8 @@ static TValue GetCurrentValue(object sender, string name) /// The property name to observe. /// An observable sequence of observed changes for the given property name. #if NET6_0_OR_GREATER - [RequiresDynamicCode("ObservableForProperty uses expression analysis which requires dynamic code generation")] - [RequiresUnreferencedCode("ObservableForProperty may reference properties that could be trimmed")] + [RequiresUnreferencedCode("This method uses reflection to access properties by name.")] + [RequiresDynamicCode("This method uses reflection to access properties by name.")] #endif public static IObservable> ObservableForProperty( this TSender? item, @@ -167,8 +166,8 @@ public static IObservable> ObservableForPropert /// If true, the observable will notify immediately before a property is going to change. /// An observable sequence of observed changes for the given property name. #if NET6_0_OR_GREATER - [RequiresDynamicCode("ObservableForProperty uses expression analysis which requires dynamic code generation")] - [RequiresUnreferencedCode("ObservableForProperty may reference properties that could be trimmed")] + [RequiresUnreferencedCode("This method uses reflection to access properties by name.")] + [RequiresDynamicCode("This method uses reflection to access properties by name.")] #endif public static IObservable> ObservableForProperty( this TSender? item, @@ -187,8 +186,8 @@ public static IObservable> ObservableForPropert /// If true, the observable will not notify with the initial value. /// An observable sequence of observed changes for the given property name. #if NET6_0_OR_GREATER - [RequiresDynamicCode("ObservableForProperty uses expression analysis which requires dynamic code generation")] - [RequiresUnreferencedCode("ObservableForProperty may reference properties that could be trimmed")] + [RequiresUnreferencedCode("This method uses reflection to access properties by name.")] + [RequiresDynamicCode("This method uses reflection to access properties by name.")] #endif public static IObservable> ObservableForProperty( this TSender? item, @@ -214,8 +213,8 @@ public static IObservable> ObservableForPropert /// notifications for the given property. /// #if NET6_0_OR_GREATER - [RequiresDynamicCode("ObservableForProperty uses expression analysis which requires dynamic code generation")] - [RequiresUnreferencedCode("ObservableForProperty may reference properties that could be trimmed")] + [RequiresUnreferencedCode("This method uses reflection to access properties by name.")] + [RequiresDynamicCode("This method uses reflection to access properties by name.")] #endif public static IObservable> ObservableForProperty( this TSender? item, @@ -240,8 +239,8 @@ public static IObservable> ObservableForPropert /// notifications for the given property. /// #if NET6_0_OR_GREATER - [RequiresDynamicCode("ObservableForProperty uses expression analysis which requires dynamic code generation")] - [RequiresUnreferencedCode("ObservableForProperty may reference properties that could be trimmed")] + [RequiresUnreferencedCode("This method uses reflection to access properties by name.")] + [RequiresDynamicCode("This method uses reflection to access properties by name.")] #endif public static IObservable> ObservableForProperty( this TSender? item, @@ -269,8 +268,8 @@ public static IObservable> ObservableForPropert /// notifications for the given property. /// #if NET6_0_OR_GREATER - [RequiresDynamicCode("ObservableForProperty uses expression analysis which requires dynamic code generation")] - [RequiresUnreferencedCode("ObservableForProperty may reference properties that could be trimmed")] + [RequiresUnreferencedCode("This method uses reflection to access properties by name.")] + [RequiresDynamicCode("This method uses reflection to access properties by name.")] #endif public static IObservable> ObservableForProperty( this TSender? item, @@ -300,8 +299,8 @@ public static IObservable> ObservableForPropert /// notifications for the given property. /// #if NET6_0_OR_GREATER - [RequiresDynamicCode("ObservableForProperty uses expression analysis which requires dynamic code generation")] - [RequiresUnreferencedCode("ObservableForProperty may reference properties that could be trimmed")] + [RequiresUnreferencedCode("This method uses reflection to access properties by name.")] + [RequiresDynamicCode("This method uses reflection to access properties by name.")] #endif public static IObservable> ObservableForProperty( this TSender? item, @@ -352,8 +351,8 @@ public static IObservable> ObservableForPropert /// An Observable representing the property change /// notifications for the given property. #if NET6_0_OR_GREATER - [RequiresDynamicCode("NotifyForProperty uses expression analysis which requires dynamic code generation")] - [RequiresUnreferencedCode("NotifyForProperty may reference properties that could be trimmed")] + [RequiresUnreferencedCode("This method uses reflection to access properties by name.")] + [RequiresDynamicCode("This method uses reflection to access properties by name.")] #endif public static IObservable ObservableForProperty( this TSender? item, @@ -386,8 +385,8 @@ public static IObservable ObservableForProperty( /// An Observable representing the property change /// notifications for the given property. #if NET6_0_OR_GREATER - [RequiresDynamicCode("NotifyForProperty uses expression analysis which requires dynamic code generation")] - [RequiresUnreferencedCode("NotifyForProperty may reference properties that could be trimmed")] + [RequiresUnreferencedCode("This method uses reflection to access properties by name.")] + [RequiresDynamicCode("This method uses reflection to access properties by name.")] #endif public static IObservable ObservableForProperty( this TSender? item, @@ -416,8 +415,8 @@ public static IObservable ObservableForProperty( /// /// If we cannot cast from the target value from the specified last property. #if NET6_0_OR_GREATER - [RequiresDynamicCode("NotifyForProperty uses expression analysis which requires dynamic code generation")] - [RequiresUnreferencedCode("NotifyForProperty may reference properties that could be trimmed")] + [RequiresUnreferencedCode("This method uses reflection to access properties by name.")] + [RequiresDynamicCode("This method uses reflection to access properties by name.")] #endif public static IObservable> SubscribeToExpressionChain( this TSender? source, @@ -439,8 +438,8 @@ public static IObservable> SubscribeToExpressio /// /// If we cannot cast from the target value from the specified last property. #if NET6_0_OR_GREATER - [RequiresDynamicCode("NotifyForProperty uses expression analysis which requires dynamic code generation")] - [RequiresUnreferencedCode("NotifyForProperty may reference properties that could be trimmed")] + [RequiresUnreferencedCode("This method uses reflection to access properties by name.")] + [RequiresDynamicCode("This method uses reflection to access properties by name.")] #endif public static IObservable> SubscribeToExpressionChain( this TSender? source, @@ -464,8 +463,8 @@ public static IObservable> SubscribeToExpressio /// /// If we cannot cast from the target value from the specified last property. #if NET6_0_OR_GREATER - [RequiresDynamicCode("NotifyForProperty uses expression analysis which requires dynamic code generation")] - [RequiresUnreferencedCode("NotifyForProperty may reference properties that could be trimmed")] + [RequiresUnreferencedCode("This method uses reflection to access properties by name.")] + [RequiresDynamicCode("This method uses reflection to access properties by name.")] #endif public static IObservable> SubscribeToExpressionChain( this TSender? source, @@ -491,8 +490,8 @@ public static IObservable> SubscribeToExpressio /// /// If we cannot cast from the target value from the specified last property. #if NET6_0_OR_GREATER - [RequiresDynamicCode("SubscribeToExpressionChain uses expression analysis which requires dynamic code generation")] - [RequiresUnreferencedCode("SubscribeToExpressionChain may reference properties that could be trimmed")] + [RequiresUnreferencedCode("This method uses reflection to access properties by name.")] + [RequiresDynamicCode("This method uses reflection to access properties by name.")] #endif public static IObservable> SubscribeToExpressionChain( this TSender? source, @@ -520,8 +519,8 @@ public static IObservable> SubscribeToExpressio /// /// If we cannot cast from the target value from the specified last property. #if NET6_0_OR_GREATER - [RequiresDynamicCode("SubscribeToExpressionChain uses expression analysis which requires dynamic code generation")] - [RequiresUnreferencedCode("SubscribeToExpressionChain may reference properties that could be trimmed")] + [RequiresUnreferencedCode("This method uses reflection to access properties by name.")] + [RequiresDynamicCode("This method uses reflection to access properties by name.")] #endif public static IObservable> SubscribeToExpressionChain( this TSender? source, @@ -567,8 +566,8 @@ public static IObservable> SubscribeToExpressio } #if NET6_0_OR_GREATER - [RequiresDynamicCode("NotifyForProperty uses expression analysis which requires dynamic code generation")] - [RequiresUnreferencedCode("NotifyForProperty may reference properties that could be trimmed")] + [RequiresUnreferencedCode("This method uses reflection to access properties by name.")] + [RequiresDynamicCode("This method uses reflection to access properties by name.")] #endif private static IObservable> NestedObservedChanges(Expression expression, IObservedChange sourceChange, bool beforeChange, bool suppressWarnings) { @@ -588,8 +587,8 @@ public static IObservable> SubscribeToExpressio } #if NET6_0_OR_GREATER - [RequiresDynamicCode("NotifyForProperty uses expression analysis which requires dynamic code generation")] - [RequiresUnreferencedCode("NotifyForProperty may reference properties that could be trimmed")] + [RequiresUnreferencedCode("This method uses reflection to access properties by name.")] + [RequiresDynamicCode("This method uses reflection to access properties by name.")] #endif private static IObservable> NotifyForProperty(object sender, Expression expression, bool beforeChange, bool suppressWarnings) { diff --git a/src/ReactiveUI/ObservableFuncMixins.cs b/src/ReactiveUI/ObservableFuncMixins.cs index fa97cec957..6e07fb9e8d 100644 --- a/src/ReactiveUI/ObservableFuncMixins.cs +++ b/src/ReactiveUI/ObservableFuncMixins.cs @@ -23,8 +23,8 @@ public static class ObservableFuncMixins /// An observable Result. /// #if NET6_0_OR_GREATER - [RequiresDynamicCode("ToObservable uses methods that require dynamic code generation")] - [RequiresUnreferencedCode("ToObservable uses methods that may require unreferenced code")] + [RequiresUnreferencedCode("This method uses reflection to access properties by name.")] + [RequiresDynamicCode("This method uses reflection to access properties by name.")] #endif public static IObservable ToObservable( this Expression> expression, diff --git a/src/ReactiveUI/Platforms/android/AndroidCommandBinders.cs b/src/ReactiveUI/Platforms/android/AndroidCommandBinders.cs index 07f3ac5416..147d524632 100644 --- a/src/ReactiveUI/Platforms/android/AndroidCommandBinders.cs +++ b/src/ReactiveUI/Platforms/android/AndroidCommandBinders.cs @@ -13,15 +13,13 @@ namespace ReactiveUI; /// Android implementation that provides binding to an ICommand in the ViewModel to a Control /// in the View. /// +[Preserve(AllMembers = true)] public class AndroidCommandBinders : FlexibleCommandBinder { /// /// Initializes a new instance of the class. /// -#if NET6_0_OR_GREATER - [RequiresDynamicCode("ObservableAsPropertyHelper uses methods that require dynamic code generation")] - [RequiresUnreferencedCode("ObservableAsPropertyHelper uses methods that may require unreferenced code")] -#endif + [SuppressMessage("Trimming", "IL2026:Members annotated with 'RequiresUnreferencedCodeAttribute' require dynamic access otherwise can break functionality when trimming application code", Justification = "Marked as Preserve")] public AndroidCommandBinders() { var view = typeof(View); diff --git a/src/ReactiveUI/Platforms/android/AndroidObservableForWidgets.cs b/src/ReactiveUI/Platforms/android/AndroidObservableForWidgets.cs index 98fd48c276..01b053414e 100644 --- a/src/ReactiveUI/Platforms/android/AndroidObservableForWidgets.cs +++ b/src/ReactiveUI/Platforms/android/AndroidObservableForWidgets.cs @@ -18,10 +18,7 @@ namespace ReactiveUI; /// Android view objects are not Generally Observableā„¢, so hard-code some /// particularly useful types. /// -#if NET6_0_OR_GREATER -[RequiresDynamicCode("AndroidObservableForWidgets uses reflection for property access and type checking which require dynamic code generation")] -[RequiresUnreferencedCode("AndroidObservableForWidgets uses reflection for property access and type checking which may require unreferenced code")] -#endif +[Preserve(AllMembers = true)] public class AndroidObservableForWidgets : ICreatesObservableForProperty { private static readonly Dictionary<(Type viewType, string? propertyName), Func>>> _dispatchTable; @@ -119,10 +116,6 @@ void Handler(object? sender, AdapterView.NothingSelectedEventArgs e) => [ObsoletedOSPlatform("android23.0")] [SupportedOSPlatform("android23.0")] -#if NET6_0_OR_GREATER - [RequiresDynamicCode("CreateFromWidget uses expression analysis which requires dynamic code generation")] - [RequiresUnreferencedCode("CreateFromWidget may reference members that could be trimmed")] -#endif private static DispatchItem CreateTimePickerHourFromWidget() { if ((int)Build.VERSION.SdkInt >= 23) @@ -135,10 +128,6 @@ private static DispatchItem CreateTimePickerHourFromWidget() [ObsoletedOSPlatform("android23.0")] [SupportedOSPlatform("android23.0")] -#if NET6_0_OR_GREATER - [RequiresDynamicCode("CreateFromWidget uses expression analysis which requires dynamic code generation")] - [RequiresUnreferencedCode("CreateFromWidget may reference members that could be trimmed")] -#endif private static DispatchItem CreateTimePickerMinuteFromWidget() { if ((int)Build.VERSION.SdkInt >= 23) @@ -149,10 +138,8 @@ private static DispatchItem CreateTimePickerMinuteFromWidget() return CreateFromWidget(v => v.CurrentMinute, (v, h) => v.TimeChanged += h, (v, h) => v.TimeChanged -= h); } -#if NET6_0_OR_GREATER - [RequiresDynamicCode("CreateFromWidget uses expression analysis which requires dynamic code generation")] - [RequiresUnreferencedCode("CreateFromWidget may reference members that could be trimmed")] -#endif + [SuppressMessage("Trimming", "IL2026:Members annotated with 'RequiresUnreferencedCodeAttribute' require dynamic access otherwise can break functionality when trimming application code", Justification = "Marked as Preserve")] + [SuppressMessage("AOT", "IL3050:Calling members annotated with 'RequiresDynamicCodeAttribute' may break functionality when AOT compiling.", Justification = "Marked as Preserve")] private static DispatchItem CreateFromWidget(Expression> property, Action> addHandler, Action> removeHandler) where TView : View where TEventArgs : EventArgs diff --git a/src/ReactiveUI/Platforms/android/BundleSuspensionDriver.cs b/src/ReactiveUI/Platforms/android/BundleSuspensionDriver.cs index 201c24e447..7a9cb2db3d 100644 --- a/src/ReactiveUI/Platforms/android/BundleSuspensionDriver.cs +++ b/src/ReactiveUI/Platforms/android/BundleSuspensionDriver.cs @@ -37,7 +37,7 @@ public class BundleSuspensionDriver : ISuspensionDriver var st = new MemoryStream(buffer); - return Observable.Return(JsonSerializer.Deserialize(st)); + return Observable.FromAsync(async () => await JsonSerializer.DeserializeAsync(st)); } catch (Exception ex) { diff --git a/src/ReactiveUI/Platforms/android/FlexibleCommandBinder.cs b/src/ReactiveUI/Platforms/android/FlexibleCommandBinder.cs index 9a25b1e582..9240466605 100644 --- a/src/ReactiveUI/Platforms/android/FlexibleCommandBinder.cs +++ b/src/ReactiveUI/Platforms/android/FlexibleCommandBinder.cs @@ -83,8 +83,7 @@ public IDisposable BindCommandToObject(ICommand? command, object? ta /// Event name. /// Enabled property name. #if NET6_0_OR_GREATER - [RequiresDynamicCode("ForEvent uses Reflection.GetValueSetterForProperty which requires dynamic code generation")] - [RequiresUnreferencedCode("ForEvent uses Reflection.GetValueSetterForProperty which may require unreferenced code")] + [RequiresUnreferencedCode("This member uses reflection to discover event members and associated delegate types.")] #endif protected static IDisposable ForEvent(ICommand? command, object? target, IObservable commandParameter, string eventName, PropertyInfo enabledProperty) { diff --git a/src/ReactiveUI/Platforms/android/PlatformRegistrations.cs b/src/ReactiveUI/Platforms/android/PlatformRegistrations.cs index 7ad50d6496..9ee85d27e6 100644 --- a/src/ReactiveUI/Platforms/android/PlatformRegistrations.cs +++ b/src/ReactiveUI/Platforms/android/PlatformRegistrations.cs @@ -12,12 +12,6 @@ namespace ReactiveUI; 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 { ArgumentNullException.ThrowIfNull(registerFunction); diff --git a/src/ReactiveUI/Platforms/apple-common/AppSupportJsonSuspensionDriver.cs b/src/ReactiveUI/Platforms/apple-common/AppSupportJsonSuspensionDriver.cs index ccb1beff12..27dacd3b53 100644 --- a/src/ReactiveUI/Platforms/apple-common/AppSupportJsonSuspensionDriver.cs +++ b/src/ReactiveUI/Platforms/apple-common/AppSupportJsonSuspensionDriver.cs @@ -12,16 +12,11 @@ namespace ReactiveUI; /// /// Loads and saves state to persistent storage. /// -#if NET6_0_OR_GREATER -[RequiresDynamicCode("AppSupportJsonSuspensionDriver uses JsonSerializer which requires dynamic code generation")] -[RequiresUnreferencedCode("AppSupportJsonSuspensionDriver uses JsonSerializer which may require unreferenced code")] -#endif public class AppSupportJsonSuspensionDriver : ISuspensionDriver { /// #if NET6_0_OR_GREATER [RequiresDynamicCode("LoadState uses JsonSerializer.Deserialize which requires dynamic code generation")] - [RequiresUnreferencedCode("LoadState uses JsonSerializer.Deserialize which may require unreferenced code")] #endif public IObservable LoadState() { @@ -46,7 +41,6 @@ public class AppSupportJsonSuspensionDriver : ISuspensionDriver /// #if NET6_0_OR_GREATER [RequiresDynamicCode("SaveState uses JsonSerializer.Serialize which requires dynamic code generation")] - [RequiresUnreferencedCode("SaveState uses JsonSerializer.Serialize which may require unreferenced code")] #endif public IObservable SaveState(object state) { @@ -68,6 +62,9 @@ public IObservable SaveState(object state) } /// +#if NET6_0_OR_GREATER + [RequiresDynamicCode("InvalidateState uses JsonSerializer.Serialize which requires dynamic code generation")] +#endif public IObservable InvalidateState() { try diff --git a/src/ReactiveUI/Platforms/apple-common/KVOObservableForProperty.cs b/src/ReactiveUI/Platforms/apple-common/KVOObservableForProperty.cs index 7185acb617..512678bba3 100644 --- a/src/ReactiveUI/Platforms/apple-common/KVOObservableForProperty.cs +++ b/src/ReactiveUI/Platforms/apple-common/KVOObservableForProperty.cs @@ -18,10 +18,7 @@ namespace ReactiveUI; /// tell whether a given property on an object is Key-Value Observable, we /// only have to hope for the best :-/. /// -#if NET6_0_OR_GREATER -[RequiresDynamicCode("KVOObservableForProperty uses reflection to analyze properties and may access members that require dynamic code")] -[RequiresUnreferencedCode("KVOObservableForProperty uses reflection to analyze properties that may be trimmed")] -#endif +[Preserve(AllMembers = true)] public class KVOObservableForProperty : ICreatesObservableForProperty { private static readonly MemoizingMRUCache<(Type type, string propertyName), bool> _declaredInNSObject; @@ -61,9 +58,16 @@ static KVOObservableForProperty() } /// - public int GetAffinityForObject(Type type, string propertyName, bool beforeChanged = false) => _declaredInNSObject.Get((type, propertyName)) ? 15 : 0; +#if NET6_0_OR_GREATER + [RequiresDynamicCode("This code uses reflection to find properties which requires dynamic code generation.")] +#endif + public int GetAffinityForObject([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type type, string propertyName, bool beforeChanged = false) => + _declaredInNSObject.Get((type, propertyName)) ? 15 : 0; /// +#if NET6_0_OR_GREATER + [RequiresDynamicCode("This code uses reflection to find properties which requires dynamic code generation.")] +#endif public IObservable> GetNotificationForProperty(object sender, Expression expression, string propertyName, bool beforeChanged = false, bool suppressWarnings = false) { if (sender is not NSObject obj) @@ -90,7 +94,7 @@ static KVOObservableForProperty() }); } - private static string FindCocoaNameFromNetName(Type senderType, string propertyName) + private static string FindCocoaNameFromNetName([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type senderType, string propertyName) { var propIsBoolean = false; diff --git a/src/ReactiveUI/Platforms/ios/UIKitCommandBinders.cs b/src/ReactiveUI/Platforms/ios/UIKitCommandBinders.cs index f5839d9529..8bc35e2f22 100644 --- a/src/ReactiveUI/Platforms/ios/UIKitCommandBinders.cs +++ b/src/ReactiveUI/Platforms/ios/UIKitCommandBinders.cs @@ -12,7 +12,8 @@ namespace ReactiveUI; /// /// UI Kit command binder platform registrations. /// -/// +/// +[Preserve(AllMembers = true)] public class UIKitCommandBinders : FlexibleCommandBinder { private const string Enabled = nameof(Enabled); @@ -20,10 +21,7 @@ public class UIKitCommandBinders : FlexibleCommandBinder /// /// Initializes a new instance of the class. /// -#if NET6_0_OR_GREATER - [RequiresDynamicCode("UIKitCommandBinders uses methods that require dynamic code generation")] - [RequiresUnreferencedCode("UIKitCommandBinders uses methods that may require unreferenced code")] -#endif + [SuppressMessage("AOT", "IL3050:Calling members annotated with 'RequiresDynamicCodeAttribute' may break functionality when AOT compiling.", Justification = "Marked as Preserve")] public UIKitCommandBinders() { Register(typeof(UIControl), 9, (cmd, t, cp) => ForTargetAction(cmd, t, cp, typeof(UIControl).GetRuntimeProperty(Enabled) ?? throw new InvalidOperationException("There is no Enabled property on the UIControl which is needed for binding."))); diff --git a/src/ReactiveUI/Platforms/mobile-common/ComponentModelTypeConverter.cs b/src/ReactiveUI/Platforms/mobile-common/ComponentModelTypeConverter.cs index ba5918dbc7..84ff037056 100644 --- a/src/ReactiveUI/Platforms/mobile-common/ComponentModelTypeConverter.cs +++ b/src/ReactiveUI/Platforms/mobile-common/ComponentModelTypeConverter.cs @@ -8,12 +8,11 @@ namespace ReactiveUI; /// /// The component model binding type converter. /// -#if NET6_0_OR_GREATER -[RequiresDynamicCode("Component model type conversion uses reflection and dynamic code generation")] -[RequiresUnreferencedCode("Component model type conversion may reference types that could be trimmed")] -#endif +[Preserve(AllMembers = true)] public class ComponentModelTypeConverter : IBindingTypeConverter { + [SuppressMessage("Trimming", "IL2026:Members annotated with 'RequiresUnreferencedCodeAttribute' require dynamic access otherwise can break functionality when trimming application code", Justification="TypeDescriptor is safe to use here as we are not using reflection ourselves")] + [SuppressMessage("AOT", "IL2077:Members annotated with 'RequiresDynamicCodeAttribute' require dynamic access otherwise can break functionality when ahead-of-time (AOT) compiling application code", Justification="TypeDescriptor is safe to use here as we are not using dynamic code ourselves")] private readonly MemoizingMRUCache<(Type fromType, Type toType), TypeConverter?> _typeConverterCache = new( static (types, _) => { diff --git a/src/ReactiveUI/Platforms/uikit-common/PlatformRegistrations.cs b/src/ReactiveUI/Platforms/uikit-common/PlatformRegistrations.cs index d9e1448d96..de394bf29a 100644 --- a/src/ReactiveUI/Platforms/uikit-common/PlatformRegistrations.cs +++ b/src/ReactiveUI/Platforms/uikit-common/PlatformRegistrations.cs @@ -8,16 +8,12 @@ namespace ReactiveUI; /// /// UIKit platform registrations. /// -/// +/// +[Preserve(AllMembers = true)] 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 + [SuppressMessage("AOT", "IL3050:Calling members annotated with 'RequiresDynamicCodeAttribute' may break functionality when AOT compiling.", Justification = "Marked as Preserve")] public void Register(Action, Type> registerFunction) { ArgumentNullException.ThrowIfNull(registerFunction); diff --git a/src/ReactiveUI/ReactiveObject/IReactiveObjectExtensions.cs b/src/ReactiveUI/ReactiveObject/IReactiveObjectExtensions.cs index b802329621..36c6739590 100644 --- a/src/ReactiveUI/ReactiveObject/IReactiveObjectExtensions.cs +++ b/src/ReactiveUI/ReactiveObject/IReactiveObjectExtensions.cs @@ -10,7 +10,7 @@ namespace ReactiveUI; /// /// Extension methods associated with the IReactiveObject interface. /// -[ReactiveUI.Preserve(AllMembers = true)] +[Preserve(AllMembers = true)] public static class IReactiveObjectExtensions { #if NETSTANDARD || NETFRAMEWORK @@ -104,10 +104,6 @@ private interface IExtensionState /// The name of the property, usually /// automatically provided through the CallerMemberName attribute. /// The newly set value, normally discarded. -#if NET6_0_OR_GREATER - [RequiresDynamicCode("Extension state uses RxApp.DefaultExceptionHandler which requires dynamic code generation")] - [RequiresUnreferencedCode("Extension state uses RxApp.DefaultExceptionHandler which may require unreferenced code")] -#endif public static TRet RaiseAndSetIfChanged( this TObj reactiveObject, ref TRet backingField, @@ -138,10 +134,6 @@ public static TRet RaiseAndSetIfChanged( /// A string representing the name of the property that has been changed. /// Leave null to let the runtime set to caller member name. /// -#if NET6_0_OR_GREATER - [RequiresDynamicCode("Extension state uses RxApp.DefaultExceptionHandler which requires dynamic code generation")] - [RequiresUnreferencedCode("Extension state uses RxApp.DefaultExceptionHandler which may require unreferenced code")] -#endif public static void RaisePropertyChanged(this TSender reactiveObject, [CallerMemberName] string? propertyName = null) where TSender : IReactiveObject { @@ -161,10 +153,6 @@ public static void RaisePropertyChanged(this TSender reactiveObject, [C /// A string representing the name of the property that has been changed. /// Leave null to let the runtime set to caller member name. /// -#if NET6_0_OR_GREATER - [RequiresDynamicCode("Extension state uses RxApp.DefaultExceptionHandler which requires dynamic code generation")] - [RequiresUnreferencedCode("Extension state uses RxApp.DefaultExceptionHandler which may require unreferenced code")] -#endif public static void RaisePropertyChanging(this TSender reactiveObject, [CallerMemberName] string? propertyName = null) where TSender : IReactiveObject { @@ -180,10 +168,6 @@ public static void RaisePropertyChanging(this TSender reactiveObject, [ /// /// The sender type. /// The instance of IReactiveObject which should propagate property changes. -#if NET6_0_OR_GREATER - [RequiresDynamicCode("Extension state uses RxApp.DefaultExceptionHandler which requires dynamic code generation")] - [RequiresUnreferencedCode("Extension state uses RxApp.DefaultExceptionHandler which may require unreferenced code")] -#endif public static void SubscribePropertyChangingEvents(this TSender reactiveObject) where TSender : IReactiveObject { @@ -198,10 +182,6 @@ public static void SubscribePropertyChangingEvents(this TSender reactiv /// /// The sender type. /// The instance of IReactiveObject which should propagate property changes. -#if NET6_0_OR_GREATER - [RequiresDynamicCode("Extension state uses RxApp.DefaultExceptionHandler which requires dynamic code generation")] - [RequiresUnreferencedCode("Extension state uses RxApp.DefaultExceptionHandler which may require unreferenced code")] -#endif public static void SubscribePropertyChangedEvents(this TSender reactiveObject) where TSender : IReactiveObject { @@ -210,10 +190,6 @@ public static void SubscribePropertyChangedEvents(this TSender reactive s.SubscribePropertyChangedEvents(); } -#if NET6_0_OR_GREATER - [RequiresDynamicCode("Extension state uses RxApp.DefaultExceptionHandler which requires dynamic code generation")] - [RequiresUnreferencedCode("Extension state uses RxApp.DefaultExceptionHandler which may require unreferenced code")] -#endif internal static IObservable> GetChangedObservable(this TSender reactiveObject) where TSender : IReactiveObject { @@ -221,10 +197,6 @@ internal static IObservable> GetChang return val.Changed.Cast>(); } -#if NET6_0_OR_GREATER - [RequiresDynamicCode("Extension state uses RxApp.DefaultExceptionHandler which requires dynamic code generation")] - [RequiresUnreferencedCode("Extension state uses RxApp.DefaultExceptionHandler which may require unreferenced code")] -#endif internal static IObservable> GetChangingObservable(this TSender reactiveObject) where TSender : IReactiveObject { @@ -232,10 +204,6 @@ internal static IObservable> GetChang return val.Changing.Cast>(); } -#if NET6_0_OR_GREATER - [RequiresDynamicCode("Extension state uses RxApp.DefaultExceptionHandler which requires dynamic code generation")] - [RequiresUnreferencedCode("Extension state uses RxApp.DefaultExceptionHandler which may require unreferenced code")] -#endif internal static IObservable GetThrownExceptionsObservable(this TSender reactiveObject) where TSender : IReactiveObject { @@ -243,10 +211,6 @@ internal static IObservable GetThrownExceptionsObservable(th return s.ThrownExceptions; } -#if NET6_0_OR_GREATER - [RequiresDynamicCode("Extension state uses RxApp.DefaultExceptionHandler which requires dynamic code generation")] - [RequiresUnreferencedCode("Extension state uses RxApp.DefaultExceptionHandler which may require unreferenced code")] -#endif internal static void RaisingPropertyChanging(this TSender reactiveObject, string propertyName) where TSender : IReactiveObject { @@ -257,10 +221,6 @@ internal static void RaisingPropertyChanging(this TSender reactiveObjec s.RaisePropertyChanging(propertyName); } -#if NET6_0_OR_GREATER - [RequiresDynamicCode("Extension state uses RxApp.DefaultExceptionHandler which requires dynamic code generation")] - [RequiresUnreferencedCode("Extension state uses RxApp.DefaultExceptionHandler which may require unreferenced code")] -#endif internal static void RaisingPropertyChanged(this TSender reactiveObject, string propertyName) where TSender : IReactiveObject { @@ -271,10 +231,6 @@ internal static void RaisingPropertyChanged(this TSender reactiveObject s.RaisePropertyChanged(propertyName); } -#if NET6_0_OR_GREATER - [RequiresDynamicCode("Extension state uses RxApp.DefaultExceptionHandler which requires dynamic code generation")] - [RequiresUnreferencedCode("Extension state uses RxApp.DefaultExceptionHandler which may require unreferenced code")] -#endif internal static IDisposable SuppressChangeNotifications(this TSender reactiveObject) where TSender : IReactiveObject { @@ -283,10 +239,6 @@ internal static IDisposable SuppressChangeNotifications(this TSender re return s.SuppressChangeNotifications(); } -#if NET6_0_OR_GREATER - [RequiresDynamicCode("Extension state uses RxApp.DefaultExceptionHandler which requires dynamic code generation")] - [RequiresUnreferencedCode("Extension state uses RxApp.DefaultExceptionHandler which may require unreferenced code")] -#endif internal static bool AreChangeNotificationsEnabled(this TSender reactiveObject) where TSender : IReactiveObject { @@ -295,10 +247,6 @@ internal static bool AreChangeNotificationsEnabled(this TSender reactiv return s.AreChangeNotificationsEnabled(); } -#if NET6_0_OR_GREATER - [RequiresDynamicCode("Extension state uses RxApp.DefaultExceptionHandler which requires dynamic code generation")] - [RequiresUnreferencedCode("Extension state uses RxApp.DefaultExceptionHandler which may require unreferenced code")] -#endif internal static IDisposable DelayChangeNotifications(this TSender reactiveObject) where TSender : IReactiveObject { @@ -307,10 +255,6 @@ internal static IDisposable DelayChangeNotifications(this TSender react return s.DelayChangeNotifications(); } -#if NET6_0_OR_GREATER - [RequiresDynamicCode("Extension state uses RxApp.DefaultExceptionHandler which requires dynamic code generation")] - [RequiresUnreferencedCode("Extension state uses RxApp.DefaultExceptionHandler which may require unreferenced code")] -#endif private class ExtensionState : IExtensionState where TSender : IReactiveObject { @@ -329,10 +273,6 @@ private class ExtensionState : IExtensionState /// Initializes a new instance of the class. /// /// The sender. -#if NET6_0_OR_GREATER - [RequiresDynamicCode("Extension state uses RxApp.DefaultExceptionHandler which requires dynamic code generation")] - [RequiresUnreferencedCode("Extension state uses RxApp.DefaultExceptionHandler which may require unreferenced code")] -#endif public ExtensionState(TSender sender) { _sender = sender; diff --git a/src/ReactiveUI/ReactiveObject/ReactiveObject.cs b/src/ReactiveUI/ReactiveObject/ReactiveObject.cs index f59344006a..3cc39334a7 100644 --- a/src/ReactiveUI/ReactiveObject/ReactiveObject.cs +++ b/src/ReactiveUI/ReactiveObject/ReactiveObject.cs @@ -22,10 +22,6 @@ public class ReactiveObject : IReactiveNotifyPropertyChanged, I /// /// Initializes a new instance of the class. /// -#if NET6_0_OR_GREATER - [RequiresDynamicCode("ReactiveObject uses extension methods that require dynamic code generation")] - [RequiresUnreferencedCode("ReactiveObject uses extension methods that may require unreferenced code")] -#endif public ReactiveObject() { _changing = new Lazy>>(() => ((IReactiveObject)this).GetChangingObservable(), LazyThreadSafetyMode.PublicationOnly); @@ -112,8 +108,8 @@ void IReactiveObject.RaisePropertyChanged(PropertyChangedEventArgs args) => /// #if NET6_0_OR_GREATER - [RequiresDynamicCode("SuppressChangeNotifications uses extension methods that require dynamic code generation")] - [RequiresUnreferencedCode("SuppressChangeNotifications uses extension methods that may require unreferenced code")] + [RequiresUnreferencedCode("This method uses reflection to access properties by name.")] + [RequiresDynamicCode("This method uses reflection to access properties by name.")] #endif public IDisposable SuppressChangeNotifications() => // TODO: Create Test IReactiveObjectExtensions.SuppressChangeNotifications(this); @@ -122,10 +118,6 @@ public IDisposable SuppressChangeNotifications() => // TODO: Create Test /// Determines if change notifications are enabled or not. /// /// A value indicating whether change notifications are enabled. -#if NET6_0_OR_GREATER - [RequiresDynamicCode("AreChangeNotificationsEnabled uses extension methods that require dynamic code generation")] - [RequiresUnreferencedCode("AreChangeNotificationsEnabled uses extension methods that may require unreferenced code")] -#endif public bool AreChangeNotificationsEnabled() => // TODO: Create Test IReactiveObjectExtensions.AreChangeNotificationsEnabled(this); @@ -133,12 +125,6 @@ public bool AreChangeNotificationsEnabled() => // TODO: Create Test /// Delays notifications until the return IDisposable is disposed. /// /// A disposable which when disposed will send delayed notifications. -#if NET6_0_OR_GREATER - [RequiresDynamicCode("DelayChangeNotifications uses extension methods that require dynamic code generation")] - [RequiresUnreferencedCode("DelayChangeNotifications uses extension methods that may require unreferenced code")] -#endif public IDisposable DelayChangeNotifications() => IReactiveObjectExtensions.DelayChangeNotifications(this); } - -// vim: tw=120 ts=4 sw=4 et : diff --git a/src/ReactiveUI/ReactiveUI.csproj b/src/ReactiveUI/ReactiveUI.csproj index b6ac52c23c..1f1aabdfa9 100644 --- a/src/ReactiveUI/ReactiveUI.csproj +++ b/src/ReactiveUI/ReactiveUI.csproj @@ -32,6 +32,7 @@ + diff --git a/src/ReactiveUI/RxApp.cs b/src/ReactiveUI/RxApp.cs index 3d75defd55..4f5b00c1d1 100644 --- a/src/ReactiveUI/RxApp.cs +++ b/src/ReactiveUI/RxApp.cs @@ -28,10 +28,6 @@ namespace ReactiveUI; /// This class also initializes a whole bunch of other stuff, including the IoC container, /// logging and error handling. /// -#if NET6_0_OR_GREATER -[RequiresDynamicCode("RxApp initialization uses reflection-based registration which requires dynamic code generation.")] -[RequiresUnreferencedCode("RxApp initialization uses reflection-based registration which may require unreferenced code.")] -#endif public static class RxApp { #if ANDROID || IOS @@ -79,24 +75,26 @@ public static class RxApp /// Initializes static members of the class. /// /// Default exception when we have unhandled exception in RxUI. + [SuppressMessage("AOT", "IL3050:Calling members annotated with 'RequiresDynamicCodeAttribute' may break functionality when AOT compiling.", Justification = "Recommend using AppBuilder")] + [SuppressMessage("Trimming", "IL2026:Calling members annotated with 'RequiresUnreferencedCodeAttribute' may break functionality when trimming.", Justification = "Recommend using AppBuilder")] static RxApp() { #if !PORTABLE _taskpoolScheduler = TaskPoolScheduler.Default; #endif - Locator.CurrentMutable.InitializeSplat(); + AppLocator.CurrentMutable.InitializeSplat(); if (!AppBuilder.UsingBuilder) { - Locator.RegisterResolverCallbackChanged(() => + AppLocator.RegisterResolverCallbackChanged(() => { - if (Locator.CurrentMutable is null) + if (AppLocator.CurrentMutable is null) { return; } - Locator.CurrentMutable.InitializeSplat(); - Locator.CurrentMutable.InitializeReactiveUI(PlatformRegistrationManager.NamespacesToRegister); + AppLocator.CurrentMutable.InitializeSplat(); + AppLocator.CurrentMutable.InitializeReactiveUI(PlatformRegistrationManager.NamespacesToRegister); }); } diff --git a/src/ReactiveUI/Suspension/SuspensionHost.cs b/src/ReactiveUI/Suspension/SuspensionHost.cs index 0155678f50..db4784c40b 100644 --- a/src/ReactiveUI/Suspension/SuspensionHost.cs +++ b/src/ReactiveUI/Suspension/SuspensionHost.cs @@ -9,10 +9,6 @@ namespace ReactiveUI; /// A internal state setup by other classes for the different suspension state of a application. /// The user does not implement themselves but is often setup via the AutoSuspendHelper class. /// -#if NET6_0_OR_GREATER -[RequiresDynamicCode("SuspensionHost uses ReactiveObject which requires dynamic code generation")] -[RequiresUnreferencedCode("SuspensionHost uses ReactiveObject which may require unreferenced code")] -#endif internal class SuspensionHost : ReactiveObject, ISuspensionHost, IDisposable { private readonly ReplaySubject> _isLaunchingNew = new(1); diff --git a/src/tests.runsettings b/src/tests.runsettings index 1fcb7c1ae3..70cbd12857 100644 --- a/src/tests.runsettings +++ b/src/tests.runsettings @@ -2,7 +2,7 @@ - 1 + 2 true