Skip to content

Commit cd61151

Browse files
TheXenocidemairaw
authored andcommitted
#2735 Improve DataMemberAttribute Note (#3376)
* #2735 Improve DataMemberAttribute Note Adds additional guidance regarding the annotation read-only or write-only properties, as per discussion in #2735 * Grammar fixes
1 parent a39d17c commit cd61151

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

xml/System.Runtime.Serialization/DataMemberAttribute.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
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.
4949
5050
> [!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.
5252
5353
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).
5454

0 commit comments

Comments
 (0)