Browse Source

Fixed NullReferenceException when decompiling "typeof(List<int>[])".

pull/172/merge
Daniel Grunwald 14 years ago
parent
commit
b01fe1b427
  1. 5
      ICSharpCode.Decompiler/Ast/AstMethodBodyBuilder.cs
  2. 2
      ICSharpCode.Decompiler/Tests/Generics.cs

5
ICSharpCode.Decompiler/Ast/AstMethodBodyBuilder.cs

@ -751,7 +751,10 @@ namespace ICSharpCode.Decompiler.Ast @@ -751,7 +751,10 @@ namespace ICSharpCode.Decompiler.Ast
AstType AddEmptyTypeArgumentsForUnboundGenerics(AstType type)
{
TypeDefinition typeDef = type.Annotation<TypeReference>().Resolve();
TypeReference typeRef = type.Annotation<TypeReference>();
if (typeRef == null)
return type;
TypeDefinition typeDef = typeRef.Resolve(); // need to resolve to figure out the number of type parameters
if (typeDef == null || !typeDef.HasGenericParameters)
return type;
SimpleType sType = type as SimpleType;

2
ICSharpCode.Decompiler/Tests/Generics.cs

@ -63,6 +63,8 @@ public static class Generics @@ -63,6 +63,8 @@ public static class Generics
private static Type type1 = typeof(List<>);
private static Type type2 = typeof(Generics.MyArray<>);
private static Type type3 = typeof(List<>.Enumerator);
private static Type type4 = typeof(Generics.MyArray<>.NestedClass<>);
private static Type type5 = typeof(List<int>[]);
public static void MethodWithConstraint<T, S>() where T : class, S where S : ICloneable, new()
{

Loading…
Cancel
Save