新.NET4.5 API在IntrospectionExtensions类为什么System.Reflection.IntrospectionExtensions.GetTypeInfo有无法访问的代码?
public static TypeInfo GetTypeInfo(this Type type)
{
if (type == (Type) null)
throw new ArgumentNullException("type");
IReflectableType reflectableType = (IReflectableType) type;
if (reflectableType == null)
return (TypeInfo) null; // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< HERE!
else
return reflectableType.GetTypeInfo();
}
为什么这种方法具有无法访问的代码下面的逻辑?这是一个错误还是故意完成的?
这是一些反编译器的输出?也许最初的源代码是'IReflectableType reflectableType = type作为IReflectableType;'和反编译器错了。 – dtb
IL DASM显示(IL_0015:castclass System.Reflection.IReflectableType)not(isinst),所以有严格的强制转换。 –