clangsharppinvokegenerator --version
ClangSharp P/Invoke Binding Generator version 20.1.2
clang version 20.1.2 (https://github.com/llvm/llvm-project 58df0ef89dd64126512e4ee27b4ac3fd8ddf6247)
clangsharp version 20.1.2
When generating for the following code from (https://github.com/libgit2/libgit2/blob/5ab90d3c273766c81fefb7d156574a87c0f9fb01/include/git2/sys/credential.h#L40C1-L43C3)
struct git_credential_username {
git_credential parent; /**< The parent credential */
char username[1]; /**< The username to authenticate as */
};
The generated code is like
...
[NativeTypeName("char[1]")]
public _username_e__FixedBuffer username;
public partial struct _username_e__FixedBuffer
{
public sbyte e0;
[UnscopedRef]
public ref sbyte this[int index]
{
get
{
return ref Unsafe.Add(ref e0, index);
}
}
[UnscopedRef]
public Span<sbyte> AsSpan(int length) => MemoryMarshal.CreateSpan(ref e0, length);
}
However, System.Runtime.CompilerServices, the namespace that contains Unsafe, is not imported in the generated code.
clangsharppinvokegenerator --version
When generating for the following code from (https://github.com/libgit2/libgit2/blob/5ab90d3c273766c81fefb7d156574a87c0f9fb01/include/git2/sys/credential.h#L40C1-L43C3)
The generated code is like
However,
System.Runtime.CompilerServices, the namespace that containsUnsafe, is not imported in the generated code.