Skip to content

Commit c569fbb

Browse files
Merge pull request #431 from jpdurot/unavailabletpye-assembly
Fix Assembly property of UnavailableType
2 parents 2c1cbbc + 28708af commit c569fbb

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

ArchUnitNET/Loader/TypeFactory.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ TypeReference typeReference
347347
)
348348
{
349349
var assemblyQualifiedName = System.Reflection.Assembly.CreateQualifiedName(
350-
typeReference.Module.Assembly.FullName,
350+
typeReference.Scope.Name,
351351
typeReference.BuildFullName()
352352
);
353353
if (_allTypes.TryGetValue(assemblyQualifiedName, out var existingTypeInstance))
@@ -361,8 +361,8 @@ TypeReference typeReference
361361
typeReference.BuildFullName(),
362362
typeReference.Name,
363363
_assemblyRegistry.GetOrCreateAssembly(
364-
typeReference.Module.Assembly.Name.Name,
365-
typeReference.Module.Assembly.FullName,
364+
typeReference.Scope.Name,
365+
typeReference.Scope.ToString(),
366366
true,
367367
null
368368
),

ArchUnitNETTests/Loader/ArchLoaderTests.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ public void TypesAreAssignedToCorrectAssemblies()
131131
public void UnavailableTypeTest()
132132
{
133133
// When loading an assembly from a file, there are situations where the assemblies dependencies are not
134-
// available in the current AppDomain. This test checks that the loader does not throw an exception in this
135-
// case.
134+
// available in the current AppDomain. This test checks that the loader does not throw an exception
135+
// and that the unavailable types contain the correct assembly they come from.
136136
var currentAssemblyPath = AppDomain.CurrentDomain.BaseDirectory[
137137
..AppDomain.CurrentDomain.BaseDirectory.IndexOf(
138138
@"ArchUnitNETTests",
@@ -153,6 +153,7 @@ public void UnavailableTypeTest()
153153
var loggerType = architecture.ReferencedTypes.WhereFullNameIs("Serilog.ILogger");
154154
Assert.NotNull(loggerType);
155155
Assert.True(loggerType is UnavailableType);
156+
Assert.Equal("Serilog", loggerType.Assembly.Name);
156157
}
157158
}
158159
}

0 commit comments

Comments
 (0)