Skip to content

Commit

Permalink
Add unit test for the issue
Browse files Browse the repository at this point in the history
  • Loading branch information
ds5678 committed Nov 21, 2024
1 parent b28cefb commit 4f7c06e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
14 changes: 14 additions & 0 deletions test/AsmResolver.DotNet.Tests/Signatures/SignatureComparerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using AsmResolver.DotNet.Signatures;
using AsmResolver.DotNet.TestCases.Methods;
using AsmResolver.PE.DotNet.Cil;
using AsmResolver.PE.DotNet.Metadata.Tables;
using Xunit;
Expand Down Expand Up @@ -117,6 +118,19 @@ public void MatchPropertySignature()
Assert.Equal(signature1, signature2, _comparer);
}

[Fact]
public void MethodSpecificationsAndTheirBaseMethodShouldNotMatch()
{
var moduleDefinition = ModuleDefinition.FromFile(typeof(GenericInstanceMethods).Assembly.Location, TestReaderParameters);
var methodDefinition = moduleDefinition
.GetAllTypes().First(t => t.Name == nameof(GenericInstanceMethods))
.Methods.First(t => t.Name == nameof(GenericInstanceMethods.InstanceMethodOneTypeParameter));
var methodSpecification = methodDefinition.MakeGenericInstanceMethod(moduleDefinition.CorLibTypeFactory.Int32);

Assert.NotEqual<IMethodDescriptor>(methodDefinition, methodSpecification, _comparer);
Assert.NotEqual<IMethodDescriptor>(methodSpecification, methodDefinition, _comparer);
}

[Fact]
public void NestedTypesWithSameNameButDifferentDeclaringTypeShouldNotMatch()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
namespace AsmResolver.DotNet.TestCases.Methods
namespace AsmResolver.DotNet.TestCases.Methods
{
public class GenericInstanceMethods
{
public void InstanceMethodOneTypeParameter<T>()
{
}
}
public class GenericInstanceMethods<T, U>
{
public void InstanceParameterlessMethod()
Expand Down

0 comments on commit 4f7c06e

Please sign in to comment.