Repository navigation
feat: cover ReactiveUI.SourceGenerators' ObservableAsProperty and IViewFor behaviour - #142
Merged
Merged
Conversation
glennawatson
enabled auto-merge (squash)
September 25, 2026 18:40
…ewFor behaviour - [ObservableAsProperty] takes InitialValue, ReadOnly and UseProtected. An initial value is returned until the helper is assigned; a non-string one is an expression bound with the declaring file's usings. - RXUIBIND018 and a code fix rewrite the older field, method and observable property forms as partial properties; RXUIBIND019 reports a marked method with parameters. - Views declared with ReactiveUI.SourceGenerators' [IViewFor] register, and views register in a ReactiveUI.Binding.Reactive consumer. - Every DebuggerDisplay starts with the name of its type.
glennawatson
force-pushed
the
feat/sourcegenerators-compat
branch
from
September 25, 2026 18:43
84a63d9 to
70caf4c
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #142 +/- ##
==========================================
+ Coverage 99.15% 99.18% +0.02%
==========================================
Files 370 374 +4
Lines 13416 13794 +378
Branches 1768 1880 +112
==========================================
+ Hits 13303 13681 +378
Misses 113 113 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Merged
4 tasks done
|
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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
[ObservableAsProperty]and view registration cover what ReactiveUI.SourceGenerators did, so it can drop its copies.[ObservableAsProperty]takesInitialValue,ReadOnlyandUseProtected. The property returns its initial value until its helper is assigned. A non-string initial value is an expression, evaluated once, bound with the declaring file's usings. A non-nullablestringproperty starts asstring.Empty.[ObservableAsProperty]get nothing generated. The fix rewrites a field as a property, carrying its initializer andInheritanceacross. It gives a method or observable property a property of its own, assigned in a writtenInitializeOAPHmethod. The attribute is valid on those members so older code compiles, andPropertyNameandInheritanceexist for the fix.[IViewFor<T>]or[IViewFor("TypeName")]register. That generator addsIViewFor<T>in output other generators cannot see, so the attribute is read directly and the lookup checks for the interface when it resolves the view.RegistrationTypeLazySingletonandConstantkeep one instance.ReactiveUI.Binding.Reactiveconsumer. Only the leanIViewFor<T>was matched, so a System.Reactive consumer got no generated view lookup.DebuggerDisplaystarts with the name of its type, and all of them are ASCII.Why
ReactiveUI.SourceGenerators is removing
[ObservableAsProperty]and[IViewFor]view registration because this library provides them (reactiveui/ReactiveUI.SourceGenerators#501). The options, forms and attributes above were the gaps. A debugger showing a bare value gave no hint of what was being looked at.Breaking changes
stringproperty marked[ObservableAsProperty]now returnsstring.Emptyrather than null before its helper is assigned.[ObservableAsProperty]on a field, a method or a non-partial property now reports RXUIBIND018 rather than doing nothing silently.ReadOnlydefaults tofalse, so existing code that assigns a helper outside a constructor keeps compiling. The[Obsolete]RegisterViewsForViewModelsSourceGeneratedshim is not generated here, because it would declare the same type in every consumer assembly.How this was verified
WhenAnyValue.Notes for the reviewer
ObservableAsPropertyGenerator.cs,ViewRegistrationExtractor.cs, andObservableAsPropertyCodeFixProvider.cswithObservableAsPropertyRewriter.cs.DebuggerDisplayedits (a Roslyn rewrite adding the type name) and the regeneratedPublicAPI.txtbaselines, which change with them.analyzerextern alias, because the analyzer compiles its own copies of the generator's shared internal types.Checklist