@@ -66,7 +66,7 @@ private static IEnumerable<TypeDefinition> EnumerateBaseClasses(this TypeDefinit
6666 /// <param name="typeDefinition">The type definition to convert.</param>
6767 /// <returns>The equivalent <see cref="Type"/> object instance.</returns>
6868 public static Type ToType ( this TypeDefinition typeDefinition )
69- {
69+ {
7070 var fullName = RuntimeNameToReflectionName ( typeDefinition . FullName ) ;
7171 return Type . GetType ( string . Concat ( fullName , ", " , typeDefinition . Module . Assembly . FullName ) , true ) ;
7272 }
@@ -105,7 +105,7 @@ public static bool IsImmutableExternally(this TypeDefinition typeDefinition)
105105 }
106106
107107
108-
108+
109109 public static bool OnlyHasNullableMembers ( this TypeDefinition typeDefinition )
110110 {
111111 var propertiesAreNullable = typeDefinition . Properties . All ( p => p . IsNullable ( ) ) ;
@@ -159,7 +159,7 @@ public static string GetFullName(this TypeDefinition typeDefinition)
159159 return typeDefinition . FullName . RemoveGenericPart ( ) ;
160160 }
161161
162-
162+
163163
164164
165165 public static bool IsDelegate ( this TypeDefinition typeDefinition )
@@ -174,7 +174,7 @@ public static bool IsStruct(this TypeDefinition typeDefinition)
174174
175175
176176 public static string GetFilePath ( this TypeDefinition typeDefinition )
177- {
177+ {
178178 if ( typeDefinition . HasMethods )
179179 {
180180 foreach ( var method in typeDefinition . Methods )
@@ -190,5 +190,22 @@ public static string GetFilePath(this TypeDefinition typeDefinition)
190190 }
191191 return null ;
192192 }
193+
194+ public static bool IsStateless ( this TypeDefinition type )
195+ {
196+ // Check if the type has any instance fields
197+ if ( type . HasFields )
198+ {
199+ foreach ( var field in type . Fields )
200+ {
201+ // If the field is not static, the type is not stateless
202+ if ( ! field . IsStatic )
203+ {
204+ return false ;
205+ }
206+ }
207+ }
208+ return true ;
209+ }
193210 }
194211}
0 commit comments