Skip to content

fix: use partial-property pattern for ObservableProperty in TodoApp.Uno TodoListViewModel#565

Merged
adrianhall merged 1 commit into
CommunityToolkit:mainfrom
adrianhall:issues/538
Jul 11, 2026
Merged

fix: use partial-property pattern for ObservableProperty in TodoApp.Uno TodoListViewModel#565
adrianhall merged 1 commit into
CommunityToolkit:mainfrom
adrianhall:issues/538

Conversation

@adrianhall

Copy link
Copy Markdown
Collaborator

Summary

TodoApp.Uno/ViewModels/TodoListViewModel.cs used the legacy [ObservableProperty] private <type> field; pattern from CommunityToolkit.Mvvm, which triggers MVVMTK0045 warnings on the net10.0-windows10.0.26100 head:

warning MVVMTK0045: The field ... using [ObservableProperty] will generate code that is not AOT compatible in WinRT scenarios (such as UWP XAML and WinUI 3 apps), and a partial property should be used instead ...

This converts isRefreshing, items, and title to the modern [ObservableProperty] public partial <Type> Name { get; set; } pattern, matching the style already used in TodoApp.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

  • Confirmed via grep across samples/todoapp/TodoApp.Uno that no code references the old lowercase field names.
  • Dispatched build-samples.yml on the fork (adrianhall/CommunityToolkit-Datasync, branch issues/538): all 17 jobs passed, including todoapp-uno / windowshttps://github.com/adrianhall/CommunityToolkit-Datasync/actions/runs/29148082198
  • Confirmed the MVVMTK0045 warning no longer appears in the todoapp-uno / windows job log.

Closes #538

…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
@adrianhall adrianhall merged commit b56e683 into CommunityToolkit:main Jul 11, 2026
20 checks passed
@adrianhall adrianhall deleted the issues/538 branch July 11, 2026 10:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TodoApp.Uno: MVVMTK0045 - ObservableProperty field pattern not WinRT/AOT-safe on windows head

1 participant