You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Bug: Win32::Foundation::HINSTANCE is not generated #1517
We can't change parameter names. When everything was HINSTANCE, the "module"-based parameters were out of sync, so if we need to standardize on 1 type for interoperability as we've done so far, the inconsistency will exist.
That said, I'm curious if we define both HMODULE and HINSTANCE and set them as AlsoUsableFor each other, if that would address the parameter name <-> type inconsistencies while also enabling interoperability. Below is what that would change.
My unqualified opinion is that it seems like there's a new level of complexity added when your type heirachy is more complex than a DAG. I could forsee some languages possibly having problems if AlsoUsableFor could create cycles? Not sure though, just a hunch mostly. As for Zig we can't really do much with AlsoUsableFor except using it to create convenient functions for conversions so these cycles wouldn't be an issue. I think there might be a proposal around adding implicit conversions between opaque types, but I think those are "one-way" meaning the relationship would have to be a DAG. Take this all with a big grain of salt :)
Activity
riverar commentedon Apr 1, 2023
Hi Muhammad Mominul Huque (@mominul), use HMODULE instead. See #1508 for more background.
mominul commentedon Apr 1, 2023
Thanks! But I think this demands a FAQ entry, many API still uses 'hinstance' as the parameter name and MSDN docs have references to
HINSTANCE.Otherwise the metadata should get rid of 'hinstance' as parameter names also.
kennykerr commentedon Apr 3, 2023
I'll pass this on to the Win32 metadata repo for visibility.
mikebattista commentedon Apr 3, 2023
We can't change parameter names. When everything was
HINSTANCE, the "module"-based parameters were out of sync, so if we need to standardize on 1 type for interoperability as we've done so far, the inconsistency will exist.That said, I'm curious if we define both
HMODULEandHINSTANCEand set them asAlsoUsableForeach other, if that would address the parameter name <-> type inconsistencies while also enabling interoperability. Below is what that would change.Fixed #1517.
mikebattista commentedon Apr 5, 2023
Should we make this change?
Kenny Kerr (@kennykerr) Andrew Arnott (@AArnott) Tim Sneath (@timsneath) Jonathan Marler (@marler8997) do you support
AlsoUsableForin this way?timsneath commentedon Apr 5, 2023
Dart doesn't need an attribute to differentiate between these (we treat them both as
IntPtr), so no issue for us here.mikebattista commentedon Apr 5, 2023
As long as examples like https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-createwindowexw#example continue to work then this would be an improvement.
The example above is passing
GetModuleHandle(null), which returns anHMODULE, intoCreateWindow, which expects anHINSTANCE.marler8997 commentedon Apr 5, 2023
My unqualified opinion is that it seems like there's a new level of complexity added when your type heirachy is more complex than a DAG. I could forsee some languages possibly having problems if AlsoUsableFor could create cycles? Not sure though, just a hunch mostly. As for Zig we can't really do much with AlsoUsableFor except using it to create convenient functions for conversions so these cycles wouldn't be an issue. I think there might be a proposal around adding implicit conversions between opaque types, but I think those are "one-way" meaning the relationship would have to be a DAG. Take this all with a big grain of salt :)
kennykerr commentedon Apr 5, 2023
Yes.
AArnott commentedon Apr 6, 2023
CsWin32 doesn't support AlsoUsableFor yet. But when it does, I don't anticipate any problems for C# if relationships were cyclical.
mikebattista commentedon Apr 6, 2023
Thanks. So if we make this change, C# users will need to cast HMODULEs to HINSTANCEs in the meantime if they need to convert?
AArnott commentedon Apr 6, 2023
I don't think a cast would work. They would have to do something like
new HMODULE(hinstance.Value).mikebattista commentedon Apr 6, 2023
Ok. I'd prefer you support the implicit conversion before we make this change.
AArnott commentedon Apr 6, 2023
Thanks. I'll bump the priority of adding that feature.
mikebattista commentedon Apr 6, 2023
Thanks!
Bug: `Win32::Foundation::HINSTANCE` is not generated. Fixed microsoft…