File tree 1 file changed +14
-3
lines changed
1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -133,10 +133,21 @@ public static bool IsMutable(this Type type)
133
133
if ( type == typeof ( object ) )
134
134
return true ;
135
135
136
- var props = type . GetTypeInfo ( ) . GetProperties ( BindingFlags . Public | BindingFlags . Instance ) . Any ( p => p . CanWrite ) ;
137
- var fields = type . GetTypeInfo ( ) . GetFields ( BindingFlags . Public | BindingFlags . Instance ) . Any ( ) ;
136
+ // Find all inherited defined properties and fields on the type
137
+ var inheritedTypes = type . GetTypeInfo ( ) . FlattenHierarchy ( ) . Select ( i => i . GetTypeInfo ( ) ) ;
138
138
139
- return props || fields ;
139
+ foreach ( var inheritedType in inheritedTypes )
140
+ {
141
+ if (
142
+ inheritedType . GetTypeInfo ( ) . GetProperties ( BindingFlags . Public | BindingFlags . Instance ) . Any ( p => p . CanWrite ) ||
143
+ inheritedType . GetTypeInfo ( ) . GetFields ( BindingFlags . Public | BindingFlags . Instance ) . Any ( )
144
+ )
145
+ {
146
+ return true ;
147
+ }
148
+ }
149
+
150
+ return false ;
140
151
}
141
152
142
153
public static object CreateDefaultForImmutable ( this Type type )
You can’t perform that action at this time.
0 commit comments