I have the following simple code in an ApiController:
public Version Get()
{
var version = new System.Version(1, 1, 0, 0);
return version;
}
which results in the following:
json
{"_Major":1,"_Minor":1,"_Build":0,"_Revision":0}
xml
<Version xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/System">
<_Build>0</_Build>
<_Major>1</_Major>
<_Minor>1</_Minor>
<_Revision>0</_Revision>
</Version>
Please note the properties are preceded with an _. Looking at the class definition of Version all those properties are Getters only, which I suspect has something to do with why the serialization is adding the _. I also tried to find information here on why this is happening, but all it says that Read-only properties are serialized by default.
The problem is that the underscore is messing up the deserialization on the client and resulting in Version 0.0.0.0.
This is a CLR class, which I can't override, so how can I remove the underscore so it deserializes correctly on the client?