From 2a63ea24e35f6af98e88204e0711a87b3b52cd70 Mon Sep 17 00:00:00 2001 From: JamesNK Date: Mon, 2 Nov 2009 08:21:02 +0000 Subject: [PATCH] -Added ObjectCreationHandling to JsonPropertyAttribute -Added IValueProvider, ReflectionValueProvider, DynamicValueProvider -Added Dynamic.snk -Added Required enum with options Default, AllowNull and Always -Added serialization event support to Silverlight version -Added Converter to JsonProperty for JsonConverter -Changed IsRequired to Required enum -Changed schema generator to allow for Required enum options -Changed Silverlight project version to Silverlight 3 -Improved error message when JSON array encountered for object and vice-versa when deserializing -Improved error message for converting types when deserializing -Improved error message from getting and setting properties when serializing and deserializing -Fixed empty string being converted to null when deserializing -Removed dependency on Entity Framework and LINQ to SQL assemblies --- Src/Doc/SerializationAttributes.html | 7 +- .../Newtonsoft.Json.Tests.Silverlight.csproj | 7 +- .../Newtonsoft.Json.Tests.csproj | 6 + Src/Newtonsoft.Json.Tests/PerformanceTests.cs | 1 + .../Schema/JsonSchemaGeneratorTests.cs | 8 +- ...lCasePropertyNamesContractResolverTests.cs | 4 +- .../Serialization/ContractResolverTests.cs | 82 +++++ .../DefaultValueHandlingTests.cs | 71 +++++ .../Serialization/JsonSerializerTest.cs | 241 ++++++++++----- .../Serialization/NullValueHandlingTests.cs | 82 +++++ .../SerializationErrorHandlingTests.cs | 5 +- .../SerializationEventAttributeTests.cs | 6 +- Src/Newtonsoft.Json.Tests/TestObjects/Car.cs | 19 ++ .../TestObjects/CircularReferenceClass.cs | 2 +- .../CircularReferenceWithIdClass.cs | 2 +- .../TestObjects/Computer.cs | 24 ++ .../TestObjects/Invoice.cs | 11 +- .../TestObjects/Movie.cs | 17 ++ .../TestObjects/RequiredMembersClass.cs | 6 +- .../SerializationEventTestDictionary.cs | 2 +- .../TestObjects/SerializationEventTestList.cs | 2 +- .../SerializationEventTestObject.cs | 2 +- ...alizationEventTestObjectWithConstructor.cs | 2 +- .../TestObjects/Store.cs | 2 + .../Converters/BinaryConverter.cs | 27 +- .../Converters/EntityKeyMemberConverter.cs | 19 +- Src/Newtonsoft.Json/Dynamic.snk | Bin 0 -> 596 bytes Src/Newtonsoft.Json/JsonPropertyAttribute.cs | 15 +- .../Newtonsoft.Json.Compact.csproj | 6 + .../Newtonsoft.Json.Net20.csproj | 6 + .../Newtonsoft.Json.Silverlight.csproj | 13 +- Src/Newtonsoft.Json/Newtonsoft.Json.csproj | 15 +- .../Properties/AssemblyInfo.cs | 2 + Src/Newtonsoft.Json/Required.cs | 9 + .../Schema/JsonSchemaGenerator.cs | 15 +- .../Serialization/DefaultContractResolver.cs | 51 +++- .../Serialization/DynamicValueProvider.cs | 55 ++++ .../Serialization/IValueProvider.cs | 13 + .../Serialization/JsonArrayContract.cs | 12 +- .../Serialization/JsonContract.cs | 19 +- .../Serialization/JsonDictionaryContract.cs | 14 +- .../Serialization/JsonObjectContract.cs | 2 +- .../Serialization/JsonProperty.cs | 21 +- .../Serialization/JsonPropertyCollection.cs | 10 +- .../JsonSerializerInternalReader.cs | 135 +++++---- .../JsonSerializerInternalWriter.cs | 48 ++- .../Serialization/ReflectionValueProvider.cs | 45 +++ Src/Newtonsoft.Json/StreamingContext.cs | 2 +- .../Utilities/DynamicWrapper.cs | 279 ++++++++++++++++++ .../Utilities/LateBoundDelegateFactory.cs | 231 +++++++++++++++ .../Utilities/ReflectionUtils.cs | 51 +++- 51 files changed, 1466 insertions(+), 260 deletions(-) create mode 100644 Src/Newtonsoft.Json.Tests/Serialization/ContractResolverTests.cs create mode 100644 Src/Newtonsoft.Json.Tests/Serialization/DefaultValueHandlingTests.cs create mode 100644 Src/Newtonsoft.Json.Tests/Serialization/NullValueHandlingTests.cs create mode 100644 Src/Newtonsoft.Json.Tests/TestObjects/Car.cs create mode 100644 Src/Newtonsoft.Json.Tests/TestObjects/Computer.cs create mode 100644 Src/Newtonsoft.Json.Tests/TestObjects/Movie.cs create mode 100644 Src/Newtonsoft.Json/Dynamic.snk create mode 100644 Src/Newtonsoft.Json/Required.cs create mode 100644 Src/Newtonsoft.Json/Serialization/DynamicValueProvider.cs create mode 100644 Src/Newtonsoft.Json/Serialization/IValueProvider.cs create mode 100644 Src/Newtonsoft.Json/Serialization/ReflectionValueProvider.cs create mode 100644 Src/Newtonsoft.Json/Utilities/DynamicWrapper.cs create mode 100644 Src/Newtonsoft.Json/Utilities/LateBoundDelegateFactory.cs diff --git a/Src/Doc/SerializationAttributes.html b/Src/Doc/SerializationAttributes.html index 5c61ad71..40538e0e 100644 --- a/Src/Doc/SerializationAttributes.html +++ b/Src/Doc/SerializationAttributes.html @@ -60,7 +60,12 @@ JSON array populated with the IEnumerable values. Placing the JsonPropertyAttribute overrides this behavor and forces the serializer to serialize the class's fields and properties.

JsonPropertyAttribute
-

Allows the name of the serialized member to be customized. The attribute also indicates that a member should be serialized when member serialization is set to opt-in.

+

JsonPropertyAttribute has a number of uses:

+
JsonIgnoreAttribute

Excludes a field or property from serialization.

JsonConverterAttribute
diff --git a/Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.Silverlight.csproj b/Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.Silverlight.csproj index c9171db4..773b54e2 100644 --- a/Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.Silverlight.csproj +++ b/Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.Silverlight.csproj @@ -12,6 +12,11 @@ Newtonsoft.Json.Tests.Silverlight v3.5 false + + + 3.5 + + true @@ -195,7 +200,7 @@ Newtonsoft.Json.Silverlight - +