StaticCS.CsSig 0.3.4

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

CsSig — C# signature files (.cssig)

StaticCS.CsSig is a Roslyn analyzer, in the spirit of the Public API analyzer, that pins a project's public API surface using ordinary C#. The expected surface lives in a .cssig file of real C# member declarations with no bodies, and the analyzer verifies the project matches it exactly, in both directions.

Example

Api.cssig:

namespace MyLibrary;

public class Greeter
{
    public Greeter(string name);
    public string Greet();
    public string Name { get; }
}

Usage

Add the package and drop a .cssig file next to your code:

dotnet add package StaticCS.CsSig

All *.cssig files in the project are included automatically and together define the entire public API surface. Set <EnableCsSigAnalyzer>false</EnableCsSigAnalyzer> to opt out. A project with no .cssig files enforces nothing.

For multi-targeted projects, name a file <name>.<tfm>.cssig (e.g. PublicApi.net8.0.cssig) to apply it only when building that target framework. Unqualified files (e.g. PublicApi.cssig) apply to every TFM, so put the shared surface there and the TFM-specific surface in qualified files.

You don't write the file by hand: create an empty PublicApi.cssig, build (every public member reports CSSIG002), then invoke the code fix → Fix all to generate it from the current surface. Apply the same fix to keep it current as the API grows.

Diagnostics

  • CSSIG001 — declared in a .cssig file but missing from the project.
  • CSSIG002 — public in the project but not declared in any .cssig file.
  • CSSIG003 — a .cssig file could not be parsed.
  • CSSIG004 — uses a construct outside the signature grammar (see GRAMMAR.md).
  • CSSIG005 — present on both sides but the signatures are not equivalent.

Every 001/002/005 message states which equivalence(s) it breaks.

Equivalence

Choose what to enforce with the CsSigEquivalence MSBuild property — Source, Binary, or Both (default):

<PropertyGroup>
  <CsSigEquivalence>Both</CsSigEquivalence>
</PropertyGroup>

Types, virtuality, static, readonly, and member types break both. Parameter names, params, optionality, in vs ref readonly, and nullable annotations break source only. A const value breaks binary only.


Syntax highlighting is provided by the VS Code extension in src/CsSig/vscode. Internals are documented in DESIGN.md.

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.3.4 318 6/29/2026
0.3.3 109 6/29/2026
0.3.2 122 6/29/2026
0.3.1 109 6/28/2026
0.3.0 238 6/28/2026
0.2.0 108 6/28/2026
0.1.0 109 6/28/2026