Skip to content

Conversation

@aka-nse
Copy link

@aka-nse aka-nse commented Sep 27, 2025

related: #561


Hello.

I tried to use ClangSharp as a library, but found the documentation lacking, which made learning quite challenging.
Looking at the discussions, it seems others have faced the same issue.

Therefore, I would like to propose adding an introduction for library usage.
I've written some content myself and will submit it as a PR.
While a Wiki would normally be more suitable for this purpose, I've added a docs/ directory to make it submittable as a PR.

I would appreciate your feedback and suggestions.

@tannergooding
Copy link
Member

While I appreciate the sentiment here, this is first and foremost a bindings library where it is a non-goal to create and maintain documentation for how to work with Clang. Clang provides its own documentation (https://clang.llvm.org/docs/index.html) and that will always be the source of truth.

With that in mind, working with this library is explicitly advanced, it requires a knowledge of C++ in addition to C#. A user is expected to already be familiar with concepts such as adding NuGet packages, how to translate basic C++ concepts into equivalent C# contexts, how to work with things like IDisposable, etc (none of which are particularly complex topics).

If a user doesn't have the capabilities to look at https://clang.llvm.org/docs/LibClang.html and translate the relatively simple code here from C++ to C#, then they are likely on a path to failure in attempting to use this library and would be met with the same challenges and failing points in any language exposing similar bindings. Doing the work to translate it for them isn't doing any favors and will not end up helping in such a scenario.

With that being said, a small document covering some of the non-obvious differences between ClangSharp and libClang would be welcome. For example, covering that methods such as clang_getCursorType are typically exposed as clang.getCursorType or that in many cases we attempt to "mirror" the C++ surface area so that documentation such as https://clang.llvm.org/docs/IntroductionToTheClangAST.html can also be followed/is valid and usable.

Likewise, documentation for the ClangSharpPInvokeGenerator tool is acceptable, as that is an entirely unique creation to this repo and has its own nuance, best practices, and other considerations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants