[Mono-list] Another reflection issue

Miguel de Icaza miguel@ximian.com
08 Jan 2002 18:16:12 -0500

> Anybody have a clue why this:
> 	private static string GetKind(Type t)
> 	{
> 		if (t.IsClass)     return "class";
> 		if (t.IsInterface) return "interface";
> 		// FIXME: IsEnum doesn't seem to return a correct value,
> 		// and all enums end up in the XML as 'struct'
> 		if (t.IsEnum)      return "enum";
> 		if (t.IsValueType) return "struct";
> 		else               return "UNKNOWN";
> 	}

Try changing it to:

	if (t.IsValueType){
		if (t.BaseType.FullName == "System.Enum")

The compiler has a similar issue, because testing for something is done
against a type loaded from an assembly, which might not be the same type
the runtime has.