Skip to content
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

Generated WaitForDebugEvent method does not generate union correctly #445

Closed
ipazanin opened this issue Nov 9, 2021 · 2 comments
Closed
Labels
bug Something isn't working

Comments

@ipazanin
Copy link

ipazanin commented Nov 9, 2021

Actual behavior

Default Implementation

When I import WaitForDebugEvent method, it throws System.TypeLoadException when invoked with message "Could not load type '_u_e__Union' from assembly 'Win32Bug, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' because it contains an object field at offset 0 that is incorrectly aligned or overlapped by a non-object field."

Don't Allow Marshaling workaround:

{
  "$schema": "https://aka.ms/CsWin32.schema.json",
  "allowMarshaling": false
}

From issue: Generated PROPVARIANT type is invalid #292
Results in:

var result = PInvoke.WaitForDebugEvent(out var debugEvent, 1000);
var lastError = Marshal.GetLastWin32Error();
Console.WriteLine($"result: {result}, lastError: {lastError}"); // result: 0, lastError: 6
// ERROR_INVALID_HANDLE 6 (0x6)

Expected behavior

WaitForDebugEvent method should not throw exception when invoked.

Repro steps

  1. NativeMethods.txt content:
WaitForDebugEvent
  1. NativeMethods.json content (if present):
{
    "$schema": "https://aka.ms/CsWin32.schema.json",
}
  1. Any of your own code that should be shared?
public static void Main(string[] _)
{
    var result = PInvoke.WaitForDebugEvent(out var debugEvent, 1000);
}

Context

  • CsWin32 version: 0.1.588-beta
  • Win32Metadata version: not set
  • Target Framework: net5.0-windows
  • LangVersion: 9.0
@ipazanin ipazanin added the bug Something isn't working label Nov 9, 2021
@AArnott
Copy link
Member

AArnott commented Nov 9, 2021

There is something about the struct (or the structs it references, actually) where at least one of them becomes "managed" in .NET terms. It's difficult to know which one it is without tedious removal of fields until it starts working. It's clearly something we need to fix. I can't give you a timeline right now.

@AArnott
Copy link
Member

AArnott commented Jun 1, 2022

Duplicate of #292

@AArnott AArnott marked this as a duplicate of #292 Jun 1, 2022
@AArnott AArnott closed this as completed Jun 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants