{{ message }}
Repository navigation
feat: generate bindings for members ReactiveUI.SourceGenerators writes - #146
Merged
Merged
Conversation
- Read [Reactive], [ReactiveCollection], [BindableDerivedList], [ReactiveCommand] and [IReactiveObject] by metadata name. - Declare what each writes in a private copy of the compilation that call sites are read from. - Add RXUIBIND021: a binding call with no generated binding throws at run time. - Add a sourcegenerators docs page, and rewrite the example that called a stub to show its exception.
|
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
Bindings over the members ReactiveUI.SourceGenerators writes are now generated, and a binding call that nothing was generated for is reported when you build.
[Reactive](field and partial property),[ReactiveCollection],[BindableDerivedList],[ReactiveCommand]and[IReactiveObject]by metadata name, and follows that package's rules for the name, type and accessibility of what each writes.WhenAnyValue,WhenAny,Bind,OneWayBind,BindCommand,ToPropertyand the rest now dispatch for those members in both runtime flavours, where they used to throw at run time.sourcegeneratorsobserves, binds and runs the members a[Reactive]field,[IReactiveObject]and[ReactiveCommand]produce.UnsafeSetupExamples.PlainCallWithStoredPathThrowsis nowPlainCallNeedsAPathWrittenInTheCall. It called a stub on purpose to show the exception, which RXUIBIND021 now reports; it names the warning and shows the path the generator reads instead.Why
No generator sees another generator's output. A call such as
vm.WhenAnyValue(x => x.Nickname), whereNicknamecomes from a[Reactive]field, named a member that did not exist in the compilation this generator reads, so nothing was generated, no diagnostic was reported, and the call threw at run time. A class marked[IReactiveObject]looked as if it raised no notification. ReactiveUI.Core now depends on ReactiveUI.SourceGenerators (reactiveui/ReactiveUI#4516), so this is the common case rather than an edge.Breaking changes
None. Calls that used to throw at run time now either run or are reported by RXUIBIND021.
How this was verified
ToProperty, extension-block stubs, and the methods that do their own work. The full solution builds with the new rule and reports nothing outside the one rewritten example.Notes for the reviewer
Generators/SourceGeneratorsCompilation.csandHelpers/SourceGeneratorsMemberExtractor.cs. The pipeline declares the members that attributes produce in one never-emitted file, adds it to a private copy of the compilation, andBindingGenerator.Detectreads call sites from that copy. A compilation that uses none of the attributes gets no copy and reads call sites exactly as before.CallSiteContextinstead ofGeneratorSyntaxContext; both exposeNodeandSemanticModel, and the bodies are unchanged.SourceGeneratorsDeclarationTestsis what to update if a rule changes.Checklist