a bug in rotor and .net 1.0 , 1.1
in our project we manage our constants as an xml file and then generate a valid c# file at the same way Type DataSet is being generated in vs.net, someone from my team (saar carmi) wrote a custom code generator.
we supplied an xml file stating the type name and value of a const and then once you hit the save button a c# file is generated,
we also support enums, one of out coders came to us saying we have a problem with enums of type byte. we did a simple sample in c# and you can write the following:
public
enum MyEnum:byte
{
val1,
val2,
val3,
val4
}
it will compile and run, but once you try to use the CSharpCodeGenerator, it doesn't support it, I've traced it down using Anakrino to the method:
private string GetBaseTypeOutput(string baseType) {
string s = CreateEscapedIdentifier(baseType);
if (s.Length == 0) {
s = "void";
}
else if (string.Compare(s, "System.Int16", true, CultureInfo.InvariantCulture) == 0) {
s = "short";
}
else if (string.Compare(s, "System.Int32", true, CultureInfo.InvariantCulture) == 0) {
s = "int";
}
else if (string.Compare(s, "System.Int64", true, CultureInfo.InvariantCulture) == 0) {
s = "long";
}
else if (string.Compare(s, "System.String", true, CultureInfo.InvariantCulture) == 0) {
s = "string";
}
else if (string.Compare(s, "System.Object", true, CultureInfo.InvariantCulture) == 0) {
s = "object";
}
else if (string.Compare(s, "System.Boolean", true, CultureInfo.InvariantCulture) == 0) {
s= "bool";
}
else if (string.Compare(s, "System.Void", true, CultureInfo.InvariantCulture) == 0) {
s = "void";
}
else if (string.Compare(s, "System.Char", true, CultureInfo.InvariantCulture) == 0) {
s = "char";
}else {
// replace + with . for nested classes.
//
s = s.Replace('+', '.');
}
return s;
}
you will notice that System.Byte simply doesn't exist.
I send the bug to MS , they replied that it is a bug but (we're over a year now) never fixed it.
I just browsed rotor source and found that rotor has the same bug.
Comments
- Anonymous
June 25, 2003
I guess that byte is not CLR compliant then... - Anonymous
June 25, 2003
None of the unsigned int types are CLS compliant. Support for them in CLR varies. - Anonymous
June 25, 2003
thnx guys,
since c# supports them and I'm using the CSharpCodeGenerator, it should support it.