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

Avoid overflow exceptions when converting BOOL to bool #645

Merged
merged 1 commit into from
Aug 9, 2022
Merged

Conversation

AArnott
Copy link
Member

@AArnott AArnott commented Aug 9, 2022

This means it has to be a lossy conversion, since BOOL is 4 bytes and bool is 1 byte. Generally .NET recommends avoiding lossy implicity operators (though explicit is ok). But for a type like this, it seems like super-high value for folks to be able to author if (!SomeBOOL()) and have that work without casts.

Fixes #624

@elachlan
Copy link
Contributor

elachlan commented Aug 9, 2022

The Tests which directly compare string values are failing. Those templates will need to be updated.

  • TestSimpleDelegate
  • TestMethodWithOverloads
  • TestSimpleStructure

This means it has to be a lossy conversion, since `BOOL` is 4 bytes and `bool` is 1 byte. Generally .NET recommends avoiding lossy implicity operators (though explicit is ok). But for a type like this, it seems like super-high value for folks to be able to author `if (!SomeBOOL())` and have that work without casts.

Fixes #624
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BOOL/BOOLEAN templates are incorrect
2 participants