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

Need way to hook initialization for given PInvokes #1308

Open
JeremyKuhne opened this issue Nov 17, 2024 · 1 comment
Open

Need way to hook initialization for given PInvokes #1308

JeremyKuhne opened this issue Nov 17, 2024 · 1 comment
Labels
enhancement New feature or request partner

Comments

@JeremyKuhne
Copy link
Member

Is your feature request related to a problem? Please describe.

Using a GDI+ API needs to have GDI+ initialized. In System.Drawing this was accomplished in the static constructor for the manually written PInvokes. Moving to CSWin32 we can still create a static constructor on the partial to do this, but not for a shared assembly where we only want to start GDI+ when we know we're going to use it (some usages of the shared assembly do not use GDI+).

Describe the solution you'd like

The ability to specify the static class a method goes to? Could leverage this for other organization?

GdipBitmapLockBits, class:GdipPInvoke

Describe alternatives you've considered

  • Creating a separate assembly for every case we have like this
  • Allowing specifying some sort of partial static initialization method in the NativeMethods.txt

Additional context

Our first regression in .NET 9 with System.Drawing after moving to CsWin32 was around this.

@AArnott
Copy link
Member

AArnott commented Jan 15, 2025

The ability to specify the static class a method goes to?

What does this mean? Do you want a pinvoke method to merely reference the static class in order to trigger its static constructor? Or are you talking about moving the pinvoke method to this other class?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request partner
Projects
None yet
Development

No branches or pull requests

2 participants