Browse Source

Fix handling of extension methods

pull/1198/head
Siegfried Pammer 7 years ago
parent
commit
2953c913d3
  1. 13
      ICSharpCode.Decompiler.Tests/TypeSystem/TypeSystemLoaderTests.cs
  2. 6
      ICSharpCode.Decompiler.Tests/TypeSystem/TypeSystemTestCase.cs
  3. 2
      ICSharpCode.Decompiler/TypeSystem/Implementation/MetadataMethod.cs

13
ICSharpCode.Decompiler.Tests/TypeSystem/TypeSystemLoaderTests.cs

@ -1316,6 +1316,19 @@ namespace ICSharpCode.Decompiler.Tests.TypeSystem @@ -1316,6 +1316,19 @@ namespace ICSharpCode.Decompiler.Tests.TypeSystem
Assert.IsTrue(type.IsStatic);
}
[Test]
public void ExtensionMethodTest()
{
ITypeDefinition type = GetTypeDefinition(typeof(StaticClass));
var method = type.Methods.Single(m => m.Name == "Extension");
Assert.IsTrue(method.IsStatic);
Assert.IsTrue(method.IsExtensionMethod);
Assert.IsNull(method.ReducedFrom);
Assert.IsTrue(type.HasExtensionMethods);
}
[Test]
public void NoDefaultConstructorOnStaticClassTest()
{

6
ICSharpCode.Decompiler.Tests/TypeSystem/TypeSystemTestCase.cs

@ -360,7 +360,11 @@ namespace ICSharpCode.Decompiler.Tests.TypeSystem @@ -360,7 +360,11 @@ namespace ICSharpCode.Decompiler.Tests.TypeSystem
new event EventHandler Evt;
}
public static class StaticClass { }
public static class StaticClass
{
public static void Extension(this object inst) { }
}
public abstract class AbstractClass { }
public class IndexerNonDefaultName

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

@ -210,7 +210,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -210,7 +210,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
}
IMember IMember.MemberDefinition => this;
IMethod IMethod.ReducedFrom => this;
IMethod IMethod.ReducedFrom => null;
TypeParameterSubstitution IMember.Substitution => TypeParameterSubstitution.Identity;
public ITypeDefinition DeclaringTypeDefinition {

Loading…
Cancel
Save