-Obsoleted FormatterAssemblyStyle in non-full .NET assemblies
-Tests
This commit is contained in:
@@ -368,24 +368,6 @@ function Edit-XmlNodes {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function Update-Project {
|
|
||||||
param (
|
|
||||||
[string] $projectPath,
|
|
||||||
[string] $sign
|
|
||||||
)
|
|
||||||
|
|
||||||
$file = switch($sign) { $true { $signKeyPath } default { $null } }
|
|
||||||
$signed = switch($sign) { $true { ";SIGNED" } default { "" } }
|
|
||||||
$constants = "CODE_ANALYSIS;TRACE$signed"
|
|
||||||
$json = (Get-Content $projectPath) -join "`n" | ConvertFrom-Json
|
|
||||||
$options = @{"warningsAsErrors" = $true; "xmlDoc" = $true; "keyFile" = $file; "define" = ($constants -split ";") }
|
|
||||||
Add-Member -InputObject $json -MemberType NoteProperty -Name "buildOptions" -Value $options -Force
|
|
||||||
|
|
||||||
$json.version = GetNuGetVersion
|
|
||||||
|
|
||||||
ConvertTo-Json $json -Depth 10 | Set-Content $projectPath
|
|
||||||
}
|
|
||||||
|
|
||||||
function Execute-Command($command) {
|
function Execute-Command($command) {
|
||||||
$currentRetry = 0
|
$currentRetry = 0
|
||||||
$success = $false
|
$success = $false
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
{
|
{
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"NUnit": "2.6.2",
|
"NUnit": "2.6.2",
|
||||||
"FSharp.Core": "4.0.0.1"
|
"FSharp.Core": "4.0.0.1",
|
||||||
|
"System.ValueTuple": "4.3.0"
|
||||||
},
|
},
|
||||||
"frameworks": {
|
"frameworks": {
|
||||||
"net40": {}
|
"net40": {}
|
||||||
|
|||||||
@@ -2,7 +2,8 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"FSharp.Core": "4.0.0.1",
|
"FSharp.Core": "4.0.0.1",
|
||||||
"NUnit": "2.6.2",
|
"NUnit": "2.6.2",
|
||||||
"System.Collections.Immutable": "1.1.37"
|
"System.Collections.Immutable": "1.1.37",
|
||||||
|
"System.ValueTuple": "4.3.0"
|
||||||
},
|
},
|
||||||
"frameworks": {
|
"frameworks": {
|
||||||
"net45": {}
|
"net45": {}
|
||||||
|
|||||||
@@ -97,7 +97,8 @@
|
|||||||
<PackageReference Include="System.Runtime.Serialization.Primitives" Version="4.1.1" />
|
<PackageReference Include="System.Runtime.Serialization.Primitives" Version="4.1.1" />
|
||||||
<PackageReference Include="System.Runtime.Serialization.Xml" Version="4.1.1" />
|
<PackageReference Include="System.Runtime.Serialization.Xml" Version="4.1.1" />
|
||||||
<PackageReference Include="System.Xml.XmlSerializer" Version="4.0.11" />
|
<PackageReference Include="System.Xml.XmlSerializer" Version="4.0.11" />
|
||||||
|
<PackageReference Include="System.ValueTuple" Version="4.3.0" />
|
||||||
|
|
||||||
<PackageReference Include="xunit" Version="2.2.0-*" />
|
<PackageReference Include="xunit" Version="2.2.0-*" />
|
||||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0-beta5-build1225" />
|
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0-beta5-build1225" />
|
||||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0-*" />
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0-*" />
|
||||||
|
|||||||
@@ -4,7 +4,8 @@
|
|||||||
"FSharp.Core": "4.0.0.1",
|
"FSharp.Core": "4.0.0.1",
|
||||||
"NUnit": "2.6.2",
|
"NUnit": "2.6.2",
|
||||||
"System.Buffers": "4.0.0",
|
"System.Buffers": "4.0.0",
|
||||||
"System.Collections.Immutable": "1.1.37"
|
"System.Collections.Immutable": "1.1.37",
|
||||||
|
"System.ValueTuple": "4.3.0"
|
||||||
},
|
},
|
||||||
"frameworks": {
|
"frameworks": {
|
||||||
"net45": {}
|
"net45": {}
|
||||||
|
|||||||
@@ -764,6 +764,47 @@ namespace Newtonsoft.Json.Tests.Serialization
|
|||||||
Assert.AreEqual("Name!", c2.Name);
|
Assert.AreEqual("Name!", c2.Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !(NET20 || NET35)
|
||||||
|
[Test]
|
||||||
|
public void SerializeValueTuple()
|
||||||
|
{
|
||||||
|
ValueTuple<int, int, string> t = ValueTuple.Create(1, 2, "string");
|
||||||
|
|
||||||
|
string json = JsonConvert.SerializeObject(t, Formatting.Indented);
|
||||||
|
|
||||||
|
StringAssert.AreEqual(@"{
|
||||||
|
""Item1"": 1,
|
||||||
|
""Item2"": 2,
|
||||||
|
""Item3"": ""string""
|
||||||
|
}", json);
|
||||||
|
|
||||||
|
ValueTuple<int, int, string> t2 = JsonConvert.DeserializeObject<ValueTuple<int, int, string>>(json);
|
||||||
|
|
||||||
|
Assert.AreEqual(1, t2.Item1);
|
||||||
|
Assert.AreEqual(2, t2.Item2);
|
||||||
|
Assert.AreEqual("string", t2.Item3);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void DeserializeStructWithConstructorAttribute()
|
||||||
|
{
|
||||||
|
ImmutableStructWithConstructorAttribute result = JsonConvert.DeserializeObject<ImmutableStructWithConstructorAttribute>("{ \"Value\": \"working\" }");
|
||||||
|
|
||||||
|
Assert.AreEqual("working", result.Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public struct ImmutableStructWithConstructorAttribute
|
||||||
|
{
|
||||||
|
[JsonConstructor]
|
||||||
|
public ImmutableStructWithConstructorAttribute(string value)
|
||||||
|
{
|
||||||
|
Value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Value { get; }
|
||||||
|
}
|
||||||
|
|
||||||
#if !(DNXCORE50 || NET20)
|
#if !(DNXCORE50 || NET20)
|
||||||
[MetadataType(typeof(CustomerValidation))]
|
[MetadataType(typeof(CustomerValidation))]
|
||||||
public partial class CustomerWithMetadataType
|
public partial class CustomerWithMetadataType
|
||||||
@@ -780,9 +821,10 @@ namespace Newtonsoft.Json.Tests.Serialization
|
|||||||
[Test]
|
[Test]
|
||||||
public void SerializeMetadataType()
|
public void SerializeMetadataType()
|
||||||
{
|
{
|
||||||
CustomerWithMetadataType c = new CustomerWithMetadataType();
|
CustomerWithMetadataType c = new CustomerWithMetadataType()
|
||||||
c.UpdatedBy_Id = Guid.NewGuid();
|
{
|
||||||
|
UpdatedBy_Id = Guid.NewGuid()
|
||||||
|
};
|
||||||
string json = JsonConvert.SerializeObject(c);
|
string json = JsonConvert.SerializeObject(c);
|
||||||
|
|
||||||
Assert.AreEqual("{}", json);
|
Assert.AreEqual("{}", json);
|
||||||
@@ -841,9 +883,14 @@ namespace Newtonsoft.Json.Tests.Serialization
|
|||||||
[Test]
|
[Test]
|
||||||
public void SerializeMetadataType2()
|
public void SerializeMetadataType2()
|
||||||
{
|
{
|
||||||
FaqItem c = new FaqItem();
|
FaqItem c = new FaqItem()
|
||||||
c.FaqId = 1;
|
{
|
||||||
c.Sections.Add(new FaqSection());
|
FaqId = 1,
|
||||||
|
Sections =
|
||||||
|
{
|
||||||
|
new FaqSection()
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
string json = JsonConvert.SerializeObject(c, Formatting.Indented);
|
string json = JsonConvert.SerializeObject(c, Formatting.Indented);
|
||||||
|
|
||||||
@@ -4734,11 +4781,12 @@ Path '', line 1, position 1.");
|
|||||||
[Test]
|
[Test]
|
||||||
public void DataContractJsonSerializerTest()
|
public void DataContractJsonSerializerTest()
|
||||||
{
|
{
|
||||||
DataContractJsonSerializerTestClass c = new DataContractJsonSerializerTestClass();
|
DataContractJsonSerializerTestClass c = new DataContractJsonSerializerTestClass()
|
||||||
c.TimeSpanProperty = new TimeSpan(200, 20, 59, 30, 900);
|
{
|
||||||
c.GuidProperty = new Guid("66143115-BE2A-4a59-AF0A-348E1EA15B1E");
|
TimeSpanProperty = new TimeSpan(200, 20, 59, 30, 900),
|
||||||
c.AnimalProperty = new Human() { Ethnicity = "European" };
|
GuidProperty = new Guid("66143115-BE2A-4a59-AF0A-348E1EA15B1E"),
|
||||||
|
AnimalProperty = new Human() { Ethnicity = "European" }
|
||||||
|
};
|
||||||
MemoryStream ms = new MemoryStream();
|
MemoryStream ms = new MemoryStream();
|
||||||
DataContractJsonSerializer serializer = new DataContractJsonSerializer(
|
DataContractJsonSerializer serializer = new DataContractJsonSerializer(
|
||||||
typeof(DataContractJsonSerializerTestClass),
|
typeof(DataContractJsonSerializerTestClass),
|
||||||
@@ -5833,9 +5881,10 @@ Path '', line 1, position 1.");
|
|||||||
|
|
||||||
Assert.AreEqual("{\"Offset\":\"2000-01-01T00:00:00+06:00\"}", serializeObject);
|
Assert.AreEqual("{\"Offset\":\"2000-01-01T00:00:00+06:00\"}", serializeObject);
|
||||||
|
|
||||||
JsonTextReader reader = new JsonTextReader(new StringReader(serializeObject));
|
JsonTextReader reader = new JsonTextReader(new StringReader(serializeObject))
|
||||||
reader.DateParseHandling = DateParseHandling.None;
|
{
|
||||||
|
DateParseHandling = DateParseHandling.None
|
||||||
|
};
|
||||||
JsonSerializer serializer = new JsonSerializer();
|
JsonSerializer serializer = new JsonSerializer();
|
||||||
|
|
||||||
var deserializeObject = serializer.Deserialize<TimeZoneOffsetObject>(reader);
|
var deserializeObject = serializer.Deserialize<TimeZoneOffsetObject>(reader);
|
||||||
@@ -6124,13 +6173,16 @@ Path '', line 1, position 1.");
|
|||||||
[Test]
|
[Test]
|
||||||
public void DeserializeNullableStruct()
|
public void DeserializeNullableStruct()
|
||||||
{
|
{
|
||||||
NullableStructPropertyClass nullableStructPropertyClass = new NullableStructPropertyClass();
|
NullableStructPropertyClass nullableStructPropertyClass = new NullableStructPropertyClass()
|
||||||
nullableStructPropertyClass.Foo1 = new StructISerializable() { Name = "foo 1" };
|
{
|
||||||
nullableStructPropertyClass.Foo2 = new StructISerializable() { Name = "foo 2" };
|
Foo1 = new StructISerializable() { Name = "foo 1" },
|
||||||
|
Foo2 = new StructISerializable() { Name = "foo 2" }
|
||||||
NullableStructPropertyClass barWithNull = new NullableStructPropertyClass();
|
};
|
||||||
barWithNull.Foo1 = new StructISerializable() { Name = "foo 1" };
|
NullableStructPropertyClass barWithNull = new NullableStructPropertyClass()
|
||||||
barWithNull.Foo2 = null;
|
{
|
||||||
|
Foo1 = new StructISerializable() { Name = "foo 1" },
|
||||||
|
Foo2 = null
|
||||||
|
};
|
||||||
|
|
||||||
//throws error on deserialization because bar1.Foo2 is of type Foo?
|
//throws error on deserialization because bar1.Foo2 is of type Foo?
|
||||||
string s = JsonConvert.SerializeObject(nullableStructPropertyClass);
|
string s = JsonConvert.SerializeObject(nullableStructPropertyClass);
|
||||||
@@ -7603,11 +7655,13 @@ Path '', line 1, position 1.");
|
|||||||
[Test]
|
[Test]
|
||||||
public void MetroBlogPost()
|
public void MetroBlogPost()
|
||||||
{
|
{
|
||||||
Product product = new Product();
|
Product product = new Product()
|
||||||
product.Name = "Apple";
|
{
|
||||||
product.ExpiryDate = new DateTime(2012, 4, 1);
|
Name = "Apple",
|
||||||
product.Price = 3.99M;
|
ExpiryDate = new DateTime(2012, 4, 1),
|
||||||
product.Sizes = new[] { "Small", "Medium", "Large" };
|
Price = 3.99M,
|
||||||
|
Sizes = new[] { "Small", "Medium", "Large" }
|
||||||
|
};
|
||||||
|
|
||||||
string json = JsonConvert.SerializeObject(product);
|
string json = JsonConvert.SerializeObject(product);
|
||||||
//{
|
//{
|
||||||
|
|||||||
@@ -61,6 +61,37 @@ namespace Newtonsoft.Json.Tests.Serialization
|
|||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class TypeNameHandlingTests : TestFixtureBase
|
public class TypeNameHandlingTests : TestFixtureBase
|
||||||
{
|
{
|
||||||
|
#if !(NET20 || NET35)
|
||||||
|
[Test]
|
||||||
|
public void SerializeValueTupleWithTypeName()
|
||||||
|
{
|
||||||
|
string tupleRef = ReflectionUtils.GetTypeName(typeof(ValueTuple<int, int, string>), TypeNameAssemblyFormatHandling.Simple, null);
|
||||||
|
|
||||||
|
ValueTuple<int, int, string> t = ValueTuple.Create(1, 2, "string");
|
||||||
|
|
||||||
|
string json = JsonConvert.SerializeObject(t, Formatting.Indented, new JsonSerializerSettings
|
||||||
|
{
|
||||||
|
TypeNameHandling = TypeNameHandling.All
|
||||||
|
});
|
||||||
|
|
||||||
|
StringAssert.AreEqual(@"{
|
||||||
|
""$type"": """ + tupleRef + @""",
|
||||||
|
""Item1"": 1,
|
||||||
|
""Item2"": 2,
|
||||||
|
""Item3"": ""string""
|
||||||
|
}", json);
|
||||||
|
|
||||||
|
ValueTuple<int, int, string> t2 = (ValueTuple<int, int, string>)JsonConvert.DeserializeObject(json, new JsonSerializerSettings
|
||||||
|
{
|
||||||
|
TypeNameHandling = TypeNameHandling.All
|
||||||
|
});
|
||||||
|
|
||||||
|
Assert.AreEqual(1, t2.Item1);
|
||||||
|
Assert.AreEqual(2, t2.Item2);
|
||||||
|
Assert.AreEqual("string", t2.Item3);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#if !(NET20 || NET35 || NET40)
|
#if !(NET20 || NET35 || NET40)
|
||||||
public class KnownAutoTypes
|
public class KnownAutoTypes
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ namespace System.Runtime.Serialization.Formatters
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Indicates the method that will be used during deserialization for locating and loading assemblies.
|
/// Indicates the method that will be used during deserialization for locating and loading assemblies.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[Obsolete("FormatterAssemblyStyle is obsolete. Use TypeNameAssemblyFormatHandling instead.")]
|
||||||
public enum FormatterAssemblyStyle
|
public enum FormatterAssemblyStyle
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user