Skip to content

Commit

Permalink
Merge pull request TNG#166 from gbtb/perf_improvement_for_AddTypesToN…
Browse files Browse the repository at this point in the history
…amespace

Passing only new types to AddTypesToNamespace load task
  • Loading branch information
fgather authored Aug 3, 2022
2 parents c26edb4 + 84d1413 commit 2ac6487
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion ArchUnitNET/Loader/ArchBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public void LoadTypesForModule(ModuleDefinition module, string namespaceFilter)
types.AddRange(nestedTypes);
}

var currentTypes = new List<IType>(types.Count);
types.Where(typeDefinition => RegexUtils.MatchNamespaces(namespaceFilter,
typeDefinition.Namespace) && typeDefinition.CustomAttributes.All(att =>
att.AttributeType.FullName != "Microsoft.VisualStudio.TestPlatform.TestSDKAutoGeneratedCode"))
Expand All @@ -81,6 +82,7 @@ public void LoadTypesForModule(ModuleDefinition module, string namespaceFilter)
var type = _typeFactory.GetOrCreateTypeFromTypeReference(typeDefinition);
if (!_architectureTypes.Contains(type) && !type.IsCompilerGenerated)
{
currentTypes.Add(type);
_architectureTypes.Add(type);
}
});
Expand All @@ -90,7 +92,7 @@ public void LoadTypesForModule(ModuleDefinition module, string namespaceFilter)
.ForEach(ns =>
{
_loadTaskRegistry.Add(typeof(AddTypesToNamespace),
new AddTypesToNamespace(ns, _architectureTypes));
new AddTypesToNamespace(ns, currentTypes));
});
}

Expand Down
2 changes: 1 addition & 1 deletion ArchUnitNETTests/Loader/ArchLoaderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public void LoadAssemblies()
Assert.NotEmpty(ArchUnitNETTestAssemblyArchitectureWithDependencies.Assemblies);
}

[Fact(Skip = "This takes very long.")]
[Fact]
public void LoadAssembliesIncludingRecursiveDependencies()
{
var archUnitNetTestArchitectureWithRecursiveDependencies =
Expand Down

0 comments on commit 2ac6487

Please sign in to comment.