diff --git a/ArchUnitNET/Loader/TypeFactory.cs b/ArchUnitNET/Loader/TypeFactory.cs index e21770aa4..240598597 100644 --- a/ArchUnitNET/Loader/TypeFactory.cs +++ b/ArchUnitNET/Loader/TypeFactory.cs @@ -347,7 +347,7 @@ TypeReference typeReference ) { var assemblyQualifiedName = System.Reflection.Assembly.CreateQualifiedName( - typeReference.Module.Assembly.FullName, + typeReference.Scope.Name, typeReference.BuildFullName() ); if (_allTypes.TryGetValue(assemblyQualifiedName, out var existingTypeInstance)) @@ -361,8 +361,8 @@ TypeReference typeReference typeReference.BuildFullName(), typeReference.Name, _assemblyRegistry.GetOrCreateAssembly( - typeReference.Module.Assembly.Name.Name, - typeReference.Module.Assembly.FullName, + typeReference.Scope.Name, + typeReference.Scope.ToString(), true, null ), diff --git a/ArchUnitNETTests/Loader/ArchLoaderTests.cs b/ArchUnitNETTests/Loader/ArchLoaderTests.cs index 31aaacdc6..5d9408025 100644 --- a/ArchUnitNETTests/Loader/ArchLoaderTests.cs +++ b/ArchUnitNETTests/Loader/ArchLoaderTests.cs @@ -131,8 +131,8 @@ public void TypesAreAssignedToCorrectAssemblies() public void UnavailableTypeTest() { // When loading an assembly from a file, there are situations where the assemblies dependencies are not - // available in the current AppDomain. This test checks that the loader does not throw an exception in this - // case. + // available in the current AppDomain. This test checks that the loader does not throw an exception + // and that the unavailable types contain the correct assembly they come from. var currentAssemblyPath = AppDomain.CurrentDomain.BaseDirectory[ ..AppDomain.CurrentDomain.BaseDirectory.IndexOf( @"ArchUnitNETTests", @@ -153,6 +153,7 @@ public void UnavailableTypeTest() var loggerType = architecture.ReferencedTypes.WhereFullNameIs("Serilog.ILogger"); Assert.NotNull(loggerType); Assert.True(loggerType is UnavailableType); + Assert.Equal("Serilog", loggerType.Assembly.Name); } } }