Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Mono.Cecil/MetadataResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,9 @@ public static MethodDefinition GetMethod (Collection<MethodDefinition> methods,
if (!AreSame (method.ReturnType, reference.ReturnType))
continue;

if (method.HasThis != reference.HasThis)
continue;

if (method.IsVarArg () != reference.IsVarArg ())
continue;

Expand Down
15 changes: 15 additions & 0 deletions Test/Mono.Cecil.Tests/MethodTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -221,5 +221,20 @@ public void ReturnParameterMethod ()
Assert.IsNotNull (method);
Assert.AreEqual (method, method.MethodReturnType.Parameter.Method);
}

[Test]
public void InstanceAndStaticMethodComparison ()
{
TestIL ("others.il", module => {
var others = module.GetType ("Others");
var instance_method = others.Methods.Single (m => m.Name == "SameMethodNameInstanceStatic" && m.HasThis);
var static_method_reference = new MethodReference ("SameMethodNameInstanceStatic", instance_method.ReturnType, others)
{
HasThis = false
};

Assert.AreNotEqual(instance_method, static_method_reference.Resolve ());
});
}
}
}
10 changes: 10 additions & 0 deletions Test/Resources/il/others.il
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,14 @@
.other instance void Others::dang_Handler (class [mscorlib]System.EventHandler)
.other instance void Others::fang_Handler (class [mscorlib]System.EventHandler)
}

.method public instance void SameMethodNameInstanceStatic() cil managed
{
ret
}

.method public static void SameMethodNameInstanceStatic() cil managed
{
ret
} // end of static method MethodNameTests::MethodName
}