Browse Source

Fix #2312: Constructors and operators may not have any generic type parameters in C#

pull/2320/head
Siegfried Pammer 4 years ago
parent
commit
ae3306b966
  1. 14
      ICSharpCode.Decompiler/TypeSystem/Implementation/MetadataMethod.cs

14
ICSharpCode.Decompiler/TypeSystem/Implementation/MetadataMethod.cs

@ -66,21 +66,28 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -66,21 +66,28 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
this.symbolKind = SymbolKind.Method;
var (accessorOwner, semanticsAttribute) = module.PEFile.MethodSemanticsLookup.GetSemantics(handle);
const MethodAttributes finalizerAttributes = (MethodAttributes.Virtual | MethodAttributes.Family | MethodAttributes.HideBySig);
this.typeParameters = MetadataTypeParameter.Create(module, this, def.GetGenericParameters());
if (semanticsAttribute != 0)
{
this.symbolKind = SymbolKind.Accessor;
this.accessorOwner = accessorOwner;
this.AccessorKind = semanticsAttribute;
}
else if ((attributes & (MethodAttributes.SpecialName | MethodAttributes.RTSpecialName)) != 0)
else if ((attributes & (MethodAttributes.SpecialName | MethodAttributes.RTSpecialName)) != 0
&& typeParameters.Length == 0)
{
string name = this.Name;
if (name == ".cctor" || name == ".ctor")
{
this.symbolKind = SymbolKind.Constructor;
else if (name.StartsWith("op_", StringComparison.Ordinal))
}
else if (name.StartsWith("op_", StringComparison.Ordinal)
&& CSharp.Syntax.OperatorDeclaration.GetOperatorType(name) != null)
{
this.symbolKind = SymbolKind.Operator;
}
}
else if ((attributes & finalizerAttributes) == finalizerAttributes)
else if ((attributes & finalizerAttributes) == finalizerAttributes && typeParameters.Length == 0)
{
if (Name == "Finalize" && Parameters.Count == 0 && ReturnType.IsKnownType(KnownTypeCode.Void)
&& (DeclaringTypeDefinition as MetadataTypeDefinition)?.Kind == TypeKind.Class)
@ -88,7 +95,6 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -88,7 +95,6 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
this.symbolKind = SymbolKind.Destructor;
}
}
this.typeParameters = MetadataTypeParameter.Create(module, this, def.GetGenericParameters());
this.IsExtensionMethod = (attributes & MethodAttributes.Static) == MethodAttributes.Static
&& (module.TypeSystemOptions & TypeSystemOptions.ExtensionMethods) == TypeSystemOptions.ExtensionMethods
&& def.GetCustomAttributes().HasKnownAttribute(metadata, KnownAttribute.Extension);

Loading…
Cancel
Save