Skip to content

Commit afb9915

Browse files
authored
Merge pull request #78 from NeVeSpl/IgnoreCompilerGeneratedTypesInDependencySearch
fix detecting global compiler-generated types in dependency search
2 parents 0127ecc + d6e98ee commit afb9915

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

src/NetArchTest.Rules/Dependencies/TypeDefinitionCheckingResult.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,14 @@ public void CheckDependency(TypeReference dependency)
102102
}
103103
else
104104
{
105-
_hasDependencyFromOutsideOfSearchTree = true;
105+
if (_hasDependencyFromOutsideOfSearchTree == false)
106+
{
107+
bool isGlobalAnonymousCompilerGeneratedType = String.IsNullOrEmpty(dependency.Namespace) && dependency.Name.StartsWith("<>");
108+
if (!isGlobalAnonymousCompilerGeneratedType)
109+
{
110+
_hasDependencyFromOutsideOfSearchTree = true;
111+
}
112+
}
106113
}
107114
}
108115
}

test/NetArchTest.TestStructure/Dependencies/TypeOfSearch/Classes.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,20 @@
22
{
33
using System;
44
using System.Collections.Generic;
5+
using System.Linq;
56
using System.Text;
67

78
#pragma warning disable 169
89

910
public class Class_A
1011
{
12+
public static void LetUsCreateSomeAnonymousTypes()
13+
{
14+
var numbers = Enumerable.Range(0, 1);
15+
var result = from x in numbers
16+
join z in numbers on x equals z
17+
select (x, z);
18+
}
1119
}
1220

1321
public class Class_B

0 commit comments

Comments
 (0)