From 1816f555ea4cc2fd40a5ef9fb8da45ef6c5142a1 Mon Sep 17 00:00:00 2001 From: James Newton-King Date: Tue, 11 Nov 2014 12:06:30 +1300 Subject: [PATCH] -Fixed tests -Fixed exception message line breaks to use Environment.NewLine --- Src/Newtonsoft.Json.Tests/Linq/LinqToJsonTest.cs | 2 +- .../Serialization/JsonSerializerCollectionsTests.cs | 2 +- .../Serialization/JsonSerializerInternalWriter.cs | 7 +++++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Src/Newtonsoft.Json.Tests/Linq/LinqToJsonTest.cs b/Src/Newtonsoft.Json.Tests/Linq/LinqToJsonTest.cs index 4fd55e35..c35652d3 100644 --- a/Src/Newtonsoft.Json.Tests/Linq/LinqToJsonTest.cs +++ b/Src/Newtonsoft.Json.Tests/Linq/LinqToJsonTest.cs @@ -1186,7 +1186,7 @@ keyword such as type of business."" var json = SerializeWithNoRedundentIdProperties(dic1); - Assert.AreEqual(@"{ + StringAssert.AreEqual(@"{ ""$id"": ""1"", ""list1"": [ ""A string!"", diff --git a/Src/Newtonsoft.Json.Tests/Serialization/JsonSerializerCollectionsTests.cs b/Src/Newtonsoft.Json.Tests/Serialization/JsonSerializerCollectionsTests.cs index 3c7646ce..ba4224ef 100644 --- a/Src/Newtonsoft.Json.Tests/Serialization/JsonSerializerCollectionsTests.cs +++ b/Src/Newtonsoft.Json.Tests/Serialization/JsonSerializerCollectionsTests.cs @@ -69,7 +69,7 @@ namespace Newtonsoft.Json.Tests.Serialization string myOtherArrayAsString = JsonConvert.SerializeObject(myOtherArray, Formatting.Indented); - Assert.AreEqual(@"[ + StringAssert.AreEqual(@"[ [ { ""Key"": ""my value"", diff --git a/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalWriter.cs b/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalWriter.cs index 84c5358f..97e8dac3 100644 --- a/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalWriter.cs +++ b/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalWriter.cs @@ -733,8 +733,11 @@ namespace Newtonsoft.Json.Serialization { if (!JsonTypeReflector.FullyTrusted) { - throw JsonSerializationException.Create(null, writer.ContainerPath, @"Type '{0}' implements ISerializable but cannot be serialized using the ISerializable interface because the current application is not fully trusted and ISerializable can expose secure data. -To fix this error either change the environment to be fully trusted, change the application to not deserialize the type, add JsonObjectAttribute to the type or change the JsonSerializer setting ContractResolver to use a new DefaultContractResolver with IgnoreSerializableInterface set to true.".FormatWith(CultureInfo.InvariantCulture, value.GetType()), null); + string message = @"Type '{0}' implements ISerializable but cannot be serialized using the ISerializable interface because the current application is not fully trusted and ISerializable can expose secure data." + Environment.NewLine + + @"To fix this error either change the environment to be fully trusted, change the application to not deserialize the type, add JsonObjectAttribute to the type or change the JsonSerializer setting ContractResolver to use a new DefaultContractResolver with IgnoreSerializableInterface set to true." + Environment.NewLine; + message = message.FormatWith(CultureInfo.InvariantCulture, value.GetType()); + + throw JsonSerializationException.Create(null, writer.ContainerPath, message, null); } OnSerializing(writer, contract, value);