@@ -20,7 +20,7 @@ namespace Castle.DynamicProxy.Generators
2020#if FEATURE_SERIALIZATION
2121 [ Serializable ]
2222#endif
23- internal class CacheKey
23+ internal struct CacheKey : IEquatable < CacheKey >
2424 {
2525 private readonly MemberInfo target ;
2626 private readonly Type [ ] interfaces ;
@@ -73,37 +73,31 @@ public override int GetHashCode()
7373
7474 public override bool Equals ( object obj )
7575 {
76- if ( this == obj )
77- {
78- return true ;
79- }
80-
81- var cacheKey = obj as CacheKey ;
82- if ( cacheKey == null )
83- {
84- return false ;
85- }
76+ return obj is CacheKey other && Equals ( other ) ;
77+ }
8678
87- if ( ! Equals ( type , cacheKey . type ) )
79+ public bool Equals ( CacheKey other )
80+ {
81+ if ( ! Equals ( type , other . type ) )
8882 {
8983 return false ;
9084 }
91- if ( ! Equals ( target , cacheKey . target ) )
85+ if ( ! Equals ( target , other . target ) )
9286 {
9387 return false ;
9488 }
95- if ( interfaces . Length != cacheKey . interfaces . Length )
89+ if ( interfaces . Length != other . interfaces . Length )
9690 {
9791 return false ;
9892 }
9993 for ( var i = 0 ; i < interfaces . Length ; i ++ )
10094 {
101- if ( ! Equals ( interfaces [ i ] , cacheKey . interfaces [ i ] ) )
95+ if ( ! Equals ( interfaces [ i ] , other . interfaces [ i ] ) )
10296 {
10397 return false ;
10498 }
10599 }
106- if ( ! Equals ( options , cacheKey . options ) )
100+ if ( ! Equals ( options , other . options ) )
107101 {
108102 return false ;
109103 }
0 commit comments