I've got this class being provided by a web service that is then being consumed by a Silverlight app (I don't know if that's relevant or not)
[Serializable]
public class Entry
{
private string _title;
public string Id { get; set; }
public string Title { get { return _title; } set { _title = value; } }
public string Link { get; set; }
public DateTime Published { get; set; }
public DateTime Updated { get; set; }
public User User { get; set; }
public Service Service { get; set; }
public List<Comment> Comments { get; set; }
public List<Like> Likes { get; set; }
public List<Media> Media { get; set; }
}
The _title
variable I added to demonstrate what's going wrong. When I reference the web service in my silverlight app, it generates the folowing xsd:
<xs:complexType name="Entry">
<xs:sequence>
<xs:element name="_title" nillable="true" type="xs:string" />
<xs:element name="_x003C_Comments_x003E_k__BackingField" nillable="true" type="tns:ArrayOfComment" />
<xs:element name="_x003C_Id_x003E_k__BackingField" nillable="true" type="xs:string" />
<xs:element name="_x003C_Likes_x003E_k__BackingField" nillable="true" type="tns:ArrayOfLike" />
<xs:element name="_x003C_Link_x003E_k__BackingField" nillable="true" type="xs:string" />
<xs:element name="_x003C_Media_x003E_k__BackingField" nillable="true" type="tns:ArrayOfMedia" />
<xs:element name="_x003C_Published_x003E_k__BackingField" type="xs:dateTime" />
<xs:element name="_x003C_Service_x003E_k__BackingField" nillable="true" type="tns:Service" />
<xs:element name="_x003C_Updated_x003E_k__BackingField" type="xs:dateTime" />
<xs:element name="_x003C_User_x003E_k__BackingField" nillable="true" type="tns:User" />
</xs:sequence>
</xs:complexType>
Note only the title property is simply named, the others are named <Link>_BackingField
which completely dies when you try and load the element because you can't have < or > in the name of a property.
Why is it serializing the backing fields and not the public properties?