Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions ArchUnitNET/Domain/UnavailableType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,26 @@ private bool Equals(Struct other)
return Equals(Type, other.Type);
}

public override bool Equals(object obj)
public bool Equals(UnavailableType other)
{
if (ReferenceEquals(null, obj))
if (ReferenceEquals(null, other))
{
return false;
}

if (ReferenceEquals(this, obj))
if (ReferenceEquals(this, other))
{
return true;
}

return obj.GetType() == GetType() && Equals((UnavailableType)obj);
return Type.Equals(other.Type);
}

public override bool Equals(object obj)
{
return obj is UnavailableType unavailableType
&& Equals(unavailableType);
}

public override int GetHashCode()
{
Expand Down
6 changes: 3 additions & 3 deletions ArchUnitNET/Loader/TypeFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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
),
Expand Down
5 changes: 3 additions & 2 deletions ArchUnitNETTests/Loader/ArchLoaderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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);
}
}
}