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

AttachConsole supports only uint, no overload to attach to parent process. #1310

Closed
SPWizard01 opened this issue Nov 21, 2024 · 1 comment
Closed
Labels
bug Something isn't working

Comments

@SPWizard01
Copy link

Actual behavior

calling Windows.Win32.PInvoke.AttachConsole(-1) will result in error because of the source generation:
internal static extern winmdroot.Foundation.BOOL AttachConsole(uint dwProcessId);

Expected behavior

-1 Should probably be allowed as an overload based on documentation here:
https://learn.microsoft.com/en-us/windows/console/attachconsole#parameters

Repro steps

  1. NativeMethods.txt content:
AttachConsole
  1. NativeMethods.json content (if present):
  1. Any of your own code that should be shared?

Context

  • CsWin32 version: 0.3.106
  • Win32Metadata version (if explicitly set by project):
  • Target Framework: net9.0-windows10.0.26100.0
  • LangVersion (if explicitly set by project): [e.g. 9]
@SPWizard01 SPWizard01 added the bug Something isn't working label Nov 21, 2024
@AArnott
Copy link
Member

AArnott commented Jan 15, 2025

Thank you for the doc reference. As the docs point out, a cast is required even in C. You can do this in C# too.

We generally hesitate to add custom overloads to arbitrary functions in Win32 to the generated code because it makes CsWin32 significantly more complex rather than being a transformation of winmd to C#. But you're always welcome to write your own method into the emitted partial class that does the cast for you if you want the syntax sugar of it.

@AArnott AArnott closed this as not planned Won't fix, can't repro, duplicate, stale Jan 15, 2025
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