-Rename SpecialPropertyHandling to MetadataPropertyHandling
This commit is contained in:
@@ -1214,7 +1214,7 @@ namespace Newtonsoft.Json.Tests.Converters
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SerializeDeserializeSpecialProperties()
|
||||
public void SerializeDeserializeMetadataProperties()
|
||||
{
|
||||
PreserveReferencesHandlingTests.CircularDictionary circularDictionary = new PreserveReferencesHandlingTests.CircularDictionary();
|
||||
circularDictionary.Add("other", new PreserveReferencesHandlingTests.CircularDictionary { { "blah", null } });
|
||||
|
||||
@@ -103,10 +103,10 @@
|
||||
<Compile Include="Serialization\ImmutableCollectionsTests.cs" />
|
||||
<Compile Include="Serialization\JsonPropertyCollectionTests.cs" />
|
||||
<Compile Include="Serialization\JsonSerializerCollectionsTests.cs" />
|
||||
<Compile Include="Serialization\MetadataPropertyHandlingTests.cs" />
|
||||
<Compile Include="Serialization\NullValueHandlingTests.cs" />
|
||||
<Compile Include="Serialization\ReferenceLoopHandlingTests.cs" />
|
||||
<Compile Include="Serialization\ShouldSerializeTests.cs" />
|
||||
<Compile Include="Serialization\SpecialPropertyHandlingTests.cs" />
|
||||
<Compile Include="Serialization\TraceWriterTests.cs" />
|
||||
<Compile Include="Serialization\WebApiIntegrationTests.cs" />
|
||||
<Compile Include="TestObjects\Aa.cs" />
|
||||
|
||||
@@ -145,10 +145,10 @@
|
||||
<Compile Include="Serialization\ImmutableCollectionsTests.cs" />
|
||||
<Compile Include="Serialization\JsonPropertyCollectionTests.cs" />
|
||||
<Compile Include="Serialization\JsonSerializerCollectionsTests.cs" />
|
||||
<Compile Include="Serialization\MetadataPropertyHandlingTests.cs" />
|
||||
<Compile Include="Serialization\NullValueHandlingTests.cs" />
|
||||
<Compile Include="Serialization\ReferenceLoopHandlingTests.cs" />
|
||||
<Compile Include="Serialization\ShouldSerializeTests.cs" />
|
||||
<Compile Include="Serialization\SpecialPropertyHandlingTests.cs" />
|
||||
<Compile Include="Serialization\TraceWriterTests.cs" />
|
||||
<Compile Include="Serialization\WebApiIntegrationTests.cs" />
|
||||
<Compile Include="TestObjects\Aa.cs" />
|
||||
|
||||
@@ -266,9 +266,9 @@
|
||||
<Compile Include="Serialization\FSharpTests.cs" />
|
||||
<Compile Include="Serialization\ImmutableCollectionsTests.cs" />
|
||||
<Compile Include="Serialization\JsonSerializerCollectionsTests.cs" />
|
||||
<Compile Include="Serialization\MetadataPropertyHandlingTests.cs" />
|
||||
<Compile Include="Serialization\ReferenceLoopHandlingTests.cs" />
|
||||
<Compile Include="Serialization\ShouldSerializeTests.cs" />
|
||||
<Compile Include="Serialization\SpecialPropertyHandlingTests.cs" />
|
||||
<Compile Include="Serialization\TraceWriterTests.cs" />
|
||||
<Compile Include="Serialization\WebApiIntegrationTests.cs" />
|
||||
<Compile Include="Serialization\JsonPropertyCollectionTests.cs" />
|
||||
|
||||
@@ -149,9 +149,9 @@
|
||||
<Compile Include="Serialization\FSharpTests.cs" />
|
||||
<Compile Include="Serialization\ImmutableCollectionsTests.cs" />
|
||||
<Compile Include="Serialization\JsonSerializerCollectionsTests.cs" />
|
||||
<Compile Include="Serialization\MetadataPropertyHandlingTests.cs" />
|
||||
<Compile Include="Serialization\ReferenceLoopHandlingTests.cs" />
|
||||
<Compile Include="Serialization\ShouldSerializeTests.cs" />
|
||||
<Compile Include="Serialization\SpecialPropertyHandlingTests.cs" />
|
||||
<Compile Include="Serialization\TraceWriterTests.cs" />
|
||||
<Compile Include="Serialization\WebApiIntegrationTests.cs" />
|
||||
<Compile Include="Serialization\JsonPropertyCollectionTests.cs" />
|
||||
|
||||
@@ -146,9 +146,9 @@
|
||||
<Compile Include="Serialization\FSharpTests.cs" />
|
||||
<Compile Include="Serialization\ImmutableCollectionsTests.cs" />
|
||||
<Compile Include="Serialization\JsonSerializerCollectionsTests.cs" />
|
||||
<Compile Include="Serialization\MetadataPropertyHandlingTests.cs" />
|
||||
<Compile Include="Serialization\ReferenceLoopHandlingTests.cs" />
|
||||
<Compile Include="Serialization\ShouldSerializeTests.cs" />
|
||||
<Compile Include="Serialization\SpecialPropertyHandlingTests.cs" />
|
||||
<Compile Include="Serialization\TraceWriterTests.cs" />
|
||||
<Compile Include="Serialization\WebApiIntegrationTests.cs" />
|
||||
<Compile Include="Serialization\JsonPropertyCollectionTests.cs" />
|
||||
|
||||
@@ -180,7 +180,7 @@
|
||||
<Compile Include="Serialization\SerializationErrorHandlingTests.cs" />
|
||||
<Compile Include="Serialization\SerializationEventAttributeTests.cs" />
|
||||
<Compile Include="Serialization\ShouldSerializeTests.cs" />
|
||||
<Compile Include="Serialization\SpecialPropertyHandlingTests.cs" />
|
||||
<Compile Include="Serialization\MetadataPropertyHandlingTests.cs" />
|
||||
<Compile Include="Serialization\TraceWriterTests.cs" />
|
||||
<Compile Include="Serialization\TypeNameHandlingTests.cs" />
|
||||
<Compile Include="Serialization\WebApiIntegrationTests.cs" />
|
||||
|
||||
@@ -242,6 +242,7 @@
|
||||
<Compile Include="Serialization\ImmutableCollectionsTests.cs" />
|
||||
<Compile Include="Serialization\JsonPropertyCollectionTests.cs" />
|
||||
<Compile Include="Serialization\JsonSerializerTest.cs" />
|
||||
<Compile Include="Serialization\MetadataPropertyHandlingTests.cs" />
|
||||
<Compile Include="Serialization\MissingMemberHandlingTests.cs" />
|
||||
<Compile Include="Serialization\NullValueHandlingTests.cs" />
|
||||
<Compile Include="Serialization\PopulateTests.cs" />
|
||||
@@ -251,7 +252,6 @@
|
||||
<Compile Include="Serialization\SerializationEventAttributeTests.cs" />
|
||||
<Compile Include="Serialization\JsonSerializerCollectionsTests.cs" />
|
||||
<Compile Include="Serialization\ShouldSerializeTests.cs" />
|
||||
<Compile Include="Serialization\SpecialPropertyHandlingTests.cs" />
|
||||
<Compile Include="Serialization\TraceWriterTests.cs" />
|
||||
<Compile Include="Serialization\TypeNameHandlingTests.cs" />
|
||||
<Compile Include="Serialization\WebApiIntegrationTests.cs" />
|
||||
|
||||
@@ -75,4 +75,4 @@ using System.Security;
|
||||
// by using the '*' as shown below:
|
||||
|
||||
[assembly: AssemblyVersion("6.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("6.0.2.17226")]
|
||||
[assembly: AssemblyFileVersion("6.0.3.17227")]
|
||||
|
||||
@@ -3407,7 +3407,7 @@ Path ''"));
|
||||
() => JsonConvert.DeserializeObject<DictionaryWithNoDefaultConstructor>(json, new JsonSerializerSettings
|
||||
{
|
||||
PreserveReferencesHandling = PreserveReferencesHandling.All,
|
||||
SpecialPropertyHandling = SpecialPropertyHandling.Default
|
||||
MetadataPropertyHandling = MetadataPropertyHandling.Default
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -4978,7 +4978,7 @@ To fix this error either change the environment to be fully trusted, change the
|
||||
{
|
||||
var data = new DecimalTest(decimal.MinValue);
|
||||
var json = JsonConvert.SerializeObject(data);
|
||||
var obj = JsonConvert.DeserializeObject<DecimalTest>(json, new JsonSerializerSettings { SpecialPropertyHandling = SpecialPropertyHandling.Default });
|
||||
var obj = JsonConvert.DeserializeObject<DecimalTest>(json, new JsonSerializerSettings { MetadataPropertyHandling = MetadataPropertyHandling.Default });
|
||||
|
||||
Assert.AreEqual(decimal.MinValue, obj.Value);
|
||||
}
|
||||
|
||||
+11
-11
@@ -41,7 +41,7 @@ using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAtt
|
||||
namespace Newtonsoft.Json.Tests.Serialization
|
||||
{
|
||||
[TestFixture]
|
||||
public class SpecialPropertyHandlingTests : TestFixtureBase
|
||||
public class MetadataPropertyHandlingTests : TestFixtureBase
|
||||
{
|
||||
[Test]
|
||||
public void DeserializeArraysWithPreserveObjectReferences()
|
||||
@@ -80,7 +80,7 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
new JsonSerializerSettings
|
||||
{
|
||||
PreserveReferencesHandling = PreserveReferencesHandling.All,
|
||||
SpecialPropertyHandling = SpecialPropertyHandling.ReadAhead
|
||||
MetadataPropertyHandling = MetadataPropertyHandling.ReadAhead
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -99,7 +99,7 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
{
|
||||
Formatting = Formatting.Indented,
|
||||
TypeNameHandling = TypeNameHandling.All,
|
||||
SpecialPropertyHandling = SpecialPropertyHandling.ReadAhead
|
||||
MetadataPropertyHandling = MetadataPropertyHandling.ReadAhead
|
||||
};
|
||||
string serializedString = JsonConvert.SerializeObject(inputContext, jsonSerializerSettings);
|
||||
|
||||
@@ -140,7 +140,7 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
|
||||
Item actual = JsonConvert.DeserializeObject<Item>(jsonString, new JsonSerializerSettings
|
||||
{
|
||||
SpecialPropertyHandling = SpecialPropertyHandling.ReadAhead
|
||||
MetadataPropertyHandling = MetadataPropertyHandling.ReadAhead
|
||||
});
|
||||
|
||||
Assert.AreEqual(new Guid("d8220a4b-75b1-4b7a-8112-b7bdae956a45"), actual.SourceTypeID);
|
||||
@@ -182,7 +182,7 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
new JsonSerializerSettings
|
||||
{
|
||||
PreserveReferencesHandling = PreserveReferencesHandling.All,
|
||||
SpecialPropertyHandling = SpecialPropertyHandling.ReadAhead
|
||||
MetadataPropertyHandling = MetadataPropertyHandling.ReadAhead
|
||||
});
|
||||
|
||||
Assert.AreEqual(3, circularList.Count);
|
||||
@@ -210,7 +210,7 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
JsonConvert.DeserializeObject(json, null, new JsonSerializerSettings
|
||||
{
|
||||
TypeNameHandling = TypeNameHandling.Objects,
|
||||
SpecialPropertyHandling = SpecialPropertyHandling.ReadAhead
|
||||
MetadataPropertyHandling = MetadataPropertyHandling.ReadAhead
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -234,7 +234,7 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
|
||||
Dictionary<string, object> result = JsonConvert.DeserializeObject<Dictionary<string, object>>(json, new JsonSerializerSettings
|
||||
{
|
||||
SpecialPropertyHandling = SpecialPropertyHandling.ReadAhead
|
||||
MetadataPropertyHandling = MetadataPropertyHandling.ReadAhead
|
||||
});
|
||||
|
||||
Assert.AreEqual(3, result.Count);
|
||||
@@ -262,7 +262,7 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
|
||||
List<EmployeeReference> employees = JsonConvert.DeserializeObject<List<EmployeeReference>>(json, new JsonSerializerSettings
|
||||
{
|
||||
SpecialPropertyHandling = SpecialPropertyHandling.ReadAhead
|
||||
MetadataPropertyHandling = MetadataPropertyHandling.ReadAhead
|
||||
});
|
||||
|
||||
Assert.AreEqual(2, employees.Count);
|
||||
@@ -294,7 +294,7 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
|
||||
List<EmployeeReference> employees = t1.ToObject<List<EmployeeReference>>(JsonSerializer.Create(new JsonSerializerSettings
|
||||
{
|
||||
SpecialPropertyHandling = SpecialPropertyHandling.ReadAhead
|
||||
MetadataPropertyHandling = MetadataPropertyHandling.ReadAhead
|
||||
}));
|
||||
|
||||
Assert.AreEqual(2, employees.Count);
|
||||
@@ -338,7 +338,7 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
{
|
||||
TypeNameHandling = TypeNameHandling.Objects,
|
||||
TypeNameAssemblyFormat = FormatterAssemblyStyle.Full,
|
||||
SpecialPropertyHandling = SpecialPropertyHandling.ReadAhead
|
||||
MetadataPropertyHandling = MetadataPropertyHandling.ReadAhead
|
||||
});
|
||||
|
||||
Assert.AreEqual(4, values.Count);
|
||||
@@ -386,7 +386,7 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
|
||||
TypeNameHandlingTests.TypeNameProperty deserialized = JsonConvert.DeserializeObject<TypeNameHandlingTests.TypeNameProperty>(json, new JsonSerializerSettings
|
||||
{
|
||||
SpecialPropertyHandling = SpecialPropertyHandling.ReadAhead
|
||||
MetadataPropertyHandling = MetadataPropertyHandling.ReadAhead
|
||||
});
|
||||
Assert.AreEqual("Name!", deserialized.Name);
|
||||
CustomAssert.IsInstanceOfType(typeof(List<int>), deserialized.Value);
|
||||
@@ -298,7 +298,7 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
new JsonSerializerSettings
|
||||
{
|
||||
PreserveReferencesHandling = PreserveReferencesHandling.All,
|
||||
SpecialPropertyHandling = SpecialPropertyHandling.Default
|
||||
MetadataPropertyHandling = MetadataPropertyHandling.Default
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -1069,7 +1069,7 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
"Error reading object reference '1'. Path 'Data.Prop2.MyProperty', line 9, position 20.",
|
||||
() => JsonConvert.DeserializeObject<PropertyItemIsReferenceObject>(json, new JsonSerializerSettings
|
||||
{
|
||||
SpecialPropertyHandling = SpecialPropertyHandling.Default
|
||||
MetadataPropertyHandling = MetadataPropertyHandling.Default
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -407,7 +407,7 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
string json = "{}";
|
||||
List<string> errors = new List<string>();
|
||||
JsonSerializer serializer = new JsonSerializer();
|
||||
serializer.SpecialPropertyHandling = SpecialPropertyHandling.Default;
|
||||
serializer.MetadataPropertyHandling = MetadataPropertyHandling.Default;
|
||||
serializer.Error += delegate(object sender, ErrorEventArgs args)
|
||||
{
|
||||
errors.Add(args.ErrorContext.Path + " - " + args.ErrorContext.Member + " - " + args.ErrorContext.Error.Message);
|
||||
@@ -540,7 +540,7 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
"{'badarray':[0,x,2],'goodarray':[0,1,2]}",
|
||||
new JsonSerializerSettings
|
||||
{
|
||||
SpecialPropertyHandling = SpecialPropertyHandling.Default,
|
||||
MetadataPropertyHandling = MetadataPropertyHandling.Default,
|
||||
Error = (sender, arg) =>
|
||||
{
|
||||
errors.Add(arg.ErrorContext.Error.Message);
|
||||
@@ -570,7 +570,7 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
JsonSerializer jsonSerializer = JsonSerializer.Create(new JsonSerializerSettings
|
||||
{
|
||||
MaxDepth = maxDepth,
|
||||
SpecialPropertyHandling = SpecialPropertyHandling.Default
|
||||
MetadataPropertyHandling = MetadataPropertyHandling.Default
|
||||
});
|
||||
jsonSerializer.Error += (sender, e) =>
|
||||
{
|
||||
@@ -601,7 +601,7 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
const int maxDepth = 256;
|
||||
using (var jsonTextReader = new JsonTextReader(new StringReader(input)) { MaxDepth = maxDepth })
|
||||
{
|
||||
JsonSerializer jsonSerializer = JsonSerializer.Create(new JsonSerializerSettings { MaxDepth = maxDepth, SpecialPropertyHandling = SpecialPropertyHandling.Default });
|
||||
JsonSerializer jsonSerializer = JsonSerializer.Create(new JsonSerializerSettings { MaxDepth = maxDepth, MetadataPropertyHandling = MetadataPropertyHandling.Default });
|
||||
jsonSerializer.Error += (sender, e) =>
|
||||
{
|
||||
errors.Add(e.ErrorContext.Error.Message);
|
||||
@@ -641,7 +641,7 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
errors.Add(e.ErrorContext.Error.Message);
|
||||
e.ErrorContext.Handled = true;
|
||||
},
|
||||
SpecialPropertyHandling = SpecialPropertyHandling.Default
|
||||
MetadataPropertyHandling = MetadataPropertyHandling.Default
|
||||
});
|
||||
Assert.AreEqual(true, newDynamicObject.Explicit);
|
||||
|
||||
|
||||
@@ -140,7 +140,7 @@ Newtonsoft.Json Error: 0 : Error!
|
||||
{
|
||||
TraceWriter = traceWriter,
|
||||
Converters = { new JavaScriptDateTimeConverter() },
|
||||
SpecialPropertyHandling = SpecialPropertyHandling.Default
|
||||
MetadataPropertyHandling = MetadataPropertyHandling.Default
|
||||
});
|
||||
|
||||
Console.WriteLine(traceWriter);
|
||||
@@ -403,7 +403,7 @@ Newtonsoft.Json Error: 0 : Error!
|
||||
new JsonSerializerSettings
|
||||
{
|
||||
PreserveReferencesHandling = PreserveReferencesHandling.All,
|
||||
SpecialPropertyHandling = SpecialPropertyHandling.Default,
|
||||
MetadataPropertyHandling = MetadataPropertyHandling.Default,
|
||||
TraceWriter = traceWriter
|
||||
});
|
||||
|
||||
@@ -523,7 +523,7 @@ Newtonsoft.Json Error: 0 : Error!
|
||||
JsonConvert.DeserializeObject(json, null, new JsonSerializerSettings
|
||||
{
|
||||
TypeNameHandling = TypeNameHandling.All,
|
||||
SpecialPropertyHandling = SpecialPropertyHandling.Default,
|
||||
MetadataPropertyHandling = MetadataPropertyHandling.Default,
|
||||
TraceWriter = traceWriter
|
||||
});
|
||||
|
||||
|
||||
@@ -122,7 +122,7 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
{
|
||||
var reader = new JsonTextReader(new StringReader(sb.ToString()));
|
||||
var ser = new JsonSerializer();
|
||||
ser.SpecialPropertyHandling = SpecialPropertyHandling.Default;
|
||||
ser.MetadataPropertyHandling = MetadataPropertyHandling.Default;
|
||||
ser.Deserialize<bool>(reader);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace Newtonsoft.Json
|
||||
internal NullValueHandling _nullValueHandling;
|
||||
internal DefaultValueHandling _defaultValueHandling;
|
||||
internal ConstructorHandling _constructorHandling;
|
||||
internal SpecialPropertyHandling _specialPropertyHandling;
|
||||
internal MetadataPropertyHandling _metadataPropertyHandling;
|
||||
internal JsonConverterCollection _converters;
|
||||
internal IContractResolver _contractResolver;
|
||||
internal ITraceWriter _traceWriter;
|
||||
@@ -259,18 +259,18 @@ namespace Newtonsoft.Json
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets how special properties are used during deserialization.
|
||||
/// Gets or sets how metadata properties are used during deserialization.
|
||||
/// </summary>
|
||||
/// <value>The special properties handling.</value>
|
||||
public virtual SpecialPropertyHandling SpecialPropertyHandling
|
||||
/// <value>The metadata properties handling.</value>
|
||||
public virtual MetadataPropertyHandling MetadataPropertyHandling
|
||||
{
|
||||
get { return _specialPropertyHandling; }
|
||||
get { return _metadataPropertyHandling; }
|
||||
set
|
||||
{
|
||||
if (value < SpecialPropertyHandling.Default || value > SpecialPropertyHandling.ReadAhead)
|
||||
if (value < MetadataPropertyHandling.Default || value > MetadataPropertyHandling.ReadAhead)
|
||||
throw new ArgumentOutOfRangeException("value");
|
||||
|
||||
_specialPropertyHandling = value;
|
||||
_metadataPropertyHandling = value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -443,7 +443,7 @@ namespace Newtonsoft.Json
|
||||
_preserveReferencesHandling = JsonSerializerSettings.DefaultPreserveReferencesHandling;
|
||||
_constructorHandling = JsonSerializerSettings.DefaultConstructorHandling;
|
||||
_typeNameHandling = JsonSerializerSettings.DefaultTypeNameHandling;
|
||||
_specialPropertyHandling = JsonSerializerSettings.DefaultSpecialPropertyHandling;
|
||||
_metadataPropertyHandling = JsonSerializerSettings.DefaultMetadataPropertyHandling;
|
||||
_context = JsonSerializerSettings.DefaultContext;
|
||||
_binder = DefaultSerializationBinder.Instance;
|
||||
|
||||
@@ -533,8 +533,8 @@ namespace Newtonsoft.Json
|
||||
// serializer specific
|
||||
if (settings._typeNameHandling != null)
|
||||
serializer.TypeNameHandling = settings.TypeNameHandling;
|
||||
if (settings._specialPropertyHandling != null)
|
||||
serializer.SpecialPropertyHandling = settings.SpecialPropertyHandling;
|
||||
if (settings._metadataPropertyHandling != null)
|
||||
serializer.MetadataPropertyHandling = settings.MetadataPropertyHandling;
|
||||
if (settings._typeNameAssemblyFormat != null)
|
||||
serializer.TypeNameAssemblyFormat = settings.TypeNameAssemblyFormat;
|
||||
if (settings._preserveReferencesHandling != null)
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace Newtonsoft.Json
|
||||
internal const PreserveReferencesHandling DefaultPreserveReferencesHandling = PreserveReferencesHandling.None;
|
||||
internal const ConstructorHandling DefaultConstructorHandling = ConstructorHandling.Default;
|
||||
internal const TypeNameHandling DefaultTypeNameHandling = TypeNameHandling.None;
|
||||
internal const SpecialPropertyHandling DefaultSpecialPropertyHandling = SpecialPropertyHandling.Default;
|
||||
internal const MetadataPropertyHandling DefaultMetadataPropertyHandling = MetadataPropertyHandling.Default;
|
||||
internal const FormatterAssemblyStyle DefaultTypeNameAssemblyFormat = FormatterAssemblyStyle.Simple;
|
||||
internal static readonly StreamingContext DefaultContext;
|
||||
|
||||
@@ -84,7 +84,7 @@ namespace Newtonsoft.Json
|
||||
internal StreamingContext? _context;
|
||||
internal ConstructorHandling? _constructorHandling;
|
||||
internal TypeNameHandling? _typeNameHandling;
|
||||
internal SpecialPropertyHandling? _specialPropertyHandling;
|
||||
internal MetadataPropertyHandling? _metadataPropertyHandling;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets how reference loops (e.g. a class referencing itself) is handled.
|
||||
@@ -163,13 +163,13 @@ namespace Newtonsoft.Json
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets how special properties are used during deserialization.
|
||||
/// Gets or sets how metadata properties are used during deserialization.
|
||||
/// </summary>
|
||||
/// <value>The special properties handling.</value>
|
||||
public SpecialPropertyHandling SpecialPropertyHandling
|
||||
/// <value>The metadata properties handling.</value>
|
||||
public MetadataPropertyHandling MetadataPropertyHandling
|
||||
{
|
||||
get { return _specialPropertyHandling ?? DefaultSpecialPropertyHandling; }
|
||||
set { _specialPropertyHandling = value; }
|
||||
get { return _metadataPropertyHandling ?? DefaultMetadataPropertyHandling; }
|
||||
set { _metadataPropertyHandling = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
+4
-4
@@ -30,17 +30,17 @@ using System.Text;
|
||||
namespace Newtonsoft.Json
|
||||
{
|
||||
/// <summary>
|
||||
/// Specifies special property handling options for the <see cref="JsonSerializer"/>.
|
||||
/// Specifies metadata property handling options for the <see cref="JsonSerializer"/>.
|
||||
/// </summary>
|
||||
public enum SpecialPropertyHandling
|
||||
public enum MetadataPropertyHandling
|
||||
{
|
||||
/// <summary>
|
||||
/// Read special properties located at the start of a JSON object.
|
||||
/// Read metadata properties located at the start of a JSON object.
|
||||
/// </summary>
|
||||
Default = 0,
|
||||
|
||||
/// <summary>
|
||||
/// Read special properties located anywhere in a JSON object. Note that this setting will impact performance.
|
||||
/// Read metadata properties located anywhere in a JSON object. Note that this setting will impact performance.
|
||||
/// </summary>
|
||||
ReadAhead = 1,
|
||||
}
|
||||
@@ -117,6 +117,7 @@
|
||||
<Compile Include="Linq\JsonPath\QueryExpression.cs" />
|
||||
<Compile Include="Linq\JsonPath\QueryFilter.cs" />
|
||||
<Compile Include="Linq\JsonPath\ScanFilter.cs" />
|
||||
<Compile Include="MetadataPropertyHandling.cs" />
|
||||
<Compile Include="SerializationBinder.cs" />
|
||||
<Compile Include="Serialization\DiagnosticsTraceWriter.cs" />
|
||||
<Compile Include="Serialization\ExpressionValueProvider.cs" />
|
||||
@@ -126,7 +127,6 @@
|
||||
<Compile Include="Serialization\MemoryTraceWriter.cs" />
|
||||
<Compile Include="Serialization\TraceJsonReader.cs" />
|
||||
<Compile Include="Serialization\TraceJsonWriter.cs" />
|
||||
<Compile Include="SpecialPropertyHandling.cs" />
|
||||
<Compile Include="StringEscapeHandling.cs" />
|
||||
<Compile Include="Utilities\DateTimeParser.cs" />
|
||||
<Compile Include="Utilities\DynamicProxy.cs" />
|
||||
|
||||
@@ -129,6 +129,7 @@
|
||||
<Compile Include="Linq\JsonPath\QueryExpression.cs" />
|
||||
<Compile Include="Linq\JsonPath\QueryFilter.cs" />
|
||||
<Compile Include="Linq\JsonPath\ScanFilter.cs" />
|
||||
<Compile Include="MetadataPropertyHandling.cs" />
|
||||
<Compile Include="SerializationBinder.cs" />
|
||||
<Compile Include="Serialization\DiagnosticsTraceWriter.cs" />
|
||||
<Compile Include="Serialization\ExpressionValueProvider.cs" />
|
||||
@@ -137,7 +138,6 @@
|
||||
<Compile Include="Serialization\MemoryTraceWriter.cs" />
|
||||
<Compile Include="Serialization\TraceJsonReader.cs" />
|
||||
<Compile Include="Serialization\TraceJsonWriter.cs" />
|
||||
<Compile Include="SpecialPropertyHandling.cs" />
|
||||
<Compile Include="StringEscapeHandling.cs" />
|
||||
<Compile Include="TraceLevel.cs" />
|
||||
<Compile Include="Utilities\DateTimeParser.cs" />
|
||||
|
||||
@@ -130,6 +130,7 @@
|
||||
<Compile Include="Linq\JsonPath\QueryExpression.cs" />
|
||||
<Compile Include="Linq\JsonPath\QueryFilter.cs" />
|
||||
<Compile Include="Linq\JsonPath\ScanFilter.cs" />
|
||||
<Compile Include="MetadataPropertyHandling.cs" />
|
||||
<Compile Include="Serialization\DiagnosticsTraceWriter.cs" />
|
||||
<Compile Include="Serialization\ExpressionValueProvider.cs" />
|
||||
<Compile Include="Serialization\ITraceWriter.cs" />
|
||||
@@ -137,7 +138,6 @@
|
||||
<Compile Include="Serialization\MemoryTraceWriter.cs" />
|
||||
<Compile Include="Serialization\TraceJsonReader.cs" />
|
||||
<Compile Include="Serialization\TraceJsonWriter.cs" />
|
||||
<Compile Include="SpecialPropertyHandling.cs" />
|
||||
<Compile Include="StringEscapeHandling.cs" />
|
||||
<Compile Include="Utilities\DateTimeParser.cs" />
|
||||
<Compile Include="Utilities\DynamicProxy.cs" />
|
||||
|
||||
@@ -129,6 +129,7 @@
|
||||
<Compile Include="Linq\JTokenWriter.cs" />
|
||||
<Compile Include="Linq\JValue.cs" />
|
||||
<Compile Include="MemberSerialization.cs" />
|
||||
<Compile Include="MetadataPropertyHandling.cs" />
|
||||
<Compile Include="MissingMemberHandling.cs" />
|
||||
<Compile Include="NullValueHandling.cs" />
|
||||
<Compile Include="ObjectCreationHandling.cs" />
|
||||
@@ -192,7 +193,6 @@
|
||||
<Compile Include="Serialization\ReflectionValueProvider.cs" />
|
||||
<Compile Include="Serialization\TraceJsonReader.cs" />
|
||||
<Compile Include="Serialization\TraceJsonWriter.cs" />
|
||||
<Compile Include="SpecialPropertyHandling.cs" />
|
||||
<Compile Include="StringEscapeHandling.cs" />
|
||||
<Compile Include="TraceLevel.cs" />
|
||||
<Compile Include="TypeNameHandling.cs" />
|
||||
|
||||
@@ -134,6 +134,7 @@
|
||||
<Compile Include="Linq\JTokenWriter.cs" />
|
||||
<Compile Include="Linq\JValue.cs" />
|
||||
<Compile Include="MemberSerialization.cs" />
|
||||
<Compile Include="MetadataPropertyHandling.cs" />
|
||||
<Compile Include="MissingMemberHandling.cs" />
|
||||
<Compile Include="NullValueHandling.cs" />
|
||||
<Compile Include="ObjectCreationHandling.cs" />
|
||||
@@ -197,7 +198,6 @@
|
||||
<Compile Include="Serialization\ReflectionValueProvider.cs" />
|
||||
<Compile Include="Serialization\TraceJsonReader.cs" />
|
||||
<Compile Include="Serialization\TraceJsonWriter.cs" />
|
||||
<Compile Include="SpecialPropertyHandling.cs" />
|
||||
<Compile Include="StringEscapeHandling.cs" />
|
||||
<Compile Include="TraceLevel.cs" />
|
||||
<Compile Include="TypeNameHandling.cs" />
|
||||
|
||||
@@ -263,7 +263,7 @@
|
||||
<Compile Include="Serialization\MemoryTraceWriter.cs" />
|
||||
<Compile Include="Serialization\TraceJsonReader.cs" />
|
||||
<Compile Include="Serialization\TraceJsonWriter.cs" />
|
||||
<Compile Include="SpecialPropertyHandling.cs" />
|
||||
<Compile Include="MetadataPropertyHandling.cs" />
|
||||
<Compile Include="StringEscapeHandling.cs" />
|
||||
<Compile Include="TraceLevel.cs" />
|
||||
<Compile Include="TypeNameHandling.cs" />
|
||||
|
||||
@@ -133,10 +133,10 @@
|
||||
<Compile Include="Linq\JTokenWriter.cs" />
|
||||
<Compile Include="Linq\JValue.cs" />
|
||||
<Compile Include="MemberSerialization.cs" />
|
||||
<Compile Include="MetadataPropertyHandling.cs" />
|
||||
<Compile Include="MissingMemberHandling.cs" />
|
||||
<Compile Include="NullValueHandling.cs" />
|
||||
<Compile Include="ObjectCreationHandling.cs" />
|
||||
<Compile Include="SpecialPropertyHandling.cs" />
|
||||
<Compile Include="PreserveReferencesHandling.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="ReferenceLoopHandling.cs" />
|
||||
|
||||
@@ -91,5 +91,5 @@ using System.Security;
|
||||
// by using the '*' as shown below:
|
||||
|
||||
[assembly: AssemblyVersion("6.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("6.0.2.17226")]
|
||||
[assembly: AssemblyFileVersion("6.0.3.17227")]
|
||||
[assembly: CLSCompliant(true)]
|
||||
|
||||
@@ -226,7 +226,7 @@ namespace Newtonsoft.Json.Serialization
|
||||
{
|
||||
ValidationUtils.ArgumentNotNull(reader, "reader");
|
||||
|
||||
// this is needed because we've already read inside the object, looking for special properties
|
||||
// this is needed because we've already read inside the object, looking for metadata properties
|
||||
using (JTokenWriter writer = new JTokenWriter())
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
@@ -376,7 +376,7 @@ namespace Newtonsoft.Json.Serialization
|
||||
object newValue;
|
||||
Type resolvedObjectType = objectType;
|
||||
|
||||
if (Serializer.SpecialPropertyHandling == SpecialPropertyHandling.ReadAhead)
|
||||
if (Serializer.MetadataPropertyHandling == MetadataPropertyHandling.ReadAhead)
|
||||
{
|
||||
var tokenReader = reader as JTokenReader;
|
||||
if (tokenReader == null)
|
||||
@@ -390,13 +390,13 @@ namespace Newtonsoft.Json.Serialization
|
||||
reader = tokenReader;
|
||||
}
|
||||
|
||||
if (ReadSpecialPropertiesToken(tokenReader, ref resolvedObjectType, ref contract, member, containerContract, containerMember, existingValue, out newValue, out id))
|
||||
if (ReadMetadataPropertiesToken(tokenReader, ref resolvedObjectType, ref contract, member, containerContract, containerMember, existingValue, out newValue, out id))
|
||||
return newValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
CheckedRead(reader);
|
||||
if (ReadSpecialProperties(reader, ref resolvedObjectType, ref contract, member, containerContract, containerMember, existingValue, out newValue, out id))
|
||||
if (ReadMetadataProperties(reader, ref resolvedObjectType, ref contract, member, containerContract, containerMember, existingValue, out newValue, out id))
|
||||
return newValue;
|
||||
}
|
||||
|
||||
@@ -508,7 +508,7 @@ To fix this error either change the JSON to a {1} or change the deserialized typ
|
||||
".FormatWith(CultureInfo.InvariantCulture, resolvedObjectType, GetExpectedDescription(contract)));
|
||||
}
|
||||
|
||||
private bool ReadSpecialPropertiesToken(JTokenReader reader, ref Type objectType, ref JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, object existingValue, out object newValue, out string id)
|
||||
private bool ReadMetadataPropertiesToken(JTokenReader reader, ref Type objectType, ref JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, object existingValue, out object newValue, out string id)
|
||||
{
|
||||
id = null;
|
||||
newValue = null;
|
||||
@@ -592,7 +592,7 @@ To fix this error either change the JSON to a {1} or change the deserialized typ
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool ReadSpecialProperties(JsonReader reader, ref Type objectType, ref JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, object existingValue, out object newValue, out string id)
|
||||
private bool ReadMetadataProperties(JsonReader reader, ref Type objectType, ref JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, object existingValue, out object newValue, out string id)
|
||||
{
|
||||
id = null;
|
||||
newValue = null;
|
||||
@@ -603,9 +603,9 @@ To fix this error either change the JSON to a {1} or change the deserialized typ
|
||||
|
||||
if (propertyName.Length > 0 && propertyName[0] == '$')
|
||||
{
|
||||
// read 'special' properties
|
||||
// read metadata properties
|
||||
// $type, $id, $ref, etc
|
||||
bool specialProperty;
|
||||
bool metadataProperty;
|
||||
|
||||
do
|
||||
{
|
||||
@@ -635,7 +635,7 @@ To fix this error either change the JSON to a {1} or change the deserialized typ
|
||||
}
|
||||
else
|
||||
{
|
||||
specialProperty = true;
|
||||
metadataProperty = true;
|
||||
}
|
||||
}
|
||||
else if (string.Equals(propertyName, JsonTypeReflector.TypePropertyName, StringComparison.Ordinal))
|
||||
@@ -647,7 +647,7 @@ To fix this error either change the JSON to a {1} or change the deserialized typ
|
||||
|
||||
CheckedRead(reader);
|
||||
|
||||
specialProperty = true;
|
||||
metadataProperty = true;
|
||||
}
|
||||
else if (string.Equals(propertyName, JsonTypeReflector.IdPropertyName, StringComparison.Ordinal))
|
||||
{
|
||||
@@ -656,7 +656,7 @@ To fix this error either change the JSON to a {1} or change the deserialized typ
|
||||
id = (reader.Value != null) ? reader.Value.ToString() : null;
|
||||
|
||||
CheckedRead(reader);
|
||||
specialProperty = true;
|
||||
metadataProperty = true;
|
||||
}
|
||||
else if (string.Equals(propertyName, JsonTypeReflector.ArrayValuesPropertyName, StringComparison.Ordinal))
|
||||
{
|
||||
@@ -668,10 +668,9 @@ To fix this error either change the JSON to a {1} or change the deserialized typ
|
||||
}
|
||||
else
|
||||
{
|
||||
specialProperty = false;
|
||||
metadataProperty = false;
|
||||
}
|
||||
} while (specialProperty
|
||||
&& reader.TokenType == JsonToken.PropertyName);
|
||||
} while (metadataProperty && reader.TokenType == JsonToken.PropertyName);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
@@ -1953,7 +1952,7 @@ To fix this error either change the environment to be fully trusted, change the
|
||||
|
||||
private bool CheckPropertyName(JsonReader reader, string memberName)
|
||||
{
|
||||
if (Serializer.SpecialPropertyHandling == SpecialPropertyHandling.ReadAhead)
|
||||
if (Serializer.MetadataPropertyHandling == MetadataPropertyHandling.ReadAhead)
|
||||
{
|
||||
switch (memberName)
|
||||
{
|
||||
|
||||
@@ -108,10 +108,10 @@ namespace Newtonsoft.Json.Serialization
|
||||
set { _serializer.TypeNameHandling = value; }
|
||||
}
|
||||
|
||||
public override SpecialPropertyHandling SpecialPropertyHandling
|
||||
public override MetadataPropertyHandling MetadataPropertyHandling
|
||||
{
|
||||
get { return _serializer.SpecialPropertyHandling; }
|
||||
set { _serializer.SpecialPropertyHandling = value; }
|
||||
get { return _serializer.MetadataPropertyHandling; }
|
||||
set { _serializer.MetadataPropertyHandling = value; }
|
||||
}
|
||||
|
||||
public override FormatterAssemblyStyle TypeNameAssemblyFormat
|
||||
|
||||
Reference in New Issue
Block a user