Repository navigation
feat!: move reflection and AOT-unsafe APIs into opt-in .Unsafe packages - #4565
Merged
Merged
Conversation
- Add 12 opt-in .Unsafe and .Unsafe.Reactive projects for ReactiveUI, AndroidX, WPF, MAUI, WinUI, and WinForms. - Move *Unsafe view hosts/hooks, RegisterViewsForViewModels, WithViewsFromAssembly, reflection AutoPersist, expression AddValidation, reflection suspension drivers, and Android ControlFetcherMixins into the .Unsafe packages. - Add reflection-free ReactivePropertyMixins.AddValidation overloads taking explicit ValidationAttribute arrays. - Update non-pinned NuGet dependencies (ReactiveUI.Primitives 10.2.3, ReactiveUI.Binding 12.1.0, ReactiveUI.SourceGenerators 7.1.0, TUnit 1.87.12, SonarAnalyzer.CSharp 10.37.0.15768, Microsoft.Bcl.TimeProvider 11.0.0) and mark delegate lambdas static. - Regenerate PublicAPI.txt baselines for all affected assemblies. BREAKING CHANGE: Reflection-based APIs moved to opt-in *.Unsafe / *.Unsafe.Reactive packages. Use the matching .Unsafe package or the compile-time generators in ReactiveUI.SourceGenerators 7.1.0.
…x Windows/Apple CI - Add compile-time [RegisterView], [AutoPersist], [ReactiveValidation], and Android [WireUpControls] examples to Documentation pages. - Mark remaining UIKit, WinForms, and WPF test binding lambdas static for ReactiveUI.Binding 12.1.0 (PSH1000). - Document InvalidOperationException on AppSupportJsonSuspensionDriverUnsafe.CreateAppDirectory (SST1662). - Update WPF tests to call DummySuspensionDriverUnsafe and UnsafeReactivePropertyMixins explicitly.
…n across .Unsafe projects - Extract SuspensionHostHelpers (SubscribeLifecycle, WaitForResult, DriverOperationObserver, PendingLoad) shared between SuspensionHostExtensions and UnsafeSuspensionHostExtensions. - Extract AppleAppDirectoryHelper.CreateAppDirectory shared between AppSupportJsonSuspensionDriver and AppSupportJsonSuspensionDriverUnsafe. - Extract ItemsControlTemplateBinding.CreateWpfItemTemplate shared between AutoDataTemplateBindingHook and AutoDataTemplateBindingHookUnsafe. - Consolidate five duplicate ViewResolutionMessages files into one shared ReactiveUI.Unsafe.Shared/ViewResolutionMessages.cs.
…ability - Call ItemsControlTemplateBinding.CreateWpfItemTemplate in UnsafeViewResolutionTests. - Match nullable Expression<Func<ReactiveProperty<string>?>> in ReactivePropertyMixinsTests (CS8620).
… mixins - Replace repeated multi-line RequiresUnreferencedCode/RequiresDynamicCode string literals with private const string fields in UnsafeAutoPersistHelperMixins and UnsafeSuspensionHostExtensions.
…rMixins and UnsafeAutoPersistHelperMixins - Extract AutoPersistMetadataInspector.Inspect into src/Shared/Mixins/AutoPersistMetadataInspector.cs and compile-include it into ReactiveUI, ReactiveUI.Reactive, ReactiveUI.Unsafe, and ReactiveUI.Unsafe.Reactive.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4565 +/- ##
==========================================
+ Coverage 93.88% 94.93% +1.05%
==========================================
Files 175 184 +9
Lines 6112 6086 -26
Branches 737 728 -9
==========================================
+ Hits 5738 5778 +40
+ Misses 374 308 -66 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…mmand helpers - Add HandleFirstRender and SetViewModel helpers in ReactiveComponentHelpers and call them from all four Blazor component bases. - Extract ItemViewLayoutHelper for MAUI text and image item views and inline BindableProperty change lambdas. - Share DisposeAll, TryRecordValue, TryFail, and TryComplete helpers across CombinedReactiveCommand sinks.
- Cover DummySuspensionDriverUnsafe typed LoadState and SaveState overloads. - Cover ReactivePropertyMixins.AddValidation without displayName and with empty attributes. - Cover SuspensionHostHelpers error, completion, synchronous throw, and double-complete paths. - Cover NonNullCastObservable error and completion forwarding.
- Wrap a locator driver that only implements ISuspensionDriver so the reflection-based SetupDefaultSuspendResume finds the platform default driver. - Add a hidden EnsureAppStateLoaded hook so the untyped GetAppState runs the load a typed setup registered. - Cover the remaining suspension and CombinedReactiveCommand sink lines and branches.
- ReactiveUI.WinUI and ReactiveUI.WinUI.Reactive compile ReactiveUI.Maui/Internal, so the MAUI-only helper broke their builds. - Keep the helper next to the item views that use it.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
Moves reflection-based and AOT-unsafe APIs out of the core ReactiveUI and platform packages into dedicated opt-in
.Unsafeand.Unsafe.Reactivepackages, adds reflection-free alternatives and runnable source-generator examples, deduplicates shared internal helpers across the safe and unsafe packages, and updates non-pinned NuGet dependencies.ReactiveUI.Unsafe,ReactiveUI.AndroidX.Unsafe,ReactiveUI.Wpf.Unsafe,ReactiveUI.Maui.Unsafe,ReactiveUI.WinUI.Unsafe,ReactiveUI.Winforms.Unsafe, and their.Reactivecounterparts) and add them tosrc/reactiveui.slnx.*Unsafeview hosts and data-template hooks,DependencyResolverMixins.RegisterViewsForViewModels,WithViewsFromAssembly(UnsafeReactiveUIBuilderExtensions), reflection-basedAutoPersist/AutoPersistCollection(UnsafeAutoPersistHelperMixins), expression-basedReactivePropertyMixins.AddValidation(UnsafeReactivePropertyMixins), reflection suspension drivers (IUnsafeSuspensionDriver,UnsafeSuspensionHostExtensions,DummySuspensionDriverUnsafe,AppSupportJsonSuspensionDriverUnsafe,BundleSuspensionDriverUnsafe), and AndroidControlFetcherMixins+ResolveStrategyinto the.Unsafepackages.ReactivePropertyMixins.AddValidation(params ValidationAttribute[])andAddValidation(string? displayName, params ValidationAttribute[])overloads, and keepReactiveTableViewSourceExtensions/ReactiveCollectionViewSourceExtensionsin the safe Apple packages without stale trim/AOT attributes.ReactiveUI.SourceGenerators7.1.0 attributes ([RegisterView],[AutoPersist],[ReactiveValidation], and Android[WireUpControls]/[WireUpResource]/[IgnoreResource]).internal statichelpers (SuspensionHostHelpers,AppleAppDirectoryHelper,ItemsControlTemplateBinding,ViewResolutionMessages,AutoPersistMetadataInspector,ReactiveComponentHelpers,ItemViewLayoutHelper, andCombinedReactiveCommandsink helpers) to eliminate duplication without changing public APIs or addingInternalsVisibleTobetween production assemblies.DummySuspensionDriverUnsafetyped overloads,ReactivePropertyMixins.AddValidationoverloads,SuspensionHostHelperserror/completion/synchronous-throw/double-complete paths, andNonNullCastObservableerror/completion forwarding.src/Directory.Packages.props(ReactiveUI.Primitives10.2.3,ReactiveUI.Binding12.1.0,ReactiveUI.SourceGenerators7.1.0,TUnit1.87.12,SonarAnalyzer.CSharp10.37.0.15768,Microsoft.Bcl.TimeProvider11.0.0) and addstaticto delegate lambdas forReactiveUI.Binding12.1.0.PublicAPI.txtbaselines.Why
Keeping
[RequiresUnreferencedCode]and[RequiresDynamicCode]reflection APIs in the main packages forces trim/AOT warnings onto consumers who never use reflection and bloats the core surface. Separating them into opt-in.Unsafepackages keeps the main packages trim- and Native AOT-clean while giving existing consumers a direct migration path and compile-time alternatives inReactiveUI.SourceGenerators7.1.0.Closes #4561
Breaking changes
ViewModelViewHostUnsafe,RoutedViewHostUnsafe,AutoDataTemplateBindingHookUnsafe),RegisterViewsForViewModels,WithViewsFromAssembly, reflectionAutoPersist/AutoPersistCollection, expression-basedReactivePropertyMixins.AddValidation, reflection suspension drivers, and AndroidControlFetcherMixinsmoved from the core/platform packages to the corresponding*.Unsafe/*.Unsafe.Reactivepackages..Unsafepackage or switch to the compile-time alternatives inReactiveUI.SourceGenerators([RegisterView],[AutoPersist],[ReactiveValidation],[WireUpControls]) and the explicitAddValidation(displayName, params ValidationAttribute[])overload.ReactiveUI.Bindingupdated to 12.1.0 (delegate-based binding lambdas).How this was verified
TrackPublicApi=true(0 warnings, 0 errors).ReactiveUI.Tests,ReactiveUI.Tests.Reactive,ReactiveUI.Blazor.Tests,ReactiveUI.Blazor.Tests.Reactive, andReactiveUI.Maui.Testson bothnet10.0andnet11.0on Linux.Notes for the reviewer
.Unsafe/.Unsafe.Reactiveprojects andsrc/ReactiveUI.Unsafe.Shared/mirror the existing project layout and packaging conventions.<Compile Include>rather thanInternalsVisibleTo;InternalsVisibleTois used only for test assemblies.staticacross tests, benchmarks, and docs are mechanical updates forReactiveUI.Binding12.1.0's delegate-based APIs underPSH1000.Xamarin.AndroidX.Collection.Jvmstays at1.6.0.1because1.7.0causes a CecilXARRA7028failure onnet10.0-androidinReactiveUI.Samples.Maui.Checklist