Getting started
Languages
Install the package
dotnet add package MvvmAIO.R3.SourceGeneratorsThe package is a DevelopmentDependency analyzer. Add:
using R3.SourceGenerators;Generated interfaces and implementations are internal in namespace R3.SourceGenerators.
Partial types for R3Command
[R3Command] requires a partial declaring type. Fix R3SG0001 by making the type partial.
public partial class ShellViewModel
{
[R3Command]
private void Save() { }
}Observable event APIs do not require partial types on the source type (only command generation does).
First observable event
public class Button : Control
{
public event EventHandler<RoutedEventArgs>? Click;
}
// IButtonEvents (internal)
var clicks = button.FromEvents().Click;See Observable events for hierarchy, generic constraints, and routed APIs.
WPF routed events
Enable WPF in the consumer project:
<UseWPF>true</UseWPF>Then use FromRoutedEvents() / FromRoutedEventHandlers() like standard routed events.
Avalonia
Routed events are detected when Avalonia.Interactivity.RoutedEvent metadata is present. Parameterless overloads use default routes (Direct | Bubble, handledEventsToo: false).
Verify your build
dotnet buildUnresolved R3SG errors point to Diagnostics reference.
Reading order
- This page — install,
partialtypes, firstFromEvents()call - Observable events — main guide (interface model, routed events,
FromEventHandlers) - R3Command — command properties
- Diagnostics reference — every R3SG id
- Changelog — releases and upgrade notes
Next steps
| Topic | Link |
|---|---|
| Observable events (primary guide) | Observable events |
| Command generation | R3Command |
| Repository layout | Architecture overview |
| Runnable demos | Samples |