A key part of Content Negotiation is that our default XML and JSON serializers need compatible behavior.
Not doing this means that user code (or serializers) may crash depending on the accept/response headers on the request message. Eg, I build and test my WebAPI using JSON, and then start crashing when clients request XML.
Since the formatters here are two totally separate serializers (JSON.Net and DCS), it's not surprising they have different behavior regarding things like anonymous types, derived properties, etc.
We have a bunch of incompatibilities.
I checked in a test that excercises these. There are a bunch of failing tests (have the Skip attribute). See test\System.Net.Http.Formatting.Test.Unit\Formatting\SerializerConsistencyTests.cs
And this changelist:
http://aspnetwebstack.codeplex.com/SourceControl/changeset/changes/e4b3efffa26c
The bug here is to fix the failing tests (and ideally expand the test coverage to find other issues).
Comments: It is hard to guarantee with content negotiation, esp. when someone writes a custom formatter. For example, different formatters will behave differently with as they honor different attributes. If one action is exposed via XML and JSON format, then it is users responsibility to test both scenarios thoroughly.
Not doing this means that user code (or serializers) may crash depending on the accept/response headers on the request message. Eg, I build and test my WebAPI using JSON, and then start crashing when clients request XML.
Since the formatters here are two totally separate serializers (JSON.Net and DCS), it's not surprising they have different behavior regarding things like anonymous types, derived properties, etc.
We have a bunch of incompatibilities.
I checked in a test that excercises these. There are a bunch of failing tests (have the Skip attribute). See test\System.Net.Http.Formatting.Test.Unit\Formatting\SerializerConsistencyTests.cs
And this changelist:
http://aspnetwebstack.codeplex.com/SourceControl/changeset/changes/e4b3efffa26c
The bug here is to fix the failing tests (and ideally expand the test coverage to find other issues).
Comments: It is hard to guarantee with content negotiation, esp. when someone writes a custom formatter. For example, different formatters will behave differently with as they honor different attributes. If one action is exposed via XML and JSON format, then it is users responsibility to test both scenarios thoroughly.