-
Notifications
You must be signed in to change notification settings - Fork 120
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
BOOL
and BOOLEAN
are defined as a struct
whereas VARIANT_BOOL
is defined as an enum
#1389
Comments
BOOL
is defined as a struct
whereas VARIANT_BOOL
is defined as an enum
BOOL
and BOOLEAN
are defined as a struct
whereas VARIANT_BOOL
is defined as an enum
@elachlan what are your thoughts on this? |
The https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types |
TRUE and FALSE were added at one point but then removed based on feedback that projections were using their own true and false. |
Ah right. In hindsight they're probably worth including. I've seen numerous requests for them as they are just so common in existing code/samples/docs that is ported to Rust. |
Sure we can add them back. As long as @elachlan confirms WinForms is ok with the breaking change for VARIANT_BOOL. |
Currently where WinForms uses it is in VARIANT.cs. I don't believe it has been re-written yet. Since it would have been moved namespace wise. I think it would be fine to change it. CC: @AArnott & @JeremyKuhne |
This will break the current code though. So its not zero effort. |
Do you agree with @kennykerr's proposal? If it's a better definition then we would make the change. |
@mikebattista Consistency is good. There are slight performance benefits to having an enum as far as .NET is concerned, which is why they're defined as such in the .NET runtime, but it is minimal. I personally prefer structs as we can provide cast operators that make going to/from |
VARIANT_BOOL is a typedef in native code, so at least it would be consistent to make it a struct in metadata too. |
Consistency is nice. We can also add extensions to it, which we do for |
Ok. Will change to struct then. I will add TRUE/FALSE back as well given that the most recent feedback is they are wanted. |
Think it's important we provide VARIANT_TRUE/VARIANT_FALSE constants, esp. given true is not represented with integer 1. |
Yes I will add those as well similar to 05fbdc9 with a NativeTypeName for the struct. |
@riverar if you get a chance could you validate usage of VARIANT_TRUE/FALSE in Rust? I defined them the same way as TRUE/FALSE but the definition in the metadata doesn't reference VARIANT_BOOL like TRUE/FALSE do with BOOL. They just show up as short. |
Whatever type the metadata uses for these constants is what Rust will use. So, if the types of the constants are not |
Everything looks correct except the VARIANT_TRUE/VARIANT_FALSE constants. Not sure why they're not getting typed as VARIANT_BOOL. |
@mikebattista Here ya go #1397 |
Thanks! |
This leads to strange inconsistencies. Can
VARIANT_BOOL
also be a[NativeTypedef] struct
?Originally posted by @kennykerr in microsoft/windows-rs#2206 (comment)
The text was updated successfully, but these errors were encountered: