File tree Expand file tree Collapse file tree 3 files changed +16
-9
lines changed Expand file tree Collapse file tree 3 files changed +16
-9
lines changed Original file line number Diff line number Diff line change @@ -47,20 +47,26 @@ private bool Equals(Struct other)
4747 return Equals ( Type , other . Type ) ;
4848 }
4949
50- public override bool Equals ( object obj )
50+ public bool Equals ( UnavailableType other )
5151 {
52- if ( ReferenceEquals ( null , obj ) )
52+ if ( ReferenceEquals ( null , other ) )
5353 {
5454 return false ;
5555 }
5656
57- if ( ReferenceEquals ( this , obj ) )
57+ if ( ReferenceEquals ( this , other ) )
5858 {
5959 return true ;
6060 }
6161
62- return obj . GetType ( ) == GetType ( ) && Equals ( ( UnavailableType ) obj ) ;
62+ return Type . Equals ( other . Type ) ;
6363 }
64+
65+ public override bool Equals ( object obj )
66+ {
67+ return obj is UnavailableType unavailableType
68+ && Equals ( unavailableType ) ;
69+ }
6470
6571 public override int GetHashCode ( )
6672 {
Original file line number Diff line number Diff 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 ) ,
Original file line number Diff line number Diff 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}
You can’t perform that action at this time.
0 commit comments