-
Notifications
You must be signed in to change notification settings - Fork 94
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
GetMessage returns a bool when it should return a BOOL #362
Comments
This is an interesting one. The Windows headers and docs type the return value as Anyway, I think we may need to special case this in the metadata. Should it be |
As I understand, in the metadata the return value of |
Yes, cswin32 is writing out the pinvoke with a .NET bool as return value. |
This has been discussed before (#308 and microsoft/win32metadata#301) and I'm surprised it hasn't been acted upon. |
It looks like @AArnott said he would find a way to preserve the full 32-bit signed |
@AArnott ? |
I have already made BOOL provide access to the underlying internal readonly partial struct BOOL
{
private readonly int value;
internal int Value => this.value;
internal BOOL(bool value) => this.value = value ? 1 : 0;
internal BOOL(int value) => this.value = value;
public static implicit operator bool(BOOL value) => value.Value != 0;
public static implicit operator BOOL(bool value) => new BOOL(value);
public static explicit operator BOOL(int value) => new BOOL(value);
} The remaining problem seems to be that although the metadata declares |
Actual behavior
Currently,
GetMessage
is defined to return a bool, which can be compared to true or false only. This incorrect according to the documentation:This means, that from C#, it's impossible to handle errors for this function.
Because of the bool return, it actually ends up being that ignoring errors is encouraged, when the docs actually call this out as wrong:
Expected behavior
GetMessage should return an
int
, so that it can be compared to -1 and 0.Repro steps
NativeMethods.txt
content:NativeMethods.json
content (if present):Nothing
Any of your own code that should be shared?
No
Context
LangVersion
(if explicitly set by project): Not explicitly setThe text was updated successfully, but these errors were encountered: