diff --git a/xml/System.Reflection/FieldInfo.xml b/xml/System.Reflection/FieldInfo.xml index 5b26f6cae63..0846cfa9a65 100644 --- a/xml/System.Reflection/FieldInfo.xml +++ b/xml/System.Reflection/FieldInfo.xml @@ -2096,6 +2096,8 @@ ## Remarks This method will assign `value` to the field reflected by this instance on object `obj`. If the field is static, `obj` will be ignored. For non-static fields, `obj` should be an instance of a class that inherits or declares the field. The new value is passed as an `Object`. For example, if the field's type is Boolean, an instance of `Object` with the appropriate Boolean value is passed. Before setting the value, `SetValue` checks to see if the user has access permission. This final method is a convenience method for calling the following `SetValue` method. +This method cannot be used to set values of static, init-only (`readonly` in C#) fields reliably. In .NET Core 3.0 and later versions, an exception is thrown if you attempt to set a value on a static, init-only field. + > [!NOTE] > Fully trusted code has the permissions that are needed to access and invoke private constructors, methods, fields, and properties using reflection. @@ -2195,6 +2197,8 @@ ## Remarks This method will assign `value` to the field reflected by this instance on `obj`. If the field is static, `obj` will be ignored. For non-static fields, `obj` should be an instance of a class that inherits or declares the field. The new value is passed as an `Object`. For example, if the field's type is `Boolean`, an instance of `Object` with the appropriate Boolean value is passed. Before setting the value, `SetValue` checks to see if the user has access permission. + +This method cannot be used to set values of static, init-only (`readonly` in C#) fields reliably. In .NET Core 3.0 and later versions, an exception is thrown if you attempt to set a value on a static, init-only field. > [!NOTE] > Fully trusted code has the permissions that are needed to access and invoke private constructors, methods, fields, and properties using reflection.