diff --git a/Src/Newtonsoft.Json.Tests/Converters/XmlNodeConverterTest.cs b/Src/Newtonsoft.Json.Tests/Converters/XmlNodeConverterTest.cs index a20e392d..b1a04668 100644 --- a/Src/Newtonsoft.Json.Tests/Converters/XmlNodeConverterTest.cs +++ b/Src/Newtonsoft.Json.Tests/Converters/XmlNodeConverterTest.cs @@ -427,7 +427,7 @@ namespace Newtonsoft.Json.Tests.Converters { JsonConvert.DeserializeXmlNode(json); }, - "JSON root object has multiple properties. The root object must have a single property in order to create a valid XML document. Consider specifing a DeserializeRootElementName."); + "JSON root object has multiple properties. The root object must have a single property in order to create a valid XML document. Consider specifing a DeserializeRootElementName. Path 'Email', line 3, position 14."); } [Test] @@ -944,7 +944,9 @@ namespace Newtonsoft.Json.Tests.Converters [Test] public void RootObjectMultipleProperties() { - ExceptionAssert.Throws(() => { XmlDocument newDoc = (XmlDocument)JsonConvert.DeserializeXmlNode(@"{Prop1:1,Prop2:2}"); }, "JSON root object has multiple properties. The root object must have a single property in order to create a valid XML document. Consider specifing a DeserializeRootElementName."); + ExceptionAssert.Throws( + () => { XmlDocument newDoc = (XmlDocument)JsonConvert.DeserializeXmlNode(@"{Prop1:1,Prop2:2}"); }, + "JSON root object has multiple properties. The root object must have a single property in order to create a valid XML document. Consider specifing a DeserializeRootElementName. Path 'Prop2', line 1, position 15."); } [Test] @@ -1060,7 +1062,9 @@ namespace Newtonsoft.Json.Tests.Converters { string json = @"{""count"": 773840,""photos"": null}"; - ExceptionAssert.Throws(() => { JsonConvert.DeserializeXmlNode(json); }, "JSON root object has multiple properties. The root object must have a single property in order to create a valid XML document. Consider specifing a DeserializeRootElementName."); + ExceptionAssert.Throws( + () => { JsonConvert.DeserializeXmlNode(json); }, + "JSON root object has multiple properties. The root object must have a single property in order to create a valid XML document. Consider specifing a DeserializeRootElementName. Path 'photos', line 1, position 26."); } #if !NET20 @@ -1069,7 +1073,9 @@ namespace Newtonsoft.Json.Tests.Converters { string json = @"{""count"": 773840,""photos"": null}"; - ExceptionAssert.Throws(() => { JsonConvert.DeserializeXNode(json); }, "JSON root object has multiple properties. The root object must have a single property in order to create a valid XML document. Consider specifing a DeserializeRootElementName."); + ExceptionAssert.Throws( + () => { JsonConvert.DeserializeXNode(json); }, + "JSON root object has multiple properties. The root object must have a single property in order to create a valid XML document. Consider specifing a DeserializeRootElementName. Path 'photos', line 1, position 26."); } #endif @@ -1436,6 +1442,162 @@ namespace Newtonsoft.Json.Tests.Converters StringAssert.AreEqual(expectedXmlJson, xmlJson); } + [Test] + public void SerializeDeserializeMetadataArray() + { + string json = @"{ + ""$id"": ""1"", + ""$values"": [ + ""1"", + ""2"", + ""3"", + ""4"", + ""5"" + ] +}"; + + XmlNode node = JsonConvert.DeserializeXmlNode(json, "root"); + string xml = GetIndentedInnerXml(node); + + StringAssert.AreEqual(@" + + 1 + 2 + 3 + 4 + 5 +", xml); + + string newJson = JsonConvert.SerializeXmlNode(node, Formatting.Indented, true); + + StringAssert.AreEqual(json, newJson); + } + + [Test] + public void SerializeDeserializeMetadataArrayNoId() + { + string json = @"{ + ""$values"": [ + ""1"", + ""2"", + ""3"", + ""4"", + ""5"" + ] +}"; + + XmlNode node = JsonConvert.DeserializeXmlNode(json, "root"); + string xml = GetIndentedInnerXml(node); + + StringAssert.AreEqual(@" + + 1 + 2 + 3 + 4 + 5 +", xml); + + string newJson = JsonConvert.SerializeXmlNode(node, Formatting.Indented, true); + + Console.WriteLine(newJson); + + StringAssert.AreEqual(json, newJson); + } + + [Test] + public void SerializeDeserializeMetadataArrayWithIdLast() + { + string json = @"{ + ""$values"": [ + ""1"", + ""2"", + ""3"", + ""4"", + ""5"" + ], + ""$id"": ""1"" +}"; + + XmlNode node = JsonConvert.DeserializeXmlNode(json, "root"); + string xml = GetIndentedInnerXml(node); + + StringAssert.AreEqual(@" + + 1 + 2 + 3 + 4 + 5 +", xml); + + string newJson = JsonConvert.SerializeXmlNode(node, Formatting.Indented, true); + + StringAssert.AreEqual(@"{ + ""$id"": ""1"", + ""$values"": [ + ""1"", + ""2"", + ""3"", + ""4"", + ""5"" + ] +}", newJson); + } + + [Test] + public void SerializeMetadataPropertyWithBadValue() + { + string json = @"{ + ""$id"": [] +}"; + + ExceptionAssert.Throws( + () => { JsonConvert.DeserializeXmlNode(json, "root"); }, + "Unexpected JsonToken: StartArray. Path '$id', line 2, position 11."); + } + + [Test] + public void SerializeDeserializeMetadataWithNullValue() + { + string json = @"{ + ""$id"": null +}"; + + XmlNode node = JsonConvert.DeserializeXmlNode(json, "root"); + string xml = GetIndentedInnerXml(node); + + StringAssert.AreEqual(@" +", xml); + + string newJson = JsonConvert.SerializeXmlNode(node, Formatting.Indented, true); + + StringAssert.AreEqual(@"{ + ""$id"": """" +}", newJson); + } + + [Test] + public void SerializeDeserializeMetadataArrayNull() + { + string json = @"{ + ""$id"": ""1"", + ""$values"": null +}"; + + XmlNode node = JsonConvert.DeserializeXmlNode(json, "root"); + string xml = GetIndentedInnerXml(node); + + StringAssert.AreEqual(@" + + +", xml); + + string newJson = JsonConvert.SerializeXmlNode(node, Formatting.Indented, true); + + StringAssert.AreEqual(json, newJson); + } + [Test] public void EmptyPropertyName() { @@ -1518,7 +1680,9 @@ namespace Newtonsoft.Json.Tests.Converters } }"; - ExceptionAssert.Throws(() => { DeserializeXmlNode(json); }, "XmlNodeConverter cannot convert JSON with an empty property name to XML."); + ExceptionAssert.Throws( + () => { DeserializeXmlNode(json); }, + "XmlNodeConverter cannot convert JSON with an empty property name to XML. Path '8452309520V2.', line 3, position 10."); } [Test] diff --git a/Src/Newtonsoft.Json.Tests/JsonConvertTest.cs b/Src/Newtonsoft.Json.Tests/JsonConvertTest.cs index d811cc99..eb2576f3 100644 --- a/Src/Newtonsoft.Json.Tests/JsonConvertTest.cs +++ b/Src/Newtonsoft.Json.Tests/JsonConvertTest.cs @@ -60,6 +60,64 @@ namespace Newtonsoft.Json.Tests [TestFixture] public class JsonConvertTest : TestFixtureBase { + public class PopulateTestObject + { + public decimal Prop { get; set; } + } + + [Test] + public void PopulateObjectWithHeaderComment() + { + string json = @"// file header +{ + ""prop"": 1.0 +}"; + + PopulateTestObject o = new PopulateTestObject(); + JsonConvert.PopulateObject(json, o); + + Assert.AreEqual(1m, o.Prop); + } + + [Test] + public void PopulateObjectWithMultipleHeaderComment() + { + string json = @"// file header +// another file header? +{ + ""prop"": 1.0 +}"; + + PopulateTestObject o = new PopulateTestObject(); + JsonConvert.PopulateObject(json, o); + + Assert.AreEqual(1m, o.Prop); + } + + [Test] + public void PopulateObjectWithNoContent() + { + ExceptionAssert.Throws(() => + { + string json = @""; + + PopulateTestObject o = new PopulateTestObject(); + JsonConvert.PopulateObject(json, o); + }, "No JSON content found. Path '', line 0, position 0."); + } + + [Test] + public void PopulateObjectWithOnlyComment() + { + ExceptionAssert.Throws(() => + { + string json = @"// file header"; + + PopulateTestObject o = new PopulateTestObject(); + JsonConvert.PopulateObject(json, o); + }, "No JSON content found. Path '', line 1, position 14."); + } + [Test] public void DefaultSettings() { diff --git a/Src/Newtonsoft.Json/Converters/XmlNodeConverter.cs b/Src/Newtonsoft.Json/Converters/XmlNodeConverter.cs index 1b719748..775e88ca 100644 --- a/Src/Newtonsoft.Json/Converters/XmlNodeConverter.cs +++ b/Src/Newtonsoft.Json/Converters/XmlNodeConverter.cs @@ -32,6 +32,7 @@ using System.Collections.Generic; using System.Globalization; using System.Xml; using System.Reflection; +using Newtonsoft.Json.Serialization; #if !(NET20 || PORTABLE40) using System.Xml.Linq; #endif @@ -995,7 +996,10 @@ namespace Newtonsoft.Json.Converters case XmlNodeType.Comment: return CommentName; case XmlNodeType.Element: - return ResolveFullName(node, manager); + if (node.NamespaceUri == JsonNamespaceUri) + return "$" + node.LocalName; + else + return ResolveFullName(node, manager); case XmlNodeType.ProcessingInstruction: return "?" + ResolveFullName(node, manager); case XmlNodeType.DocumentType: @@ -1349,7 +1353,7 @@ namespace Newtonsoft.Json.Converters private void ReadElement(JsonReader reader, IXmlDocument document, IXmlNode currentNode, string propertyName, XmlNamespaceManager manager) { if (string.IsNullOrEmpty(propertyName)) - throw new JsonSerializationException("XmlNodeConverter cannot convert JSON with an empty property name to XML."); + throw JsonSerializationException.Create(reader, "XmlNodeConverter cannot convert JSON with an empty property name to XML."); Dictionary attributeNameValues = ReadAttributeElements(reader, manager); @@ -1358,59 +1362,84 @@ namespace Newtonsoft.Json.Converters if (propertyName.StartsWith('@')) { string attributeName = propertyName.Substring(1); - string attributeValue = reader.Value.ToString(); - string attributePrefix = MiscellaneousUtils.GetPrefix(attributeName); - IXmlNode attribute = (!string.IsNullOrEmpty(attributePrefix)) - ? document.CreateAttribute(attributeName, manager.LookupNamespace(attributePrefix), attributeValue) - : document.CreateAttribute(attributeName, attributeValue); - - ((IXmlElement)currentNode).SetAttributeNode(attribute); + AddAttribute(reader, document, currentNode, attributeName, manager, attributePrefix); } - else + else if (propertyName.StartsWith('$')) { - IXmlElement element = CreateElement(propertyName, document, elementPrefix, manager); - - currentNode.AppendChild(element); - - // add attributes to newly created element - foreach (KeyValuePair nameValue in attributeNameValues) + if (propertyName == JsonTypeReflector.ArrayValuesPropertyName) { - string attributePrefix = MiscellaneousUtils.GetPrefix(nameValue.Key); - - IXmlNode attribute = (!string.IsNullOrEmpty(attributePrefix)) - ? document.CreateAttribute(nameValue.Key, manager.LookupNamespace(attributePrefix) ?? string.Empty, nameValue.Value) - : document.CreateAttribute(nameValue.Key, nameValue.Value); - - element.SetAttributeNode(attribute); - } - - if (reader.TokenType == JsonToken.String - || reader.TokenType == JsonToken.Integer - || reader.TokenType == JsonToken.Float - || reader.TokenType == JsonToken.Boolean - || reader.TokenType == JsonToken.Date) - { - element.AppendChild(document.CreateTextNode(ConvertTokenToXmlValue(reader))); - } - else if (reader.TokenType == JsonToken.Null) - { - // empty element. do nothing + propertyName = propertyName.Substring(1); + elementPrefix = manager.LookupPrefix(JsonNamespaceUri); + CreateElement(reader, document, currentNode, propertyName, manager, elementPrefix, attributeNameValues); } else { - // finished element will have no children to deserialize - if (reader.TokenType != JsonToken.EndObject) - { - manager.PushScope(); - DeserializeNode(reader, document, manager, element); - manager.PopScope(); - } - - manager.RemoveNamespace(string.Empty, manager.DefaultNamespace); + string attributeName = propertyName.Substring(1); + string attributePrefix = manager.LookupPrefix(JsonNamespaceUri); + AddAttribute(reader, document, currentNode, attributeName, manager, attributePrefix); } } + else + { + CreateElement(reader, document, currentNode, propertyName, manager, elementPrefix, attributeNameValues); + } + } + + private void CreateElement(JsonReader reader, IXmlDocument document, IXmlNode currentNode, string elementName, XmlNamespaceManager manager, string elementPrefix, Dictionary attributeNameValues) + { + IXmlElement element = CreateElement(elementName, document, elementPrefix, manager); + + currentNode.AppendChild(element); + + // add attributes to newly created element + foreach (KeyValuePair nameValue in attributeNameValues) + { + string attributePrefix = MiscellaneousUtils.GetPrefix(nameValue.Key); + + IXmlNode attribute = (!string.IsNullOrEmpty(attributePrefix)) + ? document.CreateAttribute(nameValue.Key, manager.LookupNamespace(attributePrefix) ?? string.Empty, nameValue.Value) + : document.CreateAttribute(nameValue.Key, nameValue.Value); + + element.SetAttributeNode(attribute); + } + + if (reader.TokenType == JsonToken.String + || reader.TokenType == JsonToken.Integer + || reader.TokenType == JsonToken.Float + || reader.TokenType == JsonToken.Boolean + || reader.TokenType == JsonToken.Date) + { + element.AppendChild(document.CreateTextNode(ConvertTokenToXmlValue(reader))); + } + else if (reader.TokenType == JsonToken.Null) + { + // empty element. do nothing + } + else + { + // finished element will have no children to deserialize + if (reader.TokenType != JsonToken.EndObject) + { + manager.PushScope(); + DeserializeNode(reader, document, manager, element); + manager.PopScope(); + } + + manager.RemoveNamespace(string.Empty, manager.DefaultNamespace); + } + } + + private static void AddAttribute(JsonReader reader, IXmlDocument document, IXmlNode currentNode, string attributeName, XmlNamespaceManager manager, string attributePrefix) + { + string attributeValue = reader.Value.ToString(); + + IXmlNode attribute = (!string.IsNullOrEmpty(attributePrefix)) + ? document.CreateAttribute(attributeName, manager.LookupNamespace(attributePrefix), attributeValue) + : document.CreateAttribute(attributeName, attributeValue); + + ((IXmlElement) currentNode).SetAttributeNode(attribute); } private string ConvertTokenToXmlValue(JsonReader reader) @@ -1551,10 +1580,6 @@ namespace Newtonsoft.Json.Converters } break; case '$': - attributeName = attributeName.Substring(1); - reader.Read(); - attributeValue = reader.Value.ToString(); - // check that JsonNamespaceUri is in scope // if it isn't then add it to document and namespace manager string jsonPrefix = manager.LookupPrefix(JsonNamespaceUri); @@ -1572,6 +1597,22 @@ namespace Newtonsoft.Json.Converters manager.AddNamespace(jsonPrefix, JsonNamespaceUri); } + // special case $values, it will have a non-primitive value + if (attributeName == JsonTypeReflector.ArrayValuesPropertyName) + { + finishedAttributes = true; + break; + } + + attributeName = attributeName.Substring(1); + reader.Read(); + + if (!JsonTokenUtils.IsPrimitiveToken(reader.TokenType)) + { + throw JsonSerializationException.Create(reader, "Unexpected JsonToken: " + reader.TokenType); + } + + attributeValue = (reader.Value != null) ? reader.Value.ToString() : null; attributeNameValues.Add(jsonPrefix + ":" + attributeName, attributeValue); break; default: @@ -1581,7 +1622,6 @@ namespace Newtonsoft.Json.Converters } else { - finishedAttributes = true; } @@ -1593,7 +1633,7 @@ namespace Newtonsoft.Json.Converters finishedElement = true; break; default: - throw new JsonSerializationException("Unexpected JsonToken: " + reader.TokenType); + throw JsonSerializationException.Create(reader, "Unexpected JsonToken: " + reader.TokenType); } } } @@ -1625,7 +1665,7 @@ namespace Newtonsoft.Json.Converters standalone = reader.Value.ToString(); break; default: - throw new JsonSerializationException("Unexpected property name encountered while deserializing XmlDeclaration: " + reader.Value); + throw JsonSerializationException.Create(reader, "Unexpected property name encountered while deserializing XmlDeclaration: " + reader.Value); } } @@ -1666,7 +1706,7 @@ namespace Newtonsoft.Json.Converters internalSubset = reader.Value.ToString(); break; default: - throw new JsonSerializationException("Unexpected property name encountered while deserializing XmlDeclaration: " + reader.Value); + throw JsonSerializationException.Create(reader, "Unexpected property name encountered while deserializing XmlDeclaration: " + reader.Value); } } @@ -1691,7 +1731,7 @@ namespace Newtonsoft.Json.Converters { case JsonToken.PropertyName: if (currentNode.NodeType == XmlNodeType.Document && document.DocumentElement != null) - throw new JsonSerializationException("JSON root object has multiple properties. The root object must have a single property in order to create a valid XML document. Consider specifing a DeserializeRootElementName."); + throw JsonSerializationException.Create(reader, "JSON root object has multiple properties. The root object must have a single property in order to create a valid XML document. Consider specifing a DeserializeRootElementName."); string propertyName = reader.Value.ToString(); reader.Read(); @@ -1725,13 +1765,13 @@ namespace Newtonsoft.Json.Converters } break; case JsonToken.Comment: - currentNode.AppendChild(document.CreateComment((string)reader.Value)); + currentNode.AppendChild(document.CreateComment((string) reader.Value)); break; case JsonToken.EndObject: case JsonToken.EndArray: return; default: - throw new JsonSerializationException("Unexpected JsonToken when deserializing node: " + reader.TokenType); + throw JsonSerializationException.Create(reader, "Unexpected JsonToken when deserializing node: " + reader.TokenType); } } while (reader.TokenType == JsonToken.PropertyName || reader.Read()); // don't read if current token is a property. token was already read when parsing element attributes @@ -1766,6 +1806,7 @@ namespace Newtonsoft.Json.Converters { return c.Where(a => a.NamespaceUri != JsonNamespaceUri); } + #endregion /// @@ -1778,11 +1819,11 @@ namespace Newtonsoft.Json.Converters public override bool CanConvert(Type valueType) { #if !NET20 - if (typeof(XObject).IsAssignableFrom(valueType)) + if (typeof (XObject).IsAssignableFrom(valueType)) return true; #endif #if !(DOTNET || PORTABLE) - if (typeof(XmlNode).IsAssignableFrom(valueType)) + if (typeof (XmlNode).IsAssignableFrom(valueType)) return true; #endif diff --git a/Src/Newtonsoft.Json/Newtonsoft.Json.Portable40.csproj b/Src/Newtonsoft.Json/Newtonsoft.Json.Portable40.csproj index a77ce560..2bb9aa2e 100644 --- a/Src/Newtonsoft.Json/Newtonsoft.Json.Portable40.csproj +++ b/Src/Newtonsoft.Json/Newtonsoft.Json.Portable40.csproj @@ -224,6 +224,7 @@ + diff --git a/Src/Newtonsoft.Json/Serialization/DefaultContractResolver.cs b/Src/Newtonsoft.Json/Serialization/DefaultContractResolver.cs index 7df6086d..466e22ca 100644 --- a/Src/Newtonsoft.Json/Serialization/DefaultContractResolver.cs +++ b/Src/Newtonsoft.Json/Serialization/DefaultContractResolver.cs @@ -694,7 +694,7 @@ namespace Newtonsoft.Json.Serialization return JsonTypeReflector.ReflectionDelegateFactory.CreateDefaultConstructor(createdType); } -#if !NET20 +#if NET35 [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Portability", "CA1903:UseOnlyApiFromTargetedFramework", MessageId = "System.Runtime.Serialization.DataContractAttribute.#get_IsReference()")] #endif private void InitializeContract(JsonContract contract) diff --git a/Src/Newtonsoft.Json/Serialization/JsonArrayContract.cs b/Src/Newtonsoft.Json/Serialization/JsonArrayContract.cs index d2df403c..736abdc3 100644 --- a/Src/Newtonsoft.Json/Serialization/JsonArrayContract.cs +++ b/Src/Newtonsoft.Json/Serialization/JsonArrayContract.cs @@ -212,7 +212,7 @@ namespace Newtonsoft.Json.Serialization } #endif -#if !(NET20 || NET35 || NET40 || PORTABLE40) +#if !(NET20 || NET35 || NET40) Type immutableCreatedType; ObjectConstructor immutableParameterizedCreator; if (ImmutableCollectionsUtils.TryBuildImmutableForArrayContract(underlyingType, CollectionItemType, out immutableCreatedType, out immutableParameterizedCreator)) diff --git a/Src/Newtonsoft.Json/Serialization/JsonDictionaryContract.cs b/Src/Newtonsoft.Json/Serialization/JsonDictionaryContract.cs index 7e016130..b79d48bf 100644 --- a/Src/Newtonsoft.Json/Serialization/JsonDictionaryContract.cs +++ b/Src/Newtonsoft.Json/Serialization/JsonDictionaryContract.cs @@ -176,7 +176,7 @@ namespace Newtonsoft.Json.Serialization } #endif -#if !(NET20 || NET35 || NET40 || PORTABLE40) +#if !(NET20 || NET35 || NET40) Type immutableCreatedType; ObjectConstructor immutableParameterizedCreator; if (ImmutableCollectionsUtils.TryBuildImmutableForDictionaryContract(underlyingType, DictionaryKeyType, DictionaryValueType, out immutableCreatedType, out immutableParameterizedCreator)) diff --git a/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalReader.cs b/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalReader.cs index 76578a47..eef3bfcf 100644 --- a/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalReader.cs +++ b/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalReader.cs @@ -70,8 +70,13 @@ namespace Newtonsoft.Json.Serialization JsonContract contract = Serializer._contractResolver.ResolveContract(objectType); - if (reader.TokenType == JsonToken.None) - reader.Read(); + while (reader.TokenType == JsonToken.None || reader.TokenType == JsonToken.Comment) + { + if (!reader.Read()) + { + throw JsonSerializationException.Create(reader, "No JSON content found."); + } + } if (reader.TokenType == JsonToken.StartArray) { diff --git a/Src/Newtonsoft.Json/Utilities/FSharpUtils.cs b/Src/Newtonsoft.Json/Utilities/FSharpUtils.cs index acd938bf..72cf2e83 100644 --- a/Src/Newtonsoft.Json/Utilities/FSharpUtils.cs +++ b/Src/Newtonsoft.Json/Utilities/FSharpUtils.cs @@ -88,10 +88,10 @@ namespace Newtonsoft.Json.Utilities Type fsharpType = fsharpCoreAssembly.GetType("Microsoft.FSharp.Reflection.FSharpType"); - MethodInfo isUnionMethodInfo = fsharpType.GetMethod("IsUnion", BindingFlags.Public | BindingFlags.Static); + MethodInfo isUnionMethodInfo = fsharpType.GetMethod("IsUnion", BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic); IsUnion = JsonTypeReflector.ReflectionDelegateFactory.CreateMethodCall(isUnionMethodInfo); - MethodInfo getUnionCasesMethodInfo = fsharpType.GetMethod("GetUnionCases", BindingFlags.Public | BindingFlags.Static); + MethodInfo getUnionCasesMethodInfo = fsharpType.GetMethod("GetUnionCases", BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic); GetUnionCases = JsonTypeReflector.ReflectionDelegateFactory.CreateMethodCall(getUnionCasesMethodInfo); Type fsharpValue = fsharpCoreAssembly.GetType("Microsoft.FSharp.Reflection.FSharpValue"); @@ -123,7 +123,7 @@ namespace Newtonsoft.Json.Utilities private static MethodCall CreateFSharpFuncCall(Type type, string methodName) { - MethodInfo innerMethodInfo = type.GetMethod(methodName, BindingFlags.Public | BindingFlags.Static); + MethodInfo innerMethodInfo = type.GetMethod(methodName, BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic ); MethodInfo invokeFunc = innerMethodInfo.ReturnType.GetMethod("Invoke", BindingFlags.Public | BindingFlags.Instance); MethodCall call = JsonTypeReflector.ReflectionDelegateFactory.CreateMethodCall(innerMethodInfo); diff --git a/Src/Newtonsoft.Json/Utilities/ImmutableCollectionsUtils.cs b/Src/Newtonsoft.Json/Utilities/ImmutableCollectionsUtils.cs index f18d8442..2a438199 100644 --- a/Src/Newtonsoft.Json/Utilities/ImmutableCollectionsUtils.cs +++ b/Src/Newtonsoft.Json/Utilities/ImmutableCollectionsUtils.cs @@ -23,7 +23,7 @@ // OTHER DEALINGS IN THE SOFTWARE. #endregion -#if !(NET20 || NET35 || NET40 || PORTABLE40) +#if !(NET20 || NET35 || NET40) using System; using System.Collections.Generic; using System.Linq; diff --git a/Src/Newtonsoft.Json/project.json b/Src/Newtonsoft.Json/project.json index aacedc30..2b461622 100644 --- a/Src/Newtonsoft.Json/project.json +++ b/Src/Newtonsoft.Json/project.json @@ -53,7 +53,6 @@ "System.Collections": "", "System.Core": "", "System.Diagnostics.Debug": "", - "System.Diagnostics.Tools": "", "System.Dynamic.Runtime": "", "System.Globalization": "", "System.IO": "", @@ -96,7 +95,6 @@ "System.Collections.Concurrent": "4.0.10", "System.ComponentModel.TypeConverter": "4.0.0", "System.Diagnostics.Debug": "4.0.10", - "System.Diagnostics.Tools": "4.0.0", "System.Dynamic.Runtime": "4.0.10", "System.Globalization": "4.0.10", "System.IO": "4.0.10",