File tree Expand file tree Collapse file tree
src/System.Linq.Dynamic.Core/Parser Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -58,7 +58,7 @@ private static Type[] FindEnumLikeTypes(Type[] types)
5858 try
5959 {
6060 return types
61- . Where ( t => t . GetTypeInfo ( ) . IsPublic && ! t . GetTypeInfo ( ) . IsEnum && HasStaticInstancesOfOwnType ( t ) )
61+ . Where ( t => t . GetTypeInfo ( ) . IsPublic && ! t . GetTypeInfo ( ) . IsEnum && HasStaticPropertiesOrFieldsOfOwnType ( t ) )
6262 . ToArray ( ) ;
6363 }
6464 catch
@@ -67,20 +67,20 @@ private static Type[] FindEnumLikeTypes(Type[] types)
6767 }
6868 }
6969
70- private static bool HasStaticInstancesOfOwnType ( Type type )
70+ private static bool HasStaticPropertiesOrFieldsOfOwnType ( Type type )
7171 {
72- // Check for static properties that return the same type
72+ var baseType = type . GetTypeInfo ( ) . BaseType ;
73+
7374 var anyStaticProperties = type . GetProperties ( BindingFlags . Public | BindingFlags . Static )
74- . Any ( p => p . PropertyType == type || p . PropertyType == type ) ;
75+ . Any ( p => p . PropertyType == type || p . PropertyType == baseType ) ;
7576
7677 if ( anyStaticProperties )
7778 {
7879 return true ;
7980 }
8081
81- // Check for static fields that return the same type
8282 var anyStaticFields = type . GetFields ( BindingFlags . Public | BindingFlags . Static )
83- . Any ( f => f . FieldType == type || f . FieldType == type ) ;
83+ . Any ( f => f . FieldType == type || f . FieldType == baseType ) ;
8484
8585 return anyStaticFields ;
8686 }
You can’t perform that action at this time.
0 commit comments