New .NET4.5 API có logic sau đây trong IntrospectionExtensions lớpTại sao System.Reflection.IntrospectionExtensions.GetTypeInfo có mã không thể truy cập?
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();
}
Tại sao phương pháp này có mã unreachable? Đây có phải là lỗi hoặc được thực hiện cố tình không?
Đây có phải là kết quả của một số decompiler? Có lẽ mã nguồn ban đầu là 'IReflectableType reflectableType = type như IReflectableType; 'và trình dịch ngược đã làm cho nó sai. – dtb
IL DASM cho thấy (IL_0015: castclass System.Reflection.IReflectableType) không (isinst), do đó, có một diễn viên nghiêm ngặt. –