fix: use partial-property pattern for ObservableProperty in TodoApp.Uno TodoListViewModel#565
Merged
Merged
Conversation
…no TodoListViewModel Converts isRefreshing, items, and title from the legacy [ObservableProperty] private field pattern to the modern [ObservableProperty] public partial property pattern, matching TodoApp.WinUI3's TodoListViewModel. This resolves MVVMTK0045 warnings on the net10.0-windows10.0.26100 head, since the field-based pattern is not WinRT/AOT-safe. Fixes CommunityToolkit#538
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
TodoApp.Uno/ViewModels/TodoListViewModel.csused the legacy[ObservableProperty] private <type> field;pattern fromCommunityToolkit.Mvvm, which triggersMVVMTK0045warnings on thenet10.0-windows10.0.26100head:This converts
isRefreshing,items, andtitleto the modern[ObservableProperty] public partial <Type> Name { get; set; }pattern, matching the style already used inTodoApp.WinUI3/ViewModels/TodoListViewModel.cs.No other code changes are required — all internal usages within the file (and no other file in the sample) already reference the generated PascalCase properties (
IsRefreshing,Items,Title) rather than the private backing fields.Verification
grepacrosssamples/todoapp/TodoApp.Unothat no code references the old lowercase field names.build-samples.ymlon the fork (adrianhall/CommunityToolkit-Datasync, branchissues/538): all 17 jobs passed, includingtodoapp-uno / windows— https://github.com/adrianhall/CommunityToolkit-Datasync/actions/runs/29148082198MVVMTK0045warning no longer appears in thetodoapp-uno / windowsjob log.Closes #538