@@ -8,10 +8,10 @@ namespace Java.Interop.Tools.Cecil {
88 public static class TypeDefinitionRocks {
99
1010 [ Obsolete ( "Use the TypeDefinitionCache overload for better performance." ) ]
11- public static TypeDefinition GetBaseType ( this TypeDefinition type ) =>
11+ public static TypeDefinition ? GetBaseType ( this TypeDefinition type ) =>
1212 GetBaseType ( type , cache : null ) ;
1313
14- public static TypeDefinition GetBaseType ( this TypeDefinition type , TypeDefinitionCache cache )
14+ public static TypeDefinition ? GetBaseType ( this TypeDefinition type , TypeDefinitionCache ? cache )
1515 {
1616 var bt = type . BaseType ;
1717 if ( bt == null )
@@ -25,30 +25,34 @@ public static TypeDefinition GetBaseType (this TypeDefinition type, TypeDefiniti
2525 public static IEnumerable < TypeDefinition > GetTypeAndBaseTypes ( this TypeDefinition type ) =>
2626 GetTypeAndBaseTypes ( type , cache : null ) ;
2727
28- public static IEnumerable < TypeDefinition > GetTypeAndBaseTypes ( this TypeDefinition type , TypeDefinitionCache cache )
28+ public static IEnumerable < TypeDefinition > GetTypeAndBaseTypes ( this TypeDefinition type , TypeDefinitionCache ? cache )
2929 {
30- while ( type != null ) {
31- yield return type ;
32- type = type . GetBaseType ( cache ) ;
30+ TypeDefinition ? t = type ;
31+
32+ while ( t != null ) {
33+ yield return t ;
34+ t = t . GetBaseType ( cache ) ;
3335 }
3436 }
3537
3638 [ Obsolete ( "Use the TypeDefinitionCache overload for better performance." ) ]
3739 public static IEnumerable < TypeDefinition > GetBaseTypes ( this TypeDefinition type ) =>
3840 GetBaseTypes ( type , cache : null ) ;
3941
40- public static IEnumerable < TypeDefinition > GetBaseTypes ( this TypeDefinition type , TypeDefinitionCache cache )
42+ public static IEnumerable < TypeDefinition > GetBaseTypes ( this TypeDefinition type , TypeDefinitionCache ? cache )
4143 {
42- while ( ( type = type . GetBaseType ( cache ) ) != null ) {
43- yield return type ;
44+ TypeDefinition ? t = type ;
45+
46+ while ( ( t = t . GetBaseType ( cache ) ) != null ) {
47+ yield return t ;
4448 }
4549 }
4650
4751 [ Obsolete ( "Use the TypeDefinitionCache overload for better performance." ) ]
4852 public static bool IsAssignableFrom ( this TypeReference type , TypeReference c ) =>
4953 IsAssignableFrom ( type , c , cache : null ) ;
5054
51- public static bool IsAssignableFrom ( this TypeReference type , TypeReference c , TypeDefinitionCache cache )
55+ public static bool IsAssignableFrom ( this TypeReference type , TypeReference c , TypeDefinitionCache ? cache )
5256 {
5357 if ( type . FullName == c . FullName )
5458 return true ;
@@ -71,7 +75,7 @@ public static bool IsAssignableFrom (this TypeReference type, TypeReference c, T
7175 public static bool IsSubclassOf ( this TypeDefinition type , string typeName ) =>
7276 IsSubclassOf ( type , typeName , cache : null ) ;
7377
74- public static bool IsSubclassOf ( this TypeDefinition type , string typeName , TypeDefinitionCache cache )
78+ public static bool IsSubclassOf ( this TypeDefinition type , string typeName , TypeDefinitionCache ? cache )
7579 {
7680 foreach ( var t in type . GetTypeAndBaseTypes ( cache ) ) {
7781 if ( t . FullName == typeName ) {
@@ -85,7 +89,7 @@ public static bool IsSubclassOf (this TypeDefinition type, string typeName, Type
8589 public static bool ImplementsInterface ( this TypeDefinition type , string interfaceName ) =>
8690 ImplementsInterface ( type , interfaceName , cache : null ) ;
8791
88- public static bool ImplementsInterface ( this TypeDefinition type , string interfaceName , TypeDefinitionCache cache )
92+ public static bool ImplementsInterface ( this TypeDefinition type , string interfaceName , TypeDefinitionCache ? cache )
8993 {
9094 foreach ( var t in type . GetTypeAndBaseTypes ( cache ) ) {
9195 foreach ( var i in t . Interfaces ) {
@@ -101,7 +105,7 @@ public static bool ImplementsInterface (this TypeDefinition type, string interfa
101105 public static string GetPartialAssemblyName ( this TypeReference type ) =>
102106 GetPartialAssemblyName ( type , cache : null ) ;
103107
104- public static string GetPartialAssemblyName ( this TypeReference type , TypeDefinitionCache cache )
108+ public static string GetPartialAssemblyName ( this TypeReference type , TypeDefinitionCache ? cache )
105109 {
106110 TypeDefinition def = cache != null ? cache . Resolve ( type ) : type . Resolve ( ) ;
107111 return ( def ?? type ) . Module . Assembly . Name . Name ;
@@ -111,7 +115,7 @@ public static string GetPartialAssemblyName (this TypeReference type, TypeDefini
111115 public static string GetPartialAssemblyQualifiedName ( this TypeReference type ) =>
112116 GetPartialAssemblyQualifiedName ( type , cache : null ) ;
113117
114- public static string GetPartialAssemblyQualifiedName ( this TypeReference type , TypeDefinitionCache cache )
118+ public static string GetPartialAssemblyQualifiedName ( this TypeReference type , TypeDefinitionCache ? cache )
115119 {
116120 return string . Format ( "{0}, {1}" ,
117121 // Cecil likes to use '/' as the nested type separator, while
@@ -124,7 +128,7 @@ public static string GetPartialAssemblyQualifiedName (this TypeReference type, T
124128 public static string GetAssemblyQualifiedName ( this TypeReference type ) =>
125129 GetAssemblyQualifiedName ( type , cache : null ) ;
126130
127- public static string GetAssemblyQualifiedName ( this TypeReference type , TypeDefinitionCache cache )
131+ public static string GetAssemblyQualifiedName ( this TypeReference type , TypeDefinitionCache ? cache )
128132 {
129133 TypeDefinition def = cache != null ? cache . Resolve ( type ) : type . Resolve ( ) ;
130134 return string . Format ( "{0}, {1}" ,
@@ -134,7 +138,7 @@ public static string GetAssemblyQualifiedName (this TypeReference type, TypeDefi
134138 ( def ?? type ) . Module . Assembly . Name . FullName ) ;
135139 }
136140
137- public static TypeDefinition GetNestedType ( this TypeDefinition type , string name )
141+ public static TypeDefinition ? GetNestedType ( this TypeDefinition type , string name )
138142 {
139143 if ( type == null )
140144 return null ;
@@ -147,7 +151,7 @@ public static TypeDefinition GetNestedType (this TypeDefinition type, string nam
147151 }
148152
149153 // Note: this is not recursive, so it will not find nested types.
150- public static TypeDefinition FindType ( this ModuleDefinition module , string name )
154+ public static TypeDefinition ? FindType ( this ModuleDefinition module , string name )
151155 {
152156 if ( module == null )
153157 return null ;
0 commit comments