Add MVVM dependency graph notifications#1195
Open
bestlux wants to merge 1 commit intoCommunityToolkit:mainfrom
Open
Add MVVM dependency graph notifications#1195bestlux wants to merge 1 commit intoCommunityToolkit:mainfrom
bestlux wants to merge 1 commit intoCommunityToolkit:mainfrom
Conversation
Author
@dotnet-policy-service agree |
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.
Closes #857
Addresses #959
Addresses #906
Addresses #1168
This PR adds explicit dependency graph support for MVVM source generation through a new
[DependsOn]attribute for calculated properties.The new API lets target-side calculated properties declare the source properties they depend on:
The source generator then expands those dependencies for generated observable properties, including transitive dependencies declared through
[DependsOn]. Existing[NotifyPropertyChangedFor]behavior remains direct-only for compatibility.This also adds:
[RelayCommand(CanExecute = nameof(SomeBoolProperty))]when the bool property is generated or graph-derivedINotifyPropertyChangedforwarding through[DependsOn(..., NotifyOnSubPropertyChanges = true)]PR Checklist
Validation
dotnet restore .\dotnet.slnxdotnet test .\tests\CommunityToolkit.Mvvm.SourceGenerators.Roslyn4120.UnitTests\CommunityToolkit.Mvvm.SourceGenerators.Roslyn4120.UnitTests.csproj --filter "FullyQualifiedName~DependsOn|FullyQualifiedName~ObservableProperty" --no-restore -v minimaldotnet test .\tests\CommunityToolkit.Mvvm.Roslyn4120.UnitTests\CommunityToolkit.Mvvm.Roslyn4120.UnitTests.csproj --filter "FullyQualifiedName~DependsOn|FullyQualifiedName~ObservableProperty|FullyQualifiedName~RelayCommand" --no-restore -v minimaldotnet build .\dotnet.slnx -c Debug --no-restoredotnet test .\dotnet.slnx --no-build -c Debug -l "console;verbosity=minimal"git diff --checkOther information
The API intentionally uses a new
[DependsOn]attribute rather than changing[NotifyPropertyChangedFor]transitivity, so existing behavior remains compatibility-preserving.