Removing k__BackingField

Okay, one of the most annoying thing that happened to me was my value object/model class was getting this strange k__BackingField appended to the fields. This is how the class looked like

[Serializable]
public class UserVO
{
    [DataMember]
    public long ID 
    {
        get;
        set;
    }
    [DataMember]
    public string Username
    {
        get;
        set;
    }
    [DataMember]
    public string Password
    {
        get;
        set;
    }
}

I had to use a WCF proxy generator to generate a proxy class that will access this classes parent SOAP service. However in the proxy, the fields are accessed in this manner:

var user = _userDataSource.GetCurrentUser(username, password);
string userName = user.Usernamek__BackingField;

Now that shit ain't right and I felt like I dropped the SOAP on this one.

After some digging, it turns out that the [Serializable] attribute/decorator of the class was causing this issue. Remove it and it will be solved.

Hope this helps.