VMF.NET.SourceGenerator 0.1.4

dotnet add package VMF.NET.SourceGenerator --version 0.1.4
                    
NuGet\Install-Package VMF.NET.SourceGenerator -Version 0.1.4
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="VMF.NET.SourceGenerator" Version="0.1.4" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="VMF.NET.SourceGenerator" Version="0.1.4" />
                    
Directory.Packages.props
<PackageReference Include="VMF.NET.SourceGenerator" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add VMF.NET.SourceGenerator --version 0.1.4
                    
#r "nuget: VMF.NET.SourceGenerator, 0.1.4"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package VMF.NET.SourceGenerator@0.1.4
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=VMF.NET.SourceGenerator&version=0.1.4
                    
Install as a Cake Addin
#tool nuget:?package=VMF.NET.SourceGenerator&version=0.1.4
                    
Install as a Cake Tool

VMF.NET

Build & Test NuGet Docs

VMF.NET is a lightweight modeling framework for .NET. It translates annotated C# interfaces into powerful implementations via a Roslyn Source Generator — no separate build step, no code-gen tooling, no boilerplate. It works with .NET 6 and later. VMF.NET is a port of the java VMF framework.

It generates/supports:

  • Getters and setters
  • Default values
  • Containment
  • Builder API
  • Equals() and GetHashCode()
  • Deep and shallow cloning
  • Change notification (INotifyPropertyChanged / INotifyCollectionChanged)
  • Undo/redo
  • Object graph traversal via iterators
  • Immutable types and read-only wrappers
  • Delegation
  • Annotations
  • Reflection
  • JSON serialization (System.Text.Json)
  • JSON Schema generation

A VMF.NET model consists of annotated C# interfaces. Just define the interface and its properties — VMF.NET generates a fully functional implementation including property setters/getters, builders, change listeners, and much more:

Using VMF.NET

Checkout the tutorial projects.

Add the NuGet packages to your project:

<PackageReference Include="VMF.NET.Runtime" Version="*" />
<PackageReference Include="VMF.NET.SourceGenerator" Version="*" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />

Replace * with a specific version (e.g., 0.1.1) for reproducible builds. See NuGet for the latest version.

Define your model as annotated partial interfaces. The interfaces must be marked with [VmfModel] and the namespace must end with .VmfModel:

using VMF.NET.Runtime.Core;

namespace MyApp.VmfModel;

[VmfModel]
public partial interface IParent
{
    [Contains(Opposite = nameof(IChild.Parent))]
    IList<IChild> Children { get; }

    string Name { get; set; }
}

[VmfModel]
public partial interface IChild
{
    [Container(Opposite = nameof(IParent.Children))]
    IParent? Parent { get; }

    int Value { get; set; }
}

The source generator runs automatically on every build — no task to invoke. The generated implementation is immediately available:

// Create via factory method
var parent = IParent.NewInstance();
parent.Name = "Root";

// Or use the builder
var child = IChild.Build()
    .WithValue(42)
    .Build();

parent.Children.Add(child);

// Containment is tracked automatically
Console.WriteLine(child.Parent == parent); // True

// Change listeners
parent.Vmf().Changes().AddListener(change => {
    Console.WriteLine($"Changed: {change.PropertyName}");
});

// Deep clone
var copy = parent.Clone();

// Read-only wrapper
IReadOnlyParent ro = parent.AsReadOnly();

JSON Serialization

Add the JSON package for System.Text.Json support:

<PackageReference Include="VMF.NET.Json" Version="*" />
var options = new JsonSerializerOptions
{
    Converters = { new VmfJsonConverterFactory() },
    WriteIndented = true
};

string json = JsonSerializer.Serialize(parent, options);
IParent restored = JsonSerializer.Deserialize<IParent>(json, options)!;

Building VMF.NET

Requirements

  • .NET 6 SDK or later
  • Internet connection (NuGet packages are restored automatically)

Command Line

dotnet build
dotnet test

Packing

dotnet pack --configuration Release

Testing VMF.NET

dotnet test --configuration Release --verbosity normal

The test suite includes 163 tests across unit and integration projects.

There are no supported framework assets in this package.

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
0.1.4 91 6/18/2026
0.1.3 116 4/9/2026
0.1.2 114 4/8/2026
0.1.1 108 4/8/2026
0.1.0 111 4/8/2026