-Added AttributeProvider
-Increament version to 7.0.1
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
|
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
|
||||||
<metadata>
|
<metadata>
|
||||||
<id>Newtonsoft.Json</id>
|
<id>Newtonsoft.Json</id>
|
||||||
<version>6.0.7</version>
|
<version>7.0.1-beta1</version>
|
||||||
<title>Json.NET</title>
|
<title>Json.NET</title>
|
||||||
<description>Json.NET is a popular high-performance JSON framework for .NET</description>
|
<description>Json.NET is a popular high-performance JSON framework for .NET</description>
|
||||||
<authors>James Newton-King</authors>
|
<authors>James Newton-King</authors>
|
||||||
|
|||||||
+3
-4
@@ -1,7 +1,7 @@
|
|||||||
properties {
|
properties {
|
||||||
$zipFileName = "Json60r7.zip"
|
$zipFileName = "Json70r1.zip"
|
||||||
$majorVersion = "6.0"
|
$majorVersion = "7.0"
|
||||||
$majorWithReleaseVersion = "6.0.7"
|
$majorWithReleaseVersion = "7.0.1"
|
||||||
$version = GetVersion $majorWithReleaseVersion
|
$version = GetVersion $majorWithReleaseVersion
|
||||||
$signAssemblies = $false
|
$signAssemblies = $false
|
||||||
$signKeyPath = "C:\Development\Releases\newtonsoft.snk"
|
$signKeyPath = "C:\Development\Releases\newtonsoft.snk"
|
||||||
@@ -22,7 +22,6 @@
|
|||||||
@{Name = "Newtonsoft.Json.Portable"; TestsName = "Newtonsoft.Json.Tests.Portable"; TestsFunction = "NUnitTests"; Constants="PORTABLE"; FinalDir="Portable"; NuGetDir = "portable-net45+wp80+win8+wpa81+aspnetcore50"; Framework="net-4.0"; Sign=$true},
|
@{Name = "Newtonsoft.Json.Portable"; TestsName = "Newtonsoft.Json.Tests.Portable"; TestsFunction = "NUnitTests"; Constants="PORTABLE"; FinalDir="Portable"; NuGetDir = "portable-net45+wp80+win8+wpa81+aspnetcore50"; Framework="net-4.0"; Sign=$true},
|
||||||
@{Name = "Newtonsoft.Json.Portable40"; TestsName = "Newtonsoft.Json.Tests.Portable40"; TestsFunction = "NUnitTests"; Constants="PORTABLE40"; FinalDir="Portable40"; NuGetDir = "portable-net40+sl5+wp80+win8+wpa81"; Framework="net-4.0"; Sign=$true},
|
@{Name = "Newtonsoft.Json.Portable40"; TestsName = "Newtonsoft.Json.Tests.Portable40"; TestsFunction = "NUnitTests"; Constants="PORTABLE40"; FinalDir="Portable40"; NuGetDir = "portable-net40+sl5+wp80+win8+wpa81"; Framework="net-4.0"; Sign=$true},
|
||||||
#@{Name = $null; TestsName = "Newtonsoft.Json.Tests.AspNetCore50"; TestsFunction = "CoreClrTests"; Constants="ASPNETCORE50"; FinalDir="ASPNETCORE50"; NuGetDir = $null; Framework=$null; Sign=$null},
|
#@{Name = $null; TestsName = "Newtonsoft.Json.Tests.AspNetCore50"; TestsFunction = "CoreClrTests"; Constants="ASPNETCORE50"; FinalDir="ASPNETCORE50"; NuGetDir = $null; Framework=$null; Sign=$null},
|
||||||
@{Name = "Newtonsoft.Json.WinRT"; TestsName = "Newtonsoft.Json.Tests.WinRT"; TestsFunction = "WinRTTests"; Constants="NETFX_CORE"; FinalDir="WinRT"; NuGetDir = "netcore45"; Framework="net-4.5"; Sign=$true},
|
|
||||||
@{Name = "Newtonsoft.Json.Net40"; TestsName = "Newtonsoft.Json.Tests.Net40"; TestsFunction = "NUnitTests"; Constants="NET40"; FinalDir="Net40"; NuGetDir = "net40"; Framework="net-4.0"; Sign=$true},
|
@{Name = "Newtonsoft.Json.Net40"; TestsName = "Newtonsoft.Json.Tests.Net40"; TestsFunction = "NUnitTests"; Constants="NET40"; FinalDir="Net40"; NuGetDir = "net40"; Framework="net-4.0"; Sign=$true},
|
||||||
@{Name = "Newtonsoft.Json.Net35"; TestsName = "Newtonsoft.Json.Tests.Net35"; TestsFunction = "NUnitTests"; Constants="NET35"; FinalDir="Net35"; NuGetDir = "net35"; Framework="net-2.0"; Sign=$true},
|
@{Name = "Newtonsoft.Json.Net35"; TestsName = "Newtonsoft.Json.Tests.Net35"; TestsFunction = "NUnitTests"; Constants="NET35"; FinalDir="Net35"; NuGetDir = "net35"; Framework="net-2.0"; Sign=$true},
|
||||||
@{Name = "Newtonsoft.Json.Net20"; TestsName = "Newtonsoft.Json.Tests.Net20"; TestsFunction = "NUnitTests"; Constants="NET20"; FinalDir="Net20"; NuGetDir = "net20"; Framework="net-2.0"; Sign=$true}
|
@{Name = "Newtonsoft.Json.Net20"; TestsName = "Newtonsoft.Json.Tests.Net20"; TestsFunction = "NUnitTests"; Constants="NET20"; FinalDir="Net20"; NuGetDir = "net20"; Framework="net-2.0"; Sign=$true}
|
||||||
|
|||||||
@@ -1,4 +1,29 @@
|
|||||||
using System;
|
#region License
|
||||||
|
// Copyright (c) 2007 James Newton-King
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person
|
||||||
|
// obtaining a copy of this software and associated documentation
|
||||||
|
// files (the "Software"), to deal in the Software without
|
||||||
|
// restriction, including without limitation the rights to use,
|
||||||
|
// copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the
|
||||||
|
// Software is furnished to do so, subject to the following
|
||||||
|
// conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be
|
||||||
|
// included in all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||||
|
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||||
|
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
// OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
|||||||
@@ -1,3 +1,28 @@
|
|||||||
|
#region License
|
||||||
|
// Copyright (c) 2007 James Newton-King
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person
|
||||||
|
// obtaining a copy of this software and associated documentation
|
||||||
|
// files (the "Software"), to deal in the Software without
|
||||||
|
// restriction, including without limitation the rights to use,
|
||||||
|
// copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the
|
||||||
|
// Software is furnished to do so, subject to the following
|
||||||
|
// conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be
|
||||||
|
// included in all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||||
|
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||||
|
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
// OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
#endregion
|
||||||
|
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
@@ -31,6 +56,5 @@ using System.Runtime.InteropServices;
|
|||||||
//
|
//
|
||||||
// You can specify all the values or you can default the Build and Revision Numbers
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
// by using the '*' as shown below:
|
// by using the '*' as shown below:
|
||||||
// [assembly: AssemblyVersion("6.0.0.0")]
|
[assembly: AssemblyVersion("7.0.0.0")]
|
||||||
[assembly: AssemblyVersion("6.0.0.0")]
|
[assembly: AssemblyFileVersion("7.0.1.18023")]
|
||||||
[assembly: AssemblyFileVersion("6.0.7.18023")]
|
|
||||||
|
|||||||
@@ -101,6 +101,8 @@
|
|||||||
<Compile Include="Serialization\ConstructorHandlingTests.cs" />
|
<Compile Include="Serialization\ConstructorHandlingTests.cs" />
|
||||||
<Compile Include="Serialization\ContractResolverTests.cs" />
|
<Compile Include="Serialization\ContractResolverTests.cs" />
|
||||||
<Compile Include="Serialization\DefaultValueHandlingTests.cs" />
|
<Compile Include="Serialization\DefaultValueHandlingTests.cs" />
|
||||||
|
<Compile Include="Serialization\DependencyInjectionTests.cs" />
|
||||||
|
<Compile Include="Serialization\DynamicConcreteTests.cs" />
|
||||||
<Compile Include="Serialization\DynamicTests.cs" />
|
<Compile Include="Serialization\DynamicTests.cs" />
|
||||||
<Compile Include="Serialization\ExtensionDataTests.cs" />
|
<Compile Include="Serialization\ExtensionDataTests.cs" />
|
||||||
<Compile Include="Serialization\FSharpTests.cs" />
|
<Compile Include="Serialization\FSharpTests.cs" />
|
||||||
@@ -110,6 +112,7 @@
|
|||||||
<Compile Include="Serialization\MetadataPropertyHandlingTests.cs" />
|
<Compile Include="Serialization\MetadataPropertyHandlingTests.cs" />
|
||||||
<Compile Include="Serialization\NullValueHandlingTests.cs" />
|
<Compile Include="Serialization\NullValueHandlingTests.cs" />
|
||||||
<Compile Include="Serialization\ReferenceLoopHandlingTests.cs" />
|
<Compile Include="Serialization\ReferenceLoopHandlingTests.cs" />
|
||||||
|
<Compile Include="Serialization\ReflectionAttributeProviderTests.cs" />
|
||||||
<Compile Include="Serialization\ShouldSerializeTests.cs" />
|
<Compile Include="Serialization\ShouldSerializeTests.cs" />
|
||||||
<Compile Include="Serialization\TraceWriterTests.cs" />
|
<Compile Include="Serialization\TraceWriterTests.cs" />
|
||||||
<Compile Include="Serialization\WebApiIntegrationTests.cs" />
|
<Compile Include="Serialization\WebApiIntegrationTests.cs" />
|
||||||
|
|||||||
@@ -143,6 +143,8 @@
|
|||||||
<Compile Include="Serialization\ConstructorHandlingTests.cs" />
|
<Compile Include="Serialization\ConstructorHandlingTests.cs" />
|
||||||
<Compile Include="Serialization\ContractResolverTests.cs" />
|
<Compile Include="Serialization\ContractResolverTests.cs" />
|
||||||
<Compile Include="Serialization\DefaultValueHandlingTests.cs" />
|
<Compile Include="Serialization\DefaultValueHandlingTests.cs" />
|
||||||
|
<Compile Include="Serialization\DependencyInjectionTests.cs" />
|
||||||
|
<Compile Include="Serialization\DynamicConcreteTests.cs" />
|
||||||
<Compile Include="Serialization\DynamicTests.cs" />
|
<Compile Include="Serialization\DynamicTests.cs" />
|
||||||
<Compile Include="Serialization\ExtensionDataTests.cs" />
|
<Compile Include="Serialization\ExtensionDataTests.cs" />
|
||||||
<Compile Include="Serialization\FSharpTests.cs" />
|
<Compile Include="Serialization\FSharpTests.cs" />
|
||||||
@@ -152,6 +154,7 @@
|
|||||||
<Compile Include="Serialization\MetadataPropertyHandlingTests.cs" />
|
<Compile Include="Serialization\MetadataPropertyHandlingTests.cs" />
|
||||||
<Compile Include="Serialization\NullValueHandlingTests.cs" />
|
<Compile Include="Serialization\NullValueHandlingTests.cs" />
|
||||||
<Compile Include="Serialization\ReferenceLoopHandlingTests.cs" />
|
<Compile Include="Serialization\ReferenceLoopHandlingTests.cs" />
|
||||||
|
<Compile Include="Serialization\ReflectionAttributeProviderTests.cs" />
|
||||||
<Compile Include="Serialization\ShouldSerializeTests.cs" />
|
<Compile Include="Serialization\ShouldSerializeTests.cs" />
|
||||||
<Compile Include="Serialization\TraceWriterTests.cs" />
|
<Compile Include="Serialization\TraceWriterTests.cs" />
|
||||||
<Compile Include="Serialization\WebApiIntegrationTests.cs" />
|
<Compile Include="Serialization\WebApiIntegrationTests.cs" />
|
||||||
|
|||||||
@@ -265,6 +265,8 @@
|
|||||||
<Compile Include="Serialization\ConstructorHandlingTests.cs" />
|
<Compile Include="Serialization\ConstructorHandlingTests.cs" />
|
||||||
<Compile Include="Serialization\ContractResolverTests.cs" />
|
<Compile Include="Serialization\ContractResolverTests.cs" />
|
||||||
<Compile Include="Serialization\DefaultValueHandlingTests.cs" />
|
<Compile Include="Serialization\DefaultValueHandlingTests.cs" />
|
||||||
|
<Compile Include="Serialization\DependencyInjectionTests.cs" />
|
||||||
|
<Compile Include="Serialization\DynamicConcreteTests.cs" />
|
||||||
<Compile Include="Serialization\DynamicTests.cs" />
|
<Compile Include="Serialization\DynamicTests.cs" />
|
||||||
<Compile Include="Serialization\ExtensionDataTests.cs" />
|
<Compile Include="Serialization\ExtensionDataTests.cs" />
|
||||||
<Compile Include="Serialization\FSharpTests.cs" />
|
<Compile Include="Serialization\FSharpTests.cs" />
|
||||||
@@ -272,6 +274,7 @@
|
|||||||
<Compile Include="Serialization\JsonSerializerCollectionsTests.cs" />
|
<Compile Include="Serialization\JsonSerializerCollectionsTests.cs" />
|
||||||
<Compile Include="Serialization\MetadataPropertyHandlingTests.cs" />
|
<Compile Include="Serialization\MetadataPropertyHandlingTests.cs" />
|
||||||
<Compile Include="Serialization\ReferenceLoopHandlingTests.cs" />
|
<Compile Include="Serialization\ReferenceLoopHandlingTests.cs" />
|
||||||
|
<Compile Include="Serialization\ReflectionAttributeProviderTests.cs" />
|
||||||
<Compile Include="Serialization\ShouldSerializeTests.cs" />
|
<Compile Include="Serialization\ShouldSerializeTests.cs" />
|
||||||
<Compile Include="Serialization\TraceWriterTests.cs" />
|
<Compile Include="Serialization\TraceWriterTests.cs" />
|
||||||
<Compile Include="Serialization\WebApiIntegrationTests.cs" />
|
<Compile Include="Serialization\WebApiIntegrationTests.cs" />
|
||||||
|
|||||||
@@ -144,6 +144,8 @@
|
|||||||
<Compile Include="Serialization\ConstructorHandlingTests.cs" />
|
<Compile Include="Serialization\ConstructorHandlingTests.cs" />
|
||||||
<Compile Include="Serialization\ContractResolverTests.cs" />
|
<Compile Include="Serialization\ContractResolverTests.cs" />
|
||||||
<Compile Include="Serialization\DefaultValueHandlingTests.cs" />
|
<Compile Include="Serialization\DefaultValueHandlingTests.cs" />
|
||||||
|
<Compile Include="Serialization\DependencyInjectionTests.cs" />
|
||||||
|
<Compile Include="Serialization\DynamicConcreteTests.cs" />
|
||||||
<Compile Include="Serialization\DynamicTests.cs" />
|
<Compile Include="Serialization\DynamicTests.cs" />
|
||||||
<Compile Include="Serialization\ExtensionDataTests.cs" />
|
<Compile Include="Serialization\ExtensionDataTests.cs" />
|
||||||
<Compile Include="Serialization\FSharpTests.cs" />
|
<Compile Include="Serialization\FSharpTests.cs" />
|
||||||
@@ -151,6 +153,7 @@
|
|||||||
<Compile Include="Serialization\JsonSerializerCollectionsTests.cs" />
|
<Compile Include="Serialization\JsonSerializerCollectionsTests.cs" />
|
||||||
<Compile Include="Serialization\MetadataPropertyHandlingTests.cs" />
|
<Compile Include="Serialization\MetadataPropertyHandlingTests.cs" />
|
||||||
<Compile Include="Serialization\ReferenceLoopHandlingTests.cs" />
|
<Compile Include="Serialization\ReferenceLoopHandlingTests.cs" />
|
||||||
|
<Compile Include="Serialization\ReflectionAttributeProviderTests.cs" />
|
||||||
<Compile Include="Serialization\ShouldSerializeTests.cs" />
|
<Compile Include="Serialization\ShouldSerializeTests.cs" />
|
||||||
<Compile Include="Serialization\TraceWriterTests.cs" />
|
<Compile Include="Serialization\TraceWriterTests.cs" />
|
||||||
<Compile Include="Serialization\WebApiIntegrationTests.cs" />
|
<Compile Include="Serialization\WebApiIntegrationTests.cs" />
|
||||||
|
|||||||
@@ -145,6 +145,8 @@
|
|||||||
<Compile Include="Serialization\ConstructorHandlingTests.cs" />
|
<Compile Include="Serialization\ConstructorHandlingTests.cs" />
|
||||||
<Compile Include="Serialization\ContractResolverTests.cs" />
|
<Compile Include="Serialization\ContractResolverTests.cs" />
|
||||||
<Compile Include="Serialization\DefaultValueHandlingTests.cs" />
|
<Compile Include="Serialization\DefaultValueHandlingTests.cs" />
|
||||||
|
<Compile Include="Serialization\DependencyInjectionTests.cs" />
|
||||||
|
<Compile Include="Serialization\DynamicConcreteTests.cs" />
|
||||||
<Compile Include="Serialization\DynamicTests.cs" />
|
<Compile Include="Serialization\DynamicTests.cs" />
|
||||||
<Compile Include="Serialization\ExtensionDataTests.cs" />
|
<Compile Include="Serialization\ExtensionDataTests.cs" />
|
||||||
<Compile Include="Serialization\FSharpTests.cs" />
|
<Compile Include="Serialization\FSharpTests.cs" />
|
||||||
@@ -152,6 +154,7 @@
|
|||||||
<Compile Include="Serialization\JsonSerializerCollectionsTests.cs" />
|
<Compile Include="Serialization\JsonSerializerCollectionsTests.cs" />
|
||||||
<Compile Include="Serialization\MetadataPropertyHandlingTests.cs" />
|
<Compile Include="Serialization\MetadataPropertyHandlingTests.cs" />
|
||||||
<Compile Include="Serialization\ReferenceLoopHandlingTests.cs" />
|
<Compile Include="Serialization\ReferenceLoopHandlingTests.cs" />
|
||||||
|
<Compile Include="Serialization\ReflectionAttributeProviderTests.cs" />
|
||||||
<Compile Include="Serialization\ShouldSerializeTests.cs" />
|
<Compile Include="Serialization\ShouldSerializeTests.cs" />
|
||||||
<Compile Include="Serialization\TraceWriterTests.cs" />
|
<Compile Include="Serialization\TraceWriterTests.cs" />
|
||||||
<Compile Include="Serialization\WebApiIntegrationTests.cs" />
|
<Compile Include="Serialization\WebApiIntegrationTests.cs" />
|
||||||
|
|||||||
@@ -261,6 +261,7 @@
|
|||||||
<Compile Include="Serialization\PopulateTests.cs" />
|
<Compile Include="Serialization\PopulateTests.cs" />
|
||||||
<Compile Include="Serialization\PreserveReferencesHandlingTests.cs" />
|
<Compile Include="Serialization\PreserveReferencesHandlingTests.cs" />
|
||||||
<Compile Include="Serialization\ReferenceLoopHandlingTests.cs" />
|
<Compile Include="Serialization\ReferenceLoopHandlingTests.cs" />
|
||||||
|
<Compile Include="Serialization\ReflectionAttributeProviderTests.cs" />
|
||||||
<Compile Include="Serialization\SerializationErrorHandlingTests.cs" />
|
<Compile Include="Serialization\SerializationErrorHandlingTests.cs" />
|
||||||
<Compile Include="Serialization\SerializationEventAttributeTests.cs" />
|
<Compile Include="Serialization\SerializationEventAttributeTests.cs" />
|
||||||
<Compile Include="Serialization\JsonSerializerCollectionsTests.cs" />
|
<Compile Include="Serialization\JsonSerializerCollectionsTests.cs" />
|
||||||
|
|||||||
@@ -75,5 +75,5 @@ using System.Security;
|
|||||||
// You can specify all the values or you can default the Revision and Build Numbers
|
// You can specify all the values or you can default the Revision and Build Numbers
|
||||||
// by using the '*' as shown below:
|
// by using the '*' as shown below:
|
||||||
|
|
||||||
[assembly: AssemblyVersion("6.0.0.0")]
|
[assembly: AssemblyVersion("7.0.0.0")]
|
||||||
[assembly: AssemblyFileVersion("6.0.7.18023")]
|
[assembly: AssemblyFileVersion("7.0.1.18023")]
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Runtime.Serialization;
|
using System.Runtime.Serialization;
|
||||||
#if NETFX_CORE
|
#if NETFX_CORE
|
||||||
@@ -155,6 +156,17 @@ namespace Newtonsoft.Json.Tests.Serialization
|
|||||||
Assert.IsNotNull(contract.DefaultCreator);
|
Assert.IsNotNull(contract.DefaultCreator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void PropertyAttributeProvider()
|
||||||
|
{
|
||||||
|
var resolver = new DefaultContractResolver();
|
||||||
|
var contract = (JsonObjectContract)resolver.ResolveContract(typeof(Invoice));
|
||||||
|
|
||||||
|
JsonProperty property = contract.Properties["FollowUpDays"];
|
||||||
|
Assert.AreEqual(1, property.AttributeProvider.GetAttributes(false).Count);
|
||||||
|
Assert.AreEqual(typeof(DefaultValueAttribute), property.AttributeProvider.GetAttributes(false)[0].GetType());
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void AbstractTestClass()
|
public void AbstractTestClass()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
// OTHER DEALINGS IN THE SOFTWARE.
|
// OTHER DEALINGS IN THE SOFTWARE.
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#if !(NET35 || NET20 || ASPNETCORE50)
|
#if !(NET40 || NET35 || NET20 || ASPNETCORE50 || PORTABLE || PORTABLE40)
|
||||||
using Autofac;
|
using Autofac;
|
||||||
using Newtonsoft.Json.Serialization;
|
using Newtonsoft.Json.Serialization;
|
||||||
using Newtonsoft.Json.Tests.TestObjects;
|
using Newtonsoft.Json.Tests.TestObjects;
|
||||||
|
|||||||
@@ -29,8 +29,11 @@ using System.Reflection.Emit;
|
|||||||
using Newtonsoft.Json.Serialization;
|
using Newtonsoft.Json.Serialization;
|
||||||
using Newtonsoft.Json.Tests.TestObjects;
|
using Newtonsoft.Json.Tests.TestObjects;
|
||||||
using System;
|
using System;
|
||||||
|
#if NET20
|
||||||
|
using Newtonsoft.Json.Utilities.LinqBridge;
|
||||||
|
#else
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
#endif
|
||||||
#if NETFX_CORE
|
#if NETFX_CORE
|
||||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||||
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
|
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ using Newtonsoft.Json.Linq;
|
|||||||
namespace Newtonsoft.Json.Tests.Serialization
|
namespace Newtonsoft.Json.Tests.Serialization
|
||||||
{
|
{
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
|
[Ignore]
|
||||||
public class ImmutableCollectionsTests : TestFixtureBase
|
public class ImmutableCollectionsTests : TestFixtureBase
|
||||||
{
|
{
|
||||||
#region List
|
#region List
|
||||||
|
|||||||
@@ -0,0 +1,105 @@
|
|||||||
|
#region License
|
||||||
|
// Copyright (c) 2007 James Newton-King
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person
|
||||||
|
// obtaining a copy of this software and associated documentation
|
||||||
|
// files (the "Software"), to deal in the Software without
|
||||||
|
// restriction, including without limitation the rights to use,
|
||||||
|
// copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the
|
||||||
|
// Software is furnished to do so, subject to the following
|
||||||
|
// conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be
|
||||||
|
// included in all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||||
|
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||||
|
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
// OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
using System.Text;
|
||||||
|
using Newtonsoft.Json.Serialization;
|
||||||
|
using Newtonsoft.Json.Tests.TestObjects;
|
||||||
|
using NUnit.Framework;
|
||||||
|
|
||||||
|
namespace Newtonsoft.Json.Tests.Serialization
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
public class ReflectionAttributeProviderTests : TestFixtureBase
|
||||||
|
{
|
||||||
|
public class ReflectionTestObject
|
||||||
|
{
|
||||||
|
[DefaultValue("1")]
|
||||||
|
[JsonProperty]
|
||||||
|
public int TestProperty { get; set; }
|
||||||
|
|
||||||
|
[DefaultValue("1")]
|
||||||
|
[JsonProperty]
|
||||||
|
public int TestField;
|
||||||
|
|
||||||
|
public ReflectionTestObject(
|
||||||
|
[DefaultValue("1")]
|
||||||
|
[JsonProperty]
|
||||||
|
int testParameter)
|
||||||
|
{
|
||||||
|
TestProperty = testParameter;
|
||||||
|
TestField = testParameter;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void GetAttributes_Property()
|
||||||
|
{
|
||||||
|
PropertyInfo property = typeof(ReflectionTestObject).GetProperty("TestProperty");
|
||||||
|
|
||||||
|
ReflectionAttributeProvider provider = new ReflectionAttributeProvider(property);
|
||||||
|
|
||||||
|
IList<Attribute> attributes = provider.GetAttributes(typeof(DefaultValueAttribute), false);
|
||||||
|
Assert.AreEqual(1, attributes.Count);
|
||||||
|
|
||||||
|
attributes = provider.GetAttributes(false);
|
||||||
|
Assert.AreEqual(2, attributes.Count);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void GetAttributes_Field()
|
||||||
|
{
|
||||||
|
FieldInfo field = typeof(ReflectionTestObject).GetField("TestField");
|
||||||
|
|
||||||
|
ReflectionAttributeProvider provider = new ReflectionAttributeProvider(field);
|
||||||
|
|
||||||
|
IList<Attribute> attributes = provider.GetAttributes(typeof(DefaultValueAttribute), false);
|
||||||
|
Assert.AreEqual(1, attributes.Count);
|
||||||
|
|
||||||
|
attributes = provider.GetAttributes(false);
|
||||||
|
Assert.AreEqual(2, attributes.Count);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void GetAttributes_Parameter()
|
||||||
|
{
|
||||||
|
ParameterInfo[] parameters = typeof(ReflectionTestObject).GetConstructor(new[] { typeof(int) }).GetParameters();
|
||||||
|
|
||||||
|
ParameterInfo parameter = parameters[0];
|
||||||
|
|
||||||
|
ReflectionAttributeProvider provider = new ReflectionAttributeProvider(parameter);
|
||||||
|
|
||||||
|
IList<Attribute> attributes = provider.GetAttributes(typeof(DefaultValueAttribute), false);
|
||||||
|
Assert.AreEqual(1, attributes.Count);
|
||||||
|
|
||||||
|
attributes = provider.GetAttributes(false);
|
||||||
|
Assert.AreEqual(2, attributes.Count);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -66,9 +66,6 @@ namespace Newtonsoft.Json.Linq
|
|||||||
private JToken _next;
|
private JToken _next;
|
||||||
private object _annotations;
|
private object _annotations;
|
||||||
|
|
||||||
//private int? _lineNumber;
|
|
||||||
//private int? _linePosition;
|
|
||||||
|
|
||||||
private static readonly JTokenType[] BooleanTypes = new[] { JTokenType.Integer, JTokenType.Float, JTokenType.String, JTokenType.Comment, JTokenType.Raw, JTokenType.Boolean };
|
private static readonly JTokenType[] BooleanTypes = new[] { JTokenType.Integer, JTokenType.Float, JTokenType.String, JTokenType.Comment, JTokenType.Raw, JTokenType.Boolean };
|
||||||
private static readonly JTokenType[] NumberTypes = new[] { JTokenType.Integer, JTokenType.Float, JTokenType.String, JTokenType.Comment, JTokenType.Raw, JTokenType.Boolean };
|
private static readonly JTokenType[] NumberTypes = new[] { JTokenType.Integer, JTokenType.Float, JTokenType.String, JTokenType.Comment, JTokenType.Raw, JTokenType.Boolean };
|
||||||
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE)
|
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE)
|
||||||
|
|||||||
@@ -123,10 +123,12 @@
|
|||||||
<Compile Include="SerializationBinder.cs" />
|
<Compile Include="SerializationBinder.cs" />
|
||||||
<Compile Include="Serialization\DiagnosticsTraceWriter.cs" />
|
<Compile Include="Serialization\DiagnosticsTraceWriter.cs" />
|
||||||
<Compile Include="Serialization\ExpressionValueProvider.cs" />
|
<Compile Include="Serialization\ExpressionValueProvider.cs" />
|
||||||
|
<Compile Include="Serialization\IAttributeProvider.cs" />
|
||||||
<Compile Include="Serialization\ITraceWriter.cs" />
|
<Compile Include="Serialization\ITraceWriter.cs" />
|
||||||
<Compile Include="Serialization\JsonContainerContract.cs" />
|
<Compile Include="Serialization\JsonContainerContract.cs" />
|
||||||
<Compile Include="Serialization\JsonDynamicContract.cs" />
|
<Compile Include="Serialization\JsonDynamicContract.cs" />
|
||||||
<Compile Include="Serialization\MemoryTraceWriter.cs" />
|
<Compile Include="Serialization\MemoryTraceWriter.cs" />
|
||||||
|
<Compile Include="Serialization\ReflectionAttributeProvider.cs" />
|
||||||
<Compile Include="Serialization\TraceJsonReader.cs" />
|
<Compile Include="Serialization\TraceJsonReader.cs" />
|
||||||
<Compile Include="Serialization\TraceJsonWriter.cs" />
|
<Compile Include="Serialization\TraceJsonWriter.cs" />
|
||||||
<Compile Include="StringEscapeHandling.cs" />
|
<Compile Include="StringEscapeHandling.cs" />
|
||||||
|
|||||||
@@ -135,9 +135,11 @@
|
|||||||
<Compile Include="SerializationBinder.cs" />
|
<Compile Include="SerializationBinder.cs" />
|
||||||
<Compile Include="Serialization\DiagnosticsTraceWriter.cs" />
|
<Compile Include="Serialization\DiagnosticsTraceWriter.cs" />
|
||||||
<Compile Include="Serialization\ExpressionValueProvider.cs" />
|
<Compile Include="Serialization\ExpressionValueProvider.cs" />
|
||||||
|
<Compile Include="Serialization\IAttributeProvider.cs" />
|
||||||
<Compile Include="Serialization\ITraceWriter.cs" />
|
<Compile Include="Serialization\ITraceWriter.cs" />
|
||||||
<Compile Include="Serialization\JsonContainerContract.cs" />
|
<Compile Include="Serialization\JsonContainerContract.cs" />
|
||||||
<Compile Include="Serialization\MemoryTraceWriter.cs" />
|
<Compile Include="Serialization\MemoryTraceWriter.cs" />
|
||||||
|
<Compile Include="Serialization\ReflectionAttributeProvider.cs" />
|
||||||
<Compile Include="Serialization\TraceJsonReader.cs" />
|
<Compile Include="Serialization\TraceJsonReader.cs" />
|
||||||
<Compile Include="Serialization\TraceJsonWriter.cs" />
|
<Compile Include="Serialization\TraceJsonWriter.cs" />
|
||||||
<Compile Include="StringEscapeHandling.cs" />
|
<Compile Include="StringEscapeHandling.cs" />
|
||||||
|
|||||||
@@ -135,9 +135,11 @@
|
|||||||
<Compile Include="MetadataPropertyHandling.cs" />
|
<Compile Include="MetadataPropertyHandling.cs" />
|
||||||
<Compile Include="Serialization\DiagnosticsTraceWriter.cs" />
|
<Compile Include="Serialization\DiagnosticsTraceWriter.cs" />
|
||||||
<Compile Include="Serialization\ExpressionValueProvider.cs" />
|
<Compile Include="Serialization\ExpressionValueProvider.cs" />
|
||||||
|
<Compile Include="Serialization\IAttributeProvider.cs" />
|
||||||
<Compile Include="Serialization\ITraceWriter.cs" />
|
<Compile Include="Serialization\ITraceWriter.cs" />
|
||||||
<Compile Include="Serialization\JsonContainerContract.cs" />
|
<Compile Include="Serialization\JsonContainerContract.cs" />
|
||||||
<Compile Include="Serialization\MemoryTraceWriter.cs" />
|
<Compile Include="Serialization\MemoryTraceWriter.cs" />
|
||||||
|
<Compile Include="Serialization\ReflectionAttributeProvider.cs" />
|
||||||
<Compile Include="Serialization\TraceJsonReader.cs" />
|
<Compile Include="Serialization\TraceJsonReader.cs" />
|
||||||
<Compile Include="Serialization\TraceJsonWriter.cs" />
|
<Compile Include="Serialization\TraceJsonWriter.cs" />
|
||||||
<Compile Include="StringEscapeHandling.cs" />
|
<Compile Include="StringEscapeHandling.cs" />
|
||||||
|
|||||||
@@ -166,6 +166,7 @@
|
|||||||
<Compile Include="Serialization\DynamicValueProvider.cs" />
|
<Compile Include="Serialization\DynamicValueProvider.cs" />
|
||||||
<Compile Include="Serialization\ErrorContext.cs" />
|
<Compile Include="Serialization\ErrorContext.cs" />
|
||||||
<Compile Include="Serialization\ErrorEventArgs.cs" />
|
<Compile Include="Serialization\ErrorEventArgs.cs" />
|
||||||
|
<Compile Include="Serialization\IAttributeProvider.cs" />
|
||||||
<Compile Include="Serialization\IContractResolver.cs" />
|
<Compile Include="Serialization\IContractResolver.cs" />
|
||||||
<Compile Include="Serialization\IReferenceResolver.cs" />
|
<Compile Include="Serialization\IReferenceResolver.cs" />
|
||||||
<Compile Include="Serialization\ITraceWriter.cs" />
|
<Compile Include="Serialization\ITraceWriter.cs" />
|
||||||
@@ -191,6 +192,7 @@
|
|||||||
<Compile Include="Serialization\MemoryTraceWriter.cs" />
|
<Compile Include="Serialization\MemoryTraceWriter.cs" />
|
||||||
<Compile Include="Serialization\ObjectConstructor.cs" />
|
<Compile Include="Serialization\ObjectConstructor.cs" />
|
||||||
<Compile Include="Serialization\OnErrorAttribute.cs" />
|
<Compile Include="Serialization\OnErrorAttribute.cs" />
|
||||||
|
<Compile Include="Serialization\ReflectionAttributeProvider.cs" />
|
||||||
<Compile Include="Serialization\ReflectionValueProvider.cs" />
|
<Compile Include="Serialization\ReflectionValueProvider.cs" />
|
||||||
<Compile Include="Serialization\TraceJsonReader.cs" />
|
<Compile Include="Serialization\TraceJsonReader.cs" />
|
||||||
<Compile Include="Serialization\TraceJsonWriter.cs" />
|
<Compile Include="Serialization\TraceJsonWriter.cs" />
|
||||||
|
|||||||
@@ -171,6 +171,7 @@
|
|||||||
<Compile Include="Serialization\ErrorContext.cs" />
|
<Compile Include="Serialization\ErrorContext.cs" />
|
||||||
<Compile Include="Serialization\ErrorEventArgs.cs" />
|
<Compile Include="Serialization\ErrorEventArgs.cs" />
|
||||||
<Compile Include="Serialization\ExpressionValueProvider.cs" />
|
<Compile Include="Serialization\ExpressionValueProvider.cs" />
|
||||||
|
<Compile Include="Serialization\IAttributeProvider.cs" />
|
||||||
<Compile Include="Serialization\IContractResolver.cs" />
|
<Compile Include="Serialization\IContractResolver.cs" />
|
||||||
<Compile Include="Serialization\IReferenceResolver.cs" />
|
<Compile Include="Serialization\IReferenceResolver.cs" />
|
||||||
<Compile Include="Serialization\ITraceWriter.cs" />
|
<Compile Include="Serialization\ITraceWriter.cs" />
|
||||||
@@ -196,6 +197,7 @@
|
|||||||
<Compile Include="Serialization\MemoryTraceWriter.cs" />
|
<Compile Include="Serialization\MemoryTraceWriter.cs" />
|
||||||
<Compile Include="Serialization\ObjectConstructor.cs" />
|
<Compile Include="Serialization\ObjectConstructor.cs" />
|
||||||
<Compile Include="Serialization\OnErrorAttribute.cs" />
|
<Compile Include="Serialization\OnErrorAttribute.cs" />
|
||||||
|
<Compile Include="Serialization\ReflectionAttributeProvider.cs" />
|
||||||
<Compile Include="Serialization\ReflectionValueProvider.cs" />
|
<Compile Include="Serialization\ReflectionValueProvider.cs" />
|
||||||
<Compile Include="Serialization\TraceJsonReader.cs" />
|
<Compile Include="Serialization\TraceJsonReader.cs" />
|
||||||
<Compile Include="Serialization\TraceJsonWriter.cs" />
|
<Compile Include="Serialization\TraceJsonWriter.cs" />
|
||||||
|
|||||||
@@ -170,6 +170,7 @@
|
|||||||
<Compile Include="Serialization\ErrorContext.cs" />
|
<Compile Include="Serialization\ErrorContext.cs" />
|
||||||
<Compile Include="Serialization\ErrorEventArgs.cs" />
|
<Compile Include="Serialization\ErrorEventArgs.cs" />
|
||||||
<Compile Include="Serialization\ExpressionValueProvider.cs" />
|
<Compile Include="Serialization\ExpressionValueProvider.cs" />
|
||||||
|
<Compile Include="Serialization\IAttributeProvider.cs" />
|
||||||
<Compile Include="Serialization\IContractResolver.cs" />
|
<Compile Include="Serialization\IContractResolver.cs" />
|
||||||
<Compile Include="Serialization\IReferenceResolver.cs" />
|
<Compile Include="Serialization\IReferenceResolver.cs" />
|
||||||
<Compile Include="Serialization\ITraceWriter.cs" />
|
<Compile Include="Serialization\ITraceWriter.cs" />
|
||||||
@@ -195,6 +196,7 @@
|
|||||||
<Compile Include="Serialization\MemoryTraceWriter.cs" />
|
<Compile Include="Serialization\MemoryTraceWriter.cs" />
|
||||||
<Compile Include="Serialization\ObjectConstructor.cs" />
|
<Compile Include="Serialization\ObjectConstructor.cs" />
|
||||||
<Compile Include="Serialization\OnErrorAttribute.cs" />
|
<Compile Include="Serialization\OnErrorAttribute.cs" />
|
||||||
|
<Compile Include="Serialization\ReflectionAttributeProvider.cs" />
|
||||||
<Compile Include="Serialization\ReflectionValueProvider.cs" />
|
<Compile Include="Serialization\ReflectionValueProvider.cs" />
|
||||||
<Compile Include="Serialization\TraceJsonReader.cs" />
|
<Compile Include="Serialization\TraceJsonReader.cs" />
|
||||||
<Compile Include="Serialization\TraceJsonWriter.cs" />
|
<Compile Include="Serialization\TraceJsonWriter.cs" />
|
||||||
|
|||||||
@@ -91,6 +91,6 @@ using System.Security;
|
|||||||
// You can specify all the values or you can default the Revision and Build Numbers
|
// You can specify all the values or you can default the Revision and Build Numbers
|
||||||
// by using the '*' as shown below:
|
// by using the '*' as shown below:
|
||||||
|
|
||||||
[assembly: AssemblyVersion("6.0.0.0")]
|
[assembly: AssemblyVersion("7.0.0.0")]
|
||||||
[assembly: AssemblyFileVersion("6.0.7.18023")]
|
[assembly: AssemblyFileVersion("7.0.1.18023")]
|
||||||
[assembly: CLSCompliant(true)]
|
[assembly: CLSCompliant(true)]
|
||||||
|
|||||||
@@ -640,6 +640,7 @@ namespace Newtonsoft.Json.Serialization
|
|||||||
{
|
{
|
||||||
JsonProperty property = new JsonProperty();
|
JsonProperty property = new JsonProperty();
|
||||||
property.PropertyType = parameterInfo.ParameterType;
|
property.PropertyType = parameterInfo.ParameterType;
|
||||||
|
property.AttributeProvider = new ReflectionAttributeProvider(parameterInfo);
|
||||||
|
|
||||||
bool allowNonPublicAccess;
|
bool allowNonPublicAccess;
|
||||||
SetPropertySettingsFromAttributes(property, parameterInfo, parameterInfo.Name, parameterInfo.Member.DeclaringType, MemberSerialization.OptOut, out allowNonPublicAccess);
|
SetPropertySettingsFromAttributes(property, parameterInfo, parameterInfo.Name, parameterInfo.Member.DeclaringType, MemberSerialization.OptOut, out allowNonPublicAccess);
|
||||||
@@ -1167,6 +1168,7 @@ namespace Newtonsoft.Json.Serialization
|
|||||||
property.PropertyType = ReflectionUtils.GetMemberUnderlyingType(member);
|
property.PropertyType = ReflectionUtils.GetMemberUnderlyingType(member);
|
||||||
property.DeclaringType = member.DeclaringType;
|
property.DeclaringType = member.DeclaringType;
|
||||||
property.ValueProvider = CreateMemberValueProvider(member);
|
property.ValueProvider = CreateMemberValueProvider(member);
|
||||||
|
property.AttributeProvider = new ReflectionAttributeProvider(member);
|
||||||
|
|
||||||
bool allowNonPublicAccess;
|
bool allowNonPublicAccess;
|
||||||
SetPropertySettingsFromAttributes(property, member, member.Name, member.DeclaringType, memberSerialization, out allowNonPublicAccess);
|
SetPropertySettingsFromAttributes(property, member, member.Name, member.DeclaringType, memberSerialization, out allowNonPublicAccess);
|
||||||
|
|||||||
@@ -0,0 +1,51 @@
|
|||||||
|
#region License
|
||||||
|
// Copyright (c) 2007 James Newton-King
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person
|
||||||
|
// obtaining a copy of this software and associated documentation
|
||||||
|
// files (the "Software"), to deal in the Software without
|
||||||
|
// restriction, including without limitation the rights to use,
|
||||||
|
// copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the
|
||||||
|
// Software is furnished to do so, subject to the following
|
||||||
|
// conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be
|
||||||
|
// included in all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||||
|
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||||
|
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
// OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace Newtonsoft.Json.Serialization
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Provides methods to get attributes.
|
||||||
|
/// </summary>
|
||||||
|
public interface IAttributeProvider
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Returns a collection of all of the attributes, or an empty collection if there are no attributes.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="inherit">When true, look up the hierarchy chain for the inherited custom attribute.</param>
|
||||||
|
/// <returns>A collection of <see cref="Attribute"/>s, or an empty collection.</returns>
|
||||||
|
IList<Attribute> GetAttributes(bool inherit);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns a collection of attributes, identified by type, or an empty collection if there are no attributes.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="attributeType">The type of the attributes.</param>
|
||||||
|
/// <param name="inherit">When true, look up the hierarchy chain for the inherited custom attribute.</param>
|
||||||
|
/// <returns>A collection of <see cref="Attribute"/>s, or an empty collection.</returns>
|
||||||
|
IList<Attribute> GetAttributes(Type attributeType, bool inherit);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -24,6 +24,7 @@
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Reflection;
|
||||||
using Newtonsoft.Json.Utilities;
|
using Newtonsoft.Json.Utilities;
|
||||||
|
|
||||||
#if NET20
|
#if NET20
|
||||||
@@ -87,6 +88,12 @@ namespace Newtonsoft.Json.Serialization
|
|||||||
/// <value>The <see cref="IValueProvider"/> that will get and set the <see cref="JsonProperty"/> during serialization.</value>
|
/// <value>The <see cref="IValueProvider"/> that will get and set the <see cref="JsonProperty"/> during serialization.</value>
|
||||||
public IValueProvider ValueProvider { get; set; }
|
public IValueProvider ValueProvider { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the <see cref="IAttributeProvider"/> for this property.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The <see cref="IAttributeProvider"/> for this property.</value>
|
||||||
|
public IAttributeProvider AttributeProvider { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the type of the property.
|
/// Gets or sets the type of the property.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -0,0 +1,70 @@
|
|||||||
|
#region License
|
||||||
|
// Copyright (c) 2007 James Newton-King
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person
|
||||||
|
// obtaining a copy of this software and associated documentation
|
||||||
|
// files (the "Software"), to deal in the Software without
|
||||||
|
// restriction, including without limitation the rights to use,
|
||||||
|
// copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the
|
||||||
|
// Software is furnished to do so, subject to the following
|
||||||
|
// conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be
|
||||||
|
// included in all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||||
|
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||||
|
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
// OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Reflection;
|
||||||
|
using Newtonsoft.Json.Utilities;
|
||||||
|
|
||||||
|
namespace Newtonsoft.Json.Serialization
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Provides methods to get attributes from a <see cref="Type"/>, <see cref="MemberInfo"/>, <see cref="ParameterInfo"/> or <see cref="Assembly"/>.
|
||||||
|
/// </summary>
|
||||||
|
public class ReflectionAttributeProvider : IAttributeProvider
|
||||||
|
{
|
||||||
|
private readonly object _attributeProvider;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="ReflectionAttributeProvider"/> class.
|
||||||
|
/// </summary>
|
||||||
|
public ReflectionAttributeProvider(object attributeProvider)
|
||||||
|
{
|
||||||
|
ValidationUtils.ArgumentNotNull(attributeProvider, "attributeProvider");
|
||||||
|
_attributeProvider = attributeProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns a collection of all of the attributes, or an empty collection if there are no attributes.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="inherit">When true, look up the hierarchy chain for the inherited custom attribute.</param>
|
||||||
|
/// <returns>A collection of <see cref="Attribute"/>s, or an empty collection.</returns>
|
||||||
|
public IList<Attribute> GetAttributes(bool inherit)
|
||||||
|
{
|
||||||
|
return ReflectionUtils.GetAttributes(_attributeProvider, null, inherit);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns a collection of attributes, identified by type, or an empty collection if there are no attributes.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="attributeType">The type of the attributes.</param>
|
||||||
|
/// <param name="inherit">When true, look up the hierarchy chain for the inherited custom attribute.</param>
|
||||||
|
/// <returns>A collection of <see cref="Attribute"/>s, or an empty collection.</returns>
|
||||||
|
public IList<Attribute> GetAttributes(Type attributeType, bool inherit)
|
||||||
|
{
|
||||||
|
return ReflectionUtils.GetAttributes(_attributeProvider, attributeType, inherit);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -683,24 +683,43 @@ namespace Newtonsoft.Json.Utilities
|
|||||||
// ICustomAttributeProvider doesn't do inheritance
|
// ICustomAttributeProvider doesn't do inheritance
|
||||||
|
|
||||||
if (provider is Type)
|
if (provider is Type)
|
||||||
return (Attribute[])((Type)provider).GetCustomAttributes(attributeType, inherit);
|
{
|
||||||
|
Type t = (Type)provider;
|
||||||
|
object[] attributes = (attributeType != null) ? t.GetCustomAttributes(attributeType, inherit) : t.GetCustomAttributes(inherit);
|
||||||
|
return (Attribute[])attributes;
|
||||||
|
}
|
||||||
|
|
||||||
if (provider is Assembly)
|
if (provider is Assembly)
|
||||||
return Attribute.GetCustomAttributes((Assembly)provider, attributeType);
|
{
|
||||||
|
Assembly a = (Assembly)provider;
|
||||||
|
return (attributeType != null) ? Attribute.GetCustomAttributes(a, attributeType) : Attribute.GetCustomAttributes(a);
|
||||||
|
}
|
||||||
|
|
||||||
if (provider is MemberInfo)
|
if (provider is MemberInfo)
|
||||||
return Attribute.GetCustomAttributes((MemberInfo)provider, attributeType, inherit);
|
{
|
||||||
|
MemberInfo m = (MemberInfo)provider;
|
||||||
|
return (attributeType != null) ? Attribute.GetCustomAttributes(m, attributeType, inherit) : Attribute.GetCustomAttributes(m, inherit);
|
||||||
|
}
|
||||||
|
|
||||||
#if !PORTABLE40
|
#if !PORTABLE40
|
||||||
if (provider is Module)
|
if (provider is Module)
|
||||||
return Attribute.GetCustomAttributes((Module)provider, attributeType, inherit);
|
{
|
||||||
|
Module m = (Module)provider;
|
||||||
|
return (attributeType != null) ? Attribute.GetCustomAttributes(m, attributeType, inherit) : Attribute.GetCustomAttributes(m, inherit);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (provider is ParameterInfo)
|
if (provider is ParameterInfo)
|
||||||
return Attribute.GetCustomAttributes((ParameterInfo)provider, attributeType, inherit);
|
{
|
||||||
|
ParameterInfo p = (ParameterInfo)provider;
|
||||||
|
return (attributeType != null) ? Attribute.GetCustomAttributes(p, attributeType, inherit) : Attribute.GetCustomAttributes(p, inherit);
|
||||||
|
}
|
||||||
|
|
||||||
#if !PORTABLE40
|
#if !PORTABLE40
|
||||||
return (Attribute[])((ICustomAttributeProvider)attributeProvider).GetCustomAttributes(attributeType, inherit);
|
ICustomAttributeProvider customAttributeProvider = (ICustomAttributeProvider)attributeProvider;
|
||||||
|
object[] result = (attributeType != null) ? customAttributeProvider.GetCustomAttributes(attributeType, inherit) : customAttributeProvider.GetCustomAttributes(inherit);
|
||||||
|
|
||||||
|
return (Attribute[])result;
|
||||||
#else
|
#else
|
||||||
throw new Exception("Cannot get attributes from '{0}'.".FormatWith(CultureInfo.InvariantCulture, provider));
|
throw new Exception("Cannot get attributes from '{0}'.".FormatWith(CultureInfo.InvariantCulture, provider));
|
||||||
#endif
|
#endif
|
||||||
@@ -714,19 +733,36 @@ namespace Newtonsoft.Json.Utilities
|
|||||||
public static Attribute[] GetAttributes(object provider, Type attributeType, bool inherit)
|
public static Attribute[] GetAttributes(object provider, Type attributeType, bool inherit)
|
||||||
{
|
{
|
||||||
if (provider is Type)
|
if (provider is Type)
|
||||||
return ((Type) provider).GetTypeInfo().GetCustomAttributes(attributeType, inherit).ToArray();
|
{
|
||||||
|
Type t = (Type)provider;
|
||||||
|
return (attributeType != null)
|
||||||
|
? t.GetTypeInfo().GetCustomAttributes(attributeType, inherit).ToArray()
|
||||||
|
: t.GetTypeInfo().GetCustomAttributes(inherit).ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
if (provider is Assembly)
|
if (provider is Assembly)
|
||||||
return ((Assembly) provider).GetCustomAttributes(attributeType).ToArray();
|
{
|
||||||
|
Assembly a = (Assembly)provider;
|
||||||
|
return (attributeType != null) ? a.GetCustomAttributes(attributeType).ToArray() : a.GetCustomAttributes().ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
if (provider is MemberInfo)
|
if (provider is MemberInfo)
|
||||||
return ((MemberInfo) provider).GetCustomAttributes(attributeType, inherit).ToArray();
|
{
|
||||||
|
MemberInfo m = (MemberInfo)provider;
|
||||||
|
return (attributeType != null) ? m.GetCustomAttributes(attributeType, inherit).ToArray() : m.GetCustomAttributes(inherit).ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
if (provider is Module)
|
if (provider is Module)
|
||||||
return ((Module) provider).GetCustomAttributes(attributeType).ToArray();
|
{
|
||||||
|
Module m = (Module)provider;
|
||||||
|
return (attributeType != null) ? m.GetCustomAttributes(attributeType).ToArray() : m.GetCustomAttributes().ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
if (provider is ParameterInfo)
|
if (provider is ParameterInfo)
|
||||||
return ((ParameterInfo) provider).GetCustomAttributes(attributeType, inherit).ToArray();
|
{
|
||||||
|
ParameterInfo p = (ParameterInfo)provider;
|
||||||
|
return (attributeType != null) ? p.GetCustomAttributes(attributeType, inherit).ToArray() : p.GetCustomAttributes(inherit).ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
throw new Exception("Cannot get attributes from '{0}'.".FormatWith(CultureInfo.InvariantCulture, provider));
|
throw new Exception("Cannot get attributes from '{0}'.".FormatWith(CultureInfo.InvariantCulture, provider));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user