Skip to main content
net10.0net11.0net8.0net9.0

Generate compilable C# public API stubs from .NET assemblies.

Published
May 31, 2026
4mo ago
Total Downloads
1.9K
1,866

Install

dotnet add package Meziantou.Framework.PublicApiGenerator --version 1.0.6
ProductVersions
.NET
net10.0net11.0net8.0net9.0

README

Meziantou.Framework.PublicApiGenerator

Meziantou.Framework.PublicApiGenerator generates compilable C# files that represent the public API of a .NET assembly.

It can read metadata directly from a .dll or .exe (via PEReader and MetadataReader) or from a loaded Assembly. Both paths produce the same model and deterministic output.

Usage

using Meziantou.Framework.PublicApiGenerator;

var files = PublicApi.Generate(
    assemblyPath: "/path/to/MyLibrary.dll",
    options: new PublicApiOptions
    {
        FileLayout = PublicApiFileLayout.OneFilePerNamespace,
        IncludeAutoGeneratedComment = false,
    });

foreach (var file in files)
{
    Console.WriteLine(file.RelativePath);
    Console.WriteLine(file.Content);
}

Multi-target usage

You can merge multiple target frameworks into one output and emit conditional compilation blocks for target-specific differences:

using Meziantou.Framework.PublicApiGenerator;

var files = PublicApi.Generate(
    assemblySources:
    [
        "/path/to/MyLibrary.netstandard2.0.dll",
        "/path/to/MyLibrary.net8.0.dll",
    ]);

If needed, you can provide explicit framework monikers for specific entries:

using Meziantou.Framework.PublicApiGenerator;

var files = PublicApi.Generate(
    assemblySources:
    [
        new AssemblySource("/path/to/MyLibrary.netstandard2.0.dll", ".NETStandard,Version=v2.0"),
        new AssemblySource("/path/to/MyLibrary.net8.0.dll", ".NETCoreApp,Version=v8.0"),
    ]);

If TargetFrameworkMoniker is omitted (or empty), the generator infers it from assembly metadata.

Example output

Input API:

namespace Demo;

public sealed class Sample
{
    public string? Echo(string? value) => value;
}

Generated API:

// Target Frameworks: net8.0
#nullable enable

namespace Demo
{
    public sealed class Sample
    {
        public string? Echo(string? value) => throw null;
    }
}

Changes from Previous Version

v1.0.5v1.0.6
Added Frameworks
net11.0

Adoption Assessment

A verified publisher signal is available. Assess fit from the package's supported frameworks, license and dependency graph rather than popularity alone.

Compatibility metadata lists 4 target frameworks; confirm the exact target used by your application.

Related Guides & Workflows

Learn how to evaluate, integrate, or audit this package in your .NET project.