![]() |
VOOZH | about |
dotnet add package CppAst.cgnx --version 0.13.16
NuGet\Install-Package CppAst.cgnx -Version 0.13.16
<PackageReference Include="CppAst.cgnx" Version="0.13.16" />
<PackageVersion Include="CppAst.cgnx" Version="0.13.16" />Directory.Packages.props
<PackageReference Include="CppAst.cgnx" />Project file
paket add CppAst.cgnx --version 0.13.16
#r "nuget: CppAst.cgnx, 0.13.16"
#:package CppAst.cgnx@0.13.16
#addin nuget:?package=CppAst.cgnx&version=0.13.16Install as a Cake Addin
#tool nuget:?package=CppAst.cgnx&version=0.13.16Install as a Cake Tool
<img align="right" width="160px" height="160px" src="https://raw.githubusercontent.com/xoofx/CppAst.NET/main/img/cppast.png">
CppAst provides a C/C++ parser for header files with access to the full AST, comments and macros for .NET Framework and .NET Core
The target primary usage of this library is to serve as a simple foundation for domain oriented PInvoke/Interop codegen
.NET Standard 2.0+Clang/libclang 15.0.2_declspec(...) or __attribute__((...)))const int x = (1 + 2) << 1 the (1 + 2) << 1 will be retrievable as a binary expression from the AST)CppParserOptions.ParseMacros (default is false)Check the documentation from the doc/ folder.
After installing the NuGet package, you need to modify your csproj to select a Platform RID via the RuntimeIdentifier property:
<PropertyGroup>
<RuntimeIdentifier Condition="'$(RuntimeIdentifier)' == '' AND '$(PackAsTool)' != 'true'">$(NETCoreSdkRuntimeIdentifier)</RuntimeIdentifier>
</PropertyGroup>
You can jump-start with the CppParser.Parse method:
// Parse a C++ files
var compilation = CppParser.Parse(@"
enum MyEnum { MyEnum_0, MyEnum_1 };
void function0(int a, int b);
struct MyStruct { int field0; int field1;};
typedef MyStruct* MyStructPtr;
"
);
// Print diagnostic messages
foreach (var message in compilation.Diagnostics.Messages)
Console.WriteLine(message);
// Print All enums
foreach (var cppEnum in compilation.Enums)
Console.WriteLine(cppEnum);
// Print All functions
foreach (var cppFunction in compilation.Functions)
Console.WriteLine(cppFunction);
// Print All classes, structs
foreach (var cppClass in compilation.Classes)
Console.WriteLine(cppClass);
// Print All typedefs
foreach (var cppTypedef in compilation.Typedefs)
Console.WriteLine(cppTypedef);
Prints the following result:
enum MyEnum {...}
void function0(int a, int b)
struct MyStruct { ... }
typedef MyStruct* MyStructPtr
This library is distributed as a NuGet package 👁 NuGet
The library libclang used by this project has some known issues and limitations:
This software is released under the BSD-Clause 2 license.
The C++ project cppast serves similar purpose although CppAst.NET does not share API or any implementation details.
Alexandre Mutel aka xoofx.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0 net6.0 is compatible. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 was computed. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.13.16 | 31,589 | 2/12/2025 |
| 0.13.15 | 4,956 | 12/11/2024 |
| 0.13.14 | 15,049 | 9/6/2024 |
| 0.13.13 | 239 | 6/11/2024 |
| 0.13.12 | 8,933 | 6/7/2024 |
| 0.13.11 | 228 | 6/6/2024 |
| 0.13.10 | 222 | 6/6/2024 |
| 0.13.9 | 236 | 6/4/2024 |
| 0.13.8 | 13,452 | 2/5/2024 |
| 0.13.7 | 2,420 | 1/9/2024 |
| 0.13.6 | 295 | 12/14/2023 |
| 0.13.5 | 257 | 12/13/2023 |
| 0.13.4 | 359 | 12/6/2023 |
| 0.13.3 | 265 | 12/5/2023 |
| 0.13.2 | 272 | 11/3/2023 |
| 0.13.1 | 278 | 10/25/2023 |
| 0.8.0-alpha-015 | 244 | 10/18/2023 |
| 0.8.0-alpha-014 | 238 | 9/29/2023 |
| 0.8.0-alpha-013 | 222 | 9/21/2023 |
| 0.8.0-alpha-011 | 276 | 9/15/2023 |