Latest release generates a lot of unwanted code when marshalling/overloads are disabled
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 2.5k
- Forks
- 124
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 9
Description
Actual behavior
Follow up from https://github.com/microsoft/CsWin32/issues/1332#issuecomment-2608446584.
I'd expect all COM types to only have the direct function pointer vtable slot methods, and the blittable vtable type.
Expected behavior
Some types also get a ton of unwanted stuff, like:
[UnmanagedCallersOnly]methods doing CCW marshalling (??)PopulateVTablemethod- A managed
[ComImport]interface type (this isn't even trim/AOT compatible, nor blittable, why is it here)
None of this stuff should be emitted when specifying blittable mode with no friendly overloads.
CsWin32 should literally only emit the blittable type, the vtable definition, and the IID field.
Repro steps
NativeMethods.txtcontent:
ID3D11ShaderReflection
NativeMethods.jsoncontent (if present):
{
"$schema": "https://aka.ms/CsWin32.schema.json",
"allowMarshaling": false,
"useSafeHandles": false,
"comInterop": {
"preserveSigMethods": [
"*"
]
},
"friendlyOverloads": {
"enabled": false
}
}
Context
- CsWin32 version:
0.3.162 - Win32Metadata version (if explicitly set by project): n/a
- Target Framework:
netstandard2.0andnet9.0(I can repro on both) LangVersion(if explicitly set by project): n/a
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the generated output using NativeMethods.txt with ID3D11ShaderReflection and the shown NativeMethods.json settings, targeting both netstandard2.0 and net9.0. Compare the output with the expected blittable type, vtable definition, and IID field; done means the unwanted marshalling, PopulateVTable, and managed ComImport artifacts are absent.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100