@@ -8,9 +8,10 @@ namespace AnyProcessor.CodeGen
88 public static class TypeEqualsExtension
99 {
1010 [ Pure ]
11- public static bool TypeEquals ( [ NotNull ] this TypeReference lhs , [ NotNull ] TypeReference rhs )
11+ public static bool TypeEquals ( this TypeReference ? lhs , TypeReference ? rhs )
1212 {
13- if ( lhs == null || rhs == null ) throw new ArgumentNullException ( ) ;
13+ if ( lhs == null ) throw new ArgumentNullException ( nameof ( lhs ) ) ;
14+ if ( rhs == null ) throw new ArgumentNullException ( nameof ( rhs ) ) ;
1415 if ( ReferenceEquals ( lhs , rhs ) ) return true ;
1516 return ( lhs , rhs ) switch
1617 {
@@ -42,63 +43,70 @@ public static bool TypeEquals([NotNull] this TypeReference lhs, [NotNull] TypeRe
4243 }
4344
4445 [ Pure ]
45- public static bool TypeEquals ( [ NotNull ] this TypeDefinition lhs , [ NotNull ] TypeDefinition rhs )
46+ public static bool TypeEquals ( this TypeDefinition ? lhs , TypeDefinition ? rhs )
4647 {
47- if ( lhs == null || rhs == null ) throw new ArgumentNullException ( ) ;
48- return lhs . MetadataToken == rhs . MetadataToken && lhs . Module . Name == rhs . Module . Name ;
48+ if ( lhs == null ) throw new ArgumentNullException ( nameof ( lhs ) ) ;
49+ if ( rhs == null ) throw new ArgumentNullException ( nameof ( rhs ) ) ;
50+ return lhs . MetadataToken == rhs . MetadataToken && lhs . Module ? . Name == rhs . Module ? . Name ;
4951 }
5052
5153 [ Pure ]
52- public static bool TypeEquals ( [ NotNull ] this GenericParameter lhs , [ NotNull ] GenericParameter rhs )
54+ public static bool TypeEquals ( this GenericParameter ? lhs , GenericParameter ? rhs )
5355 {
54- if ( lhs == null || rhs == null ) throw new ArgumentNullException ( ) ;
56+ if ( lhs == null ) throw new ArgumentNullException ( nameof ( lhs ) ) ;
57+ if ( rhs == null ) throw new ArgumentNullException ( nameof ( rhs ) ) ;
5558 return lhs . IsContravariant == rhs . IsContravariant && lhs . IsCovariant == rhs . IsCovariant && lhs . IsNonVariant == rhs . IsNonVariant
56- && lhs . HasConstraints == rhs . HasConstraints && lhs . Constraints . Count == rhs . Constraints . Count
59+ && lhs . HasConstraints == rhs . HasConstraints && lhs . Constraints ! . Count == rhs . Constraints ! . Count
5760 && lhs . Constraints . Zip ( rhs . Constraints , ( l , r ) => ( l , r ) ) . All ( t => TypeEquals ( t . l , t . r ) ) ;
5861 }
5962
6063 [ Pure ]
61- public static bool TypeEquals ( [ NotNull ] this GenericParameterConstraint lhs , [ NotNull ] GenericParameterConstraint rhs )
64+ public static bool TypeEquals ( this GenericParameterConstraint ? lhs , GenericParameterConstraint ? rhs )
6265 {
63- if ( lhs == null || rhs == null ) throw new ArgumentNullException ( ) ;
66+ if ( lhs == null ) throw new ArgumentNullException ( nameof ( lhs ) ) ;
67+ if ( rhs == null ) throw new ArgumentNullException ( nameof ( rhs ) ) ;
6468 return TypeEquals ( lhs . ConstraintType , rhs . ConstraintType ) ;
6569 }
6670
6771 [ Pure ]
68- public static bool TypeEquals ( [ NotNull ] this TypeSpecification lhs , [ NotNull ] TypeSpecification rhs )
72+ public static bool TypeEquals ( this TypeSpecification ? lhs , TypeSpecification ? rhs )
6973 {
70- if ( lhs == null || rhs == null ) throw new ArgumentNullException ( ) ;
74+ if ( lhs == null ) throw new ArgumentNullException ( nameof ( lhs ) ) ;
75+ if ( rhs == null ) throw new ArgumentNullException ( nameof ( rhs ) ) ;
7176 return TypeEquals ( lhs . ElementType , rhs . ElementType ) ;
7277 }
7378
7479 [ Pure ]
75- public static bool TypeEquals ( [ NotNull ] this GenericInstanceType lhs , [ NotNull ] GenericInstanceType rhs )
80+ public static bool TypeEquals ( this GenericInstanceType ? lhs , GenericInstanceType ? rhs )
7681 {
77- if ( lhs == null || rhs == null ) throw new ArgumentNullException ( ) ;
82+ if ( lhs == null ) throw new ArgumentNullException ( nameof ( lhs ) ) ;
83+ if ( rhs == null ) throw new ArgumentNullException ( nameof ( rhs ) ) ;
7884 if ( lhs . HasGenericArguments != rhs . HasGenericArguments ) return false ;
79- if ( lhs . GenericArguments . Count != rhs . GenericArguments . Count ) return false ;
85+ if ( lhs . GenericArguments ! . Count != rhs . GenericArguments ! . Count ) return false ;
8086 if ( ! TypeEquals ( lhs . Resolve ( ) , rhs . Resolve ( ) ) ) return false ;
8187 return lhs . GenericArguments . Zip ( rhs . GenericArguments , ( l , r ) => ( l , r ) ) . All ( t => TypeEquals ( t . l , t . r ) ) ;
8288 }
8389
8490 [ Pure ]
85- public static bool TypeEquals ( [ NotNull ] this OptionalModifierType lhs , [ NotNull ] OptionalModifierType rhs )
91+ public static bool TypeEquals ( this OptionalModifierType ? lhs , OptionalModifierType ? rhs )
8692 {
87- if ( lhs == null || rhs == null ) throw new ArgumentNullException ( ) ;
93+ if ( lhs == null ) throw new ArgumentNullException ( nameof ( lhs ) ) ;
94+ if ( rhs == null ) throw new ArgumentNullException ( nameof ( rhs ) ) ;
8895 return TypeEquals ( lhs . ModifierType , rhs . ModifierType ) && TypeEquals ( lhs . ElementType , rhs . ElementType ) ;
8996 }
9097
9198 [ Pure ]
92- public static bool TypeEquals ( [ NotNull ] this RequiredModifierType lhs , [ NotNull ] RequiredModifierType rhs )
99+ public static bool TypeEquals ( this RequiredModifierType ? lhs , RequiredModifierType ? rhs )
93100 {
94- if ( lhs == null || rhs == null ) throw new ArgumentNullException ( ) ;
101+ if ( lhs == null ) throw new ArgumentNullException ( nameof ( lhs ) ) ;
102+ if ( rhs == null ) throw new ArgumentNullException ( nameof ( rhs ) ) ;
95103 return TypeEquals ( lhs . ModifierType , rhs . ModifierType ) && TypeEquals ( lhs . ElementType , rhs . ElementType ) ;
96104 }
97105
98106 [ Pure ]
99- public static bool TypeEquals ( [ NotNull ] this FunctionPointerType lhs , [ NotNull ] FunctionPointerType rhs )
107+ public static bool TypeEquals ( this FunctionPointerType ? lhs , FunctionPointerType ? rhs )
100108 {
101- throw new NotSupportedException ( ) ;
109+ throw new NotSupportedException ( $ "compare between two { nameof ( FunctionPointerType ) } " ) ;
102110 }
103111 }
104112}
0 commit comments