microsoft / CsWin32

A source generator to add a user-defined set of Win32 P/Invoke methods and supporting types to a C# project.
MIT License
2k stars 84 forks source link

Support "allowMarshaling:off" on per API level. #1042

Open lianghaoGao opened 10 months ago

lianghaoGao commented 10 months ago

Is your feature request related to a problem? Please describe. CsWin32 currently doesn't support DnsQueryEx() with DNS_QUERY_REQUEST3 struct because DnsQueryEx() is getting an in parameter instead of a pointer parameter is that DNS_QUERY_REQUEST3 is detected to be a managed type because one of its fields (pQueryCompletionCallback) is a delegate. One cannot take a pointer to a struct with a delegate typed field. This leaves use the options to either setting allowMarshaling:off on a project level which cause additional errors because some other delegate type needs to be changed to pointer type or declaring our own DnsQueryEx() extern method.

Describe the solution you'd like It would be great if we can selectively choose certain APIs to set allowMarshaling:off.

Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

Additional context Add any other context or screenshots about the feature request here.