Skip to content

Latest CsWin32 generates code that fail to compile (and unnecessary methods) #1332

@Sergio0694

Description

@Sergio0694

Actual behavior

I've updated to the latest version (0.3.162) and my project is now failing to compile. Upon inspecting the generated code, it seems CsWin32 is generating a bunch of invalid code in the QueryInterface methods it's emitting. It's also not clear why these methods are generated in the first place, given I've disabled the friendly overloads. I expect (and want) literally only the vtable methods to be generated, nothing else.

Image

You can see this generated call has invalid arguments. Also, this whole method shouldn't be generated at all, really.

Expected behavior

The code should be valid and compile, and no additional "helper methods" should be generated.

Repro steps

  1. NativeMethods.txt content:
ID3D11ShaderReflection
IUnknown
  1. NativeMethods.json content (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.0 and net9.0 (I can repro on both)
  • LangVersion (if explicitly set by project): n/a

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions