Skip to content

Commit

Permalink
Merge pull request #47 from brandhuf/Issue46Fix
Browse files Browse the repository at this point in the history
Issue #46 Fix
  • Loading branch information
fgather authored Jan 28, 2021
2 parents c48ced3 + 4d62192 commit 38dfa7e
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ArchUnitNET/Loader/MonoCecilTypeExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ internal static string BuildFullName(this TypeReference typeReference)
var genericParameter = (GenericParameter) typeReference;

return (genericParameter.Type == GenericParameterType.Type
? genericParameter.DeclaringType.FullName
: genericParameter.DeclaringMethod.FullName)
? genericParameter.DeclaringType.BuildFullName()
: genericParameter.DeclaringMethod.BuildFullName())
+ "+<" + genericParameter.Name + ">";
}

Expand Down
50 changes: 50 additions & 0 deletions ArchUnitNETTests/GithubIssuesTests/GithubIssue46Test.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// Copyright 2019 Florian Gather <[email protected]>
// Copyright 2019 Fritz Brandhuber <[email protected]>
// Copyright 2020 Pavel Fischer <[email protected]>
//
// SPDX-License-Identifier: Apache-2.0
//

using System.Linq;
using ArchUnitNET.Domain;
using ArchUnitNET.Domain.Extensions;
using ArchUnitNET.Loader;
using Xunit;

namespace ArchUnitNETTests.GithubIssuesTests
{
public class GithubIssue46Test
{
private static readonly Architecture Architecture =
new ArchLoader().LoadAssembly(typeof(GithubIssue46Test).Assembly).Build();

private readonly MethodMember _oneGenericArgumentMethod;
private readonly MethodMember _twoGenericArgumentsMethod;

public GithubIssue46Test()
{
var intf = Architecture.GetInterfaceOfType(typeof(ITestGenericMethods));
_oneGenericArgumentMethod = intf.GetMethodMembers()
.First(member => member.GenericParameters.Count == 1);
_twoGenericArgumentsMethod = intf.GetMethodMembers()
.First(member => member.GenericParameters.Count == 2);
}


[Fact]
public void AssignDifferentGenericParametersToMethodsWithSameName()
{
Assert.NotNull(_oneGenericArgumentMethod);
Assert.NotNull(_twoGenericArgumentsMethod);

Assert.Empty(
_oneGenericArgumentMethod.GenericParameters.Intersect(_twoGenericArgumentsMethod.GenericParameters));
}
}

internal interface ITestGenericMethods
{
void Method<T, K>();
void Method<T>();
}
}

0 comments on commit 38dfa7e

Please sign in to comment.