Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: please support function pointer #1315

Open
HppZ opened this issue Dec 12, 2024 · 4 comments
Open

Feature request: please support function pointer #1315

HppZ opened this issue Dec 12, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@HppZ
Copy link

HppZ commented Dec 12, 2024

const char* (*item_name)(void* ctx);
[NativeTypeName("const char *(*)(void *)")]
public delegate* unmanaged[Cdecl]<void*, sbyte*> item_name;

error:
Failed while generating field: item_name. Unrecognized type: HandleTypeHandleInfo.

@HppZ HppZ added the enhancement New feature or request label Dec 12, 2024
@AArnott
Copy link
Member

AArnott commented Dec 13, 2024

I don't see anything from your description that relates to CsWin32. Can you clarify?

@HppZ
Copy link
Author

HppZ commented Dec 14, 2024

I want to generate c# bindings for some c libraries, but CsWin32 can't handle struct with function pointer such as const char* (*item_name)(void* ctx);.

src\Microsoft.Windows.CsWin32\Generator.MetadataHelpers.cs IsManagedType:244 throw this error: Unrecognized type: HandleTypeHandleInfo.

@HppZ
Copy link
Author

HppZ commented Dec 23, 2024

any update?

@AArnott
Copy link
Member

AArnott commented Jan 15, 2025

Ok, so you're not reading win32metadata here, but something custom that you produced?
If so, we don't have testing infrastructure built for anything other than the win32metadata and wdk metadata files, so support for other winmd's is 'best effort' at the moment rather than a guarantee. This is a gap that I'd like to fill, but we lack resources to do it.

If you'd like to help, the first step would be to contrive some way to produce winmd's as part of our build in this repo that can contain whatever special patterns you please (e.g. your function pointers).
Then we'd wire that up as an input to our tests.
We'd then be in a great position to add support for those patterns.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants