ClangSharpPInvokeGenerator 22.1.8

Requires NuGet 4.3 or higher.

dotnet tool install --global ClangSharpPInvokeGenerator --version 22.1.8
                    
This package contains a .NET tool you can call from the shell/command line.
dotnet new tool-manifest
                    
if you are setting up this repo
dotnet tool install --local ClangSharpPInvokeGenerator --version 22.1.8
                    
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=ClangSharpPInvokeGenerator&version=22.1.8
                    
nuke :add-package ClangSharpPInvokeGenerator --version 22.1.8
                    

ClangSharpPInvokeGenerator

ClangSharpPInvokeGenerator is a .NET tool that generates strongly-typed C#/.NET P/Invoke bindings from C and C++ header files by parsing them with libclang. It is part of the ClangSharp project, which is self-hosted and uses this tool to auto-generate its own bindings.

Installing

Install the generator as a global .NET tool:

dotnet tool install --global ClangSharpPInvokeGenerator

NOTE: The generator depends on the native libClang and libClangSharp libraries. When running as a .NET tool, you may need to manually copy the appropriate native DLLs from the libClang and libClangSharp packages due to limitations in the .NET tool support. See #46 and #118 for details.

Usage

At a minimum, the tool expects one or more input files (-f), an output namespace (-n), and an output location (-o):

ClangSharpPInvokeGenerator -f example.h -n Example.Namespace -o Example.cs

The simplest and recommended setup is to use a response file, which lets you specify and check in the command line arguments in a text file with one argument per line:

ClangSharpPInvokeGenerator @generate.rsp

See GenerateClang.rsp for a real-world example. A typical response file also specifies explicit files to traverse, configuration options, name remappings, and other fixups.

You can see the full set of available switches by passing --help, and the available configuration options by passing -c help.

More information

License

Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See LICENSE.md in the repository root for more information.

There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

Version Downloads Last Updated
22.1.8 165 11/4/2026
21.1.8.4 11,860 7/15/2026
21.1.8.3 18,517 3/23/2026
21.1.8.2 1,612 1/16/2026
21.1.8 696 1/5/2026
20.1.2.4 5,553 10/15/2025
20.1.2.3 1,380 9/1/2025
20.1.2.2 1,007 8/19/2025
20.1.2.1 26,862 5/24/2025
20.1.2 1,230 5/11/2025
18.1.0.4 1,853 4/8/2025
18.1.0.3 18,164 1/15/2025
18.1.0.2 2,384 9/26/2024
18.1.0.1 1,141 7/21/2024
18.1.0 11,778 5/15/2024
17.0.1 6,560 12/15/2023
17.0.0 1,404 11/24/2023
16.0.0 17,083 6/21/2023
15.0.2 32,415 11/7/2022
15.0.1 1,064 9/29/2022
Loading failed