You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* #2735 Improve DataMemberAttribute Note
Adds additional guidance regarding the annotation read-only or write-only properties, as per discussion in #2735
* Grammar fixes
Copy file name to clipboardExpand all lines: xml/System.Runtime.Serialization/DataMemberAttribute.xml
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -48,7 +48,7 @@
48
48
By default, the CLR member name is used as the name of the data member. By setting the <xref:System.Runtime.Serialization.DataMemberAttribute.Name%2A> property, you can customize the name of the data member. This can be used to provide a name that may not be allowed as a CLR member name. When mapping to XML using the <xref:System.Runtime.Serialization.DataContractSerializer>, this name is used as the name of the schema element in a type.
49
49
50
50
> [!NOTE]
51
-
> Properties to which the <xref:System.Runtime.Serialization.DataMemberAttribute> attribute has been applied must have both `get` and `set` fields; they cannot be `get`-only or `set`-only.
51
+
> Properties to which the <xref:System.Runtime.Serialization.DataMemberAttribute> attribute has been applied must have both `get` and `set` fields. They cannot be `get`-only or `set`-only. To serialize a property that should remain `get`-only by design (for example, a property that returns a collection), consider applying the <xref:System.Runtime.Serialization.DataMemberAttribute> to the backing field instead.
52
52
53
53
For more information about data contracts and data members, see [Using Data Contracts](~/docs/framework/wcf/feature-details/using-data-contracts.md). For more information about member names, see [Data Member Default Values](~/docs/framework/wcf/feature-details/data-member-default-values.md).
0 commit comments