I work with an external enumeration library. There are some members of this enumeration that, when calling ToString() return the name of another member of the enumeration on them.
Console.WriteLine("TOKEN_RIGHT = {0}", Tokens.TOKEN_RIGHT.ToString()); //prints TOKEN_OUTER Console.WriteLine("TOKEN_FROM = {0}", Tokens.TOKEN_FROM.ToString()); //prints TOKEN_FROM Console.WriteLine("TOKEN_OUTER = {0}", Tokens.TOKEN_OUTER.ToString()); //prints TOKEN_FULL
I know that when two members of an enumeration have the same numerical value, you can get behavior like this, but I know that after decompiling and checking the values ββat runtime, each member in the enumeration has a unique value.
Here is a snippet of an enum definition (generated by dotPeek ):
public enum Tokens { TOKEN_OR = 134, TOKEN_AND = 135, TOKEN_NOT = 136, TOKEN_DOUBLECOLON = 137, TOKEN_ELSE = 138, TOKEN_WITH = 139, TOKEN_WITH_CHECK = 140, TOKEN_GRANT = 141, TOKEN_CREATE = 142, TOKEN_DENY = 143, TOKEN_DROP = 144, TOKEN_ADD = 145, TOKEN_SET = 146, TOKEN_REVOKE = 147, TOKEN_CROSS = 148, TOKEN_FULL = 149, TOKEN_INNER = 150, TOKEN_OUTER = 151, TOKEN_LEFT = 152, TOKEN_RIGHT = 153, TOKEN_UNION = 154, TOKEN_JOIN = 155, TOKEN_PIVOT = 156, TOKEN_UNPIVOT = 157, TOKEN_FROM = 242, }
Why is this happening? Is there something I'm doing wrong, or is this another one of those fun enum enums in .NET? If the latter, is there a workaround for him?
(Why is it Tokens is part of the Microsoft.SqlServer.Management.SqlParser.Parser namespace in .NET.)