Deepstaging.Roslyn.Testing 1.0.0-dev.209

This is a prerelease version of Deepstaging.Roslyn.Testing.
dotnet add package Deepstaging.Roslyn.Testing --version 1.0.0-dev.209
                    
NuGet\Install-Package Deepstaging.Roslyn.Testing -Version 1.0.0-dev.209
                    
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="Deepstaging.Roslyn.Testing" Version="1.0.0-dev.209" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Deepstaging.Roslyn.Testing" Version="1.0.0-dev.209" />
                    
Directory.Packages.props
<PackageReference Include="Deepstaging.Roslyn.Testing" />
                    
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 Deepstaging.Roslyn.Testing --version 1.0.0-dev.209
                    
#r "nuget: Deepstaging.Roslyn.Testing, 1.0.0-dev.209"
                    
#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 Deepstaging.Roslyn.Testing@1.0.0-dev.209
                    
#: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=Deepstaging.Roslyn.Testing&version=1.0.0-dev.209&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Deepstaging.Roslyn.Testing&version=1.0.0-dev.209&prerelease
                    
Install as a Cake Tool

Deepstaging.Roslyn.Testing

Test utilities for Roslyn analyzers, generators, and code fixes.

📚 Full Documentation

**See also: ** RoslynTestBase | Reference Configuration | Roslyn Toolkit

Quick Start

All tests inherit from RoslynTestBase:

public class MyTests : RoslynTestBase
{
    [Test]
    public async Task TestSymbols()
    {
        var type = SymbolsFor("public class Foo { }").RequireNamedType("Foo");
        await Assert.That(type.Value.Name).IsEqualTo("Foo");
    }

    [Test]
    public async Task TestAnalyzer()
    {
        await AnalyzeWith<MyAnalyzer>(source)
            .ShouldReportDiagnostic("MY001");
    }

    [Test]
    public async Task TestGenerator()
    {
        await GenerateWith<MyGenerator>(source)
            .ShouldGenerate()
            .VerifySnapshot();
    }

    [Test]
    public async Task TestCodeFix()
    {
        await AnalyzeAndFixWith<MyAnalyzer, MyCodeFix>(source)
            .ForDiagnostic("MY001")
            .ShouldProduce(expectedSource);
    }
}

Reference Configuration

If tests need your own assemblies, configure once via ModuleInitializer:

[ModuleInitializer]
public static void Init() =>
    ReferenceConfiguration.AddReferencesFromTypes(typeof(MyAttribute));

Entry Points

Method Description
SymbolsFor(source) Create compilation and query symbols
CompilationFor(source) Get the raw compilation
AnalyzeWith<T>(source) Run analyzer and assert diagnostics
GenerateWith<T>(source) Run generator and assert output
FixWith<T>(source) Test code fix for compiler diagnostics
AnalyzeAndFixWith<TAnalyzer, TCodeFix>(source) Test code fix for analyzer diagnostics
RenderTemplateFrom<T>(source) Test Scriban template rendering

Documentation

Test Contexts

Each entry point returns a test context with fluent assertions:

Guides


Quick Examples

Symbol Testing

var ctx = SymbolsFor(source);

// Get types and members
var type = ctx.RequireNamedType("Customer");
var methods = ctx.Type("Customer").Methods().ThatArePublic().GetAll();

Analyzer Testing

await AnalyzeWith<MyAnalyzer>(source)
    .ShouldReportDiagnostic("MY001")
    .WithSeverity(DiagnosticSeverity.Error)
    .WithMessage("*must be partial*");

Generator Testing

await GenerateWith<MyGenerator>(source)
    .ShouldGenerate()
    .WithFileCount(2)
    .WithFileNamed("Customer.g.cs")
    .WithNoDiagnostics()
    .VerifySnapshot();

Code Fix Testing

await AnalyzeAndFixWith<MyAnalyzer, MyCodeFix>(source)
    .ForDiagnostic("MY001")
    .ShouldProduce(expectedSource);

Template Testing

await RenderTemplateFrom<MyGenerator>(source)
    .Render("MyTemplate.scriban-cs", ctx => new { Name = ctx.RequireNamedType("Foo").Value.Name })
    .ShouldRender()
    .VerifySnapshot();

License

RPL-1.5 (Reciprocal Public License) — Real reciprocity, no loopholes.

You can use this code, modify it, and share it freely. But when you deploy it — internally or externally, as a service or within your company — you share your improvements back under the same license.

Why? We believe if you benefit from this code, the community should benefit from your improvements. That's the deal we think is fair.

Personal research and experimentation? No obligations. Go learn, explore, and build.

See LICENSE for the full legal text.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.0-dev.209 34 2/19/2026
1.0.0-dev.200 38 2/18/2026
1.0.0-dev.174 26 2/17/2026
1.0.0-dev.170 35 2/17/2026
1.0.0-dev.156 44 2/16/2026
1.0.0-dev.154 36 2/16/2026
1.0.0-dev.152 39 2/16/2026
1.0.0-dev.150 41 2/16/2026
1.0.0-dev.148 45 2/16/2026
1.0.0-dev.146 38 2/16/2026
1.0.0-dev.145 35 2/16/2026
1.0.0-dev.143 43 2/16/2026
1.0.0-dev.141 37 2/16/2026
1.0.0-dev.139 35 2/16/2026
1.0.0-dev.137 40 2/16/2026
1.0.0-dev.135 41 2/16/2026
1.0.0-dev.133 40 2/16/2026
1.0.0-dev.129 58 2/16/2026
1.0.0-dev.122 47 2/14/2026
1.0.0-alpha.1 38 2/14/2026
Loading failed