Clean up NETFX_CORE directive usage

This commit is contained in:
Pyit Phyo Aung
2016-10-11 14:14:13 +13:00
parent e74d6c5a4b
commit f50f276b76
121 changed files with 218 additions and 1441 deletions
@@ -32,7 +32,7 @@ using System.Collections.Generic;
#if !(NET20 || NET35 || PORTABLE) || NETSTANDARD1_1
using System.Numerics;
#endif
#if !(NET20 || NETFX_CORE || DNXCORE50)
#if !(NET20 || DNXCORE50)
using System.ComponentModel.DataAnnotations;
using System.Configuration;
using System.Runtime.CompilerServices;
@@ -42,11 +42,7 @@ using System.Web.Script.Serialization;
#endif
using System.Text;
using System.Text.RegularExpressions;
#if NETFX_CORE
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute;
#elif DNXCORE50
#if DNXCORE50
using Xunit;
using Test = Xunit.FactAttribute;
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
@@ -86,7 +82,7 @@ using Newtonsoft.Json.Utilities.LinqBridge;
#else
using System.Linq;
#endif
#if !(NETFX_CORE || DNXCORE50)
#if !(DNXCORE50)
using System.Drawing;
#endif
@@ -736,7 +732,7 @@ namespace Newtonsoft.Json.Tests.Serialization
Assert.AreEqual("Name!", c2.Name);
}
#if !(NETFX_CORE || DNXCORE50 || NET20)
#if !(DNXCORE50 || NET20)
[MetadataType(typeof(CustomerValidation))]
public partial class CustomerWithMetadataType
{
@@ -1202,7 +1198,7 @@ namespace Newtonsoft.Json.Tests.Serialization
serializer.ConstructorHandling = ConstructorHandling.AllowNonPublicDefaultConstructor;
Assert.AreEqual(ConstructorHandling.AllowNonPublicDefaultConstructor, serializer.ConstructorHandling);
#if !(NETFX_CORE || DNXCORE50)
#if !(DNXCORE50)
serializer.Context = new StreamingContext(StreamingContextStates.Other);
Assert.AreEqual(new StreamingContext(StreamingContextStates.Other), serializer.Context);
#endif
@@ -1273,7 +1269,7 @@ namespace Newtonsoft.Json.Tests.Serialization
serializer.TraceWriter = traceWriter;
Assert.AreEqual(traceWriter, serializer.TraceWriter);
#if !(PORTABLE || PORTABLE40 || NETFX_CORE || NET20 || DNXCORE50)
#if !(PORTABLE || PORTABLE40 || NET20 || DNXCORE50)
#pragma warning disable 618
serializer.TypeNameAssemblyFormat = FormatterAssemblyStyle.Full;
Assert.AreEqual(FormatterAssemblyStyle.Full, serializer.TypeNameAssemblyFormat);
@@ -1311,7 +1307,7 @@ namespace Newtonsoft.Json.Tests.Serialization
settings.ConstructorHandling = ConstructorHandling.AllowNonPublicDefaultConstructor;
Assert.AreEqual(ConstructorHandling.AllowNonPublicDefaultConstructor, settings.ConstructorHandling);
#if !(NETFX_CORE || DNXCORE50)
#if !(DNXCORE50)
settings.Context = new StreamingContext(StreamingContextStates.Other);
Assert.AreEqual(new StreamingContext(StreamingContextStates.Other), settings.Context);
#endif
@@ -1388,7 +1384,7 @@ namespace Newtonsoft.Json.Tests.Serialization
settings.TraceWriter = traceWriter;
Assert.AreEqual(traceWriter, settings.TraceWriter);
#if !(PORTABLE || PORTABLE40 || NETFX_CORE || NET20 || DNXCORE50)
#if !(PORTABLE || PORTABLE40 || NET20 || DNXCORE50)
#pragma warning disable 618
settings.TypeNameAssemblyFormat = FormatterAssemblyStyle.Full;
Assert.AreEqual(FormatterAssemblyStyle.Full, settings.TypeNameAssemblyFormat);
@@ -1439,7 +1435,7 @@ namespace Newtonsoft.Json.Tests.Serialization
serializerProxy.ConstructorHandling = ConstructorHandling.AllowNonPublicDefaultConstructor;
Assert.AreEqual(ConstructorHandling.AllowNonPublicDefaultConstructor, serializerProxy.ConstructorHandling);
#if !(NETFX_CORE || DNXCORE50)
#if !(DNXCORE50)
serializerProxy.Context = new StreamingContext(StreamingContextStates.Other);
Assert.AreEqual(new StreamingContext(StreamingContextStates.Other), serializerProxy.Context);
#endif
@@ -1510,7 +1506,7 @@ namespace Newtonsoft.Json.Tests.Serialization
serializerProxy.TraceWriter = traceWriter;
Assert.AreEqual(traceWriter, serializerProxy.TraceWriter);
#if !(PORTABLE || PORTABLE40 || NETFX_CORE || NET20 || DNXCORE50)
#if !(PORTABLE || PORTABLE40 || NET20 || DNXCORE50)
#pragma warning disable 618
serializerProxy.TypeNameAssemblyFormat = FormatterAssemblyStyle.Full;
Assert.AreEqual(FormatterAssemblyStyle.Full, serializerProxy.TypeNameAssemblyFormat);
@@ -1531,7 +1527,7 @@ namespace Newtonsoft.Json.Tests.Serialization
Assert.AreEqual(TypeNameHandling.All, serializerProxy.TypeNameHandling);
}
#if !(NETFX_CORE || PORTABLE || PORTABLE40 || DNXCORE50)
#if !(PORTABLE || PORTABLE40 || DNXCORE50)
[Test]
public void DeserializeISerializableIConvertible()
{
@@ -1790,8 +1786,7 @@ namespace Newtonsoft.Json.Tests.Serialization
Assert.IsNotNull(deserialized.foo);
Assert.AreEqual("value", deserialized.foo.bar);
}
#if !(NETFX_CORE)
[Test]
public void ConversionOperator()
{
@@ -1815,7 +1810,6 @@ namespace Newtonsoft.Json.Tests.Serialization
var deserialize = jsonSerializer.Deserialize(new StreamReader(ms), typeof(Dictionary<DictionaryKeyCast, int>));
stopWatch.Stop();
}
#endif
internal class DictionaryKeyCast
{
@@ -2215,7 +2209,7 @@ namespace Newtonsoft.Json.Tests.Serialization
Assert.AreEqual(executorObject2.clientGetResultFunction, "ClientBanSubsCB");
}
#if !(NETFX_CORE || DNXCORE50)
#if !(DNXCORE50)
[Test]
public void HashtableDeserialization()
{
@@ -2433,7 +2427,7 @@ keyword such as type of business.""
{
string json = @"[""vvv\/vvv\tvvv\""vvv\bvvv\nvvv\rvvv\\vvv\fvvv""]";
#if !(NETFX_CORE || DNXCORE50)
#if !(DNXCORE50)
JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();
List<string> javaScriptSerializerResult = javaScriptSerializer.Deserialize<List<string>>(json);
#endif
@@ -2445,7 +2439,7 @@ keyword such as type of business.""
Assert.AreEqual(1, jsonNetResult.Count);
Assert.AreEqual(dataContractResult[0], jsonNetResult[0]);
#if !(NETFX_CORE || DNXCORE50)
#if !(DNXCORE50)
Assert.AreEqual(javaScriptSerializerResult[0], jsonNetResult[0]);
#endif
}
@@ -2656,7 +2650,7 @@ keyword such as type of business.""
string json = JsonConvert.SerializeObject(new ConverableMembers(), Formatting.Indented);
string expected = null;
#if !(NETFX_CORE || PORTABLE || DNXCORE50)
#if !(PORTABLE || DNXCORE50)
expected = @"{
""String"": ""string"",
""Int32"": 2147483647,
@@ -2696,7 +2690,7 @@ keyword such as type of business.""
ConverableMembers c = JsonConvert.DeserializeObject<ConverableMembers>(json);
Assert.AreEqual("string", c.String);
Assert.AreEqual(double.MaxValue, c.Double);
#if !(NETFX_CORE || PORTABLE || DNXCORE50 || PORTABLE40)
#if !(PORTABLE || DNXCORE50 || PORTABLE40)
Assert.AreEqual(DBNull.Value, c.DBNull);
#endif
}
@@ -3540,7 +3534,7 @@ keyword such as type of business.""
Assert.AreEqual("titleId", n.FidOrder[n.FidOrder.Count - 1]);
}
#if !(NET20 || NETFX_CORE || DNXCORE50)
#if !(NET20 || DNXCORE50)
[MetadataType(typeof(OptInClassMetadata))]
public class OptInClass
{
@@ -3922,7 +3916,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 || DNXCORE50)
#if !(PORTABLE || DNXCORE50)
[Test]
public void CannotDeserializeArrayIntoSerializable()
{
@@ -4040,7 +4034,7 @@ Path '', line 1, position 1.");
{
ContractResolver = new DefaultContractResolver
{
#if !(NETFX_CORE || PORTABLE || DNXCORE50 || PORTABLE40)
#if !(PORTABLE || DNXCORE50 || PORTABLE40)
IgnoreSerializableAttribute = true
#endif
}
@@ -4057,7 +4051,7 @@ Path '', line 1, position 1.");
{
ContractResolver = new DefaultContractResolver
{
#if !(NETFX_CORE || PORTABLE || DNXCORE50 || PORTABLE40)
#if !(PORTABLE || DNXCORE50 || PORTABLE40)
IgnoreSerializableAttribute = true
#endif
}
@@ -4074,7 +4068,7 @@ Path '', line 1, position 1.");
{
ContractResolver = new DefaultContractResolver
{
#if !(NETFX_CORE || PORTABLE || DNXCORE50 || PORTABLE40)
#if !(PORTABLE || DNXCORE50 || PORTABLE40)
IgnoreSerializableAttribute = true
#endif
}
@@ -4091,7 +4085,7 @@ Path '', line 1, position 1.");
{
ContractResolver = new DefaultContractResolver
{
#if !(NETFX_CORE || PORTABLE || DNXCORE50 || PORTABLE40)
#if !(PORTABLE || DNXCORE50 || PORTABLE40)
IgnoreSerializableAttribute = true
#endif
}
@@ -4865,7 +4859,7 @@ Path '', line 1, position 1.");
Assert.AreEqual("value", newModelStateDictionary["key"]);
}
#if !(NETFX_CORE || PORTABLE || DNXCORE50 || PORTABLE40)
#if !(PORTABLE || DNXCORE50 || PORTABLE40)
public class ISerializableTestObject : ISerializable
{
internal string _stringValue;
@@ -5354,7 +5348,7 @@ Path '', line 1, position 1.");
}
#endif
#if !(NETFX_CORE || DNXCORE50)
#if !(DNXCORE50)
public class XmlNodeTestObject
{
public XmlDocument Document { get; set; }
@@ -5392,7 +5386,7 @@ Path '', line 1, position 1.");
}
#endif
#if !(NETFX_CORE || PORTABLE || DNXCORE50 || PORTABLE40)
#if !(PORTABLE || DNXCORE50 || PORTABLE40)
[Test]
public void SerializeDeserializeXmlNodeProperties()
{
@@ -5720,7 +5714,7 @@ Path '', line 1, position 1.");
Assert.AreEqual(0, z[1].Prop1.Length);
}
#if !(NET20 || NETFX_CORE || DNXCORE50)
#if !(NET20 || DNXCORE50)
public class StringDictionaryTestClass
{
public StringDictionary StringDictionaryProperty { get; set; }
@@ -6047,7 +6041,7 @@ Path '', line 1, position 1.");
Assert.AreEqual(meh.IDontWork, "meh");
}
#if !(NET20 || NETFX_CORE || DNXCORE50)
#if !(NET20 || DNXCORE50)
[DataContract]
public struct StructISerializable : ISerializable
{
@@ -6790,7 +6784,7 @@ Path '', line 1, position 1.");
}
}
#if !(NETFX_CORE || PORTABLE || DNXCORE50 || PORTABLE40)
#if !(PORTABLE || DNXCORE50 || PORTABLE40)
[Test]
public void SerializeException1()
{
@@ -7017,7 +7011,7 @@ Path '', line 1, position 1.");
Assert.AreEqual(-3, StaticTestClass.z);
}
#if !(NET20 || NETFX_CORE || DNXCORE50)
#if !(NET20 || DNXCORE50)
[Test]
public void DeserializeDecimalsWithCulture()
{
@@ -7178,7 +7172,7 @@ Path '', line 1, position 1.");
ExceptionAssert.Throws<JsonSerializationException>(() => { List<int> numbers = JsonConvert.DeserializeObject<List<int>>(json); }, "Error converting value {null} to type 'System.Int32'. Path '[3]', line 5, position 6.");
}
#if !(PORTABLE || NETFX_CORE)
#if !(PORTABLE)
public class ConvertableIntTestClass
{
public ConvertibleInt Integer { get; set; }
@@ -7537,7 +7531,7 @@ Path '', line 1, position 1.");
}
#endif
#if !(NETFX_CORE || DNXCORE50)
#if !(DNXCORE50)
[Test]
public void MetroBlogPost()
{
@@ -7931,7 +7925,7 @@ Path '', line 1, position 1.");
Assert.AreEqual("", s);
}
#if !(NETFX_CORE || PORTABLE || DNXCORE50 || PORTABLE40)
#if !(PORTABLE || DNXCORE50 || PORTABLE40)
[Test]
public void SerializeAndDeserializeWithAttributes()
{
@@ -8092,7 +8086,7 @@ Path '', line 1, position 1.");
ExceptionAssert.Throws<JsonReaderException>(() => { s.Deserialize<Dictionary<string, int>>(new JsonTextReader(new StringReader(json))); }, "Additional text encountered after finished reading JSON content: {. Path '', line 1, position 7.");
}
#if !(NETFX_CORE || PORTABLE || DNXCORE50 || PORTABLE40)
#if !(PORTABLE || DNXCORE50 || PORTABLE40)
[Test]
public void DeserializeException()
{
@@ -8334,7 +8328,7 @@ Path '', line 1, position 1.");
Action doStuff = () => { obj = JsonConvert.DeserializeObject<MyTuple<int>>(json); };
#if !(NETFX_CORE || PORTABLE || DNXCORE50 || PORTABLE40)
#if !(PORTABLE || DNXCORE50 || PORTABLE40)
doStuff();
Assert.AreEqual(500, obj.Item1);
#else
@@ -8365,7 +8359,7 @@ Path '', line 1, position 1.");
}
#endif
#if !(NETFX_CORE || PORTABLE || NET35 || NET20 || PORTABLE40 || DNXCORE50)
#if !(PORTABLE || NET35 || NET20 || PORTABLE40 || DNXCORE50)
[Test]
public void SerializeTupleWithSerializableAttribute()
{
@@ -8392,29 +8386,6 @@ Path '', line 1, position 1.");
}
#endif
#if NETFX_CORE
[Test]
public void SerializeWinRTJsonObject()
{
var o = Windows.Data.Json.JsonObject.Parse(@"{
""CPU"": ""Intel"",
""Drives"": [
""DVD read/writer"",
""500 gigabyte hard drive""
]
}");
string json = JsonConvert.SerializeObject(o, Formatting.Indented);
Assert.AreEqual(@"{
""Drives"": [
""DVD read/writer"",
""500 gigabyte hard drive""
],
""CPU"": ""Intel""
}", json);
}
#endif
#if !NET20
[Test]
public void RoundtripOfDateTimeOffset()
@@ -8633,7 +8604,7 @@ Path '', line 1, position 1.");
}
#endif
#if !(NETFX_CORE || DNXCORE50)
#if !(DNXCORE50)
[Serializable]
#endif
[DataContract]
@@ -8662,7 +8633,7 @@ Path '', line 1, position 1.");
Assert.AreEqual(@"{""First"":""One"",""Second"":2}", json);
#if !(NETFX_CORE || PORTABLE || DNXCORE50 || PORTABLE40)
#if !(PORTABLE || DNXCORE50 || PORTABLE40)
DefaultContractResolver r = new DefaultContractResolver();
r.IgnoreSerializableAttribute = false;
@@ -8778,7 +8749,7 @@ Path '', line 1, position 1.");
Assert.AreEqual(1234567890.123456m, d);
}
#if !(PORTABLE || DNXCORE50 || NETFX_CORE || PORTABLE40)
#if !(PORTABLE || DNXCORE50 || PORTABLE40)
[Test]
public void DontSerializeStaticFields()
{
@@ -8942,7 +8913,7 @@ Path '', line 1, position 1.");
]", json);
}
#if !(PORTABLE || PORTABLE40 || NETFX_CORE || DNXCORE50)
#if !(PORTABLE || PORTABLE40 || DNXCORE50)
[Test]
public void SerializeDictionaryWithStructKey()
{
@@ -9033,7 +9004,7 @@ Path '', line 1, position 1.");
Assert.AreEqual(jane, john.Spouse);
}
#if !(NETFX_CORE || NET35 || NET20 || PORTABLE || PORTABLE40)
#if !(NET35 || NET20 || PORTABLE || PORTABLE40)
[Test]
public void TypeConverterOnInterface()
{
@@ -9099,7 +9070,7 @@ Path '', line 1, position 1.");
ParticipantEntity deserializedProduct = JsonConvert.DeserializeObject<ParticipantEntity>(json);
}
#if !(PORTABLE || NETFX_CORE)
#if !(PORTABLE)
public class ConvertibleId : IConvertible
{
public int Value;
@@ -9631,7 +9602,7 @@ Path '', line 1, position 1.");
}
#endif
#if !(NETFX_CORE || DNXCORE50)
#if !(DNXCORE50)
[Test]
public void MailMessageConverterTest()
{