Closed 0x5bfa closed 3 months ago
What do you mean? This wrong generated code is only when you set allowMarshaling=true I want to use it but I obliged to set it false. I know other people posted Discussion in CsWin32 tho, I wanted to report this here as well.
I believe @oold is pointing you to CsWin32's PreserveSig
flag.
Example: https://github.com/microsoft/CsWin32/blob/main/test/GenerationSandbox.Tests/NativeMethods.json
Not seeing a metadata bug here, so closing for now. But feel free to keep the discussion going!
Correct. I wanted to hint at PreserveSig
. The HRESULT
-returning methods actually returning void
is intentional. An exception is thrown if the result was an error. You need to set preserveSigMethods
in the NativeMethods.json
file if you want to check the result manually.
Specific advice regarding the IEnumShellItems
interface:
I presume you want to check whether Next()
returned S_FALSE
. Good news! You don't have to. The returned number of fetched items will be 0 if there are no further items.
I actually have another issue with allowMarshal where NativeAOT isn't compatible with this option set true. And so I can't use that option.
https://github.com/files-community/Files/pull/16016
But that is cool! Thank you for pointing it out:)
IEnumShellItems has 4 methods but CsWin32 produces as below (deleted comments):
But definitions are:
IEnumShellItems::Clone Gets a copy of the current enumeration.
IEnumShellItems::Next Gets an array of one or more IShellItem interfaces from the enumeration.
IEnumShellItems::Reset Resets the internal count of retrieved IShellItem interfaces in the enumeration.
IEnumShellItems::Skip Skips a given number of IShellItem interfaces in the enumeration. Used when retrieving interfaces.
I cannot remember where but I think I found this issue another function. Is there a config to change to HRESULT or does this something to do with CsWin32 for example it makes functions return void if return value type is unknown?