Closed Danielku15 closed 10 years ago
Can you elaborate on what you were doing to produce the error? I tried writing a few unit tests with byte and I couldn't repro the error.
I just debugged into the compiler when compiling my source and it seems to happen if you declare your enum as one of those clipped integer types. Here's a unit test for EnumTest.cs:
[Test]
public void ValueByte()
{
AssertEquals(((byte)ByteEnum.One), 0);
AssertEquals(((byte)ByteEnum.Two), 1);
AssertEquals(((byte)ByteEnum.Three), 2);
}
public enum ByteEnum : byte
{
One = 0,
Two = 1,
Three = 2
}
The 0,1,2 literals of the enum value initializers are interfered as byte literal which will result in this problem.
Therefore maybe the title of this issue should be: "Support for changing underlying types of enums" http://msdn.microsoft.com/en-us/library/sbbt4032.aspx
Thanks! I've fixed the issues around enums for byte/sbyte/short/ushort. Let me know if there are other scenarios where you can reproduce similar issues with respect to these primitive types.
The problem also occurs for byte parameters with default values:
public static byte Clipped(byte test = 255) // fails
{
return test;
}
But your last commit also fixed this cases. Maybe you want to add some unit tests for this case.
With this fix I am finally able to compile alphaTab. Now I'll start testing the generated JavaScript.
Thanks, I've added some unit tests in NumberTests accordingly
Currently
JsPrimitiveExpression
and theJs.Literal()
do not support all C# primitives types, the clipped integers are missing. Even if JavaScript might not support them and some special TypedArray down casting might be needed in the future, currently it completely crashes the compiler with "Unexpected primitive type".