SaveState.Generator 0.1.0

dotnet add package SaveState.Generator --version 0.1.0
                    
NuGet\Install-Package SaveState.Generator -Version 0.1.0
                    
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="SaveState.Generator" Version="0.1.0">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SaveState.Generator" Version="0.1.0" />
                    
Directory.Packages.props
<PackageReference Include="SaveState.Generator">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
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 SaveState.Generator --version 0.1.0
                    
#r "nuget: SaveState.Generator, 0.1.0"
                    
#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 SaveState.Generator@0.1.0
                    
#: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=SaveState.Generator&version=0.1.0
                    
Install as a Cake Addin
#tool nuget:?package=SaveState.Generator&version=0.1.0
                    
Install as a Cake Tool

SaveState.Generator

The incremental source generator of SaveState. It ships as an analyzer package: reference it and the partial classes you declare get their implementation at compile time.

dotnet add package SaveState.Generator

For a library that does not want to expose the analyzer to its own consumers, add PrivateAssets="all".

What it generates

For every [SaveFile("profile.json")] partial class … : SaveFileDefinition:

  • FileNameValue, GetFileName(), Version
  • one property per [SavedState] key, and
  • CollectFrom (service → DTO), RestoreTo (DTO → service, null-checking every section, then calling the service's OnAfterRestore) and FillMissingDefaults (a missing section becomes a default instance, never null).

For every [SaveService] partial class: an internal accessor per saved member (so it can stay private set) and the optional partial void OnAfterRestore() hook.

It also emits SaveServiceRegistration.AddGeneratedServices(this SaveRegistry, Func<Type, object>) - one call that registers every service of the assembly through your resolver (used by SaveState.DependencyInjection).

Compile-time diagnostics

SAV001–SAV013 catch, among others: a class that is not partial, a member with no setter, a section type that cannot be instantiated, duplicate or invalid section keys, and ambiguous file ownership. The full table is in the API reference.

Requires SaveState.Shared; see Getting started.

MIT licensed.

There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

This package has 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.0 106 9/29/2026
0.1.0-alpha.1 60 9/29/2026