This project is read-only.
1
Vote

SemanticModel.GetConstantValue() casts to short and nullables bug

description

1)
short short1 = unchecked((short)65535.17567);

GetConstantValue on the right expression above returns 0, instead of -1.

2)
Also all casts to integer nullable types are not clamped correctly.

int? nullable_int = (int?)5.5;
GetConstantValue on the right expression above returns 5.5, instead of 5.

comments

danielz80 wrote Aug 24, 2014 at 5:00 PM

Also all casts to integer nullable types are not clamped correctly.

int? nullable_int = (int?)(5.5)

GetConstantValue on the expression above returns 5.5, instead of 5.