microsoft / win32metadata

Tooling to generate metadata for Win32 APIs in the Windows SDK.
Other
1.32k stars 113 forks source link

ConstantsScraper: Using `--with-type` with a constant that has a shift produces bad code #1861

Open dpaoliello opened 6 months ago

dpaoliello commented 6 months ago

Given a constant that is calculated with a shift:

#define MY_CONST (1<<4)

Then trying to use --with-type with this constant (e.g., --with-type=MY_CONST=ushort), constants scraper will produce the following code:

public const ushort MY_CONST = 1u<<4;

Which is invalid:

error CS0266: Cannot implicitly convert type 'uint' to 'ushort'. An explicit conversion exists (are you missing a cast?)