Corvus.Text.Json.SourceGenerator 5.0.0

dotnet add package Corvus.Text.Json.SourceGenerator --version 5.0.0
                    
NuGet\Install-Package Corvus.Text.Json.SourceGenerator -Version 5.0.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="Corvus.Text.Json.SourceGenerator" Version="5.0.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="Corvus.Text.Json.SourceGenerator" Version="5.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Corvus.Text.Json.SourceGenerator">
  <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 Corvus.Text.Json.SourceGenerator --version 5.0.0
                    
#r "nuget: Corvus.Text.Json.SourceGenerator, 5.0.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 Corvus.Text.Json.SourceGenerator@5.0.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=Corvus.Text.Json.SourceGenerator&version=5.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Corvus.Text.Json.SourceGenerator&version=5.0.0
                    
Install as a Cake Tool

Corvus.Text.Json.SourceGenerator

Roslyn incremental source generator that produces strongly-typed C# from JSON Schema at build time.

Supports JSON Schema draft 4, 6, 7, 2019-09, and 2020-12. Generated types are lightweight readonly struct wrappers over pooled JSON data with type-safe property accessors, validation, serialization, and implicit conversions.

Installation

<PackageReference Include="Corvus.Text.Json.SourceGenerator" Version="5.0.0">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>

You also need the runtime library:

dotnet add package Corvus.Text.Json

Usage

  1. Add a JSON Schema file to your project (e.g. Schemas/person.json)
  2. Annotate a partial struct:
using Corvus.Text.Json;

[JsonSchemaTypeGenerator("Schemas/person.json")]
public readonly partial struct Person;
  1. Use the generated type:
using var doc = ParsedJsonDocument<Person>.Parse(
    """{"name":"Alice","age":30}""");
Person person = doc.RootElement;

string name = (string)person.Name;
int age = person.Age;
bool valid = person.EvaluateSchema();

What Gets Generated

  • Property accessors for each schema property
  • EvaluateSchema() for full JSON Schema validation
  • Match() methods for oneOf/anyOf discriminated unions
  • From() conversions for allOf composition
  • Implicit conversions to/from .NET primitives
  • Builder type for creating instances with the builder pattern
  • Mutable type for in-place modification
Package Purpose
Corvus.Text.Json Core runtime library (required)
Corvus.Json.CodeGenerator CLI alternative for ahead-of-time generation

Documentation

See the Source Generator guide.

License

Apache 2.0 — see LICENSE.

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
5.0.0 83 5/14/2026