From 88eeb8ba924f533a8dde4c473c527e03a88ea2d0 Mon Sep 17 00:00:00 2001 From: James Newton-King Date: Sat, 18 Oct 2014 00:00:26 +1300 Subject: [PATCH] -Fixed MetadataTypeAttribute reflection bug by using CustomAttributeData -Fixed immutable collections bug by getting type from known assembly -Added support from running tests on aspnetcore50 --- .../Bson/BsonReaderTests.cs | 14 +- .../Bson/BsonWriterTests.cs | 14 +- .../Converters/BinaryConverterTests.cs | 18 ++- .../CustomCreationConverterTests.cs | 11 +- .../Converters/DataSetConverterTests.cs | 12 +- .../Converters/DataTableConverterTests.cs | 20 ++- .../DiscriminatedUnionConverterTests.cs | 2 +- .../Converters/ExpandoObjectConverterTests.cs | 18 +-- .../Converters/IsoDateTimeConverterTests.cs | 12 +- .../JavaScriptDateTimeConverterTests.cs | 10 +- .../Converters/KeyValuePairConverterTests.cs | 10 +- .../Converters/ObjectIdConverterTests.cs | 11 +- .../Converters/RegexConverterTests.cs | 16 +- .../Converters/StringEnumConverterTests.cs | 10 +- .../Converters/VersionConverterTests.cs | 11 +- .../Converters/XmlNodeConverterTest.cs | 12 +- Src/Newtonsoft.Json.Tests/DemoTests.cs | 10 +- .../ConditionalPropertiesTests.cs | 12 +- .../ConvertingJsonAndXmlTests.cs | 12 +- .../Documentation/JsonSchemaTests.cs | 12 +- .../Documentation/LinqToJsonTests.cs | 12 +- .../Documentation/PerformanceTests.cs | 12 +- .../ReadingAndWritingJsonTests.cs | 12 +- .../Samples/Serializer/DeserializeDataSet.cs | 1 - .../Samples/Serializer/SerializeDataSet.cs | 2 - .../Documentation/SerializationTests.cs | 12 +- .../Documentation/TraceWriterTests.cs | 12 +- Src/Newtonsoft.Json.Tests/ExceptionTests.cs | 11 +- .../JsonArrayAttributeTests.cs | 10 +- Src/Newtonsoft.Json.Tests/JsonConvertTest.cs | 17 +- .../JsonTextReaderTest.cs | 34 ++-- .../JsonTextWriterTest.cs | 17 +- .../JsonValidatingReaderTests.cs | 16 +- .../Linq/ComponentModel/BindingTests.cs | 2 +- .../JPropertyDescriptorTests.cs | 2 +- .../Linq/DynamicTests.cs | 36 +++-- Src/Newtonsoft.Json.Tests/Linq/JArrayTests.cs | 12 +- .../Linq/JConstructorTests.cs | 10 +- .../Linq/JObjectTests.cs | 22 +-- .../Linq/JPropertyTests.cs | 12 +- Src/Newtonsoft.Json.Tests/Linq/JRawTests.cs | 11 +- .../Linq/JTokenEqualityComparerTests.cs | 10 +- .../Linq/JTokenReaderTest.cs | 10 +- Src/Newtonsoft.Json.Tests/Linq/JTokenTests.cs | 22 +-- .../Linq/JTokenWriterTest.cs | 14 +- Src/Newtonsoft.Json.Tests/Linq/JValueTests.cs | 30 ++-- .../Linq/JsonPath/JPathExecuteTests.cs | 12 +- .../Linq/JsonPath/JPathParseTests.cs | 10 +- .../Linq/JsonPath/QueryExpressionTests.cs | 37 ++++- .../Linq/LinqToJsonTest.cs | 10 +- Src/Newtonsoft.Json.Tests/Linq/MergeTests.cs | 37 ++++- .../LinqToSqlClassesSerializationTests.cs | 4 +- Src/Newtonsoft.Json.Tests/PerformanceTests.cs | 4 +- .../Schema/ExtensionsTests.cs | 17 +- .../Schema/JsonSchemaBuilderTests.cs | 10 +- .../Schema/JsonSchemaGeneratorTests.cs | 27 ++-- .../Schema/JsonSchemaModelBuilderTests.cs | 11 +- .../Schema/JsonSchemaNodeTests.cs | 11 +- .../Schema/JsonSchemaSpecTests.cs | 31 +++- .../Schema/JsonSchemaTests.cs | 11 +- ...lCasePropertyNamesContractResolverTests.cs | 12 +- .../Serialization/ConstructorHandlingTests.cs | 11 +- .../Serialization/ContractResolverTests.cs | 12 +- .../DefaultValueHandlingTests.cs | 10 +- .../Serialization/DependencyInjectionTests.cs | 12 +- .../Serialization/DynamicConcreteTests.cs | 14 +- .../Serialization/DynamicTests.cs | 11 +- .../EntitiesSerializationTests.cs | 13 +- .../Serialization/ExtensionDataTests.cs | 10 +- .../Serialization/FSharpTests.cs | 4 +- .../ImmutableCollectionsTests.cs | 17 +- .../JsonPropertyCollectionTests.cs | 10 +- .../JsonSerializerCollectionsTests.cs | 16 +- .../Serialization/JsonSerializerTest.cs | 110 ++++++------- .../MetadataPropertyHandlingTests.cs | 12 +- .../MissingMemberHandlingTests.cs | 11 +- .../Serialization/NullValueHandlingTests.cs | 11 +- .../Serialization/PopulateTests.cs | 11 +- .../PreserveReferencesHandlingTests.cs | 13 +- .../ReferenceLoopHandlingTests.cs | 12 +- .../SerializationErrorHandlingTests.cs | 10 +- .../SerializationEventAttributeTests.cs | 14 +- .../Serialization/ShouldSerializeTests.cs | 10 +- .../Serialization/TraceWriterTests.cs | 18 ++- .../Serialization/TypeNameHandlingTests.cs | 46 +++--- .../Serialization/WebApiIntegrationTests.cs | 20 ++- Src/Newtonsoft.Json.Tests/TestFixtureBase.cs | 148 +++++++++++++++++- .../TestObjects/AnswerFilterModel.cs | 2 +- .../TestObjects/ConverableMembers.cs | 2 +- .../TestObjects/Currency.cs | 2 +- .../TestObjects/CustomerDataSet.cs | 2 +- .../DefaultValueAttributeTestClass.cs | 2 +- .../TestObjects/IMyInterface.cs | 2 +- .../TestObjects/MetroPropertyNameResolver.cs | 2 +- .../TestObjects/MetroStringConverter.cs | 4 +- .../TestObjects/Person.cs | 2 +- .../TestObjects/PersonSerializable.cs | 2 +- .../TestObjects/Ratio.cs | 2 +- .../TestObjects/Shape.cs | 2 +- .../TestObjects/TypedSubHashtable.cs | 2 +- .../Utilities/DateTimeUtilsTests.cs | 30 +++- .../DynamicReflectionDelegateFactoryTests.cs | 12 +- ...xpressionReflectionDelegateFactoryTests.cs | 53 ++++--- ...LateboundReflectionDelegateFactoryTests.cs | 16 +- .../Utilities/ReflectionUtilsTests.cs | 24 +-- .../Utilities/StringUtilsTests.cs | 14 +- Src/Newtonsoft.Json.Tests/project.json | 54 +++++++ .../Serialization/JsonTypeReflector.cs | 61 +++----- .../Utilities/ImmutableCollectionsUtils.cs | 18 ++- .../Utilities/ReflectionUtils.cs | 11 ++ Src/NuGet.Config | 7 + 111 files changed, 1193 insertions(+), 573 deletions(-) create mode 100644 Src/Newtonsoft.Json.Tests/project.json create mode 100644 Src/NuGet.Config diff --git a/Src/Newtonsoft.Json.Tests/Bson/BsonReaderTests.cs b/Src/Newtonsoft.Json.Tests/Bson/BsonReaderTests.cs index 871809ae..bd743bdb 100644 --- a/Src/Newtonsoft.Json.Tests/Bson/BsonReaderTests.cs +++ b/Src/Newtonsoft.Json.Tests/Bson/BsonReaderTests.cs @@ -30,17 +30,21 @@ using System.Reflection; using System.Runtime.Serialization; using Newtonsoft.Json.Serialization; using Newtonsoft.Json.Tests.TestObjects; -#if !(NET20 || NET35 || PORTABLE) +#if !(NET20 || NET35 || PORTABLE || ASPNETCORE50) using System.Numerics; #endif using System.Text; using System.Text.RegularExpressions; -#if !NETFX_CORE -using NUnit.Framework; -#else +#if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute; +#elif ASPNETCORE50 +using Xunit; +using Test = Xunit.FactAttribute; +using Assert = Newtonsoft.Json.Tests.XUnitAssert; +#else +using NUnit.Framework; #endif using Newtonsoft.Json.Bson; using System.IO; @@ -1456,7 +1460,7 @@ namespace Newtonsoft.Json.Tests.Bson } #endif -#if !(NET20 || NET35 || PORTABLE || PORTABLE40) +#if !(NET20 || NET35 || PORTABLE || ASPNETCORE50 || PORTABLE40) public class BigIntegerTestClass { public BigInteger Blah { get; set; } diff --git a/Src/Newtonsoft.Json.Tests/Bson/BsonWriterTests.cs b/Src/Newtonsoft.Json.Tests/Bson/BsonWriterTests.cs index c4738c09..e1f54b91 100644 --- a/Src/Newtonsoft.Json.Tests/Bson/BsonWriterTests.cs +++ b/Src/Newtonsoft.Json.Tests/Bson/BsonWriterTests.cs @@ -25,17 +25,21 @@ using System; using System.Collections.Generic; -#if !(NET20 || NET35 || PORTABLE) +#if !(NET20 || NET35 || PORTABLE || ASPNETCORE50) using System.Numerics; #endif using System.Text; using System.Text.RegularExpressions; -#if !NETFX_CORE -using NUnit.Framework; -#else +#if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute; +#elif ASPNETCORE50 +using Xunit; +using Test = Xunit.FactAttribute; +using Assert = Newtonsoft.Json.Tests.XUnitAssert; +#else +using NUnit.Framework; #endif using Newtonsoft.Json.Bson; using System.IO; @@ -810,7 +814,7 @@ namespace Newtonsoft.Json.Tests.Bson Assert.AreEqual(c.AGuid, c2.AGuid.ToString()); } -#if !(NET20 || NET35 || PORTABLE || PORTABLE40) +#if !(NET20 || NET35 || PORTABLE || ASPNETCORE50 || PORTABLE40) [Test] public void WriteBigInteger() { diff --git a/Src/Newtonsoft.Json.Tests/Converters/BinaryConverterTests.cs b/Src/Newtonsoft.Json.Tests/Converters/BinaryConverterTests.cs index 3866054e..6ae0e7a4 100644 --- a/Src/Newtonsoft.Json.Tests/Converters/BinaryConverterTests.cs +++ b/Src/Newtonsoft.Json.Tests/Converters/BinaryConverterTests.cs @@ -25,20 +25,24 @@ using System; using System.Collections.Generic; -#if !NET20 && !NETFX_CORE +#if !(NET20 || NETFX_CORE || ASPNETCORE50) using System.Data.Linq; #endif -#if !(NETFX_CORE) +#if !(NETFX_CORE || ASPNETCORE50) using System.Data.SqlTypes; #endif using System.Text; using Newtonsoft.Json.Converters; -#if !NETFX_CORE -using NUnit.Framework; -#else +#if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute; +#elif ASPNETCORE50 +using Xunit; +using Test = Xunit.FactAttribute; +using Assert = Newtonsoft.Json.Tests.XUnitAssert; +#else +using NUnit.Framework; #endif namespace Newtonsoft.Json.Tests.Converters @@ -54,7 +58,7 @@ namespace Newtonsoft.Json.Tests.Converters public byte[] NullByteArray { get; set; } } -#if !(NET20 || NETFX_CORE || PORTABLE || PORTABLE40) +#if !(NET20 || NETFX_CORE || PORTABLE || PORTABLE40 || ASPNETCORE50) [Test] public void DeserializeBinaryClass() { @@ -120,7 +124,7 @@ namespace Newtonsoft.Json.Tests.Converters }", json); } -#if !(NETFX_CORE || PORTABLE || PORTABLE40) +#if !(NETFX_CORE || PORTABLE || PORTABLE40 || ASPNETCORE50) public class SqlBinaryClass { public SqlBinary SqlBinary { get; set; } diff --git a/Src/Newtonsoft.Json.Tests/Converters/CustomCreationConverterTests.cs b/Src/Newtonsoft.Json.Tests/Converters/CustomCreationConverterTests.cs index cd98a3a2..e4365f89 100644 --- a/Src/Newtonsoft.Json.Tests/Converters/CustomCreationConverterTests.cs +++ b/Src/Newtonsoft.Json.Tests/Converters/CustomCreationConverterTests.cs @@ -26,13 +26,16 @@ using System; using System.Collections.Generic; using Newtonsoft.Json.Converters; -#if !NETFX_CORE -using NUnit.Framework; - -#else +#if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute; +#elif ASPNETCORE50 +using Xunit; +using Test = Xunit.FactAttribute; +using Assert = Newtonsoft.Json.Tests.XUnitAssert; +#else +using NUnit.Framework; #endif namespace Newtonsoft.Json.Tests.Converters diff --git a/Src/Newtonsoft.Json.Tests/Converters/DataSetConverterTests.cs b/Src/Newtonsoft.Json.Tests/Converters/DataSetConverterTests.cs index 8f84f2bc..a6df0834 100644 --- a/Src/Newtonsoft.Json.Tests/Converters/DataSetConverterTests.cs +++ b/Src/Newtonsoft.Json.Tests/Converters/DataSetConverterTests.cs @@ -23,15 +23,19 @@ // OTHER DEALINGS IN THE SOFTWARE. #endregion -#if !(NETFX_CORE || PORTABLE || PORTABLE40) +#if !(NETFX_CORE || PORTABLE || ASPNETCORE50 || PORTABLE40) using System; using Newtonsoft.Json.Converters; -#if !NETFX_CORE -using NUnit.Framework; -#else +#if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute; +#elif ASPNETCORE50 +using Xunit; +using Test = Xunit.FactAttribute; +using Assert = Newtonsoft.Json.Tests.XUnitAssert; +#else +using NUnit.Framework; #endif using Newtonsoft.Json.Serialization; using Newtonsoft.Json.Tests.TestObjects; diff --git a/Src/Newtonsoft.Json.Tests/Converters/DataTableConverterTests.cs b/Src/Newtonsoft.Json.Tests/Converters/DataTableConverterTests.cs index 00ff8edb..5dce5a7b 100644 --- a/Src/Newtonsoft.Json.Tests/Converters/DataTableConverterTests.cs +++ b/Src/Newtonsoft.Json.Tests/Converters/DataTableConverterTests.cs @@ -27,15 +27,19 @@ using System.IO; using System.Text; using Newtonsoft.Json.Bson; using Newtonsoft.Json.Linq; -#if !(NETFX_CORE || PORTABLE || PORTABLE40) +#if !(NETFX_CORE || PORTABLE || ASPNETCORE50 || PORTABLE40) using System; using System.Collections.Generic; -#if !NETFX_CORE -using NUnit.Framework; -#else +#if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute; +#elif ASPNETCORE50 +using Xunit; +using Test = Xunit.FactAttribute; +using Assert = Newtonsoft.Json.Tests.XUnitAssert; +#else +using NUnit.Framework; #endif #if !NETFX_CORE using System.Data; @@ -97,17 +101,17 @@ namespace Newtonsoft.Json.Tests.Converters Assert.AreEqual(2, deserializedDataTable.Rows.Count); DataRow dr1 = deserializedDataTable.Rows[0]; - Assert.AreEqual(0, dr1["id"]); + Assert.AreEqual(0L, dr1["id"]); Assert.AreEqual("item 0", dr1["item"]); Assert.AreEqual("0!", ((DataTable)dr1["DataTableCol"]).Rows[0]["NestedStringCol"]); - Assert.AreEqual(0, ((long[])dr1["ArrayCol"])[0]); + Assert.AreEqual(0L, ((long[])dr1["ArrayCol"])[0]); Assert.AreEqual(new DateTime(2000, 12, 29, 0, 0, 0, DateTimeKind.Utc), dr1["DateCol"]); DataRow dr2 = deserializedDataTable.Rows[1]; - Assert.AreEqual(1, dr2["id"]); + Assert.AreEqual(1L, dr2["id"]); Assert.AreEqual("item 1", dr2["item"]); Assert.AreEqual("1!", ((DataTable)dr2["DataTableCol"]).Rows[0]["NestedStringCol"]); - Assert.AreEqual(1, ((long[])dr2["ArrayCol"])[0]); + Assert.AreEqual(1L, ((long[])dr2["ArrayCol"])[0]); Assert.AreEqual(new DateTime(2000, 12, 29, 0, 0, 0, DateTimeKind.Utc), dr2["DateCol"]); } diff --git a/Src/Newtonsoft.Json.Tests/Converters/DiscriminatedUnionConverterTests.cs b/Src/Newtonsoft.Json.Tests/Converters/DiscriminatedUnionConverterTests.cs index d3315de7..7edd08f4 100644 --- a/Src/Newtonsoft.Json.Tests/Converters/DiscriminatedUnionConverterTests.cs +++ b/Src/Newtonsoft.Json.Tests/Converters/DiscriminatedUnionConverterTests.cs @@ -23,7 +23,7 @@ // OTHER DEALINGS IN THE SOFTWARE. #endregion -#if !(NET35 || NET20 || NETFX_CORE) +#if !(NET35 || NET20 || NETFX_CORE || ASPNETCORE50) using System; using System.Collections.Generic; using System.Linq; diff --git a/Src/Newtonsoft.Json.Tests/Converters/ExpandoObjectConverterTests.cs b/Src/Newtonsoft.Json.Tests/Converters/ExpandoObjectConverterTests.cs index a6458c19..915adbfa 100644 --- a/Src/Newtonsoft.Json.Tests/Converters/ExpandoObjectConverterTests.cs +++ b/Src/Newtonsoft.Json.Tests/Converters/ExpandoObjectConverterTests.cs @@ -24,27 +24,23 @@ #endregion #if !(NET35 || NET20 || PORTABLE40) - using System; using System.Collections.Generic; -#if !NET20 && !NETFX_CORE -using System.Data.Linq; -#endif -#if !NETFX_CORE -using System.Data.SqlTypes; -#endif using System.Dynamic; using System.Linq; using System.Text; using Newtonsoft.Json.Converters; -#if !NETFX_CORE -using NUnit.Framework; -#else +#if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute; +#elif ASPNETCORE50 +using Xunit; +using Test = Xunit.FactAttribute; +using Assert = Newtonsoft.Json.Tests.XUnitAssert; +#else +using NUnit.Framework; #endif -using Newtonsoft.Json.Tests.TestObjects; namespace Newtonsoft.Json.Tests.Converters { diff --git a/Src/Newtonsoft.Json.Tests/Converters/IsoDateTimeConverterTests.cs b/Src/Newtonsoft.Json.Tests/Converters/IsoDateTimeConverterTests.cs index 8eae40dc..cf7d6675 100644 --- a/Src/Newtonsoft.Json.Tests/Converters/IsoDateTimeConverterTests.cs +++ b/Src/Newtonsoft.Json.Tests/Converters/IsoDateTimeConverterTests.cs @@ -25,12 +25,16 @@ using System; using Newtonsoft.Json.Tests.TestObjects; -#if !NETFX_CORE -using NUnit.Framework; -#else +#if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute; +#elif ASPNETCORE50 +using Xunit; +using Test = Xunit.FactAttribute; +using Assert = Newtonsoft.Json.Tests.XUnitAssert; +#else +using NUnit.Framework; #endif using Newtonsoft.Json.Converters; using Newtonsoft.Json.Utilities; @@ -122,7 +126,7 @@ namespace Newtonsoft.Json.Tests.Converters Assert.AreEqual(2006, d.Year); } -#if !NETFX_CORE +#if !(NETFX_CORE || ASPNETCORE50) [Test] public void SerializeFormattedDateTimeNewZealandCulture() { diff --git a/Src/Newtonsoft.Json.Tests/Converters/JavaScriptDateTimeConverterTests.cs b/Src/Newtonsoft.Json.Tests/Converters/JavaScriptDateTimeConverterTests.cs index 47935b5c..9931035b 100644 --- a/Src/Newtonsoft.Json.Tests/Converters/JavaScriptDateTimeConverterTests.cs +++ b/Src/Newtonsoft.Json.Tests/Converters/JavaScriptDateTimeConverterTests.cs @@ -25,12 +25,16 @@ using System; using System.Collections.Generic; -#if !NETFX_CORE -using NUnit.Framework; -#else +#if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute; +#elif ASPNETCORE50 +using Xunit; +using Test = Xunit.FactAttribute; +using Assert = Newtonsoft.Json.Tests.XUnitAssert; +#else +using NUnit.Framework; #endif using Newtonsoft.Json.Converters; using Newtonsoft.Json.Tests.Serialization; diff --git a/Src/Newtonsoft.Json.Tests/Converters/KeyValuePairConverterTests.cs b/Src/Newtonsoft.Json.Tests/Converters/KeyValuePairConverterTests.cs index 00c46d50..3bd593a5 100644 --- a/Src/Newtonsoft.Json.Tests/Converters/KeyValuePairConverterTests.cs +++ b/Src/Newtonsoft.Json.Tests/Converters/KeyValuePairConverterTests.cs @@ -3,12 +3,16 @@ using System.Collections.Generic; using System.Text; using Newtonsoft.Json.Converters; using Newtonsoft.Json.Serialization; -#if !NETFX_CORE -using NUnit.Framework; -#else +#if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute; +#elif ASPNETCORE50 +using Xunit; +using Test = Xunit.FactAttribute; +using Assert = Newtonsoft.Json.Tests.XUnitAssert; +#else +using NUnit.Framework; #endif namespace Newtonsoft.Json.Tests.Converters diff --git a/Src/Newtonsoft.Json.Tests/Converters/ObjectIdConverterTests.cs b/Src/Newtonsoft.Json.Tests/Converters/ObjectIdConverterTests.cs index f7d4780a..4d24f929 100644 --- a/Src/Newtonsoft.Json.Tests/Converters/ObjectIdConverterTests.cs +++ b/Src/Newtonsoft.Json.Tests/Converters/ObjectIdConverterTests.cs @@ -26,13 +26,16 @@ using System.IO; using Newtonsoft.Json.Bson; using Newtonsoft.Json.Utilities; -#if !NETFX_CORE -using NUnit.Framework; - -#else +#if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute; +#elif ASPNETCORE50 +using Xunit; +using Test = Xunit.FactAttribute; +using Assert = Newtonsoft.Json.Tests.XUnitAssert; +#else +using NUnit.Framework; #endif namespace Newtonsoft.Json.Tests.Converters diff --git a/Src/Newtonsoft.Json.Tests/Converters/RegexConverterTests.cs b/Src/Newtonsoft.Json.Tests/Converters/RegexConverterTests.cs index 5faaa3ea..e08b7aef 100644 --- a/Src/Newtonsoft.Json.Tests/Converters/RegexConverterTests.cs +++ b/Src/Newtonsoft.Json.Tests/Converters/RegexConverterTests.cs @@ -25,24 +25,22 @@ using System; using System.Collections.Generic; -#if !NET20 && !NETFX_CORE -using System.Data.Linq; -#endif -#if !NETFX_CORE -using System.Data.SqlTypes; -#endif using System.IO; using System.Text.RegularExpressions; using Newtonsoft.Json.Bson; using Newtonsoft.Json.Converters; using Newtonsoft.Json.Serialization; using Newtonsoft.Json.Utilities; -#if !NETFX_CORE -using NUnit.Framework; -#else +#if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute; +#elif ASPNETCORE50 +using Xunit; +using Test = Xunit.FactAttribute; +using Assert = Newtonsoft.Json.Tests.XUnitAssert; +#else +using NUnit.Framework; #endif using Newtonsoft.Json.Tests.TestObjects; diff --git a/Src/Newtonsoft.Json.Tests/Converters/StringEnumConverterTests.cs b/Src/Newtonsoft.Json.Tests/Converters/StringEnumConverterTests.cs index c4ae703a..bcf7bd42 100644 --- a/Src/Newtonsoft.Json.Tests/Converters/StringEnumConverterTests.cs +++ b/Src/Newtonsoft.Json.Tests/Converters/StringEnumConverterTests.cs @@ -31,12 +31,16 @@ using System.Runtime.Serialization; using System.Text; using System.Text.RegularExpressions; using Newtonsoft.Json.Converters; -#if !NETFX_CORE -using NUnit.Framework; -#else +#if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute; +#elif ASPNETCORE50 +using Xunit; +using Test = Xunit.FactAttribute; +using Assert = Newtonsoft.Json.Tests.XUnitAssert; +#else +using NUnit.Framework; #endif using Newtonsoft.Json.Tests.TestObjects; diff --git a/Src/Newtonsoft.Json.Tests/Converters/VersionConverterTests.cs b/Src/Newtonsoft.Json.Tests/Converters/VersionConverterTests.cs index aed77c3d..238608ca 100644 --- a/Src/Newtonsoft.Json.Tests/Converters/VersionConverterTests.cs +++ b/Src/Newtonsoft.Json.Tests/Converters/VersionConverterTests.cs @@ -25,13 +25,16 @@ using System; using Newtonsoft.Json.Converters; -#if !NETFX_CORE -using NUnit.Framework; - -#else +#if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute; +#elif ASPNETCORE50 +using Xunit; +using Test = Xunit.FactAttribute; +using Assert = Newtonsoft.Json.Tests.XUnitAssert; +#else +using NUnit.Framework; #endif namespace Newtonsoft.Json.Tests.Converters diff --git a/Src/Newtonsoft.Json.Tests/Converters/XmlNodeConverterTest.cs b/Src/Newtonsoft.Json.Tests/Converters/XmlNodeConverterTest.cs index 8b3ca810..41372093 100644 --- a/Src/Newtonsoft.Json.Tests/Converters/XmlNodeConverterTest.cs +++ b/Src/Newtonsoft.Json.Tests/Converters/XmlNodeConverterTest.cs @@ -29,17 +29,21 @@ using Newtonsoft.Json.Utilities.LinqBridge; using System.Linq; #endif using System.Text; -#if !(NETFX_CORE || PORTABLE || PORTABLE40) +#if !(NETFX_CORE || PORTABLE || ASPNETCORE50 || PORTABLE40) using System; using System.Collections.Generic; using Newtonsoft.Json.Tests.Serialization; using Newtonsoft.Json.Tests.TestObjects; -#if !NETFX_CORE -using NUnit.Framework; -#else +#if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute; +#elif ASPNETCORE50 +using Xunit; +using Test = Xunit.FactAttribute; +using Assert = Newtonsoft.Json.Tests.XUnitAssert; +#else +using NUnit.Framework; #endif using Newtonsoft.Json; using System.IO; diff --git a/Src/Newtonsoft.Json.Tests/DemoTests.cs b/Src/Newtonsoft.Json.Tests/DemoTests.cs index b34c1173..a52f7041 100644 --- a/Src/Newtonsoft.Json.Tests/DemoTests.cs +++ b/Src/Newtonsoft.Json.Tests/DemoTests.cs @@ -32,12 +32,16 @@ using Newtonsoft.Json.Converters; using Newtonsoft.Json.Linq; using Newtonsoft.Json.Schema; using Newtonsoft.Json.Serialization; -#if !NETFX_CORE -using NUnit.Framework; -#else +#if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute; +#elif ASPNETCORE50 +using Xunit; +using Test = Xunit.FactAttribute; +using Assert = Newtonsoft.Json.Tests.XUnitAssert; +#else +using NUnit.Framework; #endif namespace Newtonsoft.Json.Tests diff --git a/Src/Newtonsoft.Json.Tests/Documentation/ConditionalPropertiesTests.cs b/Src/Newtonsoft.Json.Tests/Documentation/ConditionalPropertiesTests.cs index 9c873313..cc7ff33a 100644 --- a/Src/Newtonsoft.Json.Tests/Documentation/ConditionalPropertiesTests.cs +++ b/Src/Newtonsoft.Json.Tests/Documentation/ConditionalPropertiesTests.cs @@ -23,7 +23,7 @@ // OTHER DEALINGS IN THE SOFTWARE. #endregion -#if !(NET35 || NET20 || PORTABLE) +#if !(NET35 || NET20 || PORTABLE || ASPNETCORE50) using System; using System.Collections.Generic; using System.ComponentModel; @@ -37,12 +37,16 @@ using System.Text; using System.Threading.Tasks; using Newtonsoft.Json.Converters; using Newtonsoft.Json.Linq; -#if !NETFX_CORE -using NUnit.Framework; -#else +#if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute; +#elif ASPNETCORE50 +using Xunit; +using Test = Xunit.FactAttribute; +using Assert = Newtonsoft.Json.Tests.XUnitAssert; +#else +using NUnit.Framework; #endif using Newtonsoft.Json.Serialization; using Newtonsoft.Json.Tests.TestObjects; diff --git a/Src/Newtonsoft.Json.Tests/Documentation/ConvertingJsonAndXmlTests.cs b/Src/Newtonsoft.Json.Tests/Documentation/ConvertingJsonAndXmlTests.cs index f4beae83..0ca02d57 100644 --- a/Src/Newtonsoft.Json.Tests/Documentation/ConvertingJsonAndXmlTests.cs +++ b/Src/Newtonsoft.Json.Tests/Documentation/ConvertingJsonAndXmlTests.cs @@ -23,7 +23,7 @@ // OTHER DEALINGS IN THE SOFTWARE. #endregion -#if !(NET35 || NET20 || PORTABLE) +#if !(NET35 || NET20 || PORTABLE || ASPNETCORE50) using System; using System.Collections.Generic; using System.ComponentModel; @@ -35,12 +35,16 @@ using System.Text; using System.Xml; using Newtonsoft.Json.Converters; using Newtonsoft.Json.Linq; -#if !NETFX_CORE -using NUnit.Framework; -#else +#if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute; +#elif ASPNETCORE50 +using Xunit; +using Test = Xunit.FactAttribute; +using Assert = Newtonsoft.Json.Tests.XUnitAssert; +#else +using NUnit.Framework; #endif using Newtonsoft.Json.Serialization; using Newtonsoft.Json.Tests.TestObjects; diff --git a/Src/Newtonsoft.Json.Tests/Documentation/JsonSchemaTests.cs b/Src/Newtonsoft.Json.Tests/Documentation/JsonSchemaTests.cs index 96d51bbe..4854f16d 100644 --- a/Src/Newtonsoft.Json.Tests/Documentation/JsonSchemaTests.cs +++ b/Src/Newtonsoft.Json.Tests/Documentation/JsonSchemaTests.cs @@ -23,7 +23,7 @@ // OTHER DEALINGS IN THE SOFTWARE. #endregion -#if !(NET35 || NET20 || PORTABLE) +#if !(NET35 || NET20 || PORTABLE || ASPNETCORE50) using System; using System.Collections.Generic; using System.ComponentModel; @@ -34,12 +34,16 @@ using System.Runtime.Serialization; using System.Text; using Newtonsoft.Json.Converters; using Newtonsoft.Json.Linq; -#if !NETFX_CORE -using NUnit.Framework; -#else +#if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute; +#elif ASPNETCORE50 +using Xunit; +using Test = Xunit.FactAttribute; +using Assert = Newtonsoft.Json.Tests.XUnitAssert; +#else +using NUnit.Framework; #endif using Newtonsoft.Json.Schema; using Newtonsoft.Json.Serialization; diff --git a/Src/Newtonsoft.Json.Tests/Documentation/LinqToJsonTests.cs b/Src/Newtonsoft.Json.Tests/Documentation/LinqToJsonTests.cs index bbd6893c..edc75749 100644 --- a/Src/Newtonsoft.Json.Tests/Documentation/LinqToJsonTests.cs +++ b/Src/Newtonsoft.Json.Tests/Documentation/LinqToJsonTests.cs @@ -23,7 +23,7 @@ // OTHER DEALINGS IN THE SOFTWARE. #endregion -#if !(NET35 || NET20 || PORTABLE) +#if !(NET35 || NET20 || PORTABLE || ASPNETCORE50) using System; using System.Collections.Generic; using System.ComponentModel; @@ -34,12 +34,16 @@ using System.Runtime.Serialization; using System.Text; using Newtonsoft.Json.Converters; using Newtonsoft.Json.Linq; -#if !NETFX_CORE -using NUnit.Framework; -#else +#if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute; +#elif ASPNETCORE50 +using Xunit; +using Test = Xunit.FactAttribute; +using Assert = Newtonsoft.Json.Tests.XUnitAssert; +#else +using NUnit.Framework; #endif using Newtonsoft.Json.Serialization; using Newtonsoft.Json.Tests.TestObjects; diff --git a/Src/Newtonsoft.Json.Tests/Documentation/PerformanceTests.cs b/Src/Newtonsoft.Json.Tests/Documentation/PerformanceTests.cs index e8a31673..85e27694 100644 --- a/Src/Newtonsoft.Json.Tests/Documentation/PerformanceTests.cs +++ b/Src/Newtonsoft.Json.Tests/Documentation/PerformanceTests.cs @@ -23,7 +23,7 @@ // OTHER DEALINGS IN THE SOFTWARE. #endregion -#if !(NET35 || NET20 || PORTABLE) +#if !(NET35 || NET20 || PORTABLE || ASPNETCORE50) using System; using System.Collections.Generic; using System.ComponentModel; @@ -36,12 +36,16 @@ using System.Text; using System.Threading.Tasks; using Newtonsoft.Json.Converters; using Newtonsoft.Json.Linq; -#if !NETFX_CORE -using NUnit.Framework; -#else +#if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute; +#elif ASPNETCORE50 +using Xunit; +using Test = Xunit.FactAttribute; +using Assert = Newtonsoft.Json.Tests.XUnitAssert; +#else +using NUnit.Framework; #endif using Newtonsoft.Json.Serialization; using Newtonsoft.Json.Tests.TestObjects; diff --git a/Src/Newtonsoft.Json.Tests/Documentation/ReadingAndWritingJsonTests.cs b/Src/Newtonsoft.Json.Tests/Documentation/ReadingAndWritingJsonTests.cs index 664aa0a6..ff5a5969 100644 --- a/Src/Newtonsoft.Json.Tests/Documentation/ReadingAndWritingJsonTests.cs +++ b/Src/Newtonsoft.Json.Tests/Documentation/ReadingAndWritingJsonTests.cs @@ -23,7 +23,7 @@ // OTHER DEALINGS IN THE SOFTWARE. #endregion -#if !(NET35 || NET20 || PORTABLE) +#if !(NET35 || NET20 || PORTABLE || ASPNETCORE50) using System; using System.Collections.Generic; using System.ComponentModel; @@ -34,12 +34,16 @@ using System.Runtime.Serialization; using System.Text; using Newtonsoft.Json.Converters; using Newtonsoft.Json.Linq; -#if !NETFX_CORE -using NUnit.Framework; -#else +#if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute; +#elif ASPNETCORE50 +using Xunit; +using Test = Xunit.FactAttribute; +using Assert = Newtonsoft.Json.Tests.XUnitAssert; +#else +using NUnit.Framework; #endif using Newtonsoft.Json.Serialization; using Newtonsoft.Json.Tests.TestObjects; diff --git a/Src/Newtonsoft.Json.Tests/Documentation/Samples/Serializer/DeserializeDataSet.cs b/Src/Newtonsoft.Json.Tests/Documentation/Samples/Serializer/DeserializeDataSet.cs index 986d8d42..adddc9cd 100644 --- a/Src/Newtonsoft.Json.Tests/Documentation/Samples/Serializer/DeserializeDataSet.cs +++ b/Src/Newtonsoft.Json.Tests/Documentation/Samples/Serializer/DeserializeDataSet.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.Data; using System.Linq; using System.Text; -using NUnit.Framework; namespace Newtonsoft.Json.Tests.Documentation.Samples.Serializer { diff --git a/Src/Newtonsoft.Json.Tests/Documentation/Samples/Serializer/SerializeDataSet.cs b/Src/Newtonsoft.Json.Tests/Documentation/Samples/Serializer/SerializeDataSet.cs index 955a7fa5..01ec6992 100644 --- a/Src/Newtonsoft.Json.Tests/Documentation/Samples/Serializer/SerializeDataSet.cs +++ b/Src/Newtonsoft.Json.Tests/Documentation/Samples/Serializer/SerializeDataSet.cs @@ -3,8 +3,6 @@ using System.Collections.Generic; using System.Data; using System.Linq; using System.Text; -using NUnit.Framework; - namespace Newtonsoft.Json.Tests.Documentation.Samples.Serializer { public class SerializeDataSet diff --git a/Src/Newtonsoft.Json.Tests/Documentation/SerializationTests.cs b/Src/Newtonsoft.Json.Tests/Documentation/SerializationTests.cs index c728f0ad..fbfd378c 100644 --- a/Src/Newtonsoft.Json.Tests/Documentation/SerializationTests.cs +++ b/Src/Newtonsoft.Json.Tests/Documentation/SerializationTests.cs @@ -23,7 +23,7 @@ // OTHER DEALINGS IN THE SOFTWARE. #endregion -#if !(NET35 || NET20 || PORTABLE) +#if !(NET35 || NET20 || PORTABLE || ASPNETCORE50) using System; using System.Collections.Generic; using System.ComponentModel; @@ -34,12 +34,16 @@ using System.Runtime.Serialization; using System.Text; using Newtonsoft.Json.Converters; using Newtonsoft.Json.Linq; -#if !NETFX_CORE -using NUnit.Framework; -#else +#if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute; +#elif ASPNETCORE50 +using Xunit; +using Test = Xunit.FactAttribute; +using Assert = Newtonsoft.Json.Tests.XUnitAssert; +#else +using NUnit.Framework; #endif using Newtonsoft.Json.Serialization; using Newtonsoft.Json.Tests.TestObjects; diff --git a/Src/Newtonsoft.Json.Tests/Documentation/TraceWriterTests.cs b/Src/Newtonsoft.Json.Tests/Documentation/TraceWriterTests.cs index b4d7d614..934ee531 100644 --- a/Src/Newtonsoft.Json.Tests/Documentation/TraceWriterTests.cs +++ b/Src/Newtonsoft.Json.Tests/Documentation/TraceWriterTests.cs @@ -23,7 +23,7 @@ // OTHER DEALINGS IN THE SOFTWARE. #endregion -#if !(NET35 || NET20 || PORTABLE) +#if !(NET35 || NET20 || PORTABLE || ASPNETCORE50) using System; using System.Collections.Generic; using System.ComponentModel; @@ -38,12 +38,16 @@ using System.Text; using System.Threading.Tasks; using Newtonsoft.Json.Converters; using Newtonsoft.Json.Linq; -#if !NETFX_CORE -using NUnit.Framework; -#else +#if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute; +#elif ASPNETCORE50 +using Xunit; +using Test = Xunit.FactAttribute; +using Assert = Newtonsoft.Json.Tests.XUnitAssert; +#else +using NUnit.Framework; #endif using Newtonsoft.Json.Serialization; using Newtonsoft.Json.Tests.Serialization; diff --git a/Src/Newtonsoft.Json.Tests/ExceptionTests.cs b/Src/Newtonsoft.Json.Tests/ExceptionTests.cs index babfc8ad..a43c177e 100644 --- a/Src/Newtonsoft.Json.Tests/ExceptionTests.cs +++ b/Src/Newtonsoft.Json.Tests/ExceptionTests.cs @@ -25,13 +25,16 @@ using System; using Newtonsoft.Json.Schema; -#if !NETFX_CORE -using NUnit.Framework; - -#else +#if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute; +#elif ASPNETCORE50 +using Xunit; +using Test = Xunit.FactAttribute; +using Assert = Newtonsoft.Json.Tests.XUnitAssert; +#else +using NUnit.Framework; #endif namespace Newtonsoft.Json.Tests diff --git a/Src/Newtonsoft.Json.Tests/JsonArrayAttributeTests.cs b/Src/Newtonsoft.Json.Tests/JsonArrayAttributeTests.cs index efdb42f3..0d3d9b7e 100644 --- a/Src/Newtonsoft.Json.Tests/JsonArrayAttributeTests.cs +++ b/Src/Newtonsoft.Json.Tests/JsonArrayAttributeTests.cs @@ -23,12 +23,16 @@ // OTHER DEALINGS IN THE SOFTWARE. #endregion -#if !NETFX_CORE -using NUnit.Framework; -#else +#if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute; +#elif ASPNETCORE50 +using Xunit; +using Test = Xunit.FactAttribute; +using Assert = Newtonsoft.Json.Tests.XUnitAssert; +#else +using NUnit.Framework; #endif namespace Newtonsoft.Json.Tests diff --git a/Src/Newtonsoft.Json.Tests/JsonConvertTest.cs b/Src/Newtonsoft.Json.Tests/JsonConvertTest.cs index 772d56ef..1ffb56d1 100644 --- a/Src/Newtonsoft.Json.Tests/JsonConvertTest.cs +++ b/Src/Newtonsoft.Json.Tests/JsonConvertTest.cs @@ -27,7 +27,7 @@ using System; using System.Collections.Generic; using System.Globalization; using System.IO; -#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) +#if !(NET20 || NET35 || PORTABLE40 || PORTABLE || ASPNETCORE50) using System.Numerics; #endif using System.Runtime.Serialization; @@ -42,13 +42,16 @@ using Newtonsoft.Json.Serialization; using Newtonsoft.Json.Tests.Serialization; using Newtonsoft.Json.Tests.TestObjects; using Newtonsoft.Json.Utilities; -#if !NETFX_CORE -using NUnit.Framework; - -#else +#if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute; +#elif ASPNETCORE50 +using Xunit; +using Test = Xunit.FactAttribute; +using Assert = Newtonsoft.Json.Tests.XUnitAssert; +#else +using NUnit.Framework; #endif namespace Newtonsoft.Json.Tests @@ -535,7 +538,7 @@ namespace Newtonsoft.Json.Tests value = null; Assert.AreEqual("null", JsonConvert.ToString(value)); -#if !(NETFX_CORE || PORTABLE || PORTABLE40) +#if !(NETFX_CORE || PORTABLE || ASPNETCORE50 || PORTABLE40) value = DBNull.Value; Assert.AreEqual("null", JsonConvert.ToString(value)); #endif @@ -1137,7 +1140,7 @@ namespace Newtonsoft.Json.Tests } -#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) +#if !(NET20 || NET35 || PORTABLE40 || PORTABLE || ASPNETCORE50) [Test] public void IntegerLengthOverflows() { diff --git a/Src/Newtonsoft.Json.Tests/JsonTextReaderTest.cs b/Src/Newtonsoft.Json.Tests/JsonTextReaderTest.cs index 1d1920db..e62d47c2 100644 --- a/Src/Newtonsoft.Json.Tests/JsonTextReaderTest.cs +++ b/Src/Newtonsoft.Json.Tests/JsonTextReaderTest.cs @@ -27,16 +27,20 @@ using System; using System.Collections.Generic; using System.Globalization; using Newtonsoft.Json.Linq; -#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) +#if !(NET20 || NET35 || PORTABLE40 || PORTABLE || ASPNETCORE50) using System.Numerics; #endif using System.Text; -#if !NETFX_CORE -using NUnit.Framework; -#else +#if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute; +#elif ASPNETCORE50 +using Xunit; +using Test = Xunit.FactAttribute; +using Assert = Newtonsoft.Json.Tests.XUnitAssert; +#else +using NUnit.Framework; #endif using Newtonsoft.Json; using System.IO; @@ -78,7 +82,7 @@ second line third line", jsonTextReader.Value); } -#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) +#if !(NET20 || NET35 || PORTABLE40 || PORTABLE || ASPNETCORE50) [Test] public void ReadBigInteger() { @@ -517,7 +521,7 @@ third line", jsonTextReader.Value); ]content"; JsonTextReader reader = new JsonTextReader(new StringReader(json)); -#if DEBUG +#if DEBUG && !NOINTERNALS reader.SetCharBuffer(new char[2]); #endif @@ -586,7 +590,7 @@ third line", jsonTextReader.Value); using (JsonTextReader jsonReader = new JsonTextReader(sr)) { -#if DEBUG +#if DEBUG && !NOINTERNALS jsonReader.SetCharBuffer(new char[5]); #endif @@ -904,7 +908,7 @@ third line", jsonTextReader.Value); ]"; JsonTextReader reader = new JsonTextReader(new StringReader(json)); -#if DEBUG +#if DEBUG && !NOINTERNALS reader.SetCharBuffer(new char[129]); #endif @@ -958,7 +962,7 @@ third line", jsonTextReader.Value); } } -#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) +#if !(NET20 || NET35 || PORTABLE40 || PORTABLE || ASPNETCORE50) [Test] public void ReadInt64Overflow() { @@ -1019,7 +1023,7 @@ third line", jsonTextReader.Value); "; JsonTextReader reader = new JsonTextReader(new StringReader(json)); -#if DEBUG +#if DEBUG && !NOINTERNALS reader.SetCharBuffer(new char[129]); #endif @@ -1562,7 +1566,7 @@ third line", jsonTextReader.Value); string json = @"[""\u003c"",""\u5f20""]"; JsonTextReader reader = new JsonTextReader(new StringReader(json)); -#if DEBUG +#if DEBUG && !NOINTERNALS reader.SetCharBuffer(new char[2]); #endif @@ -1894,7 +1898,7 @@ third line", jsonTextReader.Value); string json = @"{""Message"":""Hi,I\u0092ve send you smth""}"; JsonTextReader reader = new JsonTextReader(new StringReader(json)); -#if DEBUG +#if DEBUG && !NOINTERNALS reader.SetCharBuffer(new char[5]); #endif @@ -2251,7 +2255,7 @@ third line", jsonTextReader.Value); ]"; JsonTextReader reader = new JsonTextReader(new StringReader(json)); -#if DEBUG +#if DEBUG && !NOINTERNALS reader.SetCharBuffer(new char[5]); #endif @@ -2279,7 +2283,7 @@ third line", jsonTextReader.Value); } /*comment*/"; JsonTextReader reader = new JsonTextReader(new StringReader(json)); -#if DEBUG +#if DEBUG && !NOINTERNALS reader.SetCharBuffer(new char[5]); #endif @@ -2299,7 +2303,7 @@ third line", jsonTextReader.Value); { string json = "new Date\0()"; JsonTextReader reader = new JsonTextReader(new StringReader(json)); -#if DEBUG +#if DEBUG && !NOINTERNALS reader.SetCharBuffer(new char[7]); #endif diff --git a/Src/Newtonsoft.Json.Tests/JsonTextWriterTest.cs b/Src/Newtonsoft.Json.Tests/JsonTextWriterTest.cs index 1f930c8b..cfa4fbc9 100644 --- a/Src/Newtonsoft.Json.Tests/JsonTextWriterTest.cs +++ b/Src/Newtonsoft.Json.Tests/JsonTextWriterTest.cs @@ -35,13 +35,20 @@ using System.Linq; using System.Runtime.Serialization; using System.Text; using System.Xml; -#if !NETFX_CORE -using NUnit.Framework; -#else + +#if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute; +#elif ASPNETCORE50 +using Xunit; +using Test = Xunit.FactAttribute; +using Assert = Newtonsoft.Json.Tests.XUnitAssert; +#else +using NUnit.Framework; #endif + + using Newtonsoft.Json; using System.IO; using Newtonsoft.Json.Converters; @@ -114,7 +121,7 @@ namespace Newtonsoft.Json.Tests Assert.IsTrue(ms.CanRead); } -#if !(PORTABLE || NETFX_CORE) +#if !(PORTABLE || ASPNETCORE50 || NETFX_CORE) [Test] public void WriteIConvertable() { @@ -1509,7 +1516,7 @@ null//comment } } -#if !(PORTABLE || NETFX_CORE) +#if !(PORTABLE || ASPNETCORE50 || NETFX_CORE) public struct ConvertibleInt : IConvertible { private readonly int _value; diff --git a/Src/Newtonsoft.Json.Tests/JsonValidatingReaderTests.cs b/Src/Newtonsoft.Json.Tests/JsonValidatingReaderTests.cs index 853387d3..9a56ee13 100644 --- a/Src/Newtonsoft.Json.Tests/JsonValidatingReaderTests.cs +++ b/Src/Newtonsoft.Json.Tests/JsonValidatingReaderTests.cs @@ -29,16 +29,20 @@ using System.IO; #if NET20 using Newtonsoft.Json.Utilities.LinqBridge; #endif -#if !(NET20 || NET35 || PORTABLE) +#if !(NET20 || NET35 || PORTABLE || ASPNETCORE50) using System.Numerics; #endif using System.Text; -#if !NETFX_CORE -using NUnit.Framework; -#else +#if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute; +#elif ASPNETCORE50 +using Xunit; +using Test = Xunit.FactAttribute; +using Assert = Newtonsoft.Json.Tests.XUnitAssert; +#else +using NUnit.Framework; #endif using System.Xml; using System.Xml.Schema; @@ -352,7 +356,7 @@ namespace Newtonsoft.Json.Tests Assert.IsNotNull(validationEventArgs); } -#if !(NET20 || NET35 || PORTABLE || PORTABLE40) +#if !(NET20 || NET35 || PORTABLE || ASPNETCORE50 || PORTABLE40) [Test] public void IntegerGreaterThanMaximumValue_BigInteger() { @@ -605,7 +609,7 @@ namespace Newtonsoft.Json.Tests Assert.IsNotNull(validationEventArgs); } -#if !(NET20 || NET35 || PORTABLE || PORTABLE40) +#if !(NET20 || NET35 || PORTABLE || ASPNETCORE50 || PORTABLE40) [Test] public void BigIntegerDivisibleBy_Success() { diff --git a/Src/Newtonsoft.Json.Tests/Linq/ComponentModel/BindingTests.cs b/Src/Newtonsoft.Json.Tests/Linq/ComponentModel/BindingTests.cs index 957e1df6..74fecb08 100644 --- a/Src/Newtonsoft.Json.Tests/Linq/ComponentModel/BindingTests.cs +++ b/Src/Newtonsoft.Json.Tests/Linq/ComponentModel/BindingTests.cs @@ -23,7 +23,7 @@ // OTHER DEALINGS IN THE SOFTWARE. #endregion -#if !(NETFX_CORE || PORTABLE || PORTABLE40) +#if !(NETFX_CORE || PORTABLE || PORTABLE40 || ASPNETCORE50) using NUnit.Framework; using System.Web.UI; using Newtonsoft.Json.Linq; diff --git a/Src/Newtonsoft.Json.Tests/Linq/ComponentModel/JPropertyDescriptorTests.cs b/Src/Newtonsoft.Json.Tests/Linq/ComponentModel/JPropertyDescriptorTests.cs index 2cf7a5e2..59226b0a 100644 --- a/Src/Newtonsoft.Json.Tests/Linq/ComponentModel/JPropertyDescriptorTests.cs +++ b/Src/Newtonsoft.Json.Tests/Linq/ComponentModel/JPropertyDescriptorTests.cs @@ -23,7 +23,7 @@ // OTHER DEALINGS IN THE SOFTWARE. #endregion -#if !(NETFX_CORE || PORTABLE || PORTABLE40) +#if !(NETFX_CORE || PORTABLE || PORTABLE40 || ASPNETCORE50) using NUnit.Framework; using Newtonsoft.Json.Linq; diff --git a/Src/Newtonsoft.Json.Tests/Linq/DynamicTests.cs b/Src/Newtonsoft.Json.Tests/Linq/DynamicTests.cs index 240498f8..0e10a125 100644 --- a/Src/Newtonsoft.Json.Tests/Linq/DynamicTests.cs +++ b/Src/Newtonsoft.Json.Tests/Linq/DynamicTests.cs @@ -28,17 +28,21 @@ using System; using System.Collections.Generic; using System.Dynamic; using System.Linq; -#if !(NET20 || NET35 || PORTABLE) +#if !(NET20 || NET35 || PORTABLE || ASPNETCORE50) using System.Numerics; #endif using System.Text; using Newtonsoft.Json.Linq; -#if !NETFX_CORE -using NUnit.Framework; -#else +#if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute; +#elif ASPNETCORE50 +using Xunit; +using Test = Xunit.FactAttribute; +using Assert = Newtonsoft.Json.Tests.XUnitAssert; +#else +using NUnit.Framework; #endif using Newtonsoft.Json.Utilities; using System.Globalization; @@ -176,7 +180,7 @@ namespace Newtonsoft.Json.Tests.Linq new JProperty("Uri", new Uri("http://json.codeplex.com/")), new JProperty("Guid", new Guid("EA27FE1D-0D80-44F2-BF34-4654156FA7AF")), new JProperty("TimeSpan", TimeSpan.FromDays(1)) -#if !(NET20 || NET35 || PORTABLE) +#if !(NET20 || NET35 || PORTABLE || ASPNETCORE50) , new JProperty("BigInteger", BigInteger.Parse("1")) #endif ); @@ -209,7 +213,7 @@ namespace Newtonsoft.Json.Tests.Linq Assert.IsTrue(d.Decimal == 1.1m); Assert.IsTrue(d.Decimal != 1.0f); Assert.IsTrue(d.Decimal != 1.0d); -#if !(NET20 || NET35 || PORTABLE) +#if !(NET20 || NET35 || PORTABLE || ASPNETCORE50) Assert.IsTrue(d.Decimal > new BigInteger(0)); #endif @@ -225,11 +229,11 @@ namespace Newtonsoft.Json.Tests.Linq Assert.IsTrue(d.Float == 1.1m); Assert.IsTrue(d.Float != 1.0f); Assert.IsTrue(d.Float != 1.0d); -#if !(NET20 || NET35 || PORTABLE) +#if !(NET20 || NET35 || PORTABLE || ASPNETCORE50) Assert.IsTrue(d.Float > new BigInteger(0)); #endif -#if !(NET20 || NET35 || PORTABLE) +#if !(NET20 || NET35 || PORTABLE || ASPNETCORE50) Assert.IsTrue(d.BigInteger == d.BigInteger); Assert.IsTrue(d.BigInteger > 0); Assert.IsTrue(d.BigInteger > 0.0m); @@ -285,7 +289,7 @@ namespace Newtonsoft.Json.Tests.Linq new JProperty("Uri", new Uri("http://json.codeplex.com/")), new JProperty("Guid", new Guid("EA27FE1D-0D80-44F2-BF34-4654156FA7AF")), new JProperty("TimeSpan", TimeSpan.FromDays(1)) -#if !(NET20 || NET35 || PORTABLE) +#if !(NET20 || NET35 || PORTABLE || ASPNETCORE50) , new JProperty("BigInteger", new BigInteger(100)) #endif ); @@ -364,7 +368,7 @@ namespace Newtonsoft.Json.Tests.Linq r += 2; Assert.AreEqual(null, r.Value); -#if !(NET20 || NET35 || PORTABLE) +#if !(NET20 || NET35 || PORTABLE || ASPNETCORE50) r = d.BigInteger + null; Assert.AreEqual(null, r.Value); r += 2; @@ -443,7 +447,7 @@ namespace Newtonsoft.Json.Tests.Linq r -= 2; Assert.AreEqual(null, r.Value); -#if !(NET20 || NET35 || PORTABLE) +#if !(NET20 || NET35 || PORTABLE || ASPNETCORE50) r = d.BigInteger - null; Assert.AreEqual(null, r.Value); r -= 2; @@ -517,7 +521,7 @@ namespace Newtonsoft.Json.Tests.Linq r *= 2; Assert.AreEqual(null, r.Value); -#if !(NET20 || NET35 || PORTABLE) +#if !(NET20 || NET35 || PORTABLE || ASPNETCORE50) r = d.BigInteger * 1.1d; Assert.AreEqual(100m, (decimal)r); r *= 2; @@ -591,7 +595,7 @@ namespace Newtonsoft.Json.Tests.Linq r /= 2; Assert.AreEqual(null, r.Value); -#if !(NET20 || NET35 || PORTABLE) +#if !(NET20 || NET35 || PORTABLE || ASPNETCORE50) r = d.BigInteger / 1.1d; Assert.AreEqual(100m, (decimal)r); r /= 2; @@ -619,7 +623,7 @@ namespace Newtonsoft.Json.Tests.Linq new JProperty("Uri", new Uri("http://json.codeplex.com/")), new JProperty("Guid", new Guid("EA27FE1D-0D80-44F2-BF34-4654156FA7AF")), new JProperty("TimeSpan", TimeSpan.FromDays(1)) -#if !(NET20 || NET35 || PORTABLE) +#if !(NET20 || NET35 || PORTABLE || ASPNETCORE50) , new JProperty("BigInteger", new BigInteger(100)) #endif ); @@ -636,7 +640,7 @@ namespace Newtonsoft.Json.Tests.Linq Assert.AreEqual("http://json.codeplex.com/", d.Uri.ToString()); Assert.AreEqual("ea27fe1d-0d80-44f2-bf34-4654156fa7af", d.Guid.ToString()); Assert.AreEqual("1.00:00:00", d.TimeSpan.ToString()); -#if !(NET20 || NET35 || PORTABLE) +#if !(NET20 || NET35 || PORTABLE || ASPNETCORE50) Assert.AreEqual("100", d.BigInteger.ToString()); #endif } @@ -720,7 +724,7 @@ namespace Newtonsoft.Json.Tests.Linq AssertValueConverted(null); AssertValueConverted(new Uri("http://json.codeplex.com/")); AssertValueConverted(null); -#if !(NET20 || NET35 || PORTABLE) +#if !(NET20 || NET35 || PORTABLE || ASPNETCORE50) AssertValueConverted(new BigInteger(100)); AssertValueConverted(null); #endif diff --git a/Src/Newtonsoft.Json.Tests/Linq/JArrayTests.cs b/Src/Newtonsoft.Json.Tests/Linq/JArrayTests.cs index e41cb976..3510cd9c 100644 --- a/Src/Newtonsoft.Json.Tests/Linq/JArrayTests.cs +++ b/Src/Newtonsoft.Json.Tests/Linq/JArrayTests.cs @@ -26,12 +26,16 @@ using System; using System.Collections.Generic; using System.ComponentModel; -#if !NETFX_CORE -using NUnit.Framework; -#else +#if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute; +#elif ASPNETCORE50 +using Xunit; +using Test = Xunit.FactAttribute; +using Assert = Newtonsoft.Json.Tests.XUnitAssert; +#else +using NUnit.Framework; #endif using Newtonsoft.Json.Linq; #if NET20 @@ -432,7 +436,7 @@ Parameter name: index"); } -#if !(NETFX_CORE || PORTABLE || PORTABLE40) +#if !(NETFX_CORE || PORTABLE || ASPNETCORE50 || PORTABLE40) [Test] public void ITypedListGetItemProperties() { diff --git a/Src/Newtonsoft.Json.Tests/Linq/JConstructorTests.cs b/Src/Newtonsoft.Json.Tests/Linq/JConstructorTests.cs index db430a9c..a5d6c479 100644 --- a/Src/Newtonsoft.Json.Tests/Linq/JConstructorTests.cs +++ b/Src/Newtonsoft.Json.Tests/Linq/JConstructorTests.cs @@ -26,12 +26,16 @@ using System; using System.Collections.Generic; using Newtonsoft.Json.Linq; -#if !NETFX_CORE -using NUnit.Framework; -#else +#if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute; +#elif ASPNETCORE50 +using Xunit; +using Test = Xunit.FactAttribute; +using Assert = Newtonsoft.Json.Tests.XUnitAssert; +#else +using NUnit.Framework; #endif using System.IO; #if NET20 diff --git a/Src/Newtonsoft.Json.Tests/Linq/JObjectTests.cs b/Src/Newtonsoft.Json.Tests/Linq/JObjectTests.cs index 7f10e799..c72d411c 100644 --- a/Src/Newtonsoft.Json.Tests/Linq/JObjectTests.cs +++ b/Src/Newtonsoft.Json.Tests/Linq/JObjectTests.cs @@ -27,22 +27,26 @@ using System; using System.Collections.Generic; using System.Collections.Specialized; using System.ComponentModel; -#if !(NET20 || NET35 || PORTABLE) +#if !(NET20 || NET35 || PORTABLE || ASPNETCORE50) using System.Numerics; #endif using Newtonsoft.Json.Serialization; using Newtonsoft.Json.Tests.TestObjects; -#if !NETFX_CORE -using NUnit.Framework; -#else +#if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute; +#elif ASPNETCORE50 +using Xunit; +using Test = Xunit.FactAttribute; +using Assert = Newtonsoft.Json.Tests.XUnitAssert; +#else +using NUnit.Framework; #endif using Newtonsoft.Json.Linq; using System.IO; using System.Collections; -#if !NETFX_CORE +#if !(NETFX_CORE || ASPNETCORE50) using System.Web.UI; #endif #if NET20 @@ -697,7 +701,7 @@ Parameter name: arrayIndex"); Assert.AreEqual(p4, l[1]); } -#if !(NET20 || NETFX_CORE || PORTABLE || PORTABLE40) +#if !(NET20 || NETFX_CORE || PORTABLE || ASPNETCORE50 || PORTABLE40) [Test] public void PropertyChanging() { @@ -1240,7 +1244,7 @@ Parameter name: arrayIndex"); }, "Can not add property Test3 to Newtonsoft.Json.Linq.JObject. Property with the same name already exists on object."); } -#if !(NETFX_CORE || PORTABLE || PORTABLE40) +#if !(NETFX_CORE || PORTABLE || ASPNETCORE50 || PORTABLE40) [Test] public void IBindingListSortDirection() { @@ -1564,7 +1568,7 @@ Parameter name: arrayIndex"); Assert.AreEqual("Name2", value); } -#if !(NETFX_CORE || PORTABLE || PORTABLE40) +#if !(NETFX_CORE || PORTABLE || ASPNETCORE50 || PORTABLE40) [Test] public void WriteObjectNullDBNullValue() { @@ -1676,7 +1680,7 @@ Parameter name: arrayIndex"); }, "Unexpected end of content while loading JObject. Path 'short.error.code', line 6, position 15."); } -#if !(NETFX_CORE || PORTABLE || PORTABLE40) +#if !(NETFX_CORE || PORTABLE || ASPNETCORE50 || PORTABLE40) [Test] public void GetProperties() { diff --git a/Src/Newtonsoft.Json.Tests/Linq/JPropertyTests.cs b/Src/Newtonsoft.Json.Tests/Linq/JPropertyTests.cs index d6208700..efc30aa4 100644 --- a/Src/Newtonsoft.Json.Tests/Linq/JPropertyTests.cs +++ b/Src/Newtonsoft.Json.Tests/Linq/JPropertyTests.cs @@ -33,12 +33,16 @@ using Newtonsoft.Json.Utilities.LinqBridge; using System.Linq; #endif using Newtonsoft.Json.Linq; -#if !NETFX_CORE -using NUnit.Framework; -#else +#if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute; +#elif ASPNETCORE50 +using Xunit; +using Test = Xunit.FactAttribute; +using Assert = Newtonsoft.Json.Tests.XUnitAssert; +#else +using NUnit.Framework; #endif using System.IO; @@ -61,7 +65,7 @@ namespace Newtonsoft.Json.Tests.Linq Assert.AreEqual(p, p.Value.Parent); } -#if !(NETFX_CORE || PORTABLE || PORTABLE40) +#if !(NETFX_CORE || PORTABLE || ASPNETCORE50 || PORTABLE40) [Test] public void ListChanged() { diff --git a/Src/Newtonsoft.Json.Tests/Linq/JRawTests.cs b/Src/Newtonsoft.Json.Tests/Linq/JRawTests.cs index ac050738..b2431622 100644 --- a/Src/Newtonsoft.Json.Tests/Linq/JRawTests.cs +++ b/Src/Newtonsoft.Json.Tests/Linq/JRawTests.cs @@ -23,13 +23,16 @@ // OTHER DEALINGS IN THE SOFTWARE. #endregion -#if !NETFX_CORE -using System; -using NUnit.Framework; -#else +#if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute; +#elif ASPNETCORE50 +using Xunit; +using Test = Xunit.FactAttribute; +using Assert = Newtonsoft.Json.Tests.XUnitAssert; +#else +using NUnit.Framework; #endif using Newtonsoft.Json.Linq; diff --git a/Src/Newtonsoft.Json.Tests/Linq/JTokenEqualityComparerTests.cs b/Src/Newtonsoft.Json.Tests/Linq/JTokenEqualityComparerTests.cs index 4f0c4f21..ecc64929 100644 --- a/Src/Newtonsoft.Json.Tests/Linq/JTokenEqualityComparerTests.cs +++ b/Src/Newtonsoft.Json.Tests/Linq/JTokenEqualityComparerTests.cs @@ -24,12 +24,16 @@ #endregion using System.Collections.Generic; -#if !NETFX_CORE -using NUnit.Framework; -#else +#if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute; +#elif ASPNETCORE50 +using Xunit; +using Test = Xunit.FactAttribute; +using Assert = Newtonsoft.Json.Tests.XUnitAssert; +#else +using NUnit.Framework; #endif using Newtonsoft.Json.Linq; diff --git a/Src/Newtonsoft.Json.Tests/Linq/JTokenReaderTest.cs b/Src/Newtonsoft.Json.Tests/Linq/JTokenReaderTest.cs index 990bbd4d..c7cd98cf 100644 --- a/Src/Newtonsoft.Json.Tests/Linq/JTokenReaderTest.cs +++ b/Src/Newtonsoft.Json.Tests/Linq/JTokenReaderTest.cs @@ -26,12 +26,16 @@ using System; using System.Collections.Generic; using System.Text; -#if !NETFX_CORE -using NUnit.Framework; -#else +#if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute; +#elif ASPNETCORE50 +using Xunit; +using Test = Xunit.FactAttribute; +using Assert = Newtonsoft.Json.Tests.XUnitAssert; +#else +using NUnit.Framework; #endif using Newtonsoft.Json; using System.IO; diff --git a/Src/Newtonsoft.Json.Tests/Linq/JTokenTests.cs b/Src/Newtonsoft.Json.Tests/Linq/JTokenTests.cs index ef103b8b..a17165db 100644 --- a/Src/Newtonsoft.Json.Tests/Linq/JTokenTests.cs +++ b/Src/Newtonsoft.Json.Tests/Linq/JTokenTests.cs @@ -25,17 +25,21 @@ using System; using System.Collections.Generic; -#if !(NET20 || NET35 || PORTABLE) +#if !(NET20 || NET35 || PORTABLE || ASPNETCORE50) using System.Numerics; #endif using System.Text; using Newtonsoft.Json.Converters; -#if !NETFX_CORE -using NUnit.Framework; -#else +#if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute; +#elif ASPNETCORE50 +using Xunit; +using Test = Xunit.FactAttribute; +using Assert = Newtonsoft.Json.Tests.XUnitAssert; +#else +using NUnit.Framework; #endif using Newtonsoft.Json.Linq; using System.IO; @@ -355,7 +359,7 @@ namespace Newtonsoft.Json.Tests.Linq Assert.AreEqual(5, (int)(new JValue(StringComparison.OrdinalIgnoreCase))); -#if !(NET20 || NET35 || PORTABLE || PORTABLE40) +#if !(NET20 || NET35 || PORTABLE || ASPNETCORE50 || PORTABLE40) string bigIntegerText = "1234567899999999999999999999999999999999999999999999999999999999999990"; Assert.AreEqual(BigInteger.Parse(bigIntegerText), (new JValue(BigInteger.Parse(bigIntegerText))).Value); @@ -435,7 +439,7 @@ namespace Newtonsoft.Json.Tests.Linq #endif ExceptionAssert.Throws(() => { var i = (Uri)new JValue(true); }, "Can not convert Boolean to Uri."); -#if !(NET20 || NET35 || PORTABLE || PORTABLE40) +#if !(NET20 || NET35 || PORTABLE || ASPNETCORE50 || PORTABLE40) ExceptionAssert.Throws(() => { var i = (new JValue(new Uri("http://www.google.com"))).ToObject(); }, "Can not convert Uri to BigInteger."); ExceptionAssert.Throws(() => { var i = (JValue.CreateNull()).ToObject(); }, "Can not convert Null to BigInteger."); ExceptionAssert.Throws(() => { var i = (new JValue(Guid.NewGuid())).ToObject(); }, "Can not convert Guid to BigInteger."); @@ -452,7 +456,7 @@ namespace Newtonsoft.Json.Tests.Linq [Test] public void ToObject() { -#if !(NET20 || NET35 || PORTABLE) +#if !(NET20 || NET35 || PORTABLE || ASPNETCORE50) Assert.AreEqual((BigInteger)1, (new JValue(1).ToObject(typeof(BigInteger)))); Assert.AreEqual((BigInteger)1, (new JValue(1).ToObject(typeof(BigInteger?)))); Assert.AreEqual((BigInteger?)null, (JValue.CreateNull().ToObject(typeof(BigInteger?)))); @@ -509,7 +513,7 @@ namespace Newtonsoft.Json.Tests.Linq Assert.IsTrue(JToken.DeepEquals(new JValue((DateTimeOffset?)null), (JValue)(DateTimeOffset?)null)); #endif -#if !(NET20 || NET35 || PORTABLE || PORTABLE40) +#if !(NET20 || NET35 || PORTABLE || ASPNETCORE50 || PORTABLE40) // had to remove implicit casting to avoid user reference to System.Numerics.dll Assert.IsTrue(JToken.DeepEquals(new JValue(new BigInteger(1)), new JValue(new BigInteger(1)))); Assert.IsTrue(JToken.DeepEquals(new JValue((BigInteger?)null), new JValue((BigInteger?)null))); @@ -948,7 +952,7 @@ namespace Newtonsoft.Json.Tests.Linq Assert.IsTrue(a.DeepEquals(a2)); } -#if !(NETFX_CORE || PORTABLE || PORTABLE40) +#if !(NETFX_CORE || PORTABLE || ASPNETCORE50 || PORTABLE40) [Test] public void Clone() { diff --git a/Src/Newtonsoft.Json.Tests/Linq/JTokenWriterTest.cs b/Src/Newtonsoft.Json.Tests/Linq/JTokenWriterTest.cs index 8635de13..81d06bd4 100644 --- a/Src/Newtonsoft.Json.Tests/Linq/JTokenWriterTest.cs +++ b/Src/Newtonsoft.Json.Tests/Linq/JTokenWriterTest.cs @@ -29,12 +29,16 @@ using System.Collections.Generic; using System.Numerics; #endif using System.Text; -#if !NETFX_CORE -using NUnit.Framework; -#else +#if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute; +#elif ASPNETCORE50 +using Xunit; +using Test = Xunit.FactAttribute; +using Assert = Newtonsoft.Json.Tests.XUnitAssert; +#else +using NUnit.Framework; #endif using Newtonsoft.Json; using System.IO; @@ -120,7 +124,7 @@ namespace Newtonsoft.Json.Tests.Linq jsonWriter.WriteValue("DVD read/writer"); Assert.AreEqual(WriteState.Array, jsonWriter.WriteState); -#if !(NET20 || NET35 || PORTABLE || PORTABLE40) +#if !(NET20 || NET35 || PORTABLE || ASPNETCORE50 || PORTABLE40) jsonWriter.WriteValue(new BigInteger(123)); Assert.AreEqual(WriteState.Array, jsonWriter.WriteState); #endif @@ -149,7 +153,7 @@ namespace Newtonsoft.Json.Tests.Linq /*fail*/]", writer.Token.ToString()); } -#if !(NET20 || NET35 || PORTABLE || PORTABLE40) +#if !(NET20 || NET35 || PORTABLE || ASPNETCORE50 || PORTABLE40) [Test] public void WriteBigInteger() { diff --git a/Src/Newtonsoft.Json.Tests/Linq/JValueTests.cs b/Src/Newtonsoft.Json.Tests/Linq/JValueTests.cs index 096c8d2d..9d45bd9b 100644 --- a/Src/Newtonsoft.Json.Tests/Linq/JValueTests.cs +++ b/Src/Newtonsoft.Json.Tests/Linq/JValueTests.cs @@ -27,16 +27,20 @@ using System; using System.Collections.Generic; using System.IO; using Newtonsoft.Json.Tests.TestObjects; -#if !(NET20 || NET35 || PORTABLE) +#if !(NET20 || NET35 || PORTABLE || ASPNETCORE50) using System.Numerics; #endif using System.Text; -#if !NETFX_CORE -using NUnit.Framework; -#else +#if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute; +#elif ASPNETCORE50 +using Xunit; +using Test = Xunit.FactAttribute; +using Assert = Newtonsoft.Json.Tests.XUnitAssert; +#else +using NUnit.Framework; #endif using Newtonsoft.Json.Linq; using System.Globalization; @@ -124,7 +128,7 @@ namespace Newtonsoft.Json.Tests.Linq Assert.AreEqual("Pie", v.Value); Assert.AreEqual(JTokenType.String, v.Type); -#if !(NETFX_CORE || PORTABLE || PORTABLE40) +#if !(NETFX_CORE || PORTABLE || ASPNETCORE50 || PORTABLE40) v.Value = DBNull.Value; Assert.AreEqual(DBNull.Value, v.Value); Assert.AreEqual(JTokenType.Null, v.Type); @@ -153,7 +157,7 @@ namespace Newtonsoft.Json.Tests.Linq Assert.AreEqual(g, v.Value); Assert.AreEqual(JTokenType.Guid, v.Type); -#if !(NET20 || NET35 || PORTABLE || PORTABLE40) +#if !(NET20 || NET35 || PORTABLE || ASPNETCORE50 || PORTABLE40) BigInteger i = BigInteger.Parse("123456789999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999990"); v.Value = i; Assert.AreEqual(i, v.Value); @@ -213,13 +217,13 @@ namespace Newtonsoft.Json.Tests.Linq v = new JValue(new Guid("B282ADE7-C520-496C-A448-4084F6803DE5")); Assert.AreEqual("b282ade7-c520-496c-a448-4084f6803de5", v.ToString(null, CultureInfo.InvariantCulture)); -#if !(NET20 || NET35 || PORTABLE || PORTABLE40) +#if !(NET20 || NET35 || PORTABLE || ASPNETCORE50 || PORTABLE40) v = new JValue(BigInteger.Parse("123456789999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999990")); Assert.AreEqual("123456789999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999990", v.ToString(null, CultureInfo.InvariantCulture)); #endif } -#if !(NET20 || NET35 || PORTABLE || PORTABLE40) +#if !(NET20 || NET35 || PORTABLE || ASPNETCORE50 || PORTABLE40) [Test] public void JValueParse() { @@ -468,7 +472,7 @@ namespace Newtonsoft.Json.Tests.Linq } #endif -#if !(NETFX_CORE || PORTABLE) +#if !(NETFX_CORE || PORTABLE || ASPNETCORE50) [Test] public void ConvertsToBoolean() { @@ -487,7 +491,7 @@ namespace Newtonsoft.Json.Tests.Linq Assert.AreEqual(Int32.MaxValue, Convert.ToInt32(new JValue(Int32.MaxValue))); } -#if !(NET20 || NET35 || PORTABLE || PORTABLE40) +#if !(NET20 || NET35 || PORTABLE || ASPNETCORE50 || PORTABLE40) [Test] public void ConvertsToInt32_BigInteger() { @@ -649,7 +653,7 @@ namespace Newtonsoft.Json.Tests.Linq v = new JValue(new Uri("http://www.google.com")); Assert.AreEqual(TypeCode.Object, v.GetTypeCode()); -#if !(NET20 || NET35 || PORTABLE || PORTABLE40) +#if !(NET20 || NET35 || PORTABLE || ASPNETCORE50 || PORTABLE40) v = new JValue(new BigInteger(3)); Assert.AreEqual(TypeCode.Object, v.GetTypeCode()); #endif @@ -663,7 +667,7 @@ namespace Newtonsoft.Json.Tests.Linq int i = (int)v.ToType(typeof(int), CultureInfo.InvariantCulture); Assert.AreEqual(9, i); -#if !(NET20 || NET35 || PORTABLE) +#if !(NET20 || NET35 || PORTABLE || ASPNETCORE50) BigInteger bi = (BigInteger)v.ToType(typeof(BigInteger), CultureInfo.InvariantCulture); Assert.AreEqual(new BigInteger(9), bi); #endif @@ -678,7 +682,7 @@ namespace Newtonsoft.Json.Tests.Linq Assert.AreEqual("2013", v.ToString("yyyy")); } -#if !(NET20 || NET35 || PORTABLE || PORTABLE40) +#if !(NET20 || NET35 || PORTABLE || ASPNETCORE50 || PORTABLE40) [Test] public void ToStringNewTypes() { diff --git a/Src/Newtonsoft.Json.Tests/Linq/JsonPath/JPathExecuteTests.cs b/Src/Newtonsoft.Json.Tests/Linq/JsonPath/JPathExecuteTests.cs index f54b52a7..d676bfc0 100644 --- a/Src/Newtonsoft.Json.Tests/Linq/JsonPath/JPathExecuteTests.cs +++ b/Src/Newtonsoft.Json.Tests/Linq/JsonPath/JPathExecuteTests.cs @@ -30,12 +30,16 @@ using System.Numerics; #endif using Newtonsoft.Json.Linq.JsonPath; using Newtonsoft.Json.Tests.Bson; -#if !NETFX_CORE -using NUnit.Framework; -#else +#if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute; +#elif ASPNETCORE50 +using Xunit; +using Test = Xunit.FactAttribute; +using Assert = Newtonsoft.Json.Tests.XUnitAssert; +#else +using NUnit.Framework; #endif using Newtonsoft.Json.Linq; #if NET20 @@ -601,7 +605,7 @@ namespace Newtonsoft.Json.Tests.Linq.JsonPath Assert.IsTrue(JToken.DeepEquals(new JObject(new JProperty("hi", 3)), t[1])); } -#if !(PORTABLE || PORTABLE40 || NET35 || NET20) +#if !(PORTABLE || ASPNETCORE50 || PORTABLE40 || NET35 || NET20) [Test] public void GreaterQueryBigInteger() { diff --git a/Src/Newtonsoft.Json.Tests/Linq/JsonPath/JPathParseTests.cs b/Src/Newtonsoft.Json.Tests/Linq/JsonPath/JPathParseTests.cs index d45e0579..e2da5a5a 100644 --- a/Src/Newtonsoft.Json.Tests/Linq/JsonPath/JPathParseTests.cs +++ b/Src/Newtonsoft.Json.Tests/Linq/JsonPath/JPathParseTests.cs @@ -26,12 +26,16 @@ using System; using System.Collections.Generic; using Newtonsoft.Json.Linq.JsonPath; -#if !NETFX_CORE -using NUnit.Framework; -#else +#if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute; +#elif ASPNETCORE50 +using Xunit; +using Test = Xunit.FactAttribute; +using Assert = Newtonsoft.Json.Tests.XUnitAssert; +#else +using NUnit.Framework; #endif using Newtonsoft.Json.Linq; #if NET20 diff --git a/Src/Newtonsoft.Json.Tests/Linq/JsonPath/QueryExpressionTests.cs b/Src/Newtonsoft.Json.Tests/Linq/JsonPath/QueryExpressionTests.cs index fb04e301..707ccb0c 100644 --- a/Src/Newtonsoft.Json.Tests/Linq/JsonPath/QueryExpressionTests.cs +++ b/Src/Newtonsoft.Json.Tests/Linq/JsonPath/QueryExpressionTests.cs @@ -1,14 +1,43 @@ -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.Text; using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq.JsonPath; -#if !NETFX_CORE -using NUnit.Framework; -#else +#if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute; +#elif ASPNETCORE50 +using Xunit; +using Test = Xunit.FactAttribute; +using Assert = Newtonsoft.Json.Tests.XUnitAssert; +#else +using NUnit.Framework; #endif namespace Newtonsoft.Json.Tests.Linq.JsonPath diff --git a/Src/Newtonsoft.Json.Tests/Linq/LinqToJsonTest.cs b/Src/Newtonsoft.Json.Tests/Linq/LinqToJsonTest.cs index 2feba3ad..55c116a7 100644 --- a/Src/Newtonsoft.Json.Tests/Linq/LinqToJsonTest.cs +++ b/Src/Newtonsoft.Json.Tests/Linq/LinqToJsonTest.cs @@ -27,12 +27,16 @@ using System; using System.Collections; using System.Collections.Generic; using System.Globalization; -#if !NETFX_CORE -using NUnit.Framework; -#else +#if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute; +#elif ASPNETCORE50 +using Xunit; +using Test = Xunit.FactAttribute; +using Assert = Newtonsoft.Json.Tests.XUnitAssert; +#else +using NUnit.Framework; #endif using Newtonsoft.Json.Converters; using Newtonsoft.Json.Linq; diff --git a/Src/Newtonsoft.Json.Tests/Linq/MergeTests.cs b/Src/Newtonsoft.Json.Tests/Linq/MergeTests.cs index 4e906ba1..bba380f9 100644 --- a/Src/Newtonsoft.Json.Tests/Linq/MergeTests.cs +++ b/Src/Newtonsoft.Json.Tests/Linq/MergeTests.cs @@ -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; #if NET20 using Newtonsoft.Json.Utilities.LinqBridge; @@ -7,7 +32,17 @@ using System.Linq; #endif using System.Text; using Newtonsoft.Json.Linq; +#if NETFX_CORE +using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; +using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; +using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute; +#elif ASPNETCORE50 +using Xunit; +using Test = Xunit.FactAttribute; +using Assert = Newtonsoft.Json.Tests.XUnitAssert; +#else using NUnit.Framework; +#endif namespace Newtonsoft.Json.Tests.Linq { diff --git a/Src/Newtonsoft.Json.Tests/LinqToSql/LinqToSqlClassesSerializationTests.cs b/Src/Newtonsoft.Json.Tests/LinqToSql/LinqToSqlClassesSerializationTests.cs index 8f0e1724..c675e444 100644 --- a/Src/Newtonsoft.Json.Tests/LinqToSql/LinqToSqlClassesSerializationTests.cs +++ b/Src/Newtonsoft.Json.Tests/LinqToSql/LinqToSqlClassesSerializationTests.cs @@ -23,6 +23,7 @@ // OTHER DEALINGS IN THE SOFTWARE. #endregion +#if !(ASPNETCORE50 || NETFX_CORE || PORTABLE40 || PORTABLE40) using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; @@ -132,4 +133,5 @@ namespace Newtonsoft.Json.Tests.LinqToSql Assert.AreEqual("_FirstName", columnAttribute.Storage); } } -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/Src/Newtonsoft.Json.Tests/PerformanceTests.cs b/Src/Newtonsoft.Json.Tests/PerformanceTests.cs index 7b505642..35d2a4e8 100644 --- a/Src/Newtonsoft.Json.Tests/PerformanceTests.cs +++ b/Src/Newtonsoft.Json.Tests/PerformanceTests.cs @@ -23,8 +23,8 @@ // OTHER DEALINGS IN THE SOFTWARE. #endregion +#if !(NET20 || NET35 || NETFX_CORE || PORTABLE || ASPNETCORE50) using System.Xml; -#if !(NET20 || NET35 || NETFX_CORE || PORTABLE) using System; using System.Collections; using System.Collections.Generic; @@ -184,7 +184,7 @@ namespace Newtonsoft.Json.Tests { var json = System.IO.File.ReadAllText("large.json"); - BenchmarkDeserializeMethod>(SerializeMethod.JsonNet, json, 100, false); + BenchmarkDeserializeMethod>(SerializeMethod.JsonNet, json, Iterations / 10, false); } [Test] diff --git a/Src/Newtonsoft.Json.Tests/Schema/ExtensionsTests.cs b/Src/Newtonsoft.Json.Tests/Schema/ExtensionsTests.cs index 2865300a..69cac854 100644 --- a/Src/Newtonsoft.Json.Tests/Schema/ExtensionsTests.cs +++ b/Src/Newtonsoft.Json.Tests/Schema/ExtensionsTests.cs @@ -25,20 +25,23 @@ using System; using System.Collections.Generic; -#if !NETFX_CORE -using NUnit.Framework; -#else +#if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute; +#elif ASPNETCORE50 +using Xunit; +using Test = Xunit.FactAttribute; +using Assert = Newtonsoft.Json.Tests.XUnitAssert; +#else +using NUnit.Framework; #endif using Newtonsoft.Json.Schema; using Newtonsoft.Json.Linq; using System.IO; using Newtonsoft.Json.Tests.TestObjects; -#if !(NETFX_CORE) +#if !(NETFX_CORE || ASPNETCORE50) using System.Data; - #endif namespace Newtonsoft.Json.Tests.Schema @@ -199,7 +202,7 @@ namespace Newtonsoft.Json.Tests.Schema #if !NET20 GenerateSchemaAndSerializeFromType(new NullableDateTimeTestClass()); #endif -#if !(NETFX_CORE || PORTABLE || PORTABLE40) +#if !(NETFX_CORE || PORTABLE || ASPNETCORE50 || PORTABLE40) GenerateSchemaAndSerializeFromType(new DataSet()); #endif GenerateSchemaAndSerializeFromType(new object()); @@ -207,7 +210,7 @@ namespace Newtonsoft.Json.Tests.Schema GenerateSchemaAndSerializeFromType("Hi"); GenerateSchemaAndSerializeFromType(new DateTime(2000, 12, 29, 23, 59, 0, DateTimeKind.Utc)); GenerateSchemaAndSerializeFromType(TimeSpan.FromTicks(1000000)); -#if !(NETFX_CORE || PORTABLE || PORTABLE40) +#if !(NETFX_CORE || PORTABLE || ASPNETCORE50 || PORTABLE40) GenerateSchemaAndSerializeFromType(DBNull.Value); #endif GenerateSchemaAndSerializeFromType(new JsonPropertyWithHandlingValues()); diff --git a/Src/Newtonsoft.Json.Tests/Schema/JsonSchemaBuilderTests.cs b/Src/Newtonsoft.Json.Tests/Schema/JsonSchemaBuilderTests.cs index 565b31e3..c2c72f78 100644 --- a/Src/Newtonsoft.Json.Tests/Schema/JsonSchemaBuilderTests.cs +++ b/Src/Newtonsoft.Json.Tests/Schema/JsonSchemaBuilderTests.cs @@ -24,12 +24,16 @@ #endregion using System; -#if !NETFX_CORE -using NUnit.Framework; -#else +#if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute; +#elif ASPNETCORE50 +using Xunit; +using Test = Xunit.FactAttribute; +using Assert = Newtonsoft.Json.Tests.XUnitAssert; +#else +using NUnit.Framework; #endif using Newtonsoft.Json.Schema; using System.IO; diff --git a/Src/Newtonsoft.Json.Tests/Schema/JsonSchemaGeneratorTests.cs b/Src/Newtonsoft.Json.Tests/Schema/JsonSchemaGeneratorTests.cs index 3b6cc234..15200dfc 100644 --- a/Src/Newtonsoft.Json.Tests/Schema/JsonSchemaGeneratorTests.cs +++ b/Src/Newtonsoft.Json.Tests/Schema/JsonSchemaGeneratorTests.cs @@ -31,12 +31,16 @@ using Newtonsoft.Json.Converters; using Newtonsoft.Json.Serialization; using Newtonsoft.Json.Tests.TestObjects; using Newtonsoft.Json.Utilities; -#if !NETFX_CORE -using NUnit.Framework; -#else +#if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute; +#elif ASPNETCORE50 +using Xunit; +using Test = Xunit.FactAttribute; +using Assert = Newtonsoft.Json.Tests.XUnitAssert; +#else +using NUnit.Framework; #endif using Newtonsoft.Json.Schema; using System.IO; @@ -47,7 +51,6 @@ using Extensions = Newtonsoft.Json.Schema.Extensions; using Newtonsoft.Json.Utilities.LinqBridge; #else using System.Linq; - #endif namespace Newtonsoft.Json.Tests.Schema @@ -91,7 +94,7 @@ namespace Newtonsoft.Json.Tests.Schema Assert.IsTrue(o.IsValid(schema)); } -#if !(NETFX_CORE || PORTABLE || PORTABLE40) +#if !(NETFX_CORE || PORTABLE || ASPNETCORE50 || PORTABLE40) [Test] public void Generate_DefaultValueAttributeTestClass() { @@ -310,7 +313,7 @@ namespace Newtonsoft.Json.Tests.Schema Assert.IsTrue(v.IsValid(schema)); } -#if !(NETFX_CORE || PORTABLE || PORTABLE40) +#if !(NETFX_CORE || PORTABLE || ASPNETCORE50 || PORTABLE40) [Test] public void GenerateSchemaForISerializable() { @@ -325,7 +328,7 @@ namespace Newtonsoft.Json.Tests.Schema } #endif -#if !(NETFX_CORE || PORTABLE || PORTABLE40) +#if !(NETFX_CORE || PORTABLE || ASPNETCORE50 || PORTABLE40) [Test] public void GenerateSchemaForDBNull() { @@ -370,7 +373,7 @@ namespace Newtonsoft.Json.Tests.Schema generator.UndefinedSchemaIdHandling = UndefinedSchemaIdHandling.UseTypeName; generator.ContractResolver = new CustomDirectoryInfoMapper { -#if !(NETFX_CORE || PORTABLE) +#if !(NETFX_CORE || PORTABLE || ASPNETCORE50) IgnoreSerializableAttribute = true #endif }; @@ -454,7 +457,7 @@ namespace Newtonsoft.Json.Tests.Schema serializer.Converters.Add(new IsoDateTimeConverter()); serializer.ContractResolver = new CustomDirectoryInfoMapper { -#if !(NETFX_CORE || PORTABLE) +#if !(NETFX_CORE || PORTABLE || ASPNETCORE50) IgnoreSerializableInterface = true #endif }; @@ -474,7 +477,7 @@ namespace Newtonsoft.Json.Tests.Schema generator.UndefinedSchemaIdHandling = UndefinedSchemaIdHandling.UseTypeName; generator.ContractResolver = new CamelCasePropertyNamesContractResolver() { -#if !(NETFX_CORE || PORTABLE || PORTABLE40) +#if !(NETFX_CORE || PORTABLE || ASPNETCORE50 || PORTABLE40) IgnoreSerializableAttribute = true #endif }; @@ -519,7 +522,7 @@ namespace Newtonsoft.Json.Tests.Schema }", json); } -#if !(NETFX_CORE || PORTABLE || PORTABLE40) +#if !(NETFX_CORE || PORTABLE || ASPNETCORE50 || PORTABLE40) [Test] public void GenerateSchemaSerializable() { @@ -773,6 +776,7 @@ namespace Newtonsoft.Json.Tests.Schema public SortTypeFlagAsString y; } +#if !ASPNETCORE50 [Test] [Ignore] public void GenerateSchemaWithStringEnum() @@ -799,6 +803,7 @@ namespace Newtonsoft.Json.Tests.Schema } }", json); } +#endif } public class NullableInt32TestClass diff --git a/Src/Newtonsoft.Json.Tests/Schema/JsonSchemaModelBuilderTests.cs b/Src/Newtonsoft.Json.Tests/Schema/JsonSchemaModelBuilderTests.cs index e793c92c..aaddddae 100644 --- a/Src/Newtonsoft.Json.Tests/Schema/JsonSchemaModelBuilderTests.cs +++ b/Src/Newtonsoft.Json.Tests/Schema/JsonSchemaModelBuilderTests.cs @@ -24,13 +24,16 @@ #endregion using Newtonsoft.Json.Schema; -#if !NETFX_CORE -using NUnit.Framework; - -#else +#if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute; +#elif ASPNETCORE50 +using Xunit; +using Test = Xunit.FactAttribute; +using Assert = Newtonsoft.Json.Tests.XUnitAssert; +#else +using NUnit.Framework; #endif namespace Newtonsoft.Json.Tests.Schema diff --git a/Src/Newtonsoft.Json.Tests/Schema/JsonSchemaNodeTests.cs b/Src/Newtonsoft.Json.Tests/Schema/JsonSchemaNodeTests.cs index b622f841..0fb6baf8 100644 --- a/Src/Newtonsoft.Json.Tests/Schema/JsonSchemaNodeTests.cs +++ b/Src/Newtonsoft.Json.Tests/Schema/JsonSchemaNodeTests.cs @@ -24,13 +24,16 @@ #endregion using Newtonsoft.Json.Schema; -#if !NETFX_CORE -using NUnit.Framework; - -#else +#if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute; +#elif ASPNETCORE50 +using Xunit; +using Test = Xunit.FactAttribute; +using Assert = Newtonsoft.Json.Tests.XUnitAssert; +#else +using NUnit.Framework; #endif namespace Newtonsoft.Json.Tests.Schema diff --git a/Src/Newtonsoft.Json.Tests/Schema/JsonSchemaSpecTests.cs b/Src/Newtonsoft.Json.Tests/Schema/JsonSchemaSpecTests.cs index d1baf692..2deb500d 100644 --- a/Src/Newtonsoft.Json.Tests/Schema/JsonSchemaSpecTests.cs +++ b/Src/Newtonsoft.Json.Tests/Schema/JsonSchemaSpecTests.cs @@ -1,4 +1,30 @@ -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 + +#if !(ASPNETCORE50 || NETFX_CORE) +using System; using System.Collections.Generic; using System.IO; using System.Linq; @@ -92,4 +118,5 @@ namespace Newtonsoft.Json.Tests.Schema return specTests; } } -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/Src/Newtonsoft.Json.Tests/Schema/JsonSchemaTests.cs b/Src/Newtonsoft.Json.Tests/Schema/JsonSchemaTests.cs index 21d113d2..9bea22ce 100644 --- a/Src/Newtonsoft.Json.Tests/Schema/JsonSchemaTests.cs +++ b/Src/Newtonsoft.Json.Tests/Schema/JsonSchemaTests.cs @@ -28,13 +28,16 @@ using System.Collections.Generic; using System.IO; using Newtonsoft.Json.Linq; using Newtonsoft.Json.Schema; -#if !NETFX_CORE -using NUnit.Framework; - -#else +#if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute; +#elif ASPNETCORE50 +using Xunit; +using Test = Xunit.FactAttribute; +using Assert = Newtonsoft.Json.Tests.XUnitAssert; +#else +using NUnit.Framework; #endif namespace Newtonsoft.Json.Tests.Schema diff --git a/Src/Newtonsoft.Json.Tests/Serialization/CamelCasePropertyNamesContractResolverTests.cs b/Src/Newtonsoft.Json.Tests/Serialization/CamelCasePropertyNamesContractResolverTests.cs index 7ecc054e..44438f86 100644 --- a/Src/Newtonsoft.Json.Tests/Serialization/CamelCasePropertyNamesContractResolverTests.cs +++ b/Src/Newtonsoft.Json.Tests/Serialization/CamelCasePropertyNamesContractResolverTests.cs @@ -26,12 +26,16 @@ using System; using System.Collections.Generic; using Newtonsoft.Json.Serialization; -#if !NETFX_CORE -using NUnit.Framework; -#else +#if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute; +#elif ASPNETCORE50 +using Xunit; +using Test = Xunit.FactAttribute; +using Assert = Newtonsoft.Json.Tests.XUnitAssert; +#else +using NUnit.Framework; #endif using Newtonsoft.Json.Tests.TestObjects; using Newtonsoft.Json.Linq; @@ -101,7 +105,7 @@ namespace Newtonsoft.Json.Tests.Serialization string json = o.ToString(); } -#if !(NETFX_CORE || PORTABLE || PORTABLE40) +#if !(NETFX_CORE || PORTABLE || ASPNETCORE50 || PORTABLE40) #pragma warning disable 618 [Test] public void MemberSearchFlags() diff --git a/Src/Newtonsoft.Json.Tests/Serialization/ConstructorHandlingTests.cs b/Src/Newtonsoft.Json.Tests/Serialization/ConstructorHandlingTests.cs index 69bd5453..2f82b038 100644 --- a/Src/Newtonsoft.Json.Tests/Serialization/ConstructorHandlingTests.cs +++ b/Src/Newtonsoft.Json.Tests/Serialization/ConstructorHandlingTests.cs @@ -26,13 +26,16 @@ using System; using System.Reflection; using Newtonsoft.Json.Tests.TestObjects; -#if !NETFX_CORE -using NUnit.Framework; - -#else +#if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute; +#elif ASPNETCORE50 +using Xunit; +using Test = Xunit.FactAttribute; +using Assert = Newtonsoft.Json.Tests.XUnitAssert; +#else +using NUnit.Framework; #endif namespace Newtonsoft.Json.Tests.Serialization diff --git a/Src/Newtonsoft.Json.Tests/Serialization/ContractResolverTests.cs b/Src/Newtonsoft.Json.Tests/Serialization/ContractResolverTests.cs index 851e2721..0084d018 100644 --- a/Src/Newtonsoft.Json.Tests/Serialization/ContractResolverTests.cs +++ b/Src/Newtonsoft.Json.Tests/Serialization/ContractResolverTests.cs @@ -27,12 +27,16 @@ using System; using System.Collections.Generic; using System.IO; using System.Runtime.Serialization; -#if !NETFX_CORE -using NUnit.Framework; -#else +#if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute; +#elif ASPNETCORE50 +using Xunit; +using Test = Xunit.FactAttribute; +using Assert = Newtonsoft.Json.Tests.XUnitAssert; +#else +using NUnit.Framework; #endif #if NET20 using Newtonsoft.Json.Utilities.LinqBridge; @@ -547,7 +551,7 @@ namespace Newtonsoft.Json.Tests.Serialization }", startingWithB); } -#if !(NETFX_CORE || PORTABLE || PORTABLE40) +#if !(NETFX_CORE || PORTABLE || ASPNETCORE50 || PORTABLE40) #pragma warning disable 618 [Test] public void SerializeCompilerGeneratedMembers() diff --git a/Src/Newtonsoft.Json.Tests/Serialization/DefaultValueHandlingTests.cs b/Src/Newtonsoft.Json.Tests/Serialization/DefaultValueHandlingTests.cs index 04529f15..04d06713 100644 --- a/Src/Newtonsoft.Json.Tests/Serialization/DefaultValueHandlingTests.cs +++ b/Src/Newtonsoft.Json.Tests/Serialization/DefaultValueHandlingTests.cs @@ -32,12 +32,16 @@ using System.Runtime.Serialization.Json; #endif using System.Text; using Newtonsoft.Json.Tests.TestObjects; -#if !NETFX_CORE -using NUnit.Framework; -#else +#if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute; +#elif ASPNETCORE50 +using Xunit; +using Test = Xunit.FactAttribute; +using Assert = Newtonsoft.Json.Tests.XUnitAssert; +#else +using NUnit.Framework; #endif using Newtonsoft.Json.Utilities; diff --git a/Src/Newtonsoft.Json.Tests/Serialization/DependencyInjectionTests.cs b/Src/Newtonsoft.Json.Tests/Serialization/DependencyInjectionTests.cs index 4ee4171a..2eab44b2 100644 --- a/Src/Newtonsoft.Json.Tests/Serialization/DependencyInjectionTests.cs +++ b/Src/Newtonsoft.Json.Tests/Serialization/DependencyInjectionTests.cs @@ -23,17 +23,27 @@ // OTHER DEALINGS IN THE SOFTWARE. #endregion +#if !(NET35 || NET20 || ASPNETCORE50) using Autofac; using Newtonsoft.Json.Serialization; using Newtonsoft.Json.Tests.TestObjects; -#if !(NET35 || NET20) using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Microsoft.FSharp.Collections; +#if NETFX_CORE +using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; +using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; +using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute; +#elif ASPNETCORE50 +using Xunit; +using Test = Xunit.FactAttribute; +using Assert = Newtonsoft.Json.Tests.XUnitAssert; +#else using NUnit.Framework; +#endif namespace Newtonsoft.Json.Tests.Serialization { diff --git a/Src/Newtonsoft.Json.Tests/Serialization/DynamicConcreteTests.cs b/Src/Newtonsoft.Json.Tests/Serialization/DynamicConcreteTests.cs index c856f006..de688f32 100644 --- a/Src/Newtonsoft.Json.Tests/Serialization/DynamicConcreteTests.cs +++ b/Src/Newtonsoft.Json.Tests/Serialization/DynamicConcreteTests.cs @@ -23,6 +23,7 @@ // OTHER DEALINGS IN THE SOFTWARE. #endregion +#if !(NETFX_CORE || PORTABLE || ASPNETCORE50) using System.Reflection; using System.Reflection.Emit; using Newtonsoft.Json.Serialization; @@ -30,12 +31,16 @@ using Newtonsoft.Json.Tests.TestObjects; using System; using System.Linq; -#if !NETFX_CORE -using NUnit.Framework; -#else +#if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute; +#elif ASPNETCORE50 +using Xunit; +using Test = Xunit.FactAttribute; +using Assert = Newtonsoft.Json.Tests.XUnitAssert; +#else +using NUnit.Framework; #endif namespace Newtonsoft.Json.Tests.Serialization @@ -280,4 +285,5 @@ namespace Newtonsoft.Json.Tests.Serialization propertyBuilder.SetSetMethod(backingSet); } } -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/Src/Newtonsoft.Json.Tests/Serialization/DynamicTests.cs b/Src/Newtonsoft.Json.Tests/Serialization/DynamicTests.cs index e3db5782..f223dc2b 100644 --- a/Src/Newtonsoft.Json.Tests/Serialization/DynamicTests.cs +++ b/Src/Newtonsoft.Json.Tests/Serialization/DynamicTests.cs @@ -37,13 +37,16 @@ using System.Text; using Newtonsoft.Json.Serialization; using Newtonsoft.Json.Tests.TestObjects; using Newtonsoft.Json.Utilities; -#if !NETFX_CORE -using NUnit.Framework; - -#else +#if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute; +#elif ASPNETCORE50 +using Xunit; +using Test = Xunit.FactAttribute; +using Assert = Newtonsoft.Json.Tests.XUnitAssert; +#else +using NUnit.Framework; #endif namespace Newtonsoft.Json.Tests.Serialization diff --git a/Src/Newtonsoft.Json.Tests/Serialization/EntitiesSerializationTests.cs b/Src/Newtonsoft.Json.Tests/Serialization/EntitiesSerializationTests.cs index ddb0353d..a0ef1d1a 100644 --- a/Src/Newtonsoft.Json.Tests/Serialization/EntitiesSerializationTests.cs +++ b/Src/Newtonsoft.Json.Tests/Serialization/EntitiesSerializationTests.cs @@ -23,21 +23,24 @@ // OTHER DEALINGS IN THE SOFTWARE. #endregion +#if !(NET35 || NET20 || NETFX_CORE || PORTABLE || ASPNETCORE50 || PORTABLE40) using Newtonsoft.Json.Serialization; -#if !(NET35 || NET20 || NETFX_CORE || PORTABLE || PORTABLE40) using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Text; using Newtonsoft.Json.Converters; -#if !NETFX_CORE -using NUnit.Framework; - -#else +#if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute; +#elif ASPNETCORE50 +using Xunit; +using Test = Xunit.FactAttribute; +using Assert = Newtonsoft.Json.Tests.XUnitAssert; +#else +using NUnit.Framework; #endif namespace Newtonsoft.Json.Tests.Serialization diff --git a/Src/Newtonsoft.Json.Tests/Serialization/ExtensionDataTests.cs b/Src/Newtonsoft.Json.Tests/Serialization/ExtensionDataTests.cs index ffdaf324..5f8fbb04 100644 --- a/Src/Newtonsoft.Json.Tests/Serialization/ExtensionDataTests.cs +++ b/Src/Newtonsoft.Json.Tests/Serialization/ExtensionDataTests.cs @@ -28,12 +28,16 @@ using System.Collections.Generic; using System.Text; using Newtonsoft.Json.Linq; using Newtonsoft.Json.Tests.TestObjects; -#if !NETFX_CORE -using NUnit.Framework; -#else +#if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute; +#elif ASPNETCORE50 +using Xunit; +using Test = Xunit.FactAttribute; +using Assert = Newtonsoft.Json.Tests.XUnitAssert; +#else +using NUnit.Framework; #endif namespace Newtonsoft.Json.Tests.Serialization diff --git a/Src/Newtonsoft.Json.Tests/Serialization/FSharpTests.cs b/Src/Newtonsoft.Json.Tests/Serialization/FSharpTests.cs index 827284dc..c703f993 100644 --- a/Src/Newtonsoft.Json.Tests/Serialization/FSharpTests.cs +++ b/Src/Newtonsoft.Json.Tests/Serialization/FSharpTests.cs @@ -23,14 +23,14 @@ // OTHER DEALINGS IN THE SOFTWARE. #endregion -#if !(NET35 || NET20 || NETFX_CORE) +#if !(NET35 || NET20 || NETFX_CORE || ASPNETCORE50) +using NUnit.Framework; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Microsoft.FSharp.Collections; -using NUnit.Framework; namespace Newtonsoft.Json.Tests.Serialization { diff --git a/Src/Newtonsoft.Json.Tests/Serialization/ImmutableCollectionsTests.cs b/Src/Newtonsoft.Json.Tests/Serialization/ImmutableCollectionsTests.cs index cc8b2d36..87f2fdf5 100644 --- a/Src/Newtonsoft.Json.Tests/Serialization/ImmutableCollectionsTests.cs +++ b/Src/Newtonsoft.Json.Tests/Serialization/ImmutableCollectionsTests.cs @@ -30,12 +30,16 @@ using System.Collections.Immutable; using System.Linq; using System.Text; using System.Threading.Tasks; -#if !NETFX_CORE -using NUnit.Framework; -#else +#if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute; +#elif ASPNETCORE50 +using Xunit; +using Test = Xunit.FactAttribute; +using Assert = Newtonsoft.Json.Tests.XUnitAssert; +#else +using NUnit.Framework; #endif using Newtonsoft.Json.Linq; @@ -61,6 +65,9 @@ namespace Newtonsoft.Json.Tests.Serialization ""II"", ""3"" ]", json); + + Console.WriteLine("Serialized immutable list:"); + Console.WriteLine(json); } [Test] @@ -99,6 +106,10 @@ namespace Newtonsoft.Json.Tests.Serialization Assert.AreEqual("Volibear", champions[0]); Assert.AreEqual("Teemo", champions[1]); Assert.AreEqual("Katarina", champions[2]); + + Console.WriteLine("Deserialized immutable list:"); + Console.WriteLine(string.Join(", ", champions)); + } #endregion diff --git a/Src/Newtonsoft.Json.Tests/Serialization/JsonPropertyCollectionTests.cs b/Src/Newtonsoft.Json.Tests/Serialization/JsonPropertyCollectionTests.cs index 2edf003f..3d483ad9 100644 --- a/Src/Newtonsoft.Json.Tests/Serialization/JsonPropertyCollectionTests.cs +++ b/Src/Newtonsoft.Json.Tests/Serialization/JsonPropertyCollectionTests.cs @@ -23,12 +23,16 @@ // OTHER DEALINGS IN THE SOFTWARE. #endregion -#if !NETFX_CORE -using NUnit.Framework; -#else +#if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute; +#elif ASPNETCORE50 +using Xunit; +using Test = Xunit.FactAttribute; +using Assert = Newtonsoft.Json.Tests.XUnitAssert; +#else +using NUnit.Framework; #endif using Newtonsoft.Json.Serialization; using Newtonsoft.Json.Tests.TestObjects; diff --git a/Src/Newtonsoft.Json.Tests/Serialization/JsonSerializerCollectionsTests.cs b/Src/Newtonsoft.Json.Tests/Serialization/JsonSerializerCollectionsTests.cs index 5b7f6207..e9cd4f04 100644 --- a/Src/Newtonsoft.Json.Tests/Serialization/JsonSerializerCollectionsTests.cs +++ b/Src/Newtonsoft.Json.Tests/Serialization/JsonSerializerCollectionsTests.cs @@ -25,7 +25,7 @@ using System; using System.Collections; -#if !(NET35 || NET20 || PORTABLE || PORTABLE40) +#if !(NET35 || NET20 || PORTABLE || ASPNETCORE50 || PORTABLE40) using System.Collections.Concurrent; #endif using System.Collections.Generic; @@ -40,12 +40,16 @@ using System.Linq; using System.Text; using Newtonsoft.Json.Linq; using Newtonsoft.Json.Tests.TestObjects; -#if !NETFX_CORE -using NUnit.Framework; -#else +#if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute; +#elif ASPNETCORE50 +using Xunit; +using Test = Xunit.FactAttribute; +using Assert = Newtonsoft.Json.Tests.XUnitAssert; +#else +using NUnit.Framework; #endif namespace Newtonsoft.Json.Tests.Serialization @@ -541,7 +545,7 @@ namespace Newtonsoft.Json.Tests.Serialization Assert.AreEqual(3, v2["Third"]); } -#if !(NET35 || NET20 || PORTABLE || PORTABLE40) +#if !(NET35 || NET20 || PORTABLE || ASPNETCORE50 || PORTABLE40) [Test] public void DeserializeConcurrentDictionary() { @@ -1255,7 +1259,7 @@ namespace Newtonsoft.Json.Tests.Serialization Assert.AreEqual(1, (int)((JObject)o.Data[2])["one"]); } -#if !NETFX_CORE +#if !(NETFX_CORE || ASPNETCORE50) [Test] public void SerializeArrayAsArrayList() { diff --git a/Src/Newtonsoft.Json.Tests/Serialization/JsonSerializerTest.cs b/Src/Newtonsoft.Json.Tests/Serialization/JsonSerializerTest.cs index 1a590f41..67d11e43 100644 --- a/Src/Newtonsoft.Json.Tests/Serialization/JsonSerializerTest.cs +++ b/Src/Newtonsoft.Json.Tests/Serialization/JsonSerializerTest.cs @@ -29,10 +29,10 @@ using System.ComponentModel; using System.Collections.Concurrent; #endif using System.Collections.Generic; -#if !(NET20 || NET35 || PORTABLE) +#if !(NET20 || NET35 || PORTABLE || ASPNETCORE50) using System.Numerics; #endif -#if !NET20 && !NETFX_CORE +#if !(NET20 || NETFX_CORE || ASPNETCORE50) using System.ComponentModel.DataAnnotations; using System.Configuration; using System.Runtime.CompilerServices; @@ -42,12 +42,16 @@ using System.Web.Script.Serialization; #endif using System.Text; using System.Text.RegularExpressions; -#if !NETFX_CORE -using NUnit.Framework; -#else +#if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute; +#elif ASPNETCORE50 +using Xunit; +using Test = Xunit.FactAttribute; +using Assert = Newtonsoft.Json.Tests.XUnitAssert; +#else +using NUnit.Framework; #endif using Newtonsoft.Json; using System.IO; @@ -81,7 +85,7 @@ using Newtonsoft.Json.Utilities.LinqBridge; #else using System.Linq; #endif -#if !(NETFX_CORE) +#if !(NETFX_CORE || ASPNETCORE50) using System.Drawing; using System.Diagnostics; #endif @@ -109,7 +113,7 @@ namespace Newtonsoft.Json.Tests.Serialization public int ChildId; } -#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) +#if !(NET20 || NET35 || PORTABLE40 || PORTABLE || ASPNETCORE50) [Test] public void ReadIntegerWithError() { @@ -365,7 +369,7 @@ namespace Newtonsoft.Json.Tests.Serialization serializer.ConstructorHandling = ConstructorHandling.AllowNonPublicDefaultConstructor; Assert.AreEqual(ConstructorHandling.AllowNonPublicDefaultConstructor, serializer.ConstructorHandling); -#if !NETFX_CORE +#if !(NETFX_CORE || ASPNETCORE50) serializer.Context = new StreamingContext(StreamingContextStates.Other); Assert.AreEqual(new StreamingContext(StreamingContextStates.Other), serializer.Context); #endif @@ -433,7 +437,7 @@ namespace Newtonsoft.Json.Tests.Serialization serializer.TraceWriter = traceWriter; Assert.AreEqual(traceWriter, serializer.TraceWriter); -#if !(PORTABLE || PORTABLE40 || NETFX_CORE || NET20) +#if !(PORTABLE || PORTABLE40 || NETFX_CORE || NET20 || ASPNETCORE50) serializer.TypeNameAssemblyFormat = FormatterAssemblyStyle.Full; Assert.AreEqual(FormatterAssemblyStyle.Full, serializer.TypeNameAssemblyFormat); #endif @@ -457,7 +461,7 @@ namespace Newtonsoft.Json.Tests.Serialization settings.ConstructorHandling = ConstructorHandling.AllowNonPublicDefaultConstructor; Assert.AreEqual(ConstructorHandling.AllowNonPublicDefaultConstructor, settings.ConstructorHandling); -#if !NETFX_CORE +#if !(NETFX_CORE || ASPNETCORE50) settings.Context = new StreamingContext(StreamingContextStates.Other); Assert.AreEqual(new StreamingContext(StreamingContextStates.Other), settings.Context); #endif @@ -525,7 +529,7 @@ namespace Newtonsoft.Json.Tests.Serialization settings.TraceWriter = traceWriter; Assert.AreEqual(traceWriter, settings.TraceWriter); -#if !(PORTABLE || PORTABLE40 || NETFX_CORE || NET20) +#if !(PORTABLE || PORTABLE40 || NETFX_CORE || NET20 || ASPNETCORE50) settings.TypeNameAssemblyFormat = FormatterAssemblyStyle.Full; Assert.AreEqual(FormatterAssemblyStyle.Full, settings.TypeNameAssemblyFormat); #endif @@ -549,7 +553,7 @@ namespace Newtonsoft.Json.Tests.Serialization serializerProxy.ConstructorHandling = ConstructorHandling.AllowNonPublicDefaultConstructor; Assert.AreEqual(ConstructorHandling.AllowNonPublicDefaultConstructor, serializerProxy.ConstructorHandling); -#if !NETFX_CORE +#if !(NETFX_CORE || ASPNETCORE50) serializerProxy.Context = new StreamingContext(StreamingContextStates.Other); Assert.AreEqual(new StreamingContext(StreamingContextStates.Other), serializerProxy.Context); #endif @@ -617,7 +621,7 @@ namespace Newtonsoft.Json.Tests.Serialization serializerProxy.TraceWriter = traceWriter; Assert.AreEqual(traceWriter, serializerProxy.TraceWriter); -#if !(PORTABLE || PORTABLE40 || NETFX_CORE || NET20) +#if !(PORTABLE || PORTABLE40 || NETFX_CORE || NET20 || ASPNETCORE50) serializerProxy.TypeNameAssemblyFormat = FormatterAssemblyStyle.Full; Assert.AreEqual(FormatterAssemblyStyle.Full, serializerProxy.TypeNameAssemblyFormat); #endif @@ -626,7 +630,7 @@ namespace Newtonsoft.Json.Tests.Serialization Assert.AreEqual(TypeNameHandling.All, serializerProxy.TypeNameHandling); } -#if !(NETFX_CORE || PORTABLE || PORTABLE40) +#if !(NETFX_CORE || PORTABLE || PORTABLE40 || ASPNETCORE50) [Test] public void DeserializeISerializableIConvertible() { @@ -768,7 +772,7 @@ namespace Newtonsoft.Json.Tests.Serialization Assert.AreEqual("value", deserialized.foo.bar); } -#if !NETFX_CORE +#if !(NETFX_CORE || ASPNETCORE50) [Test] public void ConversionOperator() { @@ -1196,7 +1200,7 @@ namespace Newtonsoft.Json.Tests.Serialization Assert.AreEqual(executorObject2.clientGetResultFunction, "ClientBanSubsCB"); } -#if !NETFX_CORE +#if !(NETFX_CORE || ASPNETCORE50) [Test] public void HashtableDeserialization() { @@ -1405,7 +1409,7 @@ keyword such as type of business."" { string json = @"[""vvv\/vvv\tvvv\""vvv\bvvv\nvvv\rvvv\\vvv\fvvv""]"; -#if !NETFX_CORE +#if !(NETFX_CORE || ASPNETCORE50) JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer(); List javaScriptSerializerResult = javaScriptSerializer.Deserialize>(json); #endif @@ -1417,7 +1421,7 @@ keyword such as type of business."" Assert.AreEqual(1, jsonNetResult.Count); Assert.AreEqual(dataContractResult[0], jsonNetResult[0]); -#if !NETFX_CORE +#if !(NETFX_CORE || ASPNETCORE50) Assert.AreEqual(javaScriptSerializerResult[0], jsonNetResult[0]); #endif } @@ -1636,7 +1640,7 @@ keyword such as type of business."" string json = JsonConvert.SerializeObject(new ConverableMembers(), Formatting.Indented); string expected = null; -#if !(NETFX_CORE || PORTABLE) +#if !(NETFX_CORE || PORTABLE || ASPNETCORE50) expected = @"{ ""String"": ""string"", ""Int32"": 2147483647, @@ -1676,7 +1680,7 @@ keyword such as type of business."" ConverableMembers c = JsonConvert.DeserializeObject(json); Assert.AreEqual("string", c.String); Assert.AreEqual(double.MaxValue, c.Double); -#if !(NETFX_CORE || PORTABLE || PORTABLE40) +#if !(NETFX_CORE || PORTABLE || ASPNETCORE50 || PORTABLE40) Assert.AreEqual(DBNull.Value, c.DBNull); #endif } @@ -2523,7 +2527,7 @@ keyword such as type of business."" Assert.AreEqual("titleId", n.FidOrder[n.FidOrder.Count - 1]); } -#if !(NET20 || NETFX_CORE) +#if !(NET20 || NETFX_CORE || ASPNETCORE50 || PORTABLE40) [MetadataType(typeof(OptInClassMetadata))] public class OptInClass { @@ -2911,7 +2915,7 @@ To fix this error either change the JSON to a JSON object (e.g. {""name"":""valu Path '', line 1, position 1."); } -#if !(NETFX_CORE || PORTABLE) +#if !(NETFX_CORE || PORTABLE || ASPNETCORE50) [Test] public void CannotDeserializeArrayIntoSerializable() { @@ -3028,7 +3032,7 @@ Path '', line 1, position 1."); { ContractResolver = new DefaultContractResolver { -#if !(NETFX_CORE || PORTABLE || PORTABLE40) +#if !(NETFX_CORE || PORTABLE || ASPNETCORE50 || PORTABLE40) IgnoreSerializableAttribute = true #endif } @@ -3045,7 +3049,7 @@ Path '', line 1, position 1."); { ContractResolver = new DefaultContractResolver { -#if !(NETFX_CORE || PORTABLE || PORTABLE40) +#if !(NETFX_CORE || PORTABLE || ASPNETCORE50 || PORTABLE40) IgnoreSerializableAttribute = true #endif } @@ -3062,7 +3066,7 @@ Path '', line 1, position 1."); { ContractResolver = new DefaultContractResolver { -#if !(NETFX_CORE || PORTABLE || PORTABLE40) +#if !(NETFX_CORE || PORTABLE || ASPNETCORE50 || PORTABLE40) IgnoreSerializableAttribute = true #endif } @@ -3079,7 +3083,7 @@ Path '', line 1, position 1."); { ContractResolver = new DefaultContractResolver { -#if !(NETFX_CORE || PORTABLE || PORTABLE40) +#if !(NETFX_CORE || PORTABLE || ASPNETCORE50 || PORTABLE40) IgnoreSerializableAttribute = true #endif } @@ -3587,19 +3591,15 @@ Path '', line 1, position 1."); public TimeSpan TimeSpanProperty { get; set; } public Guid GuidProperty { get; set; } public Animal AnimalProperty { get; set; } - public Exception ExceptionProperty { get; set; } } [Test] public void DataContractJsonSerializerTest() { - Exception ex = new Exception("Blah blah blah"); - DataContractJsonSerializerTestClass c = new DataContractJsonSerializerTestClass(); c.TimeSpanProperty = new TimeSpan(200, 20, 59, 30, 900); c.GuidProperty = new Guid("66143115-BE2A-4a59-AF0A-348E1EA15B1E"); c.AnimalProperty = new Human() { Ethnicity = "European" }; - c.ExceptionProperty = ex; MemoryStream ms = new MemoryStream(); DataContractJsonSerializer serializer = new DataContractJsonSerializer( @@ -3756,7 +3756,7 @@ Path '', line 1, position 1."); Assert.AreEqual("value", newModelStateDictionary["key"]); } -#if !(NETFX_CORE || PORTABLE || PORTABLE40) +#if !(NETFX_CORE || PORTABLE || ASPNETCORE50 || PORTABLE40) public class ISerializableTestObject : ISerializable { internal string _stringValue; @@ -4081,7 +4081,7 @@ To fix this error either change the environment to be fully trusted, change the }", json); } -#if !PORTABLE +#if !(PORTABLE || ASPNETCORE50) [Test] public void DeserializeClassWithInheritedProtectedMember() { @@ -4282,7 +4282,7 @@ To fix this error either change the environment to be fully trusted, change the } #endif -#if !(NETFX_CORE || PORTABLE || PORTABLE40) +#if !(NETFX_CORE || PORTABLE || ASPNETCORE50 || PORTABLE40) [Test] public void SerializeDeserializeXmlNodeProperties() { @@ -4354,7 +4354,7 @@ To fix this error either change the environment to be fully trusted, change the public override bool CanConvert(Type objectType) { - return objectType.IsAssignableFrom(typeof(Pos)); + return objectType == typeof(Pos); } } @@ -4377,7 +4377,7 @@ To fix this error either change the environment to be fully trusted, change the public override bool CanConvert(Type objectType) { - return objectType.IsAssignableFrom(typeof(PosDouble)); + return objectType == typeof(PosDouble); } } @@ -4604,7 +4604,7 @@ To fix this error either change the environment to be fully trusted, change the Assert.AreEqual(0, z[1].Prop1.Length); } -#if !NET20 && !NETFX_CORE +#if !(NET20 || NETFX_CORE || ASPNETCORE50) public class StringDictionaryTestClass { public StringDictionary StringDictionaryProperty { get; set; } @@ -4918,7 +4918,7 @@ To fix this error either change the environment to be fully trusted, change the Assert.AreEqual(meh.IDontWork, "meh"); } -#if !(NET20 || NETFX_CORE) +#if !(NET20 || NETFX_CORE || ASPNETCORE50) [DataContract] public struct StructISerializable : ISerializable { @@ -5660,7 +5660,7 @@ To fix this error either change the environment to be fully trusted, change the } } -#if !(NETFX_CORE || PORTABLE || PORTABLE40) +#if !(NETFX_CORE || PORTABLE || ASPNETCORE50 || PORTABLE40) [Test] public void SerializeException1() { @@ -5887,7 +5887,7 @@ To fix this error either change the environment to be fully trusted, change the Assert.AreEqual(-3, StaticTestClass.z); } -#if !(NET20 || NETFX_CORE) +#if !(NET20 || NETFX_CORE || ASPNETCORE50) [Test] public void DeserializeDecimalsWithCulture() { @@ -5984,7 +5984,7 @@ To fix this error either change the environment to be fully trusted, change the ExceptionAssert.Throws(() => { List numbers = JsonConvert.DeserializeObject>(json); }, "Error converting value {null} to type 'System.Int32'. Path '[3]', line 5, position 7."); } -#if !(PORTABLE || NETFX_CORE) +#if !(PORTABLE || ASPNETCORE50 || NETFX_CORE) public class ConvertableIntTestClass { public ConvertibleInt Integer { get; set; } @@ -6341,7 +6341,7 @@ To fix this error either change the environment to be fully trusted, change the } #endif -#if !(NETFX_CORE) +#if !(NETFX_CORE || ASPNETCORE50) [Test] public void MetroBlogPost() { @@ -6702,7 +6702,7 @@ To fix this error either change the environment to be fully trusted, change the Assert.AreEqual("", s); } -#if !(NETFX_CORE || PORTABLE || PORTABLE40) +#if !(NETFX_CORE || PORTABLE || ASPNETCORE50 || PORTABLE40) [Test] public void SerializeAndDeserializeWithAttributes() { @@ -6863,7 +6863,7 @@ To fix this error either change the environment to be fully trusted, change the ExceptionAssert.Throws(() => { s.Deserialize>(new JsonTextReader(new StringReader(json))); }, "Additional text encountered after finished reading JSON content: {. Path '', line 1, position 7."); } -#if !(NETFX_CORE || PORTABLE || PORTABLE40) +#if !(NETFX_CORE || PORTABLE || ASPNETCORE50 || PORTABLE40) [Test] public void DeserializeException() { @@ -7047,7 +7047,7 @@ To fix this error either change the environment to be fully trusted, change the } #if !(NET20 || NET35 || NET40 || PORTABLE40) -#if !PORTABLE +#if !(PORTABLE || ASPNETCORE50) [Test] public void DeserializeReadOnlyListWithBigInteger() { @@ -7105,7 +7105,7 @@ To fix this error either change the environment to be fully trusted, change the Action doStuff = () => { obj = JsonConvert.DeserializeObject>(json); }; -#if !(NETFX_CORE || PORTABLE || PORTABLE40) +#if !(NETFX_CORE || PORTABLE || ASPNETCORE50 || PORTABLE40) doStuff(); Assert.AreEqual(500, obj.Item1); #else @@ -7115,7 +7115,7 @@ To fix this error either change the environment to be fully trusted, change the #endif } -#if DEBUG +#if DEBUG && !NOINTERNALS [Test] public void SerializeCustomTupleWithSerializableAttributeInPartialTrust() { @@ -7136,7 +7136,7 @@ To fix this error either change the environment to be fully trusted, change the } #endif -#if !(NETFX_CORE || PORTABLE || NET35 || NET20 || PORTABLE40) +#if !(NETFX_CORE || PORTABLE || ASPNETCORE50 || NET35 || NET20 || PORTABLE40) [Test] public void SerializeTupleWithSerializableAttribute() { @@ -7382,7 +7382,7 @@ To fix this error either change the environment to be fully trusted, change the } #endif -#if !(PORTABLE || NET35 || NET20 || PORTABLE40) +#if !(PORTABLE || ASPNETCORE50 || NET35 || NET20 || PORTABLE40) [Test] public void ReadTooLargeInteger() { @@ -7396,7 +7396,7 @@ To fix this error either change the environment to be fully trusted, change the } #endif -#if !NETFX_CORE +#if !(NETFX_CORE || ASPNETCORE50) [Serializable] #endif [DataContract] @@ -7425,7 +7425,7 @@ To fix this error either change the environment to be fully trusted, change the Assert.AreEqual(@"{""First"":""One"",""Second"":2}", json); -#if !(NETFX_CORE || PORTABLE || PORTABLE40) +#if !(NETFX_CORE || PORTABLE || ASPNETCORE50 || PORTABLE40) DefaultContractResolver r = new DefaultContractResolver(); r.IgnoreSerializableAttribute = false; @@ -7545,7 +7545,7 @@ To fix this error either change the environment to be fully trusted, change the Assert.AreEqual(1234567890.123456m, d); } -#if !(PORTABLE || NETFX_CORE || PORTABLE40) +#if !(PORTABLE || ASPNETCORE50 || NETFX_CORE || PORTABLE40) [Test] public void DontSerializeStaticFields() { @@ -7569,7 +7569,7 @@ To fix this error either change the environment to be fully trusted, change the } #endif -#if !(NET20 || NET35 || PORTABLE || PORTABLE40) +#if !(NET20 || NET35 || PORTABLE || ASPNETCORE50 || PORTABLE40) [Test] public void SerializeBigInteger() { @@ -7654,7 +7654,7 @@ To fix this error either change the environment to be fully trusted, change the ]", json); } -#if !(PORTABLE || PORTABLE40 || NETFX_CORE) +#if !(PORTABLE || PORTABLE40 || NETFX_CORE || ASPNETCORE50) [Test] public void SerializeDictionaryWithStructKey() { @@ -7707,7 +7707,7 @@ To fix this error either change the environment to be fully trusted, change the Assert.AreEqual(jane, john.Spouse); } -#if !(NETFX_CORE || NET35 || NET20 || PORTABLE || PORTABLE40) +#if !(NETFX_CORE || NET35 || NET20 || PORTABLE || ASPNETCORE50 || PORTABLE40) [Test] public void TypeConverterOnInterface() { @@ -7772,7 +7772,7 @@ To fix this error either change the environment to be fully trusted, change the ParticipantEntity deserializedProduct = JsonConvert.DeserializeObject(json); } -#if !(PORTABLE || NETFX_CORE) +#if !(PORTABLE || ASPNETCORE50 || NETFX_CORE) public class ConvertibleId : IConvertible { public int Value; diff --git a/Src/Newtonsoft.Json.Tests/Serialization/MetadataPropertyHandlingTests.cs b/Src/Newtonsoft.Json.Tests/Serialization/MetadataPropertyHandlingTests.cs index 7c9fde3e..9b4f2abb 100644 --- a/Src/Newtonsoft.Json.Tests/Serialization/MetadataPropertyHandlingTests.cs +++ b/Src/Newtonsoft.Json.Tests/Serialization/MetadataPropertyHandlingTests.cs @@ -30,12 +30,16 @@ using System.Text; using Newtonsoft.Json.Linq; using Newtonsoft.Json.Tests.TestObjects; using Newtonsoft.Json.Utilities; -#if !NETFX_CORE -using NUnit.Framework; -#else +#if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute; +#elif ASPNETCORE50 +using Xunit; +using Test = Xunit.FactAttribute; +using Assert = Newtonsoft.Json.Tests.XUnitAssert; +#else +using NUnit.Framework; #endif namespace Newtonsoft.Json.Tests.Serialization @@ -328,7 +332,7 @@ namespace Newtonsoft.Json.Tests.Serialization Assert.IsTrue(JToken.DeepEquals(t1, t2)); } -#if !(PORTABLE || PORTABLE40) +#if !(PORTABLE || ASPNETCORE50 || PORTABLE40) [Test] public void DeserializeGenericObjectListWithTypeName() { diff --git a/Src/Newtonsoft.Json.Tests/Serialization/MissingMemberHandlingTests.cs b/Src/Newtonsoft.Json.Tests/Serialization/MissingMemberHandlingTests.cs index d8e10134..3e8b7f4d 100644 --- a/Src/Newtonsoft.Json.Tests/Serialization/MissingMemberHandlingTests.cs +++ b/Src/Newtonsoft.Json.Tests/Serialization/MissingMemberHandlingTests.cs @@ -27,13 +27,16 @@ using System; using System.IO; using Newtonsoft.Json.Converters; using Newtonsoft.Json.Tests.TestObjects; -#if !NETFX_CORE -using NUnit.Framework; - -#else +#if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute; +#elif ASPNETCORE50 +using Xunit; +using Test = Xunit.FactAttribute; +using Assert = Newtonsoft.Json.Tests.XUnitAssert; +#else +using NUnit.Framework; #endif namespace Newtonsoft.Json.Tests.Serialization diff --git a/Src/Newtonsoft.Json.Tests/Serialization/NullValueHandlingTests.cs b/Src/Newtonsoft.Json.Tests/Serialization/NullValueHandlingTests.cs index 32efe09b..bbf629d2 100644 --- a/Src/Newtonsoft.Json.Tests/Serialization/NullValueHandlingTests.cs +++ b/Src/Newtonsoft.Json.Tests/Serialization/NullValueHandlingTests.cs @@ -26,13 +26,16 @@ using System; using System.IO; using Newtonsoft.Json.Tests.TestObjects; -#if !NETFX_CORE -using NUnit.Framework; - -#else +#if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute; +#elif ASPNETCORE50 +using Xunit; +using Test = Xunit.FactAttribute; +using Assert = Newtonsoft.Json.Tests.XUnitAssert; +#else +using NUnit.Framework; #endif namespace Newtonsoft.Json.Tests.Serialization diff --git a/Src/Newtonsoft.Json.Tests/Serialization/PopulateTests.cs b/Src/Newtonsoft.Json.Tests/Serialization/PopulateTests.cs index eaa654b9..bf539904 100644 --- a/Src/Newtonsoft.Json.Tests/Serialization/PopulateTests.cs +++ b/Src/Newtonsoft.Json.Tests/Serialization/PopulateTests.cs @@ -27,13 +27,16 @@ using System; using System.Collections.Generic; using System.IO; using Newtonsoft.Json.Tests.TestObjects; -#if !NETFX_CORE -using NUnit.Framework; - -#else +#if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute; +#elif ASPNETCORE50 +using Xunit; +using Test = Xunit.FactAttribute; +using Assert = Newtonsoft.Json.Tests.XUnitAssert; +#else +using NUnit.Framework; #endif namespace Newtonsoft.Json.Tests.Serialization diff --git a/Src/Newtonsoft.Json.Tests/Serialization/PreserveReferencesHandlingTests.cs b/Src/Newtonsoft.Json.Tests/Serialization/PreserveReferencesHandlingTests.cs index 8de7c84c..4bbe6214 100644 --- a/Src/Newtonsoft.Json.Tests/Serialization/PreserveReferencesHandlingTests.cs +++ b/Src/Newtonsoft.Json.Tests/Serialization/PreserveReferencesHandlingTests.cs @@ -30,13 +30,16 @@ using System.Runtime.Serialization.Formatters; using System.Text; using Newtonsoft.Json.Linq; using Newtonsoft.Json.Tests.TestObjects; -#if !NETFX_CORE -using NUnit.Framework; - -#else +#if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute; +#elif ASPNETCORE50 +using Xunit; +using Test = Xunit.FactAttribute; +using Assert = Newtonsoft.Json.Tests.XUnitAssert; +#else +using NUnit.Framework; #endif namespace Newtonsoft.Json.Tests.Serialization @@ -88,7 +91,7 @@ namespace Newtonsoft.Json.Tests.Serialization Assert.AreEqual(2, circularDictionary.Count); Assert.AreEqual(1, circularDictionary["other"].Count); - Assert.AreEqual(circularDictionary, circularDictionary["self"]); + Assert.IsTrue(ReferenceEquals(circularDictionary, circularDictionary["self"])); } public class CircularList : List diff --git a/Src/Newtonsoft.Json.Tests/Serialization/ReferenceLoopHandlingTests.cs b/Src/Newtonsoft.Json.Tests/Serialization/ReferenceLoopHandlingTests.cs index bf095293..874b34bc 100644 --- a/Src/Newtonsoft.Json.Tests/Serialization/ReferenceLoopHandlingTests.cs +++ b/Src/Newtonsoft.Json.Tests/Serialization/ReferenceLoopHandlingTests.cs @@ -25,12 +25,16 @@ using System; using System.Collections.Generic; -#if !NETFX_CORE -using NUnit.Framework; -#else +#if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute; +#elif ASPNETCORE50 +using Xunit; +using Test = Xunit.FactAttribute; +using Assert = Newtonsoft.Json.Tests.XUnitAssert; +#else +using NUnit.Framework; #endif #if !(NET20 || NET35) using System.Dynamic; @@ -149,7 +153,7 @@ namespace Newtonsoft.Json.Tests.Serialization }", json); } -#if !(PORTABLE || NETFX_CORE || PORTABLE40) +#if !(PORTABLE || ASPNETCORE50 || NETFX_CORE || PORTABLE40) public class MainClass : ISerializable { public ChildClass Child { get; set; } diff --git a/Src/Newtonsoft.Json.Tests/Serialization/SerializationErrorHandlingTests.cs b/Src/Newtonsoft.Json.Tests/Serialization/SerializationErrorHandlingTests.cs index 1858e1b0..772a4046 100644 --- a/Src/Newtonsoft.Json.Tests/Serialization/SerializationErrorHandlingTests.cs +++ b/Src/Newtonsoft.Json.Tests/Serialization/SerializationErrorHandlingTests.cs @@ -35,12 +35,16 @@ using Newtonsoft.Json.Utilities.LinqBridge; #else using System.Linq; #endif -#if !NETFX_CORE -using NUnit.Framework; -#else +#if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute; +#elif ASPNETCORE50 +using Xunit; +using Test = Xunit.FactAttribute; +using Assert = Newtonsoft.Json.Tests.XUnitAssert; +#else +using NUnit.Framework; #endif using System.IO; using ErrorEventArgs = Newtonsoft.Json.Serialization.ErrorEventArgs; diff --git a/Src/Newtonsoft.Json.Tests/Serialization/SerializationEventAttributeTests.cs b/Src/Newtonsoft.Json.Tests/Serialization/SerializationEventAttributeTests.cs index 09934304..c086f304 100644 --- a/Src/Newtonsoft.Json.Tests/Serialization/SerializationEventAttributeTests.cs +++ b/Src/Newtonsoft.Json.Tests/Serialization/SerializationEventAttributeTests.cs @@ -37,12 +37,16 @@ using System.Runtime.Serialization; using System.Text; using Newtonsoft.Json.Serialization; using Newtonsoft.Json.Tests.TestObjects; -#if !NETFX_CORE -using NUnit.Framework; -#else +#if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute; +#elif ASPNETCORE50 +using Xunit; +using Test = Xunit.FactAttribute; +using Assert = Newtonsoft.Json.Tests.XUnitAssert; +#else +using NUnit.Framework; #endif using Newtonsoft.Json.Linq; using Newtonsoft.Json.Utilities; @@ -282,7 +286,7 @@ namespace Newtonsoft.Json.Tests.Serialization }", json); } -#if !(NETFX_CORE || PORTABLE) +#if !(NETFX_CORE || PORTABLE || ASPNETCORE50) public class SerializationEventContextTestObject { public string TestMember { get; set; } @@ -313,7 +317,7 @@ namespace Newtonsoft.Json.Tests.Serialization } #endif -#if !PORTABLE +#if !(PORTABLE || ASPNETCORE50) public void WhenSerializationErrorDetectedBySerializer_ThenCallbackIsCalled() { // Verify contract is properly finding our callback diff --git a/Src/Newtonsoft.Json.Tests/Serialization/ShouldSerializeTests.cs b/Src/Newtonsoft.Json.Tests/Serialization/ShouldSerializeTests.cs index bcfcc2bb..73ad06a0 100644 --- a/Src/Newtonsoft.Json.Tests/Serialization/ShouldSerializeTests.cs +++ b/Src/Newtonsoft.Json.Tests/Serialization/ShouldSerializeTests.cs @@ -29,12 +29,16 @@ using System.Globalization; using System.IO; using System.Text; using Newtonsoft.Json.Serialization; -#if !NETFX_CORE -using NUnit.Framework; -#else +#if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute; +#elif ASPNETCORE50 +using Xunit; +using Test = Xunit.FactAttribute; +using Assert = Newtonsoft.Json.Tests.XUnitAssert; +#else +using NUnit.Framework; #endif namespace Newtonsoft.Json.Tests.Serialization diff --git a/Src/Newtonsoft.Json.Tests/Serialization/TraceWriterTests.cs b/Src/Newtonsoft.Json.Tests/Serialization/TraceWriterTests.cs index 51a56ce9..38611076 100644 --- a/Src/Newtonsoft.Json.Tests/Serialization/TraceWriterTests.cs +++ b/Src/Newtonsoft.Json.Tests/Serialization/TraceWriterTests.cs @@ -4,18 +4,22 @@ using System.Diagnostics; using System.Globalization; using System.IO; using Newtonsoft.Json.Linq; -#if !(NET20 || NET35 || PORTABLE || PORTABLE40) +#if !(NET20 || NET35 || PORTABLE || ASPNETCORE50 || PORTABLE40) using System.Numerics; #endif using System.Runtime.Serialization; using System.Runtime.Serialization.Formatters; using System.Text; -#if !NETFX_CORE -using NUnit.Framework; -#else +#if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute; +#elif ASPNETCORE50 +using Xunit; +using Test = Xunit.FactAttribute; +using Assert = Newtonsoft.Json.Tests.XUnitAssert; +#else +using NUnit.Framework; #endif using Newtonsoft.Json.Converters; using Newtonsoft.Json.Serialization; @@ -39,7 +43,7 @@ namespace Newtonsoft.Json.Tests.Serialization [TestFixture] public class TraceWriterTests : TestFixtureBase { -#if !(PORTABLE || NETFX_CORE || PORTABLE40) +#if !(PORTABLE || ASPNETCORE50 || NETFX_CORE || PORTABLE40) [Test] public void DiagnosticsTraceWriterTest() { @@ -602,7 +606,7 @@ Newtonsoft.Json Error: 0 : Error! Assert.IsTrue(traceWriter.TraceRecords[9].Message.StartsWith("Finished deserializing System.Collections.Generic.List`1[System.Object]. Path '$values'")); } -#if !(NETFX_CORE || PORTABLE || PORTABLE40) +#if !(NETFX_CORE || PORTABLE || ASPNETCORE50 || PORTABLE40) [Test] public void DeserializeISerializable() { @@ -808,7 +812,7 @@ Newtonsoft.Json Error: 0 : Error! Assert.AreEqual(23, deserialized.FavoriteNumber); } -#if !(NET20 || NET35 || PORTABLE || PORTABLE40) +#if !(NET20 || NET35 || PORTABLE || ASPNETCORE50 || PORTABLE40) [Test] public void TraceJsonWriterTest() { diff --git a/Src/Newtonsoft.Json.Tests/Serialization/TypeNameHandlingTests.cs b/Src/Newtonsoft.Json.Tests/Serialization/TypeNameHandlingTests.cs index 44abb09a..457310ec 100644 --- a/Src/Newtonsoft.Json.Tests/Serialization/TypeNameHandlingTests.cs +++ b/Src/Newtonsoft.Json.Tests/Serialization/TypeNameHandlingTests.cs @@ -23,31 +23,35 @@ // OTHER DEALINGS IN THE SOFTWARE. #endregion -#if !(PORTABLE || PORTABLE40) -#if !(NET35 || NET20 || PORTABLE) +#if !(PORTABLE || ASPNETCORE50 || PORTABLE40) +#if !(NET35 || NET20 || PORTABLE || ASPNETCORE50) using System.Dynamic; #endif using System.Text; using Newtonsoft.Json.Tests.Linq; -using global::System; -using global::System.Collections; -using global::System.Collections.Generic; -using global::System.Globalization; -using global::System.Runtime.Serialization.Formatters; -using global::Newtonsoft.Json.Linq; -using global::Newtonsoft.Json.Serialization; -using global::Newtonsoft.Json.Tests.TestObjects; -#if !NETFX_CORE -using global::NUnit.Framework; +using System; +using System.Collections; +using System.Collections.Generic; +using System.Globalization; +using System.Runtime.Serialization.Formatters; +using Newtonsoft.Json.Linq; +using Newtonsoft.Json.Serialization; +using Newtonsoft.Json.Tests.TestObjects; +#if NETFX_CORE +using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; +using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; +using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute; +#elif ASPNETCORE50 +using Xunit; +using Test = Xunit.FactAttribute; +using Assert = Newtonsoft.Json.Tests.XUnitAssert; #else -using global::Microsoft.VisualStudio.TestPlatform.UnitTestFramework; -using TestFixture = global::Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; -using Test = global::Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute; +using NUnit.Framework; #endif -using global::Newtonsoft.Json.Utilities; -using global::System.Net; -using global::System.Runtime.Serialization; -using global::System.IO; +using Newtonsoft.Json.Utilities; +using System.Net; +using System.Runtime.Serialization; +using System.IO; namespace Newtonsoft.Json.Tests.Serialization { @@ -259,7 +263,7 @@ namespace Newtonsoft.Json.Tests.Serialization Assert.AreEqual("Name!", ((EmployeeReference)employee).Name); } -#if !(NETFX_CORE || PORTABLE) +#if !(NETFX_CORE || PORTABLE || ASPNETCORE50) [Test] public void DeserializeTypeNameFromGacAssembly() { @@ -1097,7 +1101,7 @@ namespace Newtonsoft.Json.Tests.Serialization Binder = new MetroBinder(), ContractResolver = new DefaultContractResolver { -#if !(NETFX_CORE || PORTABLE) +#if !(NETFX_CORE || PORTABLE || ASPNETCORE50) IgnoreSerializableAttribute = true #endif } diff --git a/Src/Newtonsoft.Json.Tests/Serialization/WebApiIntegrationTests.cs b/Src/Newtonsoft.Json.Tests/Serialization/WebApiIntegrationTests.cs index 1f77c184..a70a881c 100644 --- a/Src/Newtonsoft.Json.Tests/Serialization/WebApiIntegrationTests.cs +++ b/Src/Newtonsoft.Json.Tests/Serialization/WebApiIntegrationTests.cs @@ -30,12 +30,16 @@ using System.IO; using System.Linq; #endif using System.Text; -#if !NETFX_CORE -using NUnit.Framework; -#else +#if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute; +#elif ASPNETCORE50 +using Xunit; +using Test = Xunit.FactAttribute; +using Assert = Newtonsoft.Json.Tests.XUnitAssert; +#else +using NUnit.Framework; #endif #if !(NETFX_CORE || NET20) using System.Runtime.Serialization.Json; @@ -59,7 +63,7 @@ namespace Newtonsoft.Json.Tests.Serialization nonSerializedField = "Error" }; -#if !(NETFX_CORE || NET20 || PORTABLE || PORTABLE40) +#if !(NETFX_CORE || NET20 || PORTABLE || ASPNETCORE50 || PORTABLE40) MemoryStream ms = new MemoryStream(); DataContractJsonSerializer dataContractJsonSerializer = new DataContractJsonSerializer(typeof(SerializableType)); dataContractJsonSerializer.WriteObject(ms, serializableType); @@ -75,7 +79,7 @@ namespace Newtonsoft.Json.Tests.Serialization { ContractResolver = new DefaultContractResolver { -#if !(NETFX_CORE || PORTABLE || PORTABLE40) +#if !(NETFX_CORE || PORTABLE || ASPNETCORE50 || PORTABLE40) IgnoreSerializableAttribute = false #endif } @@ -84,7 +88,7 @@ namespace Newtonsoft.Json.Tests.Serialization Assert.AreEqual(expected, json); } -#if !(NETFX_CORE || PORTABLE || PORTABLE40) +#if !(NETFX_CORE || PORTABLE || ASPNETCORE50 || PORTABLE40) [Test] public void SerializeInheritedType() { @@ -114,7 +118,7 @@ namespace Newtonsoft.Json.Tests.Serialization } } -#if !(NETFX_CORE || PORTABLE || PORTABLE40) +#if !(NETFX_CORE || PORTABLE || ASPNETCORE50 || PORTABLE40) [Serializable] #else [JsonObject(MemberSerialization.Fields)] @@ -138,7 +142,7 @@ namespace Newtonsoft.Json.Tests.Serialization set { privateField = value; } } -#if !(NETFX_CORE || PORTABLE || PORTABLE40) +#if !(NETFX_CORE || PORTABLE || ASPNETCORE50 || PORTABLE40) [NonSerialized] #else [JsonIgnore] diff --git a/Src/Newtonsoft.Json.Tests/TestFixtureBase.cs b/Src/Newtonsoft.Json.Tests/TestFixtureBase.cs index 296fd114..4fc71cd0 100644 --- a/Src/Newtonsoft.Json.Tests/TestFixtureBase.cs +++ b/Src/Newtonsoft.Json.Tests/TestFixtureBase.cs @@ -27,6 +27,7 @@ using System; using System.Collections.Generic; using System.Globalization; using System.IO; +using System.Reflection; using System.Text.RegularExpressions; #if NET20 using Newtonsoft.Json.Serialization; @@ -35,13 +36,17 @@ using System.Runtime.Serialization.Json; #endif using System.Text; using System.Threading; -#if !NETFX_CORE -using NUnit.Framework; -#else +#if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using TestMethod = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute; using SetUp = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestInitializeAttribute; +#elif ASPNETCORE50 +using Xunit; +using Assert = Newtonsoft.Json.Tests.XUnitAssert; +using XAssert = Xunit.Assert; +#else +using NUnit.Framework; #endif using Newtonsoft.Json.Utilities; using System.Collections; @@ -53,6 +58,137 @@ using System.Linq; namespace Newtonsoft.Json.Tests { + public class TestReflectionUtils + { + public static IEnumerable GetConstructors(Type type) + { +#if !(NETFX_CORE || ASPNETCORE50) + return type.GetConstructors(); +#else + return type.GetTypeInfo().DeclaredConstructors; +#endif + } + + public static PropertyInfo GetProperty(Type type, string name) + { +#if !(NETFX_CORE || ASPNETCORE50) + return type.GetProperty(name); +#else + return type.GetTypeInfo().GetDeclaredProperty(name); +#endif + } + + public static FieldInfo GetField(Type type, string name) + { +#if !(NETFX_CORE || ASPNETCORE50) + return type.GetField(name); +#else + return type.GetTypeInfo().GetDeclaredField(name); +#endif + } + + public static MethodInfo GetMethod(Type type, string name) + { +#if !(NETFX_CORE || ASPNETCORE50) + return type.GetMethod(name); +#else + return type.GetTypeInfo().GetDeclaredMethod(name); +#endif + } + } + +#if ASPNETCORE50 + public class TestFixtureAttribute : Attribute + { + // xunit doesn't need a test fixture attribute + // this exists so the project compiles + } + + public class XUnitAssert + { + public static void IsInstanceOf(Type expectedType, object o) + { + XAssert.IsType(expectedType, o); + } + + public static void AreEqual(double expected, double actual, double r) + { + XAssert.Equal(expected, actual, 5); // hack + } + + public static void AreEqual(object expected, object actual, string message = null) + { + XAssert.Equal(expected, actual); + } + + public static void AreEqual(T expected, T actual, string message = null) + { + XAssert.Equal(expected, actual); + } + + public static void AreNotEqual(object expected, object actual, string message = null) + { + XAssert.NotEqual(expected, actual); + } + + public static void AreNotEqual(T expected, T actual, string message = null) + { + XAssert.NotEqual(expected, actual); + } + + public static void Fail(string message = null, params object[] args) + { + if (message != null) + message = message.FormatWith(CultureInfo.InvariantCulture, args); + + XAssert.True(false, message); + } + + public static void IsTrue(bool condition, string message = null) + { + XAssert.True(condition); + } + + public static void IsFalse(bool condition) + { + XAssert.False(condition); + } + + public static void IsNull(object o) + { + XAssert.Null(o); + } + + public static void IsNotNull(object o) + { + XAssert.NotNull(o); + } + + public static void AreNotSame(object expected, object actual) + { + XAssert.NotSame(expected, actual); + } + + public static void AreSame(object expected, object actual) + { + XAssert.Same(expected, actual); + } + } + + public class CollectionAssert + { + public static void AreEquivalent(IEnumerable expected, IEnumerable actual) + { + XAssert.Equal(expected, actual); + } + + public static void AreEqual(IEnumerable expected, IEnumerable actual) + { + XAssert.Equal(expected, actual); + } + } +#endif + [TestFixture] public abstract class TestFixtureBase { @@ -118,8 +254,12 @@ namespace Newtonsoft.Json.Tests return bytes; } +#if ASPNETCORE50 + protected TestFixtureBase() +#else [SetUp] protected void TestSetup() +#endif { //#if !NETFX_CORE // CultureInfo turkey = CultureInfo.CreateSpecificCulture("tr"); @@ -169,7 +309,7 @@ namespace Newtonsoft.Json.Tests public static void Contains(IList collection, object value, string message) { -#if !NETFX_CORE +#if !(NETFX_CORE || ASPNETCORE50) Assert.Contains(value, collection, message); #else if (!collection.Cast().Any(i => i.Equals(value))) diff --git a/Src/Newtonsoft.Json.Tests/TestObjects/AnswerFilterModel.cs b/Src/Newtonsoft.Json.Tests/TestObjects/AnswerFilterModel.cs index ed484a73..5dcffa8b 100644 --- a/Src/Newtonsoft.Json.Tests/TestObjects/AnswerFilterModel.cs +++ b/Src/Newtonsoft.Json.Tests/TestObjects/AnswerFilterModel.cs @@ -33,7 +33,7 @@ using System.Linq; namespace Newtonsoft.Json.Tests.TestObjects { -#if !(NETFX_CORE || PORTABLE) +#if !(NETFX_CORE || PORTABLE || ASPNETCORE50) [Serializable] public class AnswerFilterModel { diff --git a/Src/Newtonsoft.Json.Tests/TestObjects/ConverableMembers.cs b/Src/Newtonsoft.Json.Tests/TestObjects/ConverableMembers.cs index 4d6f54a8..352ee8e1 100644 --- a/Src/Newtonsoft.Json.Tests/TestObjects/ConverableMembers.cs +++ b/Src/Newtonsoft.Json.Tests/TestObjects/ConverableMembers.cs @@ -41,7 +41,7 @@ namespace Newtonsoft.Json.Tests.TestObjects public ulong ULong = long.MaxValue; public double Double = double.MaxValue; public float Float = float.MaxValue; -#if !(NETFX_CORE || PORTABLE) +#if !(NETFX_CORE || PORTABLE || ASPNETCORE50) public DBNull DBNull = DBNull.Value; #endif public bool Bool = true; diff --git a/Src/Newtonsoft.Json.Tests/TestObjects/Currency.cs b/Src/Newtonsoft.Json.Tests/TestObjects/Currency.cs index fc856d2e..5a6585a6 100644 --- a/Src/Newtonsoft.Json.Tests/TestObjects/Currency.cs +++ b/Src/Newtonsoft.Json.Tests/TestObjects/Currency.cs @@ -23,7 +23,7 @@ // OTHER DEALINGS IN THE SOFTWARE. #endregion -#if !(NET35 || NET20 || NETFX_CORE) +#if !(NET35 || NET20 || NETFX_CORE || ASPNETCORE50) using Microsoft.FSharp.Core; using System; using System.Collections; diff --git a/Src/Newtonsoft.Json.Tests/TestObjects/CustomerDataSet.cs b/Src/Newtonsoft.Json.Tests/TestObjects/CustomerDataSet.cs index 76554d33..1f3fdab3 100644 --- a/Src/Newtonsoft.Json.Tests/TestObjects/CustomerDataSet.cs +++ b/Src/Newtonsoft.Json.Tests/TestObjects/CustomerDataSet.cs @@ -23,7 +23,7 @@ // OTHER DEALINGS IN THE SOFTWARE. #endregion -#if !(NETFX_CORE || PORTABLE40 || PORTABLE) +#if !(NETFX_CORE || PORTABLE40 || PORTABLE || ASPNETCORE50) using System; using System.Collections.Generic; using System.Text; diff --git a/Src/Newtonsoft.Json.Tests/TestObjects/DefaultValueAttributeTestClass.cs b/Src/Newtonsoft.Json.Tests/TestObjects/DefaultValueAttributeTestClass.cs index 6953a066..1312e493 100644 --- a/Src/Newtonsoft.Json.Tests/TestObjects/DefaultValueAttributeTestClass.cs +++ b/Src/Newtonsoft.Json.Tests/TestObjects/DefaultValueAttributeTestClass.cs @@ -27,7 +27,7 @@ using System.ComponentModel; namespace Newtonsoft.Json.Tests.TestObjects { -#if !NETFX_CORE +#if !(NETFX_CORE || ASPNETCORE50) [Description("DefaultValueAttributeTestClass description!")] #endif public sealed class DefaultValueAttributeTestClass diff --git a/Src/Newtonsoft.Json.Tests/TestObjects/IMyInterface.cs b/Src/Newtonsoft.Json.Tests/TestObjects/IMyInterface.cs index 725e79a2..b4787d93 100644 --- a/Src/Newtonsoft.Json.Tests/TestObjects/IMyInterface.cs +++ b/Src/Newtonsoft.Json.Tests/TestObjects/IMyInterface.cs @@ -36,7 +36,7 @@ using System.Linq; namespace Newtonsoft.Json.Tests.TestObjects { -#if !(NETFX_CORE || NET35 || NET20 || PORTABLE || PORTABLE40) +#if !(NETFX_CORE || NET35 || NET20 || PORTABLE || ASPNETCORE50 || PORTABLE40) [TypeConverter(typeof(MyInterfaceConverter))] internal interface IMyInterface { diff --git a/Src/Newtonsoft.Json.Tests/TestObjects/MetroPropertyNameResolver.cs b/Src/Newtonsoft.Json.Tests/TestObjects/MetroPropertyNameResolver.cs index 45b86277..0c339fe2 100644 --- a/Src/Newtonsoft.Json.Tests/TestObjects/MetroPropertyNameResolver.cs +++ b/Src/Newtonsoft.Json.Tests/TestObjects/MetroPropertyNameResolver.cs @@ -32,7 +32,7 @@ namespace Newtonsoft.Json.Tests.TestObjects { protected internal override string ResolvePropertyName(string propertyName) { -#if !(NETFX_CORE) +#if !(NETFX_CORE || ASPNETCORE50) return ":::" + propertyName.ToUpper(CultureInfo.InvariantCulture) + ":::"; #else return ":::" + propertyName.ToUpper() + ":::"; diff --git a/Src/Newtonsoft.Json.Tests/TestObjects/MetroStringConverter.cs b/Src/Newtonsoft.Json.Tests/TestObjects/MetroStringConverter.cs index d1488c0f..47e2d35a 100644 --- a/Src/Newtonsoft.Json.Tests/TestObjects/MetroStringConverter.cs +++ b/Src/Newtonsoft.Json.Tests/TestObjects/MetroStringConverter.cs @@ -32,7 +32,7 @@ namespace Newtonsoft.Json.Tests.TestObjects { public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) { -#if !(NETFX_CORE) +#if !(NETFX_CORE || ASPNETCORE50) writer.WriteValue(":::" + value.ToString().ToUpper(CultureInfo.InvariantCulture) + ":::"); #else writer.WriteValue(":::" + value.ToString().ToUpper() + ":::"); @@ -45,7 +45,7 @@ namespace Newtonsoft.Json.Tests.TestObjects if (s == null) return null; -#if !(NETFX_CORE) +#if !(NETFX_CORE || ASPNETCORE50) return s.ToLower(CultureInfo.InvariantCulture).Trim(new[] { ':' }); #else return s.ToLower().Trim(new[] { ':' }); diff --git a/Src/Newtonsoft.Json.Tests/TestObjects/Person.cs b/Src/Newtonsoft.Json.Tests/TestObjects/Person.cs index 15048417..b75a3e19 100644 --- a/Src/Newtonsoft.Json.Tests/TestObjects/Person.cs +++ b/Src/Newtonsoft.Json.Tests/TestObjects/Person.cs @@ -31,7 +31,7 @@ using System.ComponentModel; namespace Newtonsoft.Json.Tests.TestObjects { [JsonObject(Id = "Person", Title = "Title!", Description = "JsonObjectAttribute description!", MemberSerialization = MemberSerialization.OptIn)] -#if !NETFX_CORE +#if !(NETFX_CORE || ASPNETCORE50) [Description("DescriptionAttribute description!")] #endif public class Person diff --git a/Src/Newtonsoft.Json.Tests/TestObjects/PersonSerializable.cs b/Src/Newtonsoft.Json.Tests/TestObjects/PersonSerializable.cs index 31679626..9ba38c7c 100644 --- a/Src/Newtonsoft.Json.Tests/TestObjects/PersonSerializable.cs +++ b/Src/Newtonsoft.Json.Tests/TestObjects/PersonSerializable.cs @@ -27,7 +27,7 @@ using System; namespace Newtonsoft.Json.Tests.TestObjects { -#if !(NETFX_CORE || PORTABLE) +#if !(NETFX_CORE || PORTABLE || ASPNETCORE50) [Serializable] public class PersonSerializable { diff --git a/Src/Newtonsoft.Json.Tests/TestObjects/Ratio.cs b/Src/Newtonsoft.Json.Tests/TestObjects/Ratio.cs index efa05540..348b84f1 100644 --- a/Src/Newtonsoft.Json.Tests/TestObjects/Ratio.cs +++ b/Src/Newtonsoft.Json.Tests/TestObjects/Ratio.cs @@ -29,7 +29,7 @@ using System.Runtime.Serialization; namespace Newtonsoft.Json.Tests.TestObjects { -#if !NETFX_CORE +#if !(NETFX_CORE || ASPNETCORE50) public struct Ratio : IConvertible, IFormattable, ISerializable { private readonly int _numerator; diff --git a/Src/Newtonsoft.Json.Tests/TestObjects/Shape.cs b/Src/Newtonsoft.Json.Tests/TestObjects/Shape.cs index 2bc393cd..82e9c11a 100644 --- a/Src/Newtonsoft.Json.Tests/TestObjects/Shape.cs +++ b/Src/Newtonsoft.Json.Tests/TestObjects/Shape.cs @@ -23,7 +23,7 @@ // OTHER DEALINGS IN THE SOFTWARE. #endregion -#if !(NET35 || NET20 || NETFX_CORE) +#if !(NET35 || NET20 || NETFX_CORE || ASPNETCORE50) using System; using System.Collections; using System.Collections.Generic; diff --git a/Src/Newtonsoft.Json.Tests/TestObjects/TypedSubHashtable.cs b/Src/Newtonsoft.Json.Tests/TestObjects/TypedSubHashtable.cs index 88b01c45..24bed902 100644 --- a/Src/Newtonsoft.Json.Tests/TestObjects/TypedSubHashtable.cs +++ b/Src/Newtonsoft.Json.Tests/TestObjects/TypedSubHashtable.cs @@ -27,7 +27,7 @@ using System.Collections; namespace Newtonsoft.Json.Tests.TestObjects { -#if !NETFX_CORE +#if !(NETFX_CORE || ASPNETCORE50) public class TypedSubHashtable { public string Name; diff --git a/Src/Newtonsoft.Json.Tests/Utilities/DateTimeUtilsTests.cs b/Src/Newtonsoft.Json.Tests/Utilities/DateTimeUtilsTests.cs index 06444eef..49bfb4ab 100644 --- a/Src/Newtonsoft.Json.Tests/Utilities/DateTimeUtilsTests.cs +++ b/Src/Newtonsoft.Json.Tests/Utilities/DateTimeUtilsTests.cs @@ -28,12 +28,16 @@ using System.Collections.Generic; using System.Globalization; using System.IO; using System.Text; -#if !NETFX_CORE -using global::NUnit.Framework; +#if NETFX_CORE +using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; +using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; +using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute; +#elif ASPNETCORE50 +using Xunit; +using Test = Xunit.FactAttribute; +using Assert = Newtonsoft.Json.Tests.XUnitAssert; #else -using global::Microsoft.VisualStudio.TestPlatform.UnitTestFramework; -using TestFixture = global::Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; -using Test = global::Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute; +using NUnit.Framework; #endif using Newtonsoft.Json.Utilities; @@ -62,6 +66,20 @@ namespace Newtonsoft.Json.Tests.Utilities Assert.AreEqual(value, parsedDt); } + [Test] + public void FailingDateTimeParse() + { + string text = "2000-12-15T22:11:03.055+23:30"; + + DateTime oldDt; + bool success = DateTime.TryParseExact(text, "yyyy-MM-ddTHH:mm:ss.FFFFFFFK", CultureInfo.InvariantCulture, DateTimeStyles.RoundtripKind, out oldDt); + + Console.WriteLine("Success: " + success); + Console.WriteLine("DateTime: " + oldDt); + + Assert.IsTrue(success); + } + [Test] public void NewDateTimeParse() { @@ -138,6 +156,8 @@ namespace Newtonsoft.Json.Tests.Utilities private void AssertNewDateTimeParseEqual(string text) { + Console.WriteLine("Parsing date text: " + text); + object oldDt; TryParseDateIso(text, DateParseHandling.DateTime, DateTimeZoneHandling.RoundtripKind, out oldDt); diff --git a/Src/Newtonsoft.Json.Tests/Utilities/DynamicReflectionDelegateFactoryTests.cs b/Src/Newtonsoft.Json.Tests/Utilities/DynamicReflectionDelegateFactoryTests.cs index d1dde656..b2b90f0e 100644 --- a/Src/Newtonsoft.Json.Tests/Utilities/DynamicReflectionDelegateFactoryTests.cs +++ b/Src/Newtonsoft.Json.Tests/Utilities/DynamicReflectionDelegateFactoryTests.cs @@ -23,16 +23,20 @@ // OTHER DEALINGS IN THE SOFTWARE. #endregion -#if !(PORTABLE || NETFX_CORE || PORTABLE40) +#if !(PORTABLE || ASPNETCORE50 || NETFX_CORE || PORTABLE40) using System; using System.Diagnostics; using System.Reflection; -#if !NETFX_CORE -using NUnit.Framework; -#else +#if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute; +#elif ASPNETCORE50 +using Xunit; +using Test = Xunit.FactAttribute; +using Assert = Newtonsoft.Json.Tests.XUnitAssert; +#else +using NUnit.Framework; #endif using Newtonsoft.Json.Serialization; using Newtonsoft.Json.Utilities; diff --git a/Src/Newtonsoft.Json.Tests/Utilities/ExpressionReflectionDelegateFactoryTests.cs b/Src/Newtonsoft.Json.Tests/Utilities/ExpressionReflectionDelegateFactoryTests.cs index 967cefad..f374831c 100644 --- a/Src/Newtonsoft.Json.Tests/Utilities/ExpressionReflectionDelegateFactoryTests.cs +++ b/Src/Newtonsoft.Json.Tests/Utilities/ExpressionReflectionDelegateFactoryTests.cs @@ -23,17 +23,22 @@ // OTHER DEALINGS IN THE SOFTWARE. #endregion +using System.Collections.Generic; #if !(NET20 || NET35) using System.Linq; using System; using System.Diagnostics; using System.Reflection; -#if !NETFX_CORE -using NUnit.Framework; -#else +#if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute; +#elif ASPNETCORE50 +using Xunit; +using Test = Xunit.FactAttribute; +using Assert = Newtonsoft.Json.Tests.XUnitAssert; +#else +using NUnit.Framework; #endif using Newtonsoft.Json.Serialization; using Newtonsoft.Json.Utilities; @@ -48,7 +53,7 @@ namespace Newtonsoft.Json.Tests.Utilities [Test] public void ConstructorWithRefString() { - ConstructorInfo constructor = typeof(OutAndRefTestClass).GetConstructors().Single(c => c.GetParameters().Count() == 1); + ConstructorInfo constructor = TestReflectionUtils.GetConstructors(typeof(OutAndRefTestClass)).Single(c => c.GetParameters().Count() == 1); var creator = ExpressionReflectionDelegateFactory.Instance.CreateParametrizedConstructor(constructor); @@ -61,7 +66,7 @@ namespace Newtonsoft.Json.Tests.Utilities [Test] public void ConstructorWithRefStringAndOutBool() { - ConstructorInfo constructor = typeof(OutAndRefTestClass).GetConstructors().Single(c => c.GetParameters().Count() == 2); + ConstructorInfo constructor = TestReflectionUtils.GetConstructors(typeof(OutAndRefTestClass)).Single(c => c.GetParameters().Count() == 2); var creator = ExpressionReflectionDelegateFactory.Instance.CreateParametrizedConstructor(constructor); @@ -74,7 +79,7 @@ namespace Newtonsoft.Json.Tests.Utilities [Test] public void ConstructorWithRefStringAndRefBoolAndRefBool() { - ConstructorInfo constructor = typeof(OutAndRefTestClass).GetConstructors().Single(c => c.GetParameters().Count() == 3); + ConstructorInfo constructor = TestReflectionUtils.GetConstructors(typeof(OutAndRefTestClass)).Single(c => c.GetParameters().Count() == 3); var creator = ExpressionReflectionDelegateFactory.Instance.CreateParametrizedConstructor(constructor); @@ -121,7 +126,7 @@ namespace Newtonsoft.Json.Tests.Utilities [Test] public void CreatePropertySetter() { - Action setter = ExpressionReflectionDelegateFactory.Instance.CreateSet(typeof(Movie).GetProperty("Name")); + Action setter = ExpressionReflectionDelegateFactory.Instance.CreateSet(TestReflectionUtils.GetProperty(typeof(Movie), "Name")); Movie m = new Movie(); @@ -133,7 +138,7 @@ namespace Newtonsoft.Json.Tests.Utilities [Test] public void CreatePropertyGetter() { - Func getter = ExpressionReflectionDelegateFactory.Instance.CreateGet(typeof(Movie).GetProperty("Name")); + Func getter = ExpressionReflectionDelegateFactory.Instance.CreateGet(TestReflectionUtils.GetProperty(typeof(Movie), "Name")); Movie m = new Movie(); m.Name = "OH HAI!"; @@ -146,13 +151,13 @@ namespace Newtonsoft.Json.Tests.Utilities [Test] public void CreateMethodCall() { - MethodCall method = ExpressionReflectionDelegateFactory.Instance.CreateMethodCall(typeof(Movie).GetMethod("ToString")); + MethodCall method = ExpressionReflectionDelegateFactory.Instance.CreateMethodCall(TestReflectionUtils.GetMethod(typeof(Movie), "ToString")); Movie m = new Movie(); object result = method(m); Assert.AreEqual("Newtonsoft.Json.Tests.TestObjects.Movie", result); - method = ExpressionReflectionDelegateFactory.Instance.CreateMethodCall(typeof(Movie).GetMethod("Equals")); + method = ExpressionReflectionDelegateFactory.Instance.CreateMethodCall(TestReflectionUtils.GetMethod(typeof(Movie), "Equals")); result = method(m, m); Assert.AreEqual(true, result); @@ -180,12 +185,12 @@ namespace Newtonsoft.Json.Tests.Utilities StaticTestClass.StringField = "Field!"; StaticTestClass.StringProperty = "Property!"; - Func getter = ExpressionReflectionDelegateFactory.Instance.CreateGet(typeof(StaticTestClass).GetProperty("StringProperty")); + Func getter = ExpressionReflectionDelegateFactory.Instance.CreateGet(TestReflectionUtils.GetProperty(typeof(StaticTestClass), "StringProperty")); object v = getter(null); Assert.AreEqual(StaticTestClass.StringProperty, v); - getter = ExpressionReflectionDelegateFactory.Instance.CreateGet(typeof(StaticTestClass).GetField("StringField")); + getter = ExpressionReflectionDelegateFactory.Instance.CreateGet(TestReflectionUtils.GetField(typeof(StaticTestClass), "StringField")); v = getter(null); Assert.AreEqual(StaticTestClass.StringField, v); @@ -194,12 +199,12 @@ namespace Newtonsoft.Json.Tests.Utilities [Test] public void SetStatic() { - Action setter = ExpressionReflectionDelegateFactory.Instance.CreateSet(typeof(StaticTestClass).GetProperty("StringProperty")); + Action setter = ExpressionReflectionDelegateFactory.Instance.CreateSet(TestReflectionUtils.GetProperty(typeof(StaticTestClass), "StringProperty")); setter(null, "New property!"); Assert.AreEqual("New property!", StaticTestClass.StringProperty); - setter = ExpressionReflectionDelegateFactory.Instance.CreateSet(typeof(StaticTestClass).GetField("StringField")); + setter = ExpressionReflectionDelegateFactory.Instance.CreateSet(TestReflectionUtils.GetField(typeof(StaticTestClass), "StringField")); setter(null, "New field!"); Assert.AreEqual("New field!", StaticTestClass.StringField); @@ -222,12 +227,12 @@ namespace Newtonsoft.Json.Tests.Utilities StringField = "String!" }; - Func getter = ExpressionReflectionDelegateFactory.Instance.CreateGet(typeof(FieldsTestClass).GetField("StringField")); + Func getter = ExpressionReflectionDelegateFactory.Instance.CreateGet(TestReflectionUtils.GetField(typeof(FieldsTestClass), "StringField")); object value = getter(c); Assert.AreEqual("String!", value); - getter = ExpressionReflectionDelegateFactory.Instance.CreateGet(typeof(FieldsTestClass).GetField("BoolField")); + getter = ExpressionReflectionDelegateFactory.Instance.CreateGet(TestReflectionUtils.GetField(typeof(FieldsTestClass), "BoolField")); value = getter(c); Assert.AreEqual(true, value); @@ -238,7 +243,7 @@ namespace Newtonsoft.Json.Tests.Utilities { FieldsTestClass c = new FieldsTestClass(); - Action setter = ExpressionReflectionDelegateFactory.Instance.CreateSet(typeof(FieldsTestClass).GetField("IntReadOnlyField")); + Action setter = ExpressionReflectionDelegateFactory.Instance.CreateSet(TestReflectionUtils.GetField(typeof(FieldsTestClass), "IntReadOnlyField")); setter(c, int.MinValue); Assert.AreEqual(int.MinValue, c.IntReadOnlyField); @@ -249,12 +254,12 @@ namespace Newtonsoft.Json.Tests.Utilities { FieldsTestClass c = new FieldsTestClass(); - Action setter = ExpressionReflectionDelegateFactory.Instance.CreateSet(typeof(FieldsTestClass).GetField("StringField")); + Action setter = ExpressionReflectionDelegateFactory.Instance.CreateSet(TestReflectionUtils.GetField(typeof(FieldsTestClass), "StringField")); setter(c, "String!"); Assert.AreEqual("String!", c.StringField); - setter = ExpressionReflectionDelegateFactory.Instance.CreateSet(typeof(FieldsTestClass).GetField("BoolField")); + setter = ExpressionReflectionDelegateFactory.Instance.CreateSet(TestReflectionUtils.GetField(typeof(FieldsTestClass), "BoolField")); setter(c, true); Assert.AreEqual(true, c.BoolField); @@ -265,12 +270,12 @@ namespace Newtonsoft.Json.Tests.Utilities { object structTest = new StructTest(); - Action setter = ExpressionReflectionDelegateFactory.Instance.CreateSet(typeof(StructTest).GetProperty("StringProperty")); + Action setter = ExpressionReflectionDelegateFactory.Instance.CreateSet(TestReflectionUtils.GetProperty(typeof(StructTest), "StringProperty")); setter(structTest, "Hi1"); Assert.AreEqual("Hi1", ((StructTest)structTest).StringProperty); - setter = ExpressionReflectionDelegateFactory.Instance.CreateSet(typeof(StructTest).GetField("StringField")); + setter = ExpressionReflectionDelegateFactory.Instance.CreateSet(TestReflectionUtils.GetField(typeof(StructTest), "StringField")); setter(structTest, "Hi2"); Assert.AreEqual("Hi2", ((StructTest)structTest).StringField); @@ -284,7 +289,7 @@ namespace Newtonsoft.Json.Tests.Utilities Person p = new Person(); p.Name = "Hi"; - Func setter = ExpressionReflectionDelegateFactory.Instance.CreateGet(typeof(Movie).GetProperty("Name")); + Func setter = ExpressionReflectionDelegateFactory.Instance.CreateGet(TestReflectionUtils.GetProperty(typeof(Movie), "Name")); setter(p); }, @@ -302,7 +307,7 @@ namespace Newtonsoft.Json.Tests.Utilities Person p = new Person(); Movie m = new Movie(); - Action setter = ExpressionReflectionDelegateFactory.Instance.CreateSet(typeof(Movie).GetProperty("Name")); + Action setter = ExpressionReflectionDelegateFactory.Instance.CreateSet(TestReflectionUtils.GetProperty(typeof(Movie), "Name")); setter(m, "Hi"); @@ -325,7 +330,7 @@ namespace Newtonsoft.Json.Tests.Utilities () => { Movie m = new Movie(); - Action setter = ExpressionReflectionDelegateFactory.Instance.CreateSet(typeof(Movie).GetProperty("Name")); + Action setter = ExpressionReflectionDelegateFactory.Instance.CreateSet(TestReflectionUtils.GetProperty(typeof(Movie), "Name")); setter(m, new Version("1.1.1.1")); }, new [] { diff --git a/Src/Newtonsoft.Json.Tests/Utilities/LateboundReflectionDelegateFactoryTests.cs b/Src/Newtonsoft.Json.Tests/Utilities/LateboundReflectionDelegateFactoryTests.cs index 4de05219..e14d1ea1 100644 --- a/Src/Newtonsoft.Json.Tests/Utilities/LateboundReflectionDelegateFactoryTests.cs +++ b/Src/Newtonsoft.Json.Tests/Utilities/LateboundReflectionDelegateFactoryTests.cs @@ -1,11 +1,15 @@ using System.Reflection; using Newtonsoft.Json.Utilities; -#if !NETFX_CORE -using NUnit.Framework; -#else +#if NETFX_CORE using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute; +#elif ASPNETCORE50 +using Xunit; +using Test = Xunit.FactAttribute; +using Assert = Newtonsoft.Json.Tests.XUnitAssert; +#else +using NUnit.Framework; #endif #if NET20 using Newtonsoft.Json.Utilities.LinqBridge; @@ -48,7 +52,7 @@ namespace Newtonsoft.Json.Tests.Utilities [Test] public void ConstructorWithRefString() { - ConstructorInfo constructor = typeof(OutAndRefTestClass).GetConstructors().Single(c => c.GetParameters().Count() == 1); + ConstructorInfo constructor = TestReflectionUtils.GetConstructors(typeof(OutAndRefTestClass)).Single(c => c.GetParameters().Count() == 1); var creator = LateBoundReflectionDelegateFactory.Instance.CreateParametrizedConstructor(constructor); @@ -61,7 +65,7 @@ namespace Newtonsoft.Json.Tests.Utilities [Test] public void ConstructorWithRefStringAndOutBool() { - ConstructorInfo constructor = typeof(OutAndRefTestClass).GetConstructors().Single(c => c.GetParameters().Count() == 2); + ConstructorInfo constructor = TestReflectionUtils.GetConstructors(typeof(OutAndRefTestClass)).Single(c => c.GetParameters().Count() == 2); var creator = LateBoundReflectionDelegateFactory.Instance.CreateParametrizedConstructor(constructor); @@ -74,7 +78,7 @@ namespace Newtonsoft.Json.Tests.Utilities [Test] public void ConstructorWithRefStringAndRefBoolAndRefBool() { - ConstructorInfo constructor = typeof(OutAndRefTestClass).GetConstructors().Single(c => c.GetParameters().Count() == 3); + ConstructorInfo constructor = TestReflectionUtils.GetConstructors(typeof(OutAndRefTestClass)).Single(c => c.GetParameters().Count() == 3); var creator = LateBoundReflectionDelegateFactory.Instance.CreateParametrizedConstructor(constructor); diff --git a/Src/Newtonsoft.Json.Tests/Utilities/ReflectionUtilsTests.cs b/Src/Newtonsoft.Json.Tests/Utilities/ReflectionUtilsTests.cs index 7359335c..de5bfcb9 100644 --- a/Src/Newtonsoft.Json.Tests/Utilities/ReflectionUtilsTests.cs +++ b/Src/Newtonsoft.Json.Tests/Utilities/ReflectionUtilsTests.cs @@ -23,18 +23,22 @@ // OTHER DEALINGS IN THE SOFTWARE. #endregion -#if !(PORTABLE || PORTABLE40) -using global::System; -using global::System.Collections.Generic; -using global::System.Runtime.Serialization.Formatters; -#if !NETFX_CORE -using global::NUnit.Framework; +#if !(PORTABLE || ASPNETCORE50 || PORTABLE40) +using System; +using System.Collections.Generic; +using System.Runtime.Serialization.Formatters; +#if NETFX_CORE +using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; +using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; +using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute; +#elif ASPNETCORE50 +using Xunit; +using Test = Xunit.FactAttribute; +using Assert = Newtonsoft.Json.Tests.XUnitAssert; #else -using global::Microsoft.VisualStudio.TestPlatform.UnitTestFramework; -using TestFixture = global::Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; -using Test = global::Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute; +using NUnit.Framework; #endif -using global::Newtonsoft.Json.Utilities; +using Newtonsoft.Json.Utilities; namespace Newtonsoft.Json.Tests.Utilities { diff --git a/Src/Newtonsoft.Json.Tests/Utilities/StringUtilsTests.cs b/Src/Newtonsoft.Json.Tests/Utilities/StringUtilsTests.cs index 5f44fc4c..09720b35 100644 --- a/Src/Newtonsoft.Json.Tests/Utilities/StringUtilsTests.cs +++ b/Src/Newtonsoft.Json.Tests/Utilities/StringUtilsTests.cs @@ -23,12 +23,16 @@ // OTHER DEALINGS IN THE SOFTWARE. #endregion -#if !NETFX_CORE -using global::NUnit.Framework; +#if NETFX_CORE +using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; +using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; +using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute; +#elif ASPNETCORE50 +using Xunit; +using Test = Xunit.FactAttribute; +using Assert = Newtonsoft.Json.Tests.XUnitAssert; #else -using global::Microsoft.VisualStudio.TestPlatform.UnitTestFramework; -using TestFixture = global::Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; -using Test = global::Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute; +using NUnit.Framework; #endif using Newtonsoft.Json.Utilities; diff --git a/Src/Newtonsoft.Json.Tests/project.json b/Src/Newtonsoft.Json.Tests/project.json new file mode 100644 index 00000000..751da208 --- /dev/null +++ b/Src/Newtonsoft.Json.Tests/project.json @@ -0,0 +1,54 @@ +{ + "version": "1.0.0-*", + "compilationOptions": { + "define": [ + "NOINTERNALS" + ] + }, + "exclude":[ + "LinqToSql", + "Documentation", + "FileSystemEntityModel.Designer.cs" + ], + "dependencies": { + "Xunit.KRunner": "1.0.0-*", + "Newtonsoft.Json": "6.0.6" + }, + "commands": { + "test": "Xunit.KRunner" + }, + "frameworks": { + "aspnetcore50": { + "dependencies": { + "Microsoft.CSharp": "4.0.0-beta-*", + "System.Collections": "4.0.10-beta-*", + "System.ComponentModel.TypeConverter": "4.0.0-beta-*", + "System.Diagnostics.Debug": "4.0.10-beta-*", + "System.Dynamic.Runtime": "4.0.0-beta-*", + "System.Globalization": "4.0.10-beta-*", + "System.IO": "4.0.10-beta-*", + "System.Linq": "4.0.0-beta-*", + "System.Linq.Expressions": "4.0.0-beta-*", + "System.Reflection.Extensions": "4.0.0-beta-*", + "System.Reflection.TypeExtensions": "4.0.0-beta-*", + "System.Runtime": "4.0.20-beta-*", + "System.Runtime.Extensions": "4.0.10-beta-*", + "System.Runtime.Serialization.Primitives": "4.0.0-beta-*", + "System.Runtime.Numerics": "4.0.0-beta-*", + "System.Runtime.Serialization.Json": "4.0.0-beta-*", + "System.Runtime.Serialization.Xml": "4.0.0-beta-*", + "System.Reflection.Emit.ILGeneration": "4.0.0-beta-*", + "System.Text.Encoding": "4.0.10-beta-*", + "System.Text.RegularExpressions": "4.0.0-beta-*", + "System.Text.Encoding.Extensions": "4.0.10-beta-*", + "System.Text.Encoding.CodePages": "4.0.0-beta-*", + "System.Threading": "4.0.0-beta-*", + "System.Xml.XDocument": "4.0.0-beta-*", + "System.Xml.XmlDocument": "4.0.0-beta-*", + "System.Xml.XmlSerializer": "4.0.0-beta-*", + "System.Xml.ReaderWriter": "4.0.10-beta-*", + "Microsoft.Bcl.Immutable": "1.1.20-beta" + } + } + } +} \ No newline at end of file diff --git a/Src/Newtonsoft.Json/Serialization/JsonTypeReflector.cs b/Src/Newtonsoft.Json/Serialization/JsonTypeReflector.cs index a2fdf14d..6b694930 100644 --- a/Src/Newtonsoft.Json/Serialization/JsonTypeReflector.cs +++ b/Src/Newtonsoft.Json/Serialization/JsonTypeReflector.cs @@ -24,6 +24,7 @@ #endregion using System; +using System.Collections.Generic; using System.ComponentModel; using System.Globalization; using System.Reflection; @@ -58,13 +59,8 @@ namespace Newtonsoft.Json.Serialization private static readonly ThreadSafeStore> JsonConverterCreatorCache = new ThreadSafeStore>(GetJsonConverterCreator); -#if !(NET20 || NETFX_CORE) +#if !(NET20 || PORTABLE40 || NETFX_CORE) private static readonly ThreadSafeStore AssociatedMetadataTypesCache = new ThreadSafeStore(GetAssociateMetadataTypeFromAttribute); - - private const string MetadataTypeAttributeTypeName = - "System.ComponentModel.DataAnnotations.MetadataTypeAttribute, System.ComponentModel.DataAnnotations, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"; - - private static Type _cachedMetadataTypeAttributeType; #endif public static T GetCachedAttribute(object attributeProvider) where T : Attribute @@ -224,47 +220,38 @@ namespace Newtonsoft.Json.Serialization } #endif -#if !(NET20 || NETFX_CORE) +#if !(NET20 || PORTABLE40 || NETFX_CORE) private static Type GetAssociatedMetadataType(Type type) { return AssociatedMetadataTypesCache.Get(type); } - private static ReflectionObject _metadataTypeAttributeReflectionObject; - private static Type GetAssociateMetadataTypeFromAttribute(Type type) { - Type metadataTypeAttributeType = GetMetadataTypeAttributeType(); - if (metadataTypeAttributeType == null) - return null; + IList customAttributes = ReflectionUtils.GetCustomAttributeData(type); - Attribute attribute = ReflectionUtils.GetAttributes(type, metadataTypeAttributeType, true).SingleOrDefault(); - if (attribute == null) - return null; - - const string metadataClassTypeName = "MetadataClassType"; - - if (_metadataTypeAttributeReflectionObject == null) - _metadataTypeAttributeReflectionObject = ReflectionObject.Create(metadataTypeAttributeType, metadataClassTypeName); - - return (Type)_metadataTypeAttributeReflectionObject.GetValue(attribute, metadataClassTypeName); - } - - private static Type GetMetadataTypeAttributeType() - { - // always attempt to get the metadata type attribute type - // the assembly may have been loaded since last time - if (_cachedMetadataTypeAttributeType == null) + foreach (CustomAttributeData customAttributeData in customAttributes) { - Type metadataTypeAttributeType = Type.GetType(MetadataTypeAttributeTypeName); + Type attributeType; - if (metadataTypeAttributeType != null) - _cachedMetadataTypeAttributeType = metadataTypeAttributeType; - else - return null; +#if (NET20 || NET35 || NET40) + attributeType = customAttributeData.Constructor.DeclaringType; +#else + attributeType = customAttributeData.AttributeType; +#endif + + if (attributeType != null + && string.Equals(attributeType.Name, "MetadataTypeAttribute", StringComparison.Ordinal) + && attributeType.Assembly().GetName().Name == "System.ComponentModel.DataAnnotations") + { + // MetadataTypeAttribute constructor takes one argument, the type we're looking for + CustomAttributeTypedArgument o = customAttributeData.ConstructorArguments[0]; + + return (Type)o.Value; + } } - return _cachedMetadataTypeAttributeType; + return null; } #endif @@ -272,7 +259,7 @@ namespace Newtonsoft.Json.Serialization { T attribute; -#if !(NET20 || NETFX_CORE) +#if !(NET20 || PORTABLE40 || NETFX_CORE) Type metadataType = GetAssociatedMetadataType(type); if (metadataType != null) { @@ -300,7 +287,7 @@ namespace Newtonsoft.Json.Serialization { T attribute; -#if !(NET20 || NETFX_CORE) +#if !(NET20 || PORTABLE40 || NETFX_CORE) Type metadataType = GetAssociatedMetadataType(memberInfo.DeclaringType); if (metadataType != null) { diff --git a/Src/Newtonsoft.Json/Utilities/ImmutableCollectionsUtils.cs b/Src/Newtonsoft.Json/Utilities/ImmutableCollectionsUtils.cs index 307558b8..f18d8442 100644 --- a/Src/Newtonsoft.Json/Utilities/ImmutableCollectionsUtils.cs +++ b/Src/Newtonsoft.Json/Utilities/ImmutableCollectionsUtils.cs @@ -106,12 +106,15 @@ namespace Newtonsoft.Json.Utilities { if (underlyingType.IsGenericType()) { - string name = underlyingType.GetGenericTypeDefinition().FullName; + Type underlyingTypeDefinition = underlyingType.GetGenericTypeDefinition(); + string name = underlyingTypeDefinition.FullName; + ImmutableCollectionTypeInfo definition = ArrayContractImmutableCollectionDefinitions.FirstOrDefault(d => d.ContractTypeName == name); if (definition != null) { - Type createdTypeDefinition = Type.GetType(definition.CreatedTypeName + ", System.Collections.Immutable"); - Type builderTypeDefinition = Type.GetType(definition.BuilderTypeName + ", System.Collections.Immutable"); + Type createdTypeDefinition = underlyingTypeDefinition.Assembly().GetType(definition.CreatedTypeName); + Type builderTypeDefinition = underlyingTypeDefinition.Assembly().GetType(definition.BuilderTypeName); + if (createdTypeDefinition != null && builderTypeDefinition != null) { MethodInfo mb = builderTypeDefinition.GetMethods().FirstOrDefault(m => m.Name == "CreateRange" && m.GetParameters().Length == 1); @@ -135,12 +138,15 @@ namespace Newtonsoft.Json.Utilities { if (underlyingType.IsGenericType()) { - string name = underlyingType.GetGenericTypeDefinition().FullName; + Type underlyingTypeDefinition = underlyingType.GetGenericTypeDefinition(); + string name = underlyingTypeDefinition.FullName; + ImmutableCollectionTypeInfo definition = DictionaryContractImmutableCollectionDefinitions.FirstOrDefault(d => d.ContractTypeName == name); if (definition != null) { - Type createdTypeDefinition = Type.GetType(definition.CreatedTypeName + ", System.Collections.Immutable"); - Type builderTypeDefinition = Type.GetType(definition.BuilderTypeName + ", System.Collections.Immutable"); + Type createdTypeDefinition = underlyingTypeDefinition.Assembly().GetType(definition.CreatedTypeName); + Type builderTypeDefinition = underlyingTypeDefinition.Assembly().GetType(definition.BuilderTypeName); + if (createdTypeDefinition != null && builderTypeDefinition != null) { MethodInfo mb = builderTypeDefinition.GetMethods().FirstOrDefault(m => diff --git a/Src/Newtonsoft.Json/Utilities/ReflectionUtils.cs b/Src/Newtonsoft.Json/Utilities/ReflectionUtils.cs index ca32ebb5..d0bd4366 100644 --- a/Src/Newtonsoft.Json/Utilities/ReflectionUtils.cs +++ b/Src/Newtonsoft.Json/Utilities/ReflectionUtils.cs @@ -732,6 +732,17 @@ namespace Newtonsoft.Json.Utilities } #endif +#if !PORTABLE40 + public static IList GetCustomAttributeData(Type t) + { +#if !(NETFX_CORE || ASPNETCORE50 || PORTABLE) + return CustomAttributeData.GetCustomAttributes(t); +#else + return t.GetTypeInfo().CustomAttributes.ToList(); +#endif + } +#endif + public static void SplitFullyQualifiedTypeName(string fullyQualifiedTypeName, out string typeName, out string assemblyName) { int? assemblyDelimiterIndex = GetAssemblyDelimiterIndex(fullyQualifiedTypeName); diff --git a/Src/NuGet.Config b/Src/NuGet.Config new file mode 100644 index 00000000..f41e9c63 --- /dev/null +++ b/Src/NuGet.Config @@ -0,0 +1,7 @@ + + + + + + +