Neon.Roslyn.Xunit 4.0.22

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

Neon.Roslyn.Xunit

This package provides some utilities to test Roslyn analyzers, code fix providers, and source generators using FluentAssertions.

Install

dotnet add package Neon.Roslyn.Xunit

Testing an analyzer

Verify generated source code

var inputSource = @"
namespace MyNamespace
{
    public partial class MyClass
    {
        public void MyMethod()
        {
            Console.WriteLine(""Hello, World!"");
        }
    }
}";

var expectedSource = @"
namespace MyNamespace
{
    public partial class MyClass
    {
        public void MyGeneratedMethod()
        {
            Console.WriteLine(""Hello, Roslyn!"");
        }
    }
}";

var testCompilation = new TestCompilationBuilder()
    .AddSourceGenerator<MySourceGenerator>()
    .AddSource(source)
    .Build();

// verify that the expected source code was generated
testCompilation.Should().ContainSource(expectedSource);

// verify the number of generated source files
testCompilation.Sources.Should().HaveCount(1);

Verify diagnostics

var testCompilation = new TestCompilationBuilder()
    .AddSourceGenerator<MySourceGenerator>()
    .AddSource(mySource)
    .Build();

// verify the number of diagnostics
testCompilation.Diagnostics.Should().HaveCount(2);

// verify the specific diagnostics using the diagnostic code
testCompilation.Should().HaveDiagnostics(["D1001", "D1002"]);

// verify the specific diagnostics using the diagnostic descriptor
testCompilation.Should().HaveDiagnostic(
    diagnostic: Diagnostic.Create(
        descriptor:  MyDiagnosticDescriptor,
        location:    Location.None,
        messageArgs: ["foo", 123]));

Adding assemblies to the compilation

var testCompilation = new TestCompilationBuilder()
    .AddSourceGenerator<MySourceGenerator>()
    .AddAssembly(typeof(MyType).Assembly)
    .Build();

Adding MSBuild options to the compilation

var testCompilation = new TestCompilationBuilder()
    .AddSourceGenerator<MySourceGenerator>()
    .AddOption("build_property.TargetFramework", "net8.0")
    .Build();
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
4.0.22 94 11/3/2026
4.0.21 128 9/11/2026
4.0.21-preview.0 168 9/9/2026
4.0.20 132 8/13/2026
4.0.20-preview.2 85 8/11/2026
4.0.20-preview.1 87 6/10/2026
4.0.20-preview.0 93 5/9/2026
4.0.19 157 4/29/2026
4.0.19-preview.4 86 4/26/2026
4.0.19-preview.3 97 4/17/2026
4.0.19-preview.2 206 8/14/2025
4.0.19-preview.1 201 8/13/2025
4.0.19-preview.0 198 8/13/2025
4.0.18 332 8/6/2025
4.0.17 307 4/15/2025
4.0.17-preview.0 257 4/14/2025
4.0.16 312 4/14/2025
4.0.15 280 4/10/2025
4.0.14 217 12/19/2024
4.0.13-preview.11 155 8/9/2024
Loading failed