Serializable attribute and private fields being returned in response?

Topics: Web Api
Apr 25, 2011 at 2:27 AM

Just curious, using the ContactManager example in preview4

When I add the [Serializable] attribute to the Contact class the JSON data returned to the client includes all the backing fields instead of the public properties. (

[{"_contactId":1,"_name":"Glenn Block","<Address>k__BackingField":"1 Microsoft Way","<City>k__BackingField":"Redmond","<Email>k__BackingField":"gblock...","<State>k__BackingField":"Washington","<Twitter>k__BackingField":"gblock","<Zip>k__BackingField":"98112"}

(The first two properties i had private fields created)  Removing the [Serializable] attribute reverts to sending only the public properties to the http response.

Is this to be expected as it seems weird?