-
Notifications
You must be signed in to change notification settings - Fork 114
Description
Actual behavior
COM interfaces that use PROPVARIANT or similar structs can not be used in a .NET JIT project, when CsWin32 is set to use CsWin32RunAsBuildTask and UseComSourceGenerators. A compiler error is raised:
unsafe void GetProperty(winmdroot.Foundation.PROPERTYKEY* key, out winmdroot.System.Com.StructuredStorage.PROPVARIANT ppropvar);
SYSLIB1051 Runtime marshalling must be disabled in this project by applying the 'System.Runtime.CompilerServices.DisableRuntimeMarshallingAttribute' to the assembly to enable marshalling this type. The generated source will not handle marshalling of parameter 'ppropvar'. For types that are not supported by source-generated COM, the resulting function pointer will rely on the underlying runtime to marshal the specified type.
Expected behavior
JIT (non-AOT) projects using CsWin32 with CsWin32RunAsBuildTask and UseComSourceGenerators can be used to generate COM interfaces using PROPVARIANT or similar structs without having to disable DisableRuntimeMarshallingAttribute for the entire assembly.
I understand this may be expected behavior right now, or due to limitations by .NET, but it would be nice if we didn't have to disable DisableRuntimeMarshallingAttribute for the entire assembly. Feel free to close the issue if this is not fixable.
Repro steps
NativeMethods.txtcontent:
IShellItem2
NativeMethods.jsoncontent (if present):
{
"$schema": "https://aka.ms/CsWin32.schema.json",
"comInterop": {"useComSourceGenerators": true}
}- Any of your own code that should be shared?
none required
Context
- CsWin32 version: 0.3.217
- Target Framework: net8.0-windows10.0.26100.0
- CsWin32RunAsBuildTask = true