microsoft / CsWin32

A source generator to add a user-defined set of Win32 P/Invoke methods and supporting types to a C# project.
MIT License
2k stars 84 forks source link

Add ToString() methods to ordinary typedef structs #1020

Closed AArnott closed 11 months ago

elachlan commented 10 months ago

We are running into an issue where we have implemented BOOL.ToString() => ((bool)this).ToString(); This clashes with this change. Obvious solution would be to rename the winforms ToString to something else.

Does returning to hex value for BOOL make sense though?

AArnott commented 10 months ago

I could imagine CsWin32 special casing BOOL to print a boolean value. However since some uses of BOOL stick more values into it than the customary two, it may indeed be useful to print its full value as an integer.

AArnott commented 10 months ago

Another option is to notice that your compilation already defines a ToString method and suppress automatic generation.