-
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Let me start by saying that I haven't used ClangSharp, but I can speak a bit to some of the differences. Parsing / ASTClangSharp provides bindings to CppSharp started by only providing the relevant AST information for generating bindings, in practice this means no statements/expressions information besides the ones used for default parameters, but we have since added support for parsing this information too, but it's not enabled by default and doesn't have much testing. So if you need statements/expressions information, the AST provided by ClangSharp might be more stable. Bindings/P/Invoke generationCppSharp provides an advanced bindings generation system, with support for advanced features like overriding of (pure) virtual methods from .NET, and allowing to pass these inheriting class instances back to native, through which C++ can call back to .NET. We also provide facilities to generate symbols for inline entities, which is usually a pain in the ass since the symbols are not provided for P/Invoke to bind to by the C++ compiler. Among a host of other things, like automatic documentation comments conversion, some support for converting templates to C# generics, type maps. We also support multiple languages/backends, with support for C++/CLI, C#, and some flavors of JavaScript in development. On the other hand, C has never been a priority for us, and while you can generate bindings for C libraries, there's been some issues reported before, which means ClangSharp might be better suited for this task. Another relevant difference is that traditionally the bindings generation part of CppSharp has been architected to be consumed as a library, through which a user authors a separate generator project. This provides a lot of flexibility as C# code can be written to manipulate the AST before bindings generation, but makes it a bit harder to use from an usability perspective. We have since added a CLI tool but it has not been the focus and could use some improvements. We have also not kept up with the times in the .NET land, so there's a bunch of stuff we could be doing to make CppSharp better, like MSBuild integrationm, .NET tool support, source generators, taking of advantage of more recent P/Invoke features for better optimizations, etc. Hope this helps. |
Beta Was this translation helpful? Give feedback.
Let me start by saying that I haven't used ClangSharp, but I can speak a bit to some of the differences.
Parsing / AST
ClangSharp provides bindings to
libclang
, which is a C interface to Clang. We actually started binding tolibclang
in CppSharp but quickly found limitations when it came to more advanced C++ constructs like templates, and had to switch to the Clang C++ API, which is not stable, and at a higher maintenance burden, but provides anything you might need. We have even needed to sometimes go into private APIs to get some information like vtable layouts. Now, this was almost a decade ago, so maybelibclang
already provides some of this information, I am not sure.CppSharp starte…