Dreamine.MVVM.Generators
1.0.13
dotnet add package Dreamine.MVVM.Generators --version 1.0.13
NuGet\Install-Package Dreamine.MVVM.Generators -Version 1.0.13
<PackageReference Include="Dreamine.MVVM.Generators" Version="1.0.13" />
<PackageVersion Include="Dreamine.MVVM.Generators" Version="1.0.13" />
<PackageReference Include="Dreamine.MVVM.Generators" />
paket add Dreamine.MVVM.Generators --version 1.0.13
#r "nuget: Dreamine.MVVM.Generators, 1.0.13"
#:package Dreamine.MVVM.Generators@1.0.13
#addin nuget:?package=Dreamine.MVVM.Generators&version=1.0.13
#tool nuget:?package=Dreamine.MVVM.Generators&version=1.0.13
Dreamine.MVVM.Generators
Dreamine.MVVM.Generators is a Roslyn incremental source generator package used by the Dreamine MVVM ecosystem.
This package generates MVVM boilerplate code at compile time based on declarative attributes.
The main attributes currently handled are:
DreaminePropertyDreamineEntryDreamineModelDreamineEventDreamineCommand
The goal of this package is to reduce repetitive code while keeping generation rules and constraints explicit.
What this package does
MVVM projects repeatedly need the following patterns:
- backing field → property exposure
- method →
ICommandproperty generation - model / event reference exposure
- application entry bootstrap generation
- declarative command forwarding generation
Dreamine.MVVM.Generators moves those repetitive patterns into the generation layer so ViewModel and App code can stay smaller.
Key Features
- Built on Roslyn Incremental Source Generators
- Can be packaged as an analyzer package
- Generates code from Dreamine attributes
- Supports entry bootstrap generation
- Supports field-based auto wiring
- Supports DreamineCommand-based direct and forwarding command generation
- Can be packed into
analyzers/dotnet/cs - Supports automatic analyzer registration through
buildTransitive
Requirements
- Target Framework:
netstandard2.0 - Usually used together with:
Dreamine.MVVM.AttributesDreamine.MVVM.Core- WPF / .NET MVVM applications
Installation
Option A) NuGet
dotnet add package Dreamine.MVVM.Generators
Option B) PackageReference
<ItemGroup>
<PackageReference Include="Dreamine.MVVM.Generators" Version="1.0.6" />
</ItemGroup>
This package is intended to be used as an analyzer package, and buildTransitive is the recommended way to register it automatically in consuming projects.
Project Structure
Dreamine.MVVM.Generators
├── DreamineAutoWiringGenerator.cs
├── DreamineCommandSourceGenerator.cs
├── DreamineEntryGenerator.cs
├── AnalyzerReleases.Shipped.md
├── AnalyzerReleases.Unshipped.md
├── buildTransitive/
│ └── Dreamine.MVVM.Generators.targets
└── Dreamine.MVVM.Generators.csproj
Architecture Role
This package belongs to the generation layer of the Dreamine MVVM stack.
ViewModel / App Source Code
│
├─ Dreamine.MVVM.Attributes
│ (markers / metadata)
│
├─ Dreamine.MVVM.Generators
│ (compile-time code generation)
│
└─ Dreamine.MVVM.Core
(runtime MVVM infrastructure)
The responsibility split is:
- Attributes: declare intent
- Generators: emit source code
- Core: executes runtime behavior
Supported Generators
1) DreamineEntryGenerator
Generates application bootstrap code for types marked with [DreamineEntry].
Current responsibilities
- Generates application startup initialization code
- Calls
DMContainer.AutoRegisterAll(...) - Calls
ViewModelLocator.RegisterAll(...) - Hooks
FrameworkElement.Loadedto attach View ↔ ViewModel automatically - Generates
RegisterBefore,RegisterAfter, andShowMainWindowpartial hooks
Current constraints
- The target type must be partial
- The target type must inherit
System.Windows.Application - The design assumes only one valid entry type
Example
using Dreamine.MVVM.Attributes;
[DreamineEntry]
public partial class App : Application
{
}
2) DreamineAutoWiringGenerator
Generates helper properties from fields marked with [DreamineProperty], [DreamineModel], and [DreamineEvent].
Current responsibilities
_title→Title_model→Model_event→Event
Current behavior
- Handles field-based generation only
- Does not regenerate from property declarations
- Adds helper properties to a partial class
- Skips generation when a member name conflict already exists
Example
using Dreamine.MVVM.Attributes;
public partial class MainViewModel
{
[DreamineProperty]
private string _title;
[DreamineModel]
private MainModel _model;
[DreamineEvent]
private MainEvent _event;
}
Generated intent
Title→ field-backed propertyModel→ model access propertyEvent→ event access property
Notes
[DreamineProperty]generation assumesSetProperty(ref field, value)is available
so the target type must provideSetProperty[DreamineModel]and[DreamineEvent]currently should not be used on readonly fieldsDreamineModeluses anew T()initialization pathDreamineEventuses aDMContainer.Resolve<T>()initialization path- Generated code no longer forces inheritance from
ViewModelBase
3) DreamineCommandSourceGenerator
Generates ICommand properties from methods marked with [DreamineCommand].
Current responsibilities
- Generates a
{MethodName}Commandproperty - Supports
CommandNameoverride when provided - Directly wraps the annotated method when
TargetMethodis not specified - Generates
TargetMethodinvocation code when forwarding is requested - Assigns the result to the
BindToproperty when forwarding with a return value - Generates a forwarding body when the method has no implementation body and
TargetMethodis specified - Avoids direct dependency on an external
RelayCommandtype by emitting an internal generatedICommandwrapper
Example
using Dreamine.MVVM.Attributes;
public partial class MainViewModel
{
[DreamineCommand]
private void Save()
{
}
[DreamineCommand("Event.ReadmeClick", BindTo = "Readme")]
partial void LoadReadme();
}
Current constraints
- The containing type must be partial
- The target method must be parameterless void
- Forwarding methods without a body must be partial
- Generation is skipped when the command property name conflicts with an existing member
Quick Start
1) Add the required packages
<ItemGroup>
<PackageReference Include="Dreamine.MVVM.Attributes" Version="1.0.6" />
<PackageReference Include="Dreamine.MVVM.Core" Version="1.0.9" />
<PackageReference Include="Dreamine.MVVM.Generators" Version="1.0.11" PrivateAssets="all" OutputItemType="Analyzer" />
</ItemGroup>
2) Declare attributes
using Dreamine.MVVM.Attributes;
public partial class MainViewModel
{
[DreamineProperty]
private string _title;
[DreamineCommand]
private void Save()
{
}
[DreamineCommand("Event.ReadmeClick", BindTo = "Readme")]
partial void LoadReadme();
}
3) Build
During build, partial source files are generated.
Typical outputs include:
TitlepropertySaveCommandLoadReadmeCommand- forwarding method body
Important Notes Based on the Current Code
1) The generator package is not a standalone runtime framework
Generated code still assumes some Dreamine runtime concepts exist.
Examples:
DMContainerViewModelLocatorSetProperty
This package is intended to be used inside the Dreamine MVVM stack.
2) Not all attributes have the same usage scope
Under the current implementation:
DreamineEntry→ App / bootstrap layerDreamineProperty→ ViewModel layer withSetPropertyDreamineModel,DreamineEvent→ field access generationDreamineCommand→ method-based command generation
3) The generation rules are intentionally becoming stricter
The current generator implementations prioritize:
- partial type validation
- method signature validation
- name conflict prevention
- diagnostics for invalid usage
Packaging Notes
The current project assumes analyzer-style packaging.
Typical configuration points are:
PackageType=AnalyzerOutputItemType=AnalyzerIncludeBuildOutput=false- package the generator DLL into
analyzers/dotnet/cs - use
buildTransitivefor automatic registration
Comparison
| Package | Role | Runtime Logic | Compile-Time Generation |
|---|---|---|---|
| Dreamine.MVVM.Attributes | declaration layer | No | No |
| Dreamine.MVVM.Generators | generation layer | No | Yes |
| Dreamine.MVVM.Core | runtime layer | Yes | No |
This separation keeps the system layered by responsibility.
Recommended Pairing
This package is usually used together with:
Dreamine.MVVM.Attributes
Dreamine.MVVM.Core
Dreamine WPF / UI / App packages
License
MIT License
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.13 | 102 | 7/8/2026 |
| 1.0.12 | 109 | 4/30/2026 |
| 1.0.11 | 107 | 4/29/2026 |
| 1.0.10 | 120 | 3/24/2026 |
| 1.0.9 | 117 | 3/22/2026 |
| 1.0.8 | 116 | 3/21/2026 |
| 1.0.7 | 116 | 3/21/2026 |
| 1.0.6 | 129 | 2/20/2026 |
| 1.0.5 | 114 | 2/20/2026 |
| 1.0.4 | 120 | 2/18/2026 |
| 1.0.3 | 212 | 5/31/2025 |
| 1.0.2 | 217 | 5/26/2025 |
| 1.0.1 | 213 | 5/25/2025 |
| 1.0.0 | 226 | 5/25/2025 |