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

WinFormsComInterop.SourceGenerator does not work with Type StringBuilder #58

Open
ghost opened this issue Feb 20, 2023 · 0 comments
Open

Comments

@ghost
Copy link

ghost commented Feb 20, 2023

WinFormsComInterop.SourceGenerator does not work with argument type StringBuilder.

Test interface:
Interface IQueryAssociations

https://www.pinvoke.net/default.aspx/shlwapi/AssocCreate.html
https://learn.microsoft.com/en-us/windows/win32/api/shlwapi/nn-shlwapi-iqueryassociations

In method:
void GetString(
[In] ASSOCF flags,
[In] ASSOCSTR str,
[In, MarshalAs(UnmanagedType.LPWStr)] string pwszExtra,
[Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder pwszOut,
[In, Out] ref int pcchOut);

It has a StringBuilder argument type. If you compile this interface, Visual Studio will prompt an error:
Error CS8894 Cannot use 'StringBuilder' as a parameter type on a method attributed with 'UnmanagedCallersOnly'.

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

No branches or pull requests

0 participants