Skip to content

Commit 5875ac4

Browse files
committed
.
1 parent 21d30cb commit 5875ac4

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

src/System.Linq.Dynamic.Core/Parser/EnumerationsAndWellKnownTypesFromMscorlib.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff 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
}

0 commit comments

Comments
 (0)