Skip to content

Commit 64f56d0

Browse files
committed
failing test for: Problem with Generic types #3
1 parent cbfc3a7 commit 64f56d0

File tree

3 files changed

+26
-5
lines changed

3 files changed

+26
-5
lines changed

src/NetArchTest.Rules/Dependencies/DataStructures/NamespaceTree.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,11 @@ private IEnumerable<string> GetTokens(TypeReference reference)
210210
{
211211
if ((reference.IsArray == false) && (reference.IsByReference == false) && (reference.IsPointer == false))
212212
{
213-
yield return reference.GetNamespace();
213+
var @namespace = reference.GetNamespace();
214+
if (!string.IsNullOrEmpty(@namespace))
215+
{
216+
yield return @namespace;
217+
}
214218
yield return reference.Name;
215219
}
216220
else

test/NetArchTest.Rules.UnitTests/DependencySearch/VariousTests.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,14 @@ public void DependencySearch_IndirectReference_NotFound()
2424
[Fact(DisplayName = "Does not find things that are not dependency at all")]
2525
public void DependencySearch_Garbage_NotFound()
2626
{
27-
Utils.RunDependencyTest(Utils.GetTypesThatResideInTheSameNamespaceButWithoutGivenType(typeof(IndirectReference)), new List<string> { "System.Object::.ctor()", "T", "T1", "T2", "ctor()", "!1)", "::.ctor(!0" }, false);
27+
Utils.RunDependencyTest(Utils.GetTypesThatResideInTheSameNamespaceButWithoutGivenType(typeof(IndirectReference)), new List<string> { "System.Object::.ctor()", "T", "T1", "T2", "ctor()", "!1)", "::.ctor(!0", "T1&", "T2&", "T1[]", "T2[]" }, false);
2828
}
2929

3030
[Fact(DisplayName = "Does not find a dependency that only partially matches actually referenced type.")]
3131
public void DependencySearch_PartiallyMatchingDependency_NotFound()
32-
{
33-
Utils.RunDependencyTest(Utils.GetTypesThatResideInTheSameNamespaceButWithoutGivenType(typeof(IndirectReference)),
32+
{
33+
var subjects = Utils.GetTypesThatResideInTheSameNamespaceButWithoutGivenType(typeof(IndirectReference), typeof(GenericMethodGenericParameter));
34+
Utils.RunDependencyTest(subjects,
3435
dependencyToSearch: typeof(ExampleDep),
3536
expectToFindClass: false,
3637
expectToFindNamespace: true);
@@ -48,7 +49,8 @@ public void DependencySearch_PartiallyMatchingNamespace_NotFound()
4849
[Fact(DisplayName = "Does not find a dependency that differs only in case from actually referenced type.")]
4950
public void DependencySearch_DependencyWithDifferentCaseOfCharacters_NotFound()
5051
{
51-
Utils.RunDependencyTest(Utils.GetTypesThatResideInTheSameNamespaceButWithoutGivenType(typeof(IndirectReference)),
52+
var subjects = Utils.GetTypesThatResideInTheSameNamespaceButWithoutGivenType(typeof(IndirectReference), typeof(GenericMethodGenericParameter));
53+
Utils.RunDependencyTest(subjects,
5254
dependencyToSearch: typeof(ExampleDEPENDENCY),
5355
expectToFindClass: false,
5456
expectToFindNamespace: true);
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
5+
namespace NetArchTest.TestStructure.Dependencies.Search
6+
{
7+
internal class GenericMethodGenericParameter
8+
{
9+
public static void Deconstruct<T1, T2>(KeyValuePair<T1, T2> tuple, T1[] key, out T2 value)
10+
{
11+
key = null;
12+
value = tuple.Value;
13+
}
14+
}
15+
}

0 commit comments

Comments
 (0)