-Fixed IsoDateTimeConverter on DateTime properties with DateTimeFormatHandling.DateTimeOffset
-Fixed preserving object references with read only properties
This commit is contained in:
@@ -138,10 +138,10 @@ namespace Newtonsoft.Json.Converters
|
||||
{
|
||||
#if !NET20
|
||||
if (t == typeof(DateTimeOffset))
|
||||
return reader.Value is DateTimeOffset ? reader.Value : new DateTimeOffset((DateTime)reader.Value);
|
||||
return (reader.Value is DateTimeOffset) ? reader.Value : new DateTimeOffset((DateTime)reader.Value);
|
||||
#endif
|
||||
|
||||
return reader.Value;
|
||||
return (reader.Value is DateTime) ? reader.Value : ((DateTimeOffset)reader.Value).DateTime;
|
||||
}
|
||||
|
||||
if (reader.TokenType != JsonToken.String)
|
||||
|
||||
@@ -497,7 +497,8 @@ namespace Newtonsoft.Json.Serialization
|
||||
writer.WriteStartObject();
|
||||
|
||||
bool isReference = ResolveIsReference(contract, member, collectionContract, containerProperty) ?? HasFlag(Serializer._preserveReferencesHandling, PreserveReferencesHandling.Objects);
|
||||
if (isReference)
|
||||
// don't make readonly fields the referenced value because they can't be deserialized to
|
||||
if (isReference && (member == null || member.Writable))
|
||||
{
|
||||
WriteReferenceIdProperty(writer, contract.UnderlyingType, value);
|
||||
}
|
||||
@@ -701,6 +702,9 @@ namespace Newtonsoft.Json.Serialization
|
||||
private bool WriteStartArray(JsonWriter writer, object values, JsonArrayContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerProperty)
|
||||
{
|
||||
bool isReference = ResolveIsReference(contract, member, containerContract, containerProperty) ?? HasFlag(Serializer._preserveReferencesHandling, PreserveReferencesHandling.Arrays);
|
||||
// don't make readonly fields the referenced value because they can't be deserialized to
|
||||
isReference = (isReference && (member == null || member.Writable));
|
||||
|
||||
bool includeTypeDetails = ShouldWriteType(TypeNameHandling.Arrays, contract, member, containerContract, containerProperty);
|
||||
bool writeMetadataObject = isReference || includeTypeDetails;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user