Repository navigation
fix: make view WhenActivated trim and AOT safe; build without runtime-async - #4532
Merged
Merged
Conversation
4 tasks done
glennawatson
marked this pull request as draft
October 3, 2026 04:58
glennawatson
force-pushed
the
fix/aot-safe-view-activation
branch
from
October 3, 2026 06:46
a391c68 to
08df06b
Compare
glennawatson
marked this pull request as ready for review
October 3, 2026 06:46
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4532 +/- ##
==========================================
+ Coverage 93.69% 93.75% +0.06%
==========================================
Files 175 175
Lines 6231 6182 -49
Branches 743 736 -7
==========================================
- Hits 5838 5796 -42
+ Misses 392 386 -6
+ Partials 1 0 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
- Watch IViewFor.ViewModel through the registered ICreatesObservableForProperty plugin, as the binding generator does, instead of WhenAnyValueUnsafe. - Fall back to the current ViewModel once when no plugin can watch the property. - Remove RequiresUnreferencedCode from the IActivatableView and WPF WhenActivated overloads. - Remove the design-mode branch in view activation. IActivatableView.GetIsDesignMode always returns false there, so it never ran. - Update the WPF public API baselines. - Build the .NET 11 assemblies without runtime-async. Mono does not support it, so it breaks Blazor WebAssembly and other Mono hosts. - Update ReactiveUI.Binding to 9.0.0, TUnit to 1.72.16, SonarAnalyzer.CSharp to 10.35.0.4138 and the Blazor WASM example's Microsoft.AspNetCore.Components to 10.0.12. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
glennawatson
force-pushed
the
fix/aot-safe-view-activation
branch
from
October 3, 2026 08:10
08df06b to
f0bca16
Compare
|
ChrisPulman
approved these changes
Oct 3, 2026
glennawatson
added a commit
that referenced
this pull request
Oct 3, 2026
…-async (#4532) - Watch IViewFor.ViewModel through the registered ICreatesObservableForProperty plugin, as the binding generator does, instead of WhenAnyValueUnsafe. - Fall back to the current ViewModel once when no plugin can watch the property. - Remove RequiresUnreferencedCode from the IActivatableView and WPF WhenActivated overloads. - Remove the design-mode branch in view activation. IActivatableView.GetIsDesignMode always returns false there, so it never ran. - Update the WPF public API baselines. - Build the .NET 11 assemblies without runtime-async. Mono does not support it, so it breaks Blazor WebAssembly and other Mono hosts. - Update ReactiveUI.Binding to 9.0.0, TUnit to 1.72.16, SonarAnalyzer.CSharp to 10.35.0.4138 and the Blazor WASM example's Microsoft.AspNetCore.Components to 10.0.12.
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
View
WhenActivatedis now trim and AOT safe, and the .NET 11 build no longer uses runtime-async.ViewModelthrough the registeredICreatesObservableForPropertyplugin, as the binding source generator does, instead of reflection.[RequiresUnreferencedCode]is removed from every viewWhenActivatedoverload, including the WPF ones.Why
Any app that called
this.WhenActivated(...)in a view, or derived from a platform base that does, got trim warnings when published with Native AOT. Separately, Blazor WebAssembly, Avalonia's browser apps and other Mono hosts can fail on a runtime-async build.Breaking changes
The .NET 11 assemblies no longer use runtime-async. The public API does not change apart from dropping
[RequiresUnreferencedCode]. This ships as a major release because of the runtime change.How this was verified
A new test covers activation when no plugin can watch the ViewModel. Existing activation tests cover ViewModel swap and clear while active. The WinForms and WPF suites were run on Windows.
Notes for the reviewer
Start with
ObserveViewModelinViewForMixins.cs, which mirrors the generator's plugin path. The removed design-mode branch calledIActivatableView.GetIsDesignMode(), which always returns false in this assembly. WinForms and WPF still check design mode in their own code. The WPF baseline updates are mechanical.Checklist