-
Notifications
You must be signed in to change notification settings - Fork 117
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
Recognize COM _NewEnum method as IEnumerable (possibly by parsing .idl file) #1918
Comments
The win32metadata expresses the result of |
I don't think there's anything to do in metadata for this. CsWin32 should probably instead detect that it is in an IDispatch/OLE context ( |
This isn't about the method name. This is about the return type. And there's nothing in the metadata today that could serve as a hint to CsWin32 that |
Are you referring to these docs? Note that when a COM object "supports" an interface it means the caller must query for that interface using |
Additional more explicit docs here: |
Ok, I see what you mean. Good points. Then I guess we should Won't Fix this. Maybe one day we'll have capacity in CsWin32 to do a custom marshaler as the OP requests to workaround this, but I don't see it happening in the foreseeable future. |
@TSlivede Can you share a bit more information on what you're trying to do that necessitates implementing FolderItems? |
I already solved my specific problem, this issue was more intended to improve the state of generated interface declarations. There are probably more interfaces for which Regarding the current Metadata: Based on what I can see via ILSpy, currently the Metadata is: [Documentation("https://learn.microsoft.com/windows/win32/shell/folderitems--newenum")]
unsafe HRESULT _NewEnum([Out][RetVal] IUnknown* ppunk); The type can of course not simply be changed to Would it instead be possible for the metadata to include some Attribute, that documents that the object supports additional interfaces? Sadly the header file [id(-4), helpstring("Enumerates the figures")]
HRESULT _NewEnum([out, retval] IUnknown **ppunk); As the dispatch id of I do understand, that it's a lot to ask and that it probably won't happen in the near (or even far) future, but maybe this issue could remain until someone who has too much time wants to tackle it? 😉 Additional motivation to parse IDL files: The IDL can contain helpstrings, which could be used to generate documentation comments for the c# code. I know that for the win32 APIs there are already links to the actual microsoft online documentation. But this is not only the project for the Metadata of the Win32 APIs but also AFAIK the home of the more general WinmdGenerator which can be used for other c libraries. And in that case it could be really helpful to pass through the helpstrings from IDL files... What I was actually doing:"necessitates implementing" might be a bit strong, but I was essentially trying to do the same as this guy: Copying multiple items with Powershell and shell.application.copyHere As I'm using powershell, I only wanted to use CsWin32 to generate the c# interface signature and embed the generated c# code via I'm aware, that I could use |
Is your feature request related to a problem? Please describe.
CsWin32 doesn't seem to recognise
_NewEnum()
as equivalent to IEnumerable, which makes it hard to implement an Interface like FolderItems which CsWin32 generates as:As far as I can tell that would require me to implement my own
IEnumVARIANT
to return from _NewEnum.Describe the solution you'd like
If I instead add Shell32.dll as COM Reference, Visual studio generates the same interface as:
This makes it much more convenient to implement the interface. (No member named
_NewEnum
is generated at all, instead the[DispId(-4)]
attribute is used to map to the correct IDispatch member (see DISPID_NEWENUM).)Describe alternatives you've considered
I could probably use both cswin32 and Visual Studio Add COM Reference in the same project, but that does not seem like the right way to do it...
Additional context
Similar: microsoft/CsWin32#824
The text was updated successfully, but these errors were encountered: