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);