-Changed StringEnumConverter.AllowIntegerValues to also reject writing enum values with no name

This commit is contained in:
James Newton-King
2017-03-19 16:46:33 +13:00
parent 937b25be20
commit 7673a18e55
16 changed files with 103 additions and 861 deletions
-28
View File
@@ -1,28 +0,0 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.23107.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Newtonsoft.Json.Portable40", "Newtonsoft.Json\Newtonsoft.Json.Portable40.csproj", "{959F7F85-C98B-4876-971A-9036224578E4}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Newtonsoft.Json.Tests.Portable40", "Newtonsoft.Json.Tests\Newtonsoft.Json.Tests.Portable40.csproj", "{3E6E2335-B079-4B5B-A65A-9D586914BCBB}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{959F7F85-C98B-4876-971A-9036224578E4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{959F7F85-C98B-4876-971A-9036224578E4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{959F7F85-C98B-4876-971A-9036224578E4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{959F7F85-C98B-4876-971A-9036224578E4}.Release|Any CPU.Build.0 = Release|Any CPU
{3E6E2335-B079-4B5B-A65A-9D586914BCBB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3E6E2335-B079-4B5B-A65A-9D586914BCBB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3E6E2335-B079-4B5B-A65A-9D586914BCBB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3E6E2335-B079-4B5B-A65A-9D586914BCBB}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
@@ -612,12 +612,21 @@ namespace Newtonsoft.Json.Tests.Converters
{
JsonSerializationException ex = ExceptionAssert.Throws<JsonSerializationException>(() =>
{
JsonConvert.DeserializeObject<StoreColor>("\"1\"", new StringEnumConverter {AllowIntegerValues = false});
JsonConvert.DeserializeObject<StoreColor>("\"1\"", new StringEnumConverter { AllowIntegerValues = false });
});
Assert.AreEqual("Integer string '1' is not allowed.", ex.InnerException.Message);
}
[Test]
public void AllowIntegerValueAndNonNamedValue()
{
ExceptionAssert.Throws<JsonSerializationException>(() =>
{
JsonConvert.SerializeObject((StoreColor)999, new StringEnumConverter { AllowIntegerValues = false });
}, "Integer value 999 is not allowed. Path ''.");
}
public enum EnumWithDifferentCases
{
M,
@@ -1052,7 +1052,7 @@ namespace Newtonsoft.Json.Tests.Converters
[Test]
public void NoRootObject()
{
ExceptionAssert.Throws<JsonSerializationException>(() => { XmlDocument newDoc = (XmlDocument)JsonConvert.DeserializeXmlNode(@"[1]"); }, "XmlNodeConverter can only convert JSON that begins with an object.");
ExceptionAssert.Throws<JsonSerializationException>(() => { XmlDocument newDoc = (XmlDocument)JsonConvert.DeserializeXmlNode(@"[1]"); }, "XmlNodeConverter can only convert JSON that begins with an object. Path '', line 1, position 1.");
}
[Test]
@@ -1,431 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{3E6E2335-B079-4B5B-A65A-9D586914BCBB}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Newtonsoft.Json.Tests</RootNamespace>
<AssemblyName>Newtonsoft.Json.Tests</AssemblyName>
<SccProjectName>
</SccProjectName>
<SccLocalPath>
</SccLocalPath>
<SccAuxPath>
</SccAuxPath>
<SccProvider>
</SccProvider>
<FileUpgradeFlags>
</FileUpgradeFlags>
<OldToolsVersion>3.5</OldToolsVersion>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<SignAssembly>false</SignAssembly>
<AssemblyOriginatorKeyFile>
</AssemblyOriginatorKeyFile>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
<TargetFrameworkProfile>
</TargetFrameworkProfile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\Portable40\</OutputPath>
<IntermediateOutputPath>obj\Debug\Portable40\</IntermediateOutputPath>
<DefineConstants>TRACE;DEBUG;PORTABLE40</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\Portable40\</OutputPath>
<IntermediateOutputPath>obj\Release\Portable40\</IntermediateOutputPath>
<DefineConstants>TRACE;PORTABLE40</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.CSharp" />
<Reference Include="System" />
<Reference Include="System.ComponentModel.DataAnnotations">
</Reference>
<Reference Include="System.Core">
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Data.Entity">
</Reference>
<Reference Include="System.Data.Linq">
</Reference>
<Reference Include="System.Drawing" />
<Reference Include="System.Numerics" />
<Reference Include="System.Runtime.Serialization">
</Reference>
<Reference Include="System.Security" />
<Reference Include="System.ServiceModel">
</Reference>
<Reference Include="System.ServiceModel.Web">
</Reference>
<Reference Include="System.Web" />
<Reference Include="System.Web.Extensions">
</Reference>
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq">
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Bson\BsonWriterTests.cs" />
<Compile Include="Bson\BsonReaderTests.cs" />
<Compile Include="Converters\BinaryConverterTests.cs" />
<Compile Include="Converters\DiscriminatedUnionConverterTests.cs" />
<Compile Include="Converters\ExpandoObjectConverterTests.cs" />
<Compile Include="Converters\KeyValuePairConverterTests.cs" />
<Compile Include="Converters\RegexConverterTests.cs" />
<Compile Include="Converters\DataTableConverterTests.cs" />
<Compile Include="Converters\DataSetConverterTests.cs" />
<Compile Include="Converters\CustomCreationConverterTests.cs" />
<Compile Include="Converters\ObjectIdConverterTests.cs" />
<Compile Include="Converters\StringEnumConverterTests.cs" />
<Compile Include="Converters\VersionConverterTests.cs" />
<Compile Include="FileSystemEntityModel.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>FileSystemEntityModel.edmx</DependentUpon>
</Compile>
<Compile Include="JsonArrayAttributeTests.cs" />
<Compile Include="ExceptionTests.cs" />
<Compile Include="JsonTextReaderTests\ExceptionHandlingTests.cs" />
<Compile Include="JsonTextReaderTests\FloatTests.cs" />
<Compile Include="JsonTextReaderTests\MiscTests.cs" />
<Compile Include="JsonTextReaderTests\ParseTests.cs" />
<Compile Include="JsonTextReaderTests\ReadTests.cs" />
<Compile Include="JsonValidatingReaderTests.cs" />
<Compile Include="Linq\ComponentModel\BindingTests.cs" />
<Compile Include="Linq\ComponentModel\JPropertyDescriptorTests.cs" />
<Compile Include="Linq\DynamicTests.cs" />
<Compile Include="Linq\JRawTests.cs" />
<Compile Include="Linq\JsonPath\JPathExecuteTests.cs" />
<Compile Include="Linq\JsonPath\JPathParseTests.cs" />
<Compile Include="Linq\JsonPath\QueryExpressionTests.cs" />
<Compile Include="Linq\MergeTests.cs" />
<Compile Include="Serialization\CamelCaseNamingStrategyTests.cs" />
<Compile Include="Serialization\ConstructorHandlingTests.cs" />
<Compile Include="Serialization\ContractResolverTests.cs" />
<Compile Include="Serialization\DefaultValueHandlingTests.cs" />
<Compile Include="Serialization\DependencyInjectionTests.cs" />
<Compile Include="Serialization\DynamicConcreteTests.cs" />
<Compile Include="Serialization\DynamicTests.cs" />
<Compile Include="Serialization\ExtensionDataTests.cs" />
<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\ReflectionAttributeProviderTests.cs" />
<Compile Include="Serialization\ShouldSerializeTests.cs" />
<Compile Include="Serialization\SnakeCaseNamingStrategyTests.cs" />
<Compile Include="Serialization\TraceWriterTests.cs" />
<Compile Include="Serialization\WebApiIntegrationTests.cs" />
<Compile Include="Serialization\JsonPropertyCollectionTests.cs" />
<Compile Include="Serialization\NullValueHandlingTests.cs" />
<Compile Include="TestObjects\Aa.cs" />
<Compile Include="TestObjects\AnswerFilterModel.cs" />
<Compile Include="TestObjects\Antworten.cs" />
<Compile Include="TestObjects\Bar.cs" />
<Compile Include="TestObjects\Bb.cs" />
<Compile Include="TestObjects\Car.cs" />
<Compile Include="TestObjects\Component.cs" />
<Compile Include="TestObjects\Computer.cs" />
<Compile Include="TestObjects\ConsoleWriter.cs" />
<Compile Include="TestObjects\ConstructorReadonlyFields.cs" />
<Compile Include="TestObjects\Container.cs" />
<Compile Include="TestObjects\ContentBaseClass.cs" />
<Compile Include="TestObjects\ContentSubClass.cs" />
<Compile Include="TestObjects\CustomerDataSet.cs" />
<Compile Include="TestObjects\DataContractSerializationAttributesClass.cs" />
<Compile Include="TestObjects\DateTimeWrapper.cs" />
<Compile Include="TestObjects\DecimalTestClass.cs" />
<Compile Include="TestObjects\DerivedSerializationEventTestObject.cs" />
<Compile Include="TestObjects\DirectoryAccount.cs" />
<Compile Include="TestObjects\Events\Event.cs" />
<Compile Include="TestObjects\Events\Event1.cs" />
<Compile Include="TestObjects\Events\EventType.cs" />
<Compile Include="TestObjects\Foo.cs" />
<Compile Include="TestObjects\GameObject.cs" />
<Compile Include="TestObjects\GeoCoding\AddressDetails.cs" />
<Compile Include="TestObjects\GeoCoding\AdministrativeArea.cs" />
<Compile Include="TestObjects\GeoCoding\Country.cs" />
<Compile Include="TestObjects\GeoCoding\GoogleMapGeocoderStructure.cs" />
<Compile Include="TestObjects\GeoCoding\Locality.cs" />
<Compile Include="TestObjects\GeoCoding\Placemark.cs" />
<Compile Include="TestObjects\GeoCoding\Point.cs" />
<Compile Include="TestObjects\GeoCoding\PostalCode.cs" />
<Compile Include="TestObjects\GeoCoding\Status.cs" />
<Compile Include="TestObjects\GeoCoding\SubAdministrativeArea.cs" />
<Compile Include="TestObjects\GeoCoding\Thoroughfare.cs" />
<Compile Include="TestObjects\GeometricForms\Shape.cs" />
<Compile Include="TestObjects\GeometricForms\Tags.cs" />
<Compile Include="TestObjects\HolderClass.cs" />
<Compile Include="TestObjects\IdReferenceResolver.cs" />
<Compile Include="TestObjects\IMyInterface.cs" />
<Compile Include="TestObjects\IntToFloatConverter.cs" />
<Compile Include="TestObjects\IPrivateImplementationA.cs" />
<Compile Include="TestObjects\IPrivateImplementationB.cs" />
<Compile Include="TestObjects\IPrivateOverriddenImplementation.cs" />
<Compile Include="TestObjects\Item.cs" />
<Compile Include="TestObjects\JsonReaderStubWithIsClosed.cs" />
<Compile Include="TestObjects\JsonTextReaderTests\FakeArrayPool.cs" />
<Compile Include="TestObjects\JsonTextReaderTests\SlowStream.cs" />
<Compile Include="TestObjects\JsonTextReaderTests\ToggleReaderError.cs" />
<Compile Include="TestObjects\JsonTextReaderTests\UnmanagedResourceFakingJsonReader.cs" />
<Compile Include="TestObjects\ListOfIds.cs" />
<Compile Include="TestObjects\MetroPropertyNameResolver.cs" />
<Compile Include="TestObjects\MetroStringConverter.cs" />
<Compile Include="TestObjects\Money\Currency.cs" />
<Compile Include="TestObjects\Money\Tags.cs" />
<Compile Include="TestObjects\Movie.cs" />
<Compile Include="TestObjects\MyEnum.cs" />
<Compile Include="TestObjects\MyInterfaceConverter.cs" />
<Compile Include="TestObjects\NameContainer.cs" />
<Compile Include="TestObjects\NameContainerConverter.cs" />
<Compile Include="TestObjects\NullableGuid.cs" />
<Compile Include="TestObjects\Organization\Employee.cs" />
<Compile Include="TestObjects\Organization\IPerson.cs" />
<Compile Include="TestObjects\Organization\Manager.cs" />
<Compile Include="TestObjects\Organization\Person.cs" />
<Compile Include="TestObjects\Organization\PersonPropertyClass.cs" />
<Compile Include="TestObjects\Organization\WagePerson.cs" />
<Compile Include="TestObjects\ParticipantEntity.cs" />
<Compile Include="TestObjects\PersonError.cs" />
<Compile Include="TestObjects\PersonReference.cs" />
<Compile Include="TestObjects\PersonSerializable.cs" />
<Compile Include="TestObjects\PersonWithPrivateConstructor.cs" />
<Compile Include="TestObjects\PocoDataContractSerializationAttributesClass.cs" />
<Compile Include="TestObjects\PrivateConstructorTestClass.cs" />
<Compile Include="TestObjects\PrivateConstructorWithPublicParameterizedConstructorTestClass.cs" />
<Compile Include="TestObjects\Content.cs" />
<Compile Include="TestObjects\DateTimeErrorObjectCollection.cs" />
<Compile Include="Serialization\EntitiesSerializationTests.cs" />
<Compile Include="TestObjects\DictionaryInterfaceClass.cs" />
<Compile Include="TestObjects\InterfacePropertyTestClass.cs" />
<Compile Include="TestObjects\JsonPropertyClass.cs" />
<Compile Include="TestObjects\ListErrorObject.cs" />
<Compile Include="TestObjects\ListErrorObjectCollection.cs" />
<Compile Include="Serialization\MissingMemberHandlingTests.cs" />
<Compile Include="Serialization\PopulateTests.cs" />
<Compile Include="Serialization\SerializationErrorHandlingTests.cs" />
<Compile Include="Serialization\SerializationEventAttributeTests.cs" />
<Compile Include="Schema\ExtensionsTests.cs" />
<Compile Include="Schema\JsonSchemaModelBuilderTests.cs" />
<Compile Include="Schema\JsonSchemaNodeTests.cs" />
<Compile Include="Serialization\CamelCasePropertyNamesContractResolverTests.cs" />
<Compile Include="Serialization\PreserveReferencesHandlingTests.cs" />
<Compile Include="Serialization\TypeNameHandlingTests.cs" />
<Compile Include="TestObjects\ListTestClass.cs" />
<Compile Include="TestObjects\LogEntry.cs" />
<Compile Include="TestObjects\NonRequest.cs" />
<Compile Include="TestObjects\ObjectArrayPropertyTest.cs" />
<Compile Include="TestObjects\PrivateImplementationAClass.cs" />
<Compile Include="TestObjects\PrivateImplementationBClass.cs" />
<Compile Include="TestObjects\PropertyItemConverter.cs" />
<Compile Include="TestObjects\PublicParameterizedConstructorRequiringConverterTestClass.cs" />
<Compile Include="TestObjects\PublicParameterizedConstructorRequiringConverterWithParameterAttributeTestClass.cs" />
<Compile Include="TestObjects\PublicParameterizedConstructorRequiringConverterWithPropertyAttributeTestClass.cs" />
<Compile Include="TestObjects\PublicParameterizedConstructorTestClass.cs" />
<Compile Include="TestObjects\PublicParameterizedConstructorWithNonPropertyParameterTestClass.cs" />
<Compile Include="TestObjects\PublicParameterizedConstructorWithPropertyNameConflict.cs" />
<Compile Include="TestObjects\PublicParameterizedConstructorWithPropertyNameConflictWithAttribute.cs" />
<Compile Include="TestObjects\Ratio.cs" />
<Compile Include="TestObjects\RequiredObject.cs" />
<Compile Include="TestObjects\RoleTransferDirection.cs" />
<Compile Include="TestObjects\RoleTransferOperation.cs" />
<Compile Include="TestObjects\SearchResult.cs" />
<Compile Include="TestObjects\SelectListItem.cs" />
<Compile Include="TestObjects\StructTest.cs" />
<Compile Include="TestObjects\TestComponent.cs" />
<Compile Include="TestObjects\TestComponentSimple.cs" />
<Compile Include="TestObjects\TestObject.cs" />
<Compile Include="TestObjects\TraceWriter.cs" />
<Compile Include="TestObjects\TypeConverterJsonConverter.cs" />
<Compile Include="TestObjects\UriGuidTimeSpanTestClass.cs" />
<Compile Include="TestObjects\PropertyCase.cs" />
<Compile Include="TestObjects\RequestOnly.cs" />
<Compile Include="TestObjects\RoleTransfer.cs" />
<Compile Include="TestObjects\SetOnlyPropertyClass2.cs" />
<Compile Include="TestObjects\SubKlass.cs" />
<Compile Include="TestObjects\SuperKlass.cs" />
<Compile Include="TestObjects\VersionKeyedCollection.cs" />
<Compile Include="TestObjects\AbstractGenericBase.cs" />
<Compile Include="TestObjects\ArgumentConverterPrecedenceClassConverter.cs" />
<Compile Include="TestObjects\BadJsonPropertyClass.cs" />
<Compile Include="TestObjects\CircularReferenceClass.cs" />
<Compile Include="TestObjects\ClassAndMemberConverterClass.cs" />
<Compile Include="TestObjects\ClassConverterPrecedenceClassConverter.cs" />
<Compile Include="TestObjects\ConstructorCaseSensitivityClass.cs" />
<Compile Include="TestObjects\ConverterPrecedenceClass.cs" />
<Compile Include="TestObjects\ConverterPrecedenceClassConverter.cs" />
<Compile Include="TestObjects\CircularReferenceWithIdClass.cs" />
<Compile Include="TestObjects\EmployeeReference.cs" />
<Compile Include="TestObjects\JsonPropertyWithHandlingValues.cs" />
<Compile Include="TestObjects\DefaultValueAttributeTestClass.cs" />
<Compile Include="TestObjects\DoubleClass.cs" />
<Compile Include="TestObjects\GenericImpl.cs" />
<Compile Include="TestObjects\GenericListAndDictionaryInterfaceProperties.cs" />
<Compile Include="TestObjects\GetOnlyPropertyClass.cs" />
<Compile Include="TestObjects\IncompatibleJsonAttributeClass.cs" />
<Compile Include="TestObjects\Invoice.cs" />
<Compile Include="TestObjects\JsonIgnoreAttributeTestClass.cs" />
<Compile Include="TestObjects\MemberConverterPrecedenceClassConverter.cs" />
<Compile Include="TestObjects\MethodExecutorObject.cs" />
<Compile Include="TestObjects\JaggedArray.cs" />
<Compile Include="TestObjects\MyClass.cs" />
<Compile Include="TestObjects\Name.cs" />
<Compile Include="TestObjects\PersonRaw.cs" />
<Compile Include="TestObjects\PhoneNumber.cs" />
<Compile Include="TestObjects\PrivateMembersClass.cs" />
<Compile Include="TestObjects\RequiredMembersClass.cs" />
<Compile Include="TestObjects\SerializationEventTestDictionary.cs" />
<Compile Include="TestObjects\SerializationEventTestList.cs" />
<Compile Include="TestObjects\SerializationEventTestObject.cs" />
<Compile Include="TestObjects\SerializationEventTestObjectWithConstructor.cs" />
<Compile Include="TestObjects\SetOnlyPropertyClass.cs" />
<Compile Include="TestObjects\Article.cs" />
<Compile Include="TestObjects\ArticleCollection.cs" />
<Compile Include="TestObjects\ClassWithArray.cs" />
<Compile Include="TestObjects\ClassWithGuid.cs" />
<Compile Include="TestObjects\ConverableMembers.cs" />
<Compile Include="TestObjects\JsonIgnoreAttributeOnClassTestClass.cs" />
<Compile Include="Linq\JConstructorTests.cs" />
<Compile Include="Linq\JPropertyTests.cs" />
<Compile Include="TestObjects\MemberConverterClass.cs" />
<Compile Include="TestObjects\Product.cs" />
<Compile Include="TestObjects\ProductCollection.cs" />
<Compile Include="TestObjects\ProductShort.cs" />
<Compile Include="TestObjects\Shortie.cs" />
<Compile Include="TestObjects\Store.cs" />
<Compile Include="TestObjects\StoreColor.cs" />
<Compile Include="Schema\JsonSchemaBuilderTests.cs" />
<Compile Include="Schema\JsonSchemaGeneratorTests.cs" />
<Compile Include="Schema\JsonSchemaTests.cs" />
<Compile Include="TestObjects\NullableDateTimeTestClass.cs" />
<Compile Include="TestObjects\DateTimeTestClass.cs" />
<Compile Include="Converters\IsoDateTimeConverterTests.cs" />
<Compile Include="JsonConvertTest.cs" />
<Compile Include="Converters\JavaScriptDateTimeConverterTests.cs" />
<Compile Include="Serialization\JsonSerializerTest.cs" />
<Compile Include="JsonTextWriterTest.cs" />
<Compile Include="Linq\JTokenReaderTest.cs" />
<Compile Include="Linq\JTokenWriterTest.cs" />
<Compile Include="Linq\JArrayTests.cs" />
<Compile Include="Linq\JObjectTests.cs" />
<Compile Include="Linq\JTokenEqualityComparerTests.cs" />
<Compile Include="Linq\JTokenTests.cs" />
<Compile Include="Linq\JValueTests.cs" />
<Compile Include="Linq\LinqToJsonTest.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="TestFixtureBase.cs" />
<Compile Include="Converters\XmlNodeConverterTest.cs" />
<Compile Include="TestObjects\TypeClass.cs" />
<Compile Include="TestObjects\TypedSubHashtable.cs" />
<Compile Include="TestObjects\UserNullable.cs" />
<Compile Include="TestObjects\Widget.cs" />
<Compile Include="TestObjects\Widget1.cs" />
<Compile Include="TestObjects\WidgetId.cs" />
<Compile Include="TestObjects\WidgetId1.cs" />
<Compile Include="TestObjects\WidgetIdJsonConverter.cs" />
<Compile Include="TestObjects\WithEnums.cs" />
<Compile Include="Utilities\DateTimeUtilsTests.cs" />
<Compile Include="Utilities\DynamicReflectionDelegateFactoryTests.cs" />
<Compile Include="Utilities\ExpressionReflectionDelegateFactoryTests.cs" />
<Compile Include="Utilities\LateboundReflectionDelegateFactoryTests.cs" />
<Compile Include="Utilities\ReflectionUtilsTests.cs" />
<Compile Include="Utilities\StringUtilsTests.cs" />
</ItemGroup>
<ItemGroup>
<Service Include="{3259AA49-8AA1-44D3-9025-A0B520596A8C}" />
</ItemGroup>
<ItemGroup>
<EntityDeploy Include="FileSystemEntityModel.edmx">
<Generator>EntityModelCodeGenerator</Generator>
<LastGenOutput>FileSystemEntityModel.Designer.cs</LastGenOutput>
</EntityDeploy>
</ItemGroup>
<ItemGroup>
<Content Include="bunny_pancake.jpg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="large_sample.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="PoisonText.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
<Visible>False</Visible>
<ProductName>Windows Installer 3.1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Newtonsoft.Json\Newtonsoft.Json.Portable40.csproj">
<Project>{959f7f85-c98b-4876-971a-9036224578e4}</Project>
<Name>Newtonsoft.Json.Portable40</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Content Include="SpaceShipV2.bson">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<Content Include="large.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<None Include="Newtonsoft.Json.Tests.Portable40.project.json" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
@@ -1,12 +0,0 @@
{
"dependencies": {
"FSharp.Core": "4.0.0.1",
"NUnit": "2.6.2"
},
"frameworks": {
"net40": {}
},
"runtimes": {
"win": {}
}
}
@@ -18,6 +18,7 @@
<DebugType Condition="'$(TargetFramework)' != '' AND '$(TargetFramework)' != 'netcoreapp1.0'">Full</DebugType>
</PropertyGroup>
<ItemGroup>
<None Remove="**\*.orig" />
<Compile Condition="'$(TargetFramework)' != '' AND '$(TargetFramework)' != 'net45'" Remove="Benchmarks\**" />
<None Include="large.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
@@ -95,6 +95,11 @@ namespace Newtonsoft.Json.Converters
if (char.IsNumber(enumName[0]) || enumName[0] == '-')
{
if (!AllowIntegerValues)
{
throw JsonSerializationException.Create(null, writer.ContainerPath, "Integer value {0} is not allowed.".FormatWith(CultureInfo.InvariantCulture, enumName), null);
}
// enum value has no name so write number
writer.WriteValue(value);
}
@@ -1617,7 +1617,7 @@ namespace Newtonsoft.Json.Converters
case JsonToken.StartObject:
break;
default:
throw new JsonSerializationException("XmlNodeConverter can only convert JSON that begins with an object.");
throw JsonSerializationException.Create(reader, "XmlNodeConverter can only convert JSON that begins with an object.");
}
XmlNamespaceManager manager = new XmlNamespaceManager(new NameTable());
@@ -1629,7 +1629,7 @@ namespace Newtonsoft.Json.Converters
{
if (objectType != typeof(XDocument) && objectType != typeof(XElement))
{
throw new JsonSerializationException("XmlNodeConverter only supports deserializing XDocument or XElement.");
throw JsonSerializationException.Create(reader, "XmlNodeConverter only supports deserializing XDocument or XElement.");
}
XDocument d = new XDocument();
@@ -1642,7 +1642,7 @@ namespace Newtonsoft.Json.Converters
{
if (objectType != typeof(XmlDocument))
{
throw new JsonSerializationException("XmlNodeConverter only supports deserializing XmlDocuments");
throw JsonSerializationException.Create(reader, "XmlNodeConverter only supports deserializing XmlDocuments");
}
XmlDocument d = new XmlDocument();
@@ -1656,9 +1656,9 @@ namespace Newtonsoft.Json.Converters
}
#endif
if (document == null || rootNode == null)
if (document == null || rootNode == null)
{
throw new JsonSerializationException("Unexpected type when converting XML: " + objectType);
throw JsonSerializationException.Create(reader, "Unexpected type when converting XML: " + objectType);
}
if (!string.IsNullOrEmpty(DeserializeRootElementName))
+1 -1
View File
@@ -130,7 +130,7 @@ namespace Newtonsoft.Json.Linq
return writer.WriteValueAsync((Uri)_value, cancellationToken);
}
throw MiscellaneousUtils.CreateArgumentOutOfRangeException("TokenType", _valueType, "Unexpected token type.");
throw MiscellaneousUtils.CreateArgumentOutOfRangeException(nameof(Type), _valueType, "Unexpected token type.");
}
}
}
@@ -1,270 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{959F7F85-C98B-4876-971A-9036224578E4}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Newtonsoft.Json</RootNamespace>
<AssemblyName>Newtonsoft.Json</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Profile328</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<MinimumVisualStudioVersion>10.0</MinimumVisualStudioVersion>
<FileUpgradeFlags>
</FileUpgradeFlags>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<OldToolsVersion>4.0</OldToolsVersion>
<DefineConstants>PORTABLE40;HAVE_CHAR_TO_LOWER_WITH_CULTURE;HAVE_DATA_CONTRACTS;HAVE_DATE_TIME_OFFSET;HAVE_DB_NULL_TYPE_CODE;HAVE_FSHARP_TYPES;HAVE_FULL_REFLECTION;HAVE_GUID_TRY_PARSE;HAVE_ICONVERTIBLE;HAVE_IGNORE_DATA_MEMBER_ATTRIBUTE;HAVE_IMMUTABLE_COLLECTIONS;HAVE_ISET;HAVE_LINQ;HAVE_MEMORY_BARRIER;HAVE_SECURITY_SAFE_CRITICAL_ATTRIBUTE;HAVE_SERIALIZATION_BINDER_BIND_TO_NAME;HAVE_STRING_JOIN_WITH_ENUMERABLE;HAVE_TIME_SPAN_PARSE_WITH_CULTURE;HAVE_TIME_SPAN_TO_STRING_WITH_CULTURE;HAVE_TIME_ZONE_INFO;HAVE_VARIANT_TYPE_PARAMETERS;HAVE_VERSION_TRY_PARSE</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\Portable40\</OutputPath>
<IntermediateOutputPath>obj\Debug\Portable40\</IntermediateOutputPath>
<DefineConstants>TRACE;DEBUG;CODE_ANALYSIS;$(DefineConstants);$(AdditionalConstants)</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<RunCodeAnalysis>true</RunCodeAnalysis>
<CodeAnalysisRuleSet>Newtonsoft.Json.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\Portable40\</OutputPath>
<IntermediateOutputPath>obj\Release\Portable40\</IntermediateOutputPath>
<DefineConstants>TRACE;CODE_ANALYSIS;$(DefineConstants);$(AdditionalConstants)</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Release\Portable40\Newtonsoft.Json.xml</DocumentationFile>
<RunCodeAnalysis>true</RunCodeAnalysis>
<CodeAnalysisRuleSet>Newtonsoft.Json.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Bson\BsonBinaryType.cs" />
<Compile Include="Bson\BsonBinaryWriter.cs" />
<Compile Include="Bson\BsonObjectId.cs" />
<Compile Include="Bson\BsonReader.cs" />
<Compile Include="Bson\BsonToken.cs" />
<Compile Include="Bson\BsonType.cs" />
<Compile Include="Bson\BsonWriter.cs" />
<Compile Include="ConstructorHandling.cs" />
<Compile Include="Converters\BinaryConverter.cs" />
<Compile Include="Converters\BsonObjectIdConverter.cs" />
<Compile Include="Converters\CustomCreationConverter.cs" />
<Compile Include="Converters\DataSetConverter.cs" />
<Compile Include="Converters\DataTableConverter.cs" />
<Compile Include="Converters\DateTimeConverterBase.cs" />
<Compile Include="Converters\DiscriminatedUnionConverter.cs" />
<Compile Include="Converters\EntityKeyMemberConverter.cs" />
<Compile Include="Converters\ExpandoObjectConverter.cs" />
<Compile Include="Converters\IsoDateTimeConverter.cs" />
<Compile Include="Converters\JavaScriptDateTimeConverter.cs" />
<Compile Include="Converters\KeyValuePairConverter.cs" />
<Compile Include="Converters\RegexConverter.cs" />
<Compile Include="Converters\StringEnumConverter.cs" />
<Compile Include="Converters\VersionConverter.cs" />
<Compile Include="Converters\XmlNodeConverter.cs" />
<Compile Include="DateFormatHandling.cs" />
<Compile Include="DateParseHandling.cs" />
<Compile Include="DateTimeZoneHandling.cs" />
<Compile Include="DefaultValueHandling.cs" />
<Compile Include="FloatFormatHandling.cs" />
<Compile Include="FloatParseHandling.cs" />
<Compile Include="FormatterAssemblyStyle.cs" />
<Compile Include="Formatting.cs" />
<Compile Include="IArrayPool.cs" />
<Compile Include="IJsonLineInfo.cs" />
<Compile Include="JsonArrayAttribute.cs" />
<Compile Include="JsonConstructorAttribute.cs" />
<Compile Include="JsonContainerAttribute.cs" />
<Compile Include="JsonConvert.cs" />
<Compile Include="JsonConverter.cs" />
<Compile Include="JsonConverterAttribute.cs" />
<Compile Include="JsonConverterCollection.cs" />
<Compile Include="JsonDictionaryAttribute.cs" />
<Compile Include="JsonException.cs" />
<Compile Include="JsonExtensionDataAttribute.cs" />
<Compile Include="JsonIgnoreAttribute.cs" />
<Compile Include="JsonObjectAttribute.cs" />
<Compile Include="JsonPosition.cs" />
<Compile Include="JsonPropertyAttribute.cs" />
<Compile Include="JsonReader.cs" />
<Compile Include="JsonReaderException.cs" />
<Compile Include="JsonRequiredAttribute.cs" />
<Compile Include="JsonSerializationException.cs" />
<Compile Include="JsonSerializer.cs" />
<Compile Include="JsonSerializerSettings.cs" />
<Compile Include="JsonTextReader.cs" />
<Compile Include="JsonTextWriter.cs" />
<Compile Include="JsonToken.cs" />
<Compile Include="JsonValidatingReader.cs" />
<Compile Include="JsonWriter.cs" />
<Compile Include="JsonWriterException.cs" />
<Compile Include="Linq\CommentHandling.cs" />
<Compile Include="Linq\Extensions.cs" />
<Compile Include="Linq\IJEnumerable.cs" />
<Compile Include="Linq\JArray.cs" />
<Compile Include="Linq\JConstructor.cs" />
<Compile Include="Linq\JContainer.cs" />
<Compile Include="Linq\JEnumerable.cs" />
<Compile Include="Linq\JObject.cs" />
<Compile Include="Linq\JProperty.cs" />
<Compile Include="Linq\JPropertyDescriptor.cs" />
<Compile Include="Linq\JPropertyKeyedCollection.cs" />
<Compile Include="Linq\JRaw.cs" />
<Compile Include="Linq\JsonLoadSettings.cs" />
<Compile Include="Linq\JsonMergeSettings.cs" />
<Compile Include="Linq\JsonPath\ArrayIndexFilter.cs" />
<Compile Include="Linq\JsonPath\ArrayMultipleIndexFilter.cs" />
<Compile Include="Linq\JsonPath\ArraySliceFilter.cs" />
<Compile Include="Linq\JsonPath\FieldFilter.cs" />
<Compile Include="Linq\JsonPath\FieldMultipleFilter.cs" />
<Compile Include="Linq\JsonPath\JPath.cs" />
<Compile Include="Linq\JsonPath\PathFilter.cs" />
<Compile Include="Linq\JsonPath\QueryExpression.cs" />
<Compile Include="Linq\JsonPath\QueryFilter.cs" />
<Compile Include="Linq\JsonPath\RootFilter.cs" />
<Compile Include="Linq\JsonPath\ScanFilter.cs" />
<Compile Include="Linq\JsonPath\ScanMultipleFilter.cs" />
<Compile Include="Linq\JToken.cs" />
<Compile Include="Linq\JTokenEqualityComparer.cs" />
<Compile Include="Linq\JTokenReader.cs" />
<Compile Include="Linq\JTokenType.cs" />
<Compile Include="Linq\JTokenWriter.cs" />
<Compile Include="Linq\JValue.cs" />
<Compile Include="Linq\MergeArrayHandling.cs" />
<Compile Include="Linq\MergeNullValueHandling.cs" />
<Compile Include="MemberSerialization.cs" />
<Compile Include="MetadataPropertyHandling.cs" />
<Compile Include="MissingMemberHandling.cs" />
<Compile Include="NullValueHandling.cs" />
<Compile Include="ObjectCreationHandling.cs" />
<Compile Include="PreserveReferencesHandling.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ReferenceLoopHandling.cs" />
<Compile Include="Required.cs" />
<Compile Include="Schema\Extensions.cs" />
<Compile Include="Schema\JsonSchema.cs" />
<Compile Include="Schema\JsonSchemaBuilder.cs" />
<Compile Include="Schema\JsonSchemaConstants.cs" />
<Compile Include="Schema\JsonSchemaException.cs" />
<Compile Include="Schema\JsonSchemaGenerator.cs" />
<Compile Include="Schema\JsonSchemaModel.cs" />
<Compile Include="Schema\JsonSchemaModelBuilder.cs" />
<Compile Include="Schema\JsonSchemaNode.cs" />
<Compile Include="Schema\JsonSchemaNodeCollection.cs" />
<Compile Include="Schema\JsonSchemaResolver.cs" />
<Compile Include="Schema\JsonSchemaType.cs" />
<Compile Include="Schema\JsonSchemaWriter.cs" />
<Compile Include="Schema\UndefinedSchemaIdHandling.cs" />
<Compile Include="Schema\ValidationEventArgs.cs" />
<Compile Include="Schema\ValidationEventHandler.cs" />
<Compile Include="SerializationBinder.cs" />
<Compile Include="Serialization\CachedAttributeGetter.cs" />
<Compile Include="Serialization\CamelCaseNamingStrategy.cs" />
<Compile Include="Serialization\CamelCasePropertyNamesContractResolver.cs" />
<Compile Include="Serialization\DefaultContractResolver.cs" />
<Compile Include="Serialization\DefaultNamingStrategy.cs" />
<Compile Include="Serialization\DefaultReferenceResolver.cs" />
<Compile Include="Serialization\DefaultSerializationBinder.cs" />
<Compile Include="Serialization\DiagnosticsTraceWriter.cs" />
<Compile Include="Serialization\DynamicValueProvider.cs" />
<Compile Include="Serialization\ErrorContext.cs" />
<Compile Include="Serialization\ErrorEventArgs.cs" />
<Compile Include="Serialization\ExpressionValueProvider.cs" />
<Compile Include="Serialization\IAttributeProvider.cs" />
<Compile Include="Serialization\IContractResolver.cs" />
<Compile Include="Serialization\IReferenceResolver.cs" />
<Compile Include="Serialization\ISerializationBinder.cs" />
<Compile Include="Serialization\ITraceWriter.cs" />
<Compile Include="Serialization\IValueProvider.cs" />
<Compile Include="Serialization\JsonArrayContract.cs" />
<Compile Include="Serialization\JsonContainerContract.cs" />
<Compile Include="Serialization\JsonContract.cs" />
<Compile Include="Serialization\JsonDictionaryContract.cs" />
<Compile Include="Serialization\JsonDynamicContract.cs" />
<Compile Include="Serialization\JsonFormatterConverter.cs" />
<Compile Include="Serialization\JsonISerializableContract.cs" />
<Compile Include="Serialization\JsonLinqContract.cs" />
<Compile Include="Serialization\JsonObjectContract.cs" />
<Compile Include="Serialization\JsonPrimitiveContract.cs" />
<Compile Include="Serialization\JsonProperty.cs" />
<Compile Include="Serialization\JsonPropertyCollection.cs" />
<Compile Include="Serialization\JsonSerializerInternalBase.cs" />
<Compile Include="Serialization\JsonSerializerInternalReader.cs" />
<Compile Include="Serialization\JsonSerializerInternalWriter.cs" />
<Compile Include="Serialization\JsonSerializerProxy.cs" />
<Compile Include="Serialization\JsonStringContract.cs" />
<Compile Include="Serialization\JsonTypeReflector.cs" />
<Compile Include="Serialization\MemoryTraceWriter.cs" />
<Compile Include="Serialization\NamingStrategy.cs" />
<Compile Include="Serialization\ObjectConstructor.cs" />
<Compile Include="Serialization\OnErrorAttribute.cs" />
<Compile Include="Serialization\ReflectionAttributeProvider.cs" />
<Compile Include="Serialization\ReflectionValueProvider.cs" />
<Compile Include="Serialization\SerializationBinderAdapter.cs" />
<Compile Include="Serialization\SnakeCaseNamingStrategy.cs" />
<Compile Include="Serialization\TraceJsonReader.cs" />
<Compile Include="Serialization\TraceJsonWriter.cs" />
<Compile Include="StringEscapeHandling.cs" />
<Compile Include="TraceLevel.cs" />
<Compile Include="TypeNameAssemblyFormatHandling.cs" />
<Compile Include="TypeNameHandling.cs" />
<Compile Include="Utilities\Base64Encoder.cs" />
<Compile Include="Utilities\BidirectionalDictionary.cs" />
<Compile Include="Utilities\CollectionUtils.cs" />
<Compile Include="Utilities\CollectionWrapper.cs" />
<Compile Include="Utilities\ConvertUtils.cs" />
<Compile Include="Utilities\DateTimeParser.cs" />
<Compile Include="Utilities\DateTimeUtils.cs" />
<Compile Include="Utilities\DictionaryWrapper.cs" />
<Compile Include="Utilities\DynamicProxy.cs" />
<Compile Include="Utilities\DynamicProxyMetaObject.cs" />
<Compile Include="Utilities\DynamicReflectionDelegateFactory.cs" />
<Compile Include="Utilities\DynamicUtils.cs" />
<Compile Include="Utilities\EnumUtils.cs" />
<Compile Include="Utilities\EnumValue.cs" />
<Compile Include="Utilities\ExpressionReflectionDelegateFactory.cs" />
<Compile Include="Utilities\FSharpUtils.cs" />
<Compile Include="Utilities\ILGeneratorExtensions.cs" />
<Compile Include="Utilities\ImmutableCollectionsUtils.cs" />
<Compile Include="Utilities\JavaScriptUtils.cs" />
<Compile Include="Utilities\JsonTokenUtils.cs" />
<Compile Include="Utilities\LateBoundReflectionDelegateFactory.cs" />
<Compile Include="Utilities\LinqBridge.cs" />
<Compile Include="Utilities\MathUtils.cs" />
<Compile Include="Utilities\MethodBinder.cs" />
<Compile Include="Utilities\MethodCall.cs" />
<Compile Include="Utilities\MiscellaneousUtils.cs" />
<Compile Include="Utilities\PropertyNameTable.cs" />
<Compile Include="Utilities\ReflectionDelegateFactory.cs" />
<Compile Include="Utilities\ReflectionObject.cs" />
<Compile Include="Utilities\ReflectionUtils.cs" />
<Compile Include="Utilities\StringBuffer.cs" />
<Compile Include="Utilities\StringReference.cs" />
<Compile Include="Utilities\StringUtils.cs" />
<Compile Include="Utilities\ThreadSafeStore.cs" />
<Compile Include="Utilities\TypeExtensions.cs" />
<Compile Include="Utilities\ValidationUtils.cs" />
<Compile Include="WriteState.cs" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
@@ -1,8 +0,0 @@
{
"frameworks": {
".NETPortable,Version=v4.0,Profile=Profile328": {}
},
"runtimes": {
"win": {}
}
}
@@ -2,7 +2,6 @@
<PropertyGroup>
<TargetFrameworks Condition="'$(DotnetOnly)'==''">net45;net40;net35;net20;netstandard1.0;netstandard1.3;portable-net45+win8+wpa81+wp8</TargetFrameworks>
<TargetFrameworks Condition="'$(DotnetOnly)'=='true'">netstandard1.0;netstandard1.3</TargetFrameworks>
<!--<TargetFrameworks>net45;net40;net35;net20;netstandard1.0;portable-net45+win8+wpa81+wp8</TargetFrameworks>-->
<VersionPrefix>10.0.1</VersionPrefix>
<VersionSuffix>beta1</VersionSuffix>
<Authors>James Newton-King</Authors>
@@ -2,6 +2,7 @@
using System.Globalization;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using Newtonsoft.Json.Utilities;
#if HAVE_BINARY_SERIALIZATION && !HAVE_BINARY_FORMATTER
@@ -11,154 +12,103 @@ namespace Newtonsoft.Json.Serialization
{
public object Convert(object value, Type type)
{
if (value == null)
{
throw new ArgumentNullException("value");
}
ValidationUtils.ArgumentNotNull(value, nameof(value));
return System.Convert.ChangeType(value, type, CultureInfo.InvariantCulture);
}
public object Convert(object value, TypeCode typeCode)
{
if (value == null)
{
throw new ArgumentNullException("value");
}
ValidationUtils.ArgumentNotNull(value, nameof(value));
return System.Convert.ChangeType(value, typeCode, CultureInfo.InvariantCulture);
}
public bool ToBoolean(object value)
{
if (value == null)
{
throw new ArgumentNullException("value");
}
ValidationUtils.ArgumentNotNull(value, nameof(value));
return System.Convert.ToBoolean(value, CultureInfo.InvariantCulture);
}
public byte ToByte(object value)
{
if (value == null)
{
throw new ArgumentNullException("value");
}
ValidationUtils.ArgumentNotNull(value, nameof(value));
return System.Convert.ToByte(value, CultureInfo.InvariantCulture);
}
public char ToChar(object value)
{
if (value == null)
{
throw new ArgumentNullException("value");
}
ValidationUtils.ArgumentNotNull(value, nameof(value));
return System.Convert.ToChar(value, CultureInfo.InvariantCulture);
}
public DateTime ToDateTime(object value)
{
if (value == null)
{
throw new ArgumentNullException("value");
}
ValidationUtils.ArgumentNotNull(value, nameof(value));
return System.Convert.ToDateTime(value, CultureInfo.InvariantCulture);
}
public decimal ToDecimal(object value)
{
if (value == null)
{
throw new ArgumentNullException("value");
}
ValidationUtils.ArgumentNotNull(value, nameof(value));
return System.Convert.ToDecimal(value, CultureInfo.InvariantCulture);
}
public double ToDouble(object value)
{
if (value == null)
{
throw new ArgumentNullException("value");
}
ValidationUtils.ArgumentNotNull(value, nameof(value));
return System.Convert.ToDouble(value, CultureInfo.InvariantCulture);
}
public short ToInt16(object value)
{
if (value == null)
{
throw new ArgumentNullException("value");
}
ValidationUtils.ArgumentNotNull(value, nameof(value));
return System.Convert.ToInt16(value, CultureInfo.InvariantCulture);
}
public int ToInt32(object value)
{
if (value == null)
{
throw new ArgumentNullException("value");
}
ValidationUtils.ArgumentNotNull(value, nameof(value));
return System.Convert.ToInt32(value, CultureInfo.InvariantCulture);
}
public long ToInt64(object value)
{
if (value == null)
{
throw new ArgumentNullException("value");
}
ValidationUtils.ArgumentNotNull(value, nameof(value));
return System.Convert.ToInt64(value, CultureInfo.InvariantCulture);
}
public sbyte ToSByte(object value)
{
if (value == null)
{
throw new ArgumentNullException("value");
}
ValidationUtils.ArgumentNotNull(value, nameof(value));
return System.Convert.ToSByte(value, CultureInfo.InvariantCulture);
}
public float ToSingle(object value)
{
if (value == null)
{
throw new ArgumentNullException("value");
}
ValidationUtils.ArgumentNotNull(value, nameof(value));
return System.Convert.ToSingle(value, CultureInfo.InvariantCulture);
}
public string ToString(object value)
{
if (value == null)
{
throw new ArgumentNullException("value");
}
ValidationUtils.ArgumentNotNull(value, nameof(value));
return System.Convert.ToString(value, CultureInfo.InvariantCulture);
}
public ushort ToUInt16(object value)
{
if (value == null)
{
throw new ArgumentNullException("value");
}
ValidationUtils.ArgumentNotNull(value, nameof(value));
return System.Convert.ToUInt16(value, CultureInfo.InvariantCulture);
}
public uint ToUInt32(object value)
{
if (value == null)
{
throw new ArgumentNullException("value");
}
ValidationUtils.ArgumentNotNull(value, nameof(value));
return System.Convert.ToUInt32(value, CultureInfo.InvariantCulture);
}
public ulong ToUInt64(object value)
{
if (value == null)
{
throw new ArgumentNullException("value");
}
ValidationUtils.ArgumentNotNull(value, nameof(value));
return System.Convert.ToUInt64(value, CultureInfo.InvariantCulture);
}
}
@@ -1139,7 +1139,7 @@ namespace Newtonsoft.Json.Serialization
}
#if HAVE_DATE_TIME_OFFSET
case PrimitiveTypeCode.DateTimeOffset:
case PrimitiveTypeCode.DateTimeOffsetNullable:
case PrimitiveTypeCode.DateTimeOffsetNullable:
{
escape = false;
StringWriter sw = new StringWriter(CultureInfo.InvariantCulture);
@@ -49,35 +49,35 @@ namespace Newtonsoft.Json.Utilities
public override DynamicMetaObject BindGetMember(GetMemberBinder binder)
{
return IsOverridden("TryGetMember")
? CallMethodWithResult("TryGetMember", binder, NoArgs, e => binder.FallbackGetMember(this, e))
return IsOverridden(nameof(DynamicProxy<T>.TryGetMember))
? CallMethodWithResult(nameof(DynamicProxy<T>.TryGetMember), binder, NoArgs, e => binder.FallbackGetMember(this, e))
: base.BindGetMember(binder);
}
public override DynamicMetaObject BindSetMember(SetMemberBinder binder, DynamicMetaObject value)
{
return IsOverridden("TrySetMember")
? CallMethodReturnLast("TrySetMember", binder, GetArgs(value), e => binder.FallbackSetMember(this, value, e))
return IsOverridden(nameof(DynamicProxy<T>.TrySetMember))
? CallMethodReturnLast(nameof(DynamicProxy<T>.TrySetMember), binder, GetArgs(value), e => binder.FallbackSetMember(this, value, e))
: base.BindSetMember(binder, value);
}
public override DynamicMetaObject BindDeleteMember(DeleteMemberBinder binder)
{
return IsOverridden("TryDeleteMember")
? CallMethodNoResult("TryDeleteMember", binder, NoArgs, e => binder.FallbackDeleteMember(this, e))
return IsOverridden(nameof(DynamicProxy<T>.TryDeleteMember))
? CallMethodNoResult(nameof(DynamicProxy<T>.TryDeleteMember), binder, NoArgs, e => binder.FallbackDeleteMember(this, e))
: base.BindDeleteMember(binder);
}
public override DynamicMetaObject BindConvert(ConvertBinder binder)
{
return IsOverridden("TryConvert")
? CallMethodWithResult("TryConvert", binder, NoArgs, e => binder.FallbackConvert(this, e))
return IsOverridden(nameof(DynamicProxy<T>.TryConvert))
? CallMethodWithResult(nameof(DynamicProxy<T>.TryConvert), binder, NoArgs, e => binder.FallbackConvert(this, e))
: base.BindConvert(binder);
}
public override DynamicMetaObject BindInvokeMember(InvokeMemberBinder binder, DynamicMetaObject[] args)
{
if (!IsOverridden("TryInvokeMember"))
if (!IsOverridden(nameof(DynamicProxy<T>.TryInvokeMember)))
{
return base.BindInvokeMember(binder, args);
}
@@ -101,11 +101,11 @@ namespace Newtonsoft.Json.Utilities
Fallback fallback = e => binder.FallbackInvokeMember(this, args, e);
return BuildCallMethodWithResult(
"TryInvokeMember",
nameof(DynamicProxy<T>.TryInvokeMember),
binder,
GetArgArray(args),
BuildCallMethodWithResult(
"TryGetMember",
nameof(DynamicProxy<T>.TryGetMember),
new GetBinderAdapter(binder),
NoArgs,
fallback(null),
@@ -117,50 +117,50 @@ namespace Newtonsoft.Json.Utilities
public override DynamicMetaObject BindCreateInstance(CreateInstanceBinder binder, DynamicMetaObject[] args)
{
return IsOverridden("TryCreateInstance")
? CallMethodWithResult("TryCreateInstance", binder, GetArgArray(args), e => binder.FallbackCreateInstance(this, args, e))
return IsOverridden(nameof(DynamicProxy<T>.TryCreateInstance))
? CallMethodWithResult(nameof(DynamicProxy<T>.TryCreateInstance), binder, GetArgArray(args), e => binder.FallbackCreateInstance(this, args, e))
: base.BindCreateInstance(binder, args);
}
public override DynamicMetaObject BindInvoke(InvokeBinder binder, DynamicMetaObject[] args)
{
return IsOverridden("TryInvoke")
? CallMethodWithResult("TryInvoke", binder, GetArgArray(args), e => binder.FallbackInvoke(this, args, e))
return IsOverridden(nameof(DynamicProxy<T>.TryInvoke))
? CallMethodWithResult(nameof(DynamicProxy<T>.TryInvoke), binder, GetArgArray(args), e => binder.FallbackInvoke(this, args, e))
: base.BindInvoke(binder, args);
}
public override DynamicMetaObject BindBinaryOperation(BinaryOperationBinder binder, DynamicMetaObject arg)
{
return IsOverridden("TryBinaryOperation")
? CallMethodWithResult("TryBinaryOperation", binder, GetArgs(arg), e => binder.FallbackBinaryOperation(this, arg, e))
return IsOverridden(nameof(DynamicProxy<T>.TryBinaryOperation))
? CallMethodWithResult(nameof(DynamicProxy<T>.TryBinaryOperation), binder, GetArgs(arg), e => binder.FallbackBinaryOperation(this, arg, e))
: base.BindBinaryOperation(binder, arg);
}
public override DynamicMetaObject BindUnaryOperation(UnaryOperationBinder binder)
{
return IsOverridden("TryUnaryOperation")
? CallMethodWithResult("TryUnaryOperation", binder, NoArgs, e => binder.FallbackUnaryOperation(this, e))
return IsOverridden(nameof(DynamicProxy<T>.TryUnaryOperation))
? CallMethodWithResult(nameof(DynamicProxy<T>.TryUnaryOperation), binder, NoArgs, e => binder.FallbackUnaryOperation(this, e))
: base.BindUnaryOperation(binder);
}
public override DynamicMetaObject BindGetIndex(GetIndexBinder binder, DynamicMetaObject[] indexes)
{
return IsOverridden("TryGetIndex")
? CallMethodWithResult("TryGetIndex", binder, GetArgArray(indexes), e => binder.FallbackGetIndex(this, indexes, e))
return IsOverridden(nameof(DynamicProxy<T>.TryGetIndex))
? CallMethodWithResult(nameof(DynamicProxy<T>.TryGetIndex), binder, GetArgArray(indexes), e => binder.FallbackGetIndex(this, indexes, e))
: base.BindGetIndex(binder, indexes);
}
public override DynamicMetaObject BindSetIndex(SetIndexBinder binder, DynamicMetaObject[] indexes, DynamicMetaObject value)
{
return IsOverridden("TrySetIndex")
? CallMethodReturnLast("TrySetIndex", binder, GetArgArray(indexes, value), e => binder.FallbackSetIndex(this, indexes, value, e))
return IsOverridden(nameof(DynamicProxy<T>.TrySetIndex))
? CallMethodReturnLast(nameof(DynamicProxy<T>.TrySetIndex), binder, GetArgArray(indexes, value), e => binder.FallbackSetIndex(this, indexes, value, e))
: base.BindSetIndex(binder, indexes, value);
}
public override DynamicMetaObject BindDeleteIndex(DeleteIndexBinder binder, DynamicMetaObject[] indexes)
{
return IsOverridden("TryDeleteIndex")
? CallMethodNoResult("TryDeleteIndex", binder, GetArgArray(indexes), e => binder.FallbackDeleteIndex(this, indexes, e))
return IsOverridden(nameof(DynamicProxy<T>.TryDeleteIndex))
? CallMethodNoResult(nameof(DynamicProxy<T>.TryDeleteIndex), binder, GetArgArray(indexes), e => binder.FallbackDeleteIndex(this, indexes, e))
: base.BindDeleteIndex(binder, indexes);
}
+36 -9
View File
@@ -1,12 +1,40 @@
namespace Newtonsoft.Json.Utilities
#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;
#if !HAVE_LINQ
using Newtonsoft.Json.Utilities.LinqBridge;
#else
using System.Linq;
#endif
using System.Reflection;
namespace Newtonsoft.Json.Utilities
{
#if PORTABLE
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
internal static class MethodBinder
{
@@ -314,6 +342,5 @@
}
}
#endif
}
}