File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed
Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -128,6 +128,7 @@ public static MemberPath Get(Type type, string path)
128128 bool canWrite = true ;
129129 bool canRead = true ;
130130 MemberInfo memberInfo = null ;
131+ var leafIndex = pathItems . Length - 1 ;
131132 for ( int i = 0 ; i < pathItems . Length ; i ++ )
132133 {
133134 var memberName = pathItems [ i ] ;
@@ -140,12 +141,16 @@ public static MemberPath Get(Type type, string path)
140141 if ( memberInfo is FieldInfo fieldInfo ) {
141142 memberType = fieldInfo . FieldType ;
142143 if ( fieldInfo . IsInitOnly ) {
143- canWrite = false ;
144+ if ( i == leafIndex || memberType . IsValueType ) {
145+ canWrite = false ;
146+ }
144147 }
145148 } else if ( memberInfo is PropertyInfo propertyInfo ) {
146149 memberType = propertyInfo . PropertyType ;
147150 if ( ! propertyInfo . CanWrite ) {
148- canWrite = false ;
151+ if ( i == leafIndex || memberType . IsValueType ) {
152+ canWrite = false ;
153+ }
149154 }
150155 }
151156 if ( IsInvalidType ( memberType ) ) {
You can’t perform that action at this time.
0 commit comments