Browse Source

Fix #2913: ArgumentException when generic class is missing `1 suffix.

pull/2993/head
Daniel Grunwald 2 years ago
parent
commit
4fc8f4e66e
  1. 7
      ICSharpCode.Decompiler/TypeSystem/TypeProvider.cs

7
ICSharpCode.Decompiler/TypeSystem/TypeProvider.cs

@ -72,6 +72,13 @@ namespace ICSharpCode.Decompiler.TypeSystem
public IType GetGenericInstantiation(IType genericType, ImmutableArray<IType> typeArguments) public IType GetGenericInstantiation(IType genericType, ImmutableArray<IType> typeArguments)
{ {
int tpc = genericType.TypeParameterCount;
if (tpc == 0 || tpc != typeArguments.Length)
{
// This can occur when the genericType is from another assembly,
// doesn't have the typical `1 suffix, and that other assembly is not loaded.
return genericType;
}
return new ParameterizedType(genericType, typeArguments); return new ParameterizedType(genericType, typeArguments);
} }

Loading…
Cancel
Save