·
Last changedVersion:
This version passed the hardening gate. Hardening applied 12 targeted changes and preserved all other text. Classified findings before hardening: 0. Classified findings closed: 0. Classified findings remaining: 0. Unclassified scanner findings remaining: 0. Review findings closed: 8. Review findings remaining: 1.
None
None
Expand | File | Group | Subtype | Severity | Status |
|---|
No findings available
0 findings
Use this skill when authoring or reviewing ViewModels, properties,
commands, or validation in apps that use CommunityToolkit.Mvvm 8.x.
For production projects, pin an exact, reviewed 8.x release instead of a floating range (or use a NuGet lock file), and raise the pin deliberately, because the package runs source generators inside the compiler.
Targets: netstandard2.0, netstandard2.1, net6.0+. Works on .NET, .NET
Framework, Mono. Source generators ship in the same NuGet — no extra
analyzer reference required.
Namespaces:
| Attribute | Applied to | Generates |
|---|---|---|
| private field | Public |
| observable field | Also raises |
| observable field | Calls |
| observable field on | Calls |
| observable field on |
|
| instance method | Lazy |
| instance method | Wires |
| async method with | Also generates |
| async method | Allows queued/parallel invocations (default disables while running) |
| async method | Surfaces exceptions via |
| observable field or | Forwards |
Naming. Field name / _name / m_name → Name. Method LoadAsync →
LoadCommand (the Async suffix is stripped; a leading On is also
stripped).
See references/source-generators.md for
the full attribute reference with generated-code samples.
OnXxxChanging / OnXxxChangedBoth single-arg (value) and two-arg (oldValue, newValue) overloads
are available. Implement only the ones you need; unimplemented hooks are
elided by the compiler (zero runtime cost).
Pass a static lambda (no captured state) to keep the call allocation-free.
Reach for manual RelayCommand / AsyncRelayCommand constructors only
when you must own the command's lifetime explicitly or compose it from
non-trivial sources. The attribute style covers ~95% of cases.
See references/relaycommand-cookbook.md
for sync / async / cancellable / concurrency / error-surfacing recipes.
| Base class | Use when |
|---|---|
| Default. |
| The VM needs |
| The VM sends or receives |
C# is single-inheritance: ObservableValidator and ObservableRecipient
both extend ObservableObject, so combining them requires composition
(e.g., inject IMessenger into an ObservableValidator).
Other entry points: TrySetProperty, ValidateProperty(value, name),
ClearAllErrors(), GetErrors(propertyName). Custom rules support
[CustomValidation] methods and custom ValidationAttribute subclasses.
See references/validation.md for the full
validator surface area.
partial. Class (and every enclosing type) must be
partial, or the build fails with compiler errors.[ObservableProperty] private string Name;
collides with the generated property. Use name, _name, or m_name.async void on [RelayCommand]. The generator only wraps
Task-returning methods as IAsyncRelayCommand. async void becomes
a sync RelayCommand and exceptions are unobserved. The toolkit also
reports an analyzer diagnostic for this pattern. Always return
Task.[NotifyCanExecuteChangedFor]. The Save button stays
disabled even though CanSave() would now return true.[ObservableProperty]
field. EqualityComparer<T>.Default returns true, no notification
fires. Replace the instance instead of mutating it.For the full diagnostic table (MVVMTK0xxx) and more pitfalls, see
references/troubleshooting.md.
A two-pane Notes app demonstrating generators + commands +
[NotifyCanExecuteChangedFor]:
For the full sample (DI wiring, View code-behind, XAML, unit tests), see
references/end-to-end-walkthrough.md.
| Topic | Where |
|---|---|
Source generator attribute reference | |
RelayCommand recipes | |
Validation deep dive | |
Full Notes-app walkthrough | |
| |
Messenger pub/sub | Companion skill: |
| Companion skill: |
External sources:
Get started with chainctlchainctl skill install public/github/mvvm-toolkit:latest
Bring Chainguard's hardening pipeline to your first-party skills — custom rulesets, automated remediation, full audit trail.
skills.cgr.dev/public/github.com/github/skills/mvvm-toolkit:latest
MIT
HARDENING.md
LICENSE
SKILL.md
references/end-to-end-walkthrough.md
references/relaycommand-cookbook.md
references/source-generators.md
references/troubleshooting.md
references/validation.md