mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-05-28 17:05:57 +00:00
updated SimpleJson to v0.34
This commit is contained in:
+67
-27
@@ -17,7 +17,7 @@
|
||||
// <website>https://github.com/facebook-csharp-sdk/simple-json</website>
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
// VERSION: 0.30.0
|
||||
// VERSION: 0.34.0
|
||||
|
||||
// NOTE: uncomment the following line to make SimpleJson class internal.
|
||||
//#define SIMPLE_JSON_INTERNAL
|
||||
@@ -31,6 +31,9 @@
|
||||
// NOTE: uncomment the following line to enable DataContract support.
|
||||
//#define SIMPLE_JSON_DATACONTRACT
|
||||
|
||||
// NOTE: uncomment the following line to enable IReadOnlyCollection<T> and IReadOnlyList<T> support.
|
||||
//#define SIMPLE_JSON_READONLY_COLLECTIONS
|
||||
|
||||
// NOTE: uncomment the following line to disable linq expressions/compiled lambda (better performance) instead of method.invoke().
|
||||
// define if you are using .net framework <= 3.0 or < WP7.5
|
||||
//#define SIMPLE_JSON_NO_LINQ_EXPRESSION
|
||||
@@ -51,7 +54,6 @@ using System;
|
||||
using System.CodeDom.Compiler;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
#if !SIMPLE_JSON_NO_LINQ_EXPRESSION
|
||||
using System.Linq.Expressions;
|
||||
#endif
|
||||
@@ -513,6 +515,22 @@ namespace Octokit
|
||||
private const int TOKEN_NULL = 11;
|
||||
private const int BUILDER_CAPACITY = 2000;
|
||||
|
||||
private static readonly char[] EscapeTable;
|
||||
private static readonly char[] EscapeCharacters = new char[] { '"', '\\', '\b', '\f', '\n', '\r', '\t' };
|
||||
private static readonly string EscapeCharactersString = new string(EscapeCharacters);
|
||||
|
||||
static SimpleJson()
|
||||
{
|
||||
EscapeTable = new char[93];
|
||||
EscapeTable['"'] = '"';
|
||||
EscapeTable['\\'] = '\\';
|
||||
EscapeTable['\b'] = 'b';
|
||||
EscapeTable['\f'] = 'f';
|
||||
EscapeTable['\n'] = 'n';
|
||||
EscapeTable['\r'] = 'r';
|
||||
EscapeTable['\t'] = 't';
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parses the string json into a value
|
||||
/// </summary>
|
||||
@@ -1074,29 +1092,50 @@ namespace Octokit
|
||||
|
||||
static bool SerializeString(string aString, StringBuilder builder)
|
||||
{
|
||||
builder.Append("\"");
|
||||
// Happy path if there's nothing to be escaped. IndexOfAny is highly optimized (and unmanaged)
|
||||
if (aString.IndexOfAny(EscapeCharacters) == -1)
|
||||
{
|
||||
builder.Append('"');
|
||||
builder.Append(aString);
|
||||
builder.Append('"');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
builder.Append('"');
|
||||
int safeCharacterCount = 0;
|
||||
char[] charArray = aString.ToCharArray();
|
||||
|
||||
for (int i = 0; i < charArray.Length; i++)
|
||||
{
|
||||
char c = charArray[i];
|
||||
if (c == '"')
|
||||
builder.Append("\\\"");
|
||||
else if (c == '\\')
|
||||
builder.Append("\\\\");
|
||||
else if (c == '\b')
|
||||
builder.Append("\\b");
|
||||
else if (c == '\f')
|
||||
builder.Append("\\f");
|
||||
else if (c == '\n')
|
||||
builder.Append("\\n");
|
||||
else if (c == '\r')
|
||||
builder.Append("\\r");
|
||||
else if (c == '\t')
|
||||
builder.Append("\\t");
|
||||
|
||||
// Non ascii characters are fine, buffer them up and send them to the builder
|
||||
// in larger chunks if possible. The escape table is a 1:1 translation table
|
||||
// with \0 [default(char)] denoting a safe character.
|
||||
if (c >= EscapeTable.Length || EscapeTable[c] == default(char))
|
||||
{
|
||||
safeCharacterCount++;
|
||||
}
|
||||
else
|
||||
builder.Append(c);
|
||||
{
|
||||
if (safeCharacterCount > 0)
|
||||
{
|
||||
builder.Append(charArray, i - safeCharacterCount, safeCharacterCount);
|
||||
safeCharacterCount = 0;
|
||||
}
|
||||
|
||||
builder.Append('\\');
|
||||
builder.Append(EscapeTable[c]);
|
||||
}
|
||||
}
|
||||
builder.Append("\"");
|
||||
|
||||
if (safeCharacterCount > 0)
|
||||
{
|
||||
builder.Append(charArray, charArray.Length - safeCharacterCount, safeCharacterCount);
|
||||
}
|
||||
|
||||
builder.Append('"');
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1647,7 +1686,14 @@ namespace Octokit
|
||||
|
||||
Type genericDefinition = type.GetGenericTypeDefinition();
|
||||
|
||||
return (genericDefinition == typeof(IList<>) || genericDefinition == typeof(ICollection<>) || genericDefinition == typeof(IEnumerable<>));
|
||||
return (genericDefinition == typeof(IList<>)
|
||||
|| genericDefinition == typeof(ICollection<>)
|
||||
|| genericDefinition == typeof(IEnumerable<>)
|
||||
#if SIMPLE_JSON_READONLY_COLLECTIONS
|
||||
|| genericDefinition == typeof(IReadOnlyCollection<>)
|
||||
|| genericDefinition == typeof(IReadOnlyList<>)
|
||||
#endif
|
||||
);
|
||||
}
|
||||
|
||||
public static bool IsAssignableFrom(Type type1, Type type2)
|
||||
@@ -1727,13 +1773,7 @@ namespace Octokit
|
||||
public static IEnumerable<PropertyInfo> GetProperties(Type type)
|
||||
{
|
||||
#if SIMPLE_JSON_TYPEINFO
|
||||
var info = type.GetTypeInfo();
|
||||
|
||||
var baseProperties = info.BaseType != null && info.BaseType != typeof(Object)
|
||||
? GetProperties(info.BaseType)
|
||||
: new PropertyInfo[0];
|
||||
|
||||
return info.DeclaredProperties.Concat(baseProperties);
|
||||
return type.GetTypeInfo().DeclaredProperties;
|
||||
#else
|
||||
return type.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
|
||||
#endif
|
||||
|
||||
@@ -6,5 +6,5 @@
|
||||
<package id="Rx-Linq" version="2.1.30214.0" targetFramework="net40" requireReinstallation="True" />
|
||||
<package id="Rx-Main" version="2.1.30214.0" targetFramework="net40" />
|
||||
<package id="Rx-PlatformServices" version="2.1.30214.0" targetFramework="net40" requireReinstallation="True" />
|
||||
<package id="SimpleJson" version="0.30.0" targetFramework="net45" developmentDependency="true" />
|
||||
<package id="SimpleJson" version="0.34.0" targetFramework="net45" developmentDependency="true" />
|
||||
</packages>
|
||||
Binary file not shown.
@@ -1,15 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
|
||||
<metadata>
|
||||
<id>SimpleJson</id>
|
||||
<version>0.30.0</version>
|
||||
<authors>Jim Zimmerman, Nathan Totten, Prabir Shrestha</authors>
|
||||
<owners>Jim Zimmerman, Nathan Totten, Prabir Shrestha</owners>
|
||||
<licenseUrl>https://raw.github.com/facebook-csharp-sdk/simple-json/master/LICENSE.txt</licenseUrl>
|
||||
<projectUrl>https://raw.github.com/facebook-csharp-sdk/simple-json</projectUrl>
|
||||
<requireLicenseAcceptance>false</requireLicenseAcceptance>
|
||||
<description>Super lightweight Json library for .NET 2.0+/SL4+/WP7/WindowsStore Apps/Portable Class Libraries along with dynamic and DataContract support</description>
|
||||
<language>en-US</language>
|
||||
<tags>json</tags>
|
||||
</metadata>
|
||||
</package>
|
||||
Binary file not shown.
+67
-20
@@ -1,6 +1,6 @@
|
||||
# SimpleJson https://github.com/facebook-csharp-sdk/simple-json
|
||||
# License: MIT License
|
||||
# Version: 0.30.0
|
||||
# Version: 0.34.0
|
||||
|
||||
function ConvertFrom-Json
|
||||
{
|
||||
@@ -87,7 +87,7 @@ $source = @"
|
||||
// <website>https://github.com/facebook-csharp-sdk/simple-json</website>
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
// VERSION: 0.30.0
|
||||
// VERSION: 0.34.0
|
||||
|
||||
// NOTE: uncomment the following line to make SimpleJson class internal.
|
||||
//#define SIMPLE_JSON_INTERNAL
|
||||
@@ -101,6 +101,9 @@ $source = @"
|
||||
// NOTE: uncomment the following line to enable DataContract support.
|
||||
//#define SIMPLE_JSON_DATACONTRACT
|
||||
|
||||
// NOTE: uncomment the following line to enable IReadOnlyCollection<T> and IReadOnlyList<T> support.
|
||||
//#define SIMPLE_JSON_READONLY_COLLECTIONS
|
||||
|
||||
// NOTE: uncomment the following line to disable linq expressions/compiled lambda (better performance) instead of method.invoke().
|
||||
// define if you are using .net framework <= 3.0 or < WP7.5
|
||||
//#define SIMPLE_JSON_NO_LINQ_EXPRESSION
|
||||
@@ -582,6 +585,22 @@ namespace SimpleJson
|
||||
private const int TOKEN_NULL = 11;
|
||||
private const int BUILDER_CAPACITY = 2000;
|
||||
|
||||
private static readonly char[] EscapeTable;
|
||||
private static readonly char[] EscapeCharacters = new char[] { '"', '\\', '\b', '\f', '\n', '\r', '\t' };
|
||||
private static readonly string EscapeCharactersString = new string(EscapeCharacters);
|
||||
|
||||
static SimpleJson()
|
||||
{
|
||||
EscapeTable = new char[93];
|
||||
EscapeTable['"'] = '"';
|
||||
EscapeTable['\\'] = '\\';
|
||||
EscapeTable['\b'] = 'b';
|
||||
EscapeTable['\f'] = 'f';
|
||||
EscapeTable['\n'] = 'n';
|
||||
EscapeTable['\r'] = 'r';
|
||||
EscapeTable['\t'] = 't';
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parses the string json into a value
|
||||
/// </summary>
|
||||
@@ -1143,29 +1162,50 @@ namespace SimpleJson
|
||||
|
||||
static bool SerializeString(string aString, StringBuilder builder)
|
||||
{
|
||||
builder.Append("\"");
|
||||
// Happy path if there's nothing to be escaped. IndexOfAny is highly optimized (and unmanaged)
|
||||
if (aString.IndexOfAny(EscapeCharacters) == -1)
|
||||
{
|
||||
builder.Append('"');
|
||||
builder.Append(aString);
|
||||
builder.Append('"');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
builder.Append('"');
|
||||
int safeCharacterCount = 0;
|
||||
char[] charArray = aString.ToCharArray();
|
||||
|
||||
for (int i = 0; i < charArray.Length; i++)
|
||||
{
|
||||
char c = charArray[i];
|
||||
if (c == '"')
|
||||
builder.Append("\\\"");
|
||||
else if (c == '\\')
|
||||
builder.Append("\\\\");
|
||||
else if (c == '\b')
|
||||
builder.Append("\\b");
|
||||
else if (c == '\f')
|
||||
builder.Append("\\f");
|
||||
else if (c == '\n')
|
||||
builder.Append("\\n");
|
||||
else if (c == '\r')
|
||||
builder.Append("\\r");
|
||||
else if (c == '\t')
|
||||
builder.Append("\\t");
|
||||
|
||||
// Non ascii characters are fine, buffer them up and send them to the builder
|
||||
// in larger chunks if possible. The escape table is a 1:1 translation table
|
||||
// with \0 [default(char)] denoting a safe character.
|
||||
if (c >= EscapeTable.Length || EscapeTable[c] == default(char))
|
||||
{
|
||||
safeCharacterCount++;
|
||||
}
|
||||
else
|
||||
builder.Append(c);
|
||||
{
|
||||
if (safeCharacterCount > 0)
|
||||
{
|
||||
builder.Append(charArray, i - safeCharacterCount, safeCharacterCount);
|
||||
safeCharacterCount = 0;
|
||||
}
|
||||
|
||||
builder.Append('\\');
|
||||
builder.Append(EscapeTable[c]);
|
||||
}
|
||||
}
|
||||
builder.Append("\"");
|
||||
|
||||
if (safeCharacterCount > 0)
|
||||
{
|
||||
builder.Append(charArray, charArray.Length - safeCharacterCount, safeCharacterCount);
|
||||
}
|
||||
|
||||
builder.Append('"');
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1716,7 +1756,14 @@ namespace SimpleJson
|
||||
|
||||
Type genericDefinition = type.GetGenericTypeDefinition();
|
||||
|
||||
return (genericDefinition == typeof(IList<>) || genericDefinition == typeof(ICollection<>) || genericDefinition == typeof(IEnumerable<>));
|
||||
return (genericDefinition == typeof(IList<>)
|
||||
|| genericDefinition == typeof(ICollection<>)
|
||||
|| genericDefinition == typeof(IEnumerable<>)
|
||||
#if SIMPLE_JSON_READONLY_COLLECTIONS
|
||||
|| genericDefinition == typeof(IReadOnlyCollection<>)
|
||||
|| genericDefinition == typeof(IReadOnlyList<>)
|
||||
#endif
|
||||
);
|
||||
}
|
||||
|
||||
public static bool IsAssignableFrom(Type type1, Type type2)
|
||||
+66
-19
@@ -17,7 +17,7 @@
|
||||
// <website>https://github.com/facebook-csharp-sdk/simple-json</website>
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
// VERSION: 0.30.0
|
||||
// VERSION: 0.34.0
|
||||
|
||||
// NOTE: uncomment the following line to make SimpleJson class internal.
|
||||
//#define SIMPLE_JSON_INTERNAL
|
||||
@@ -31,6 +31,9 @@
|
||||
// NOTE: uncomment the following line to enable DataContract support.
|
||||
//#define SIMPLE_JSON_DATACONTRACT
|
||||
|
||||
// NOTE: uncomment the following line to enable IReadOnlyCollection<T> and IReadOnlyList<T> support.
|
||||
//#define SIMPLE_JSON_READONLY_COLLECTIONS
|
||||
|
||||
// NOTE: uncomment the following line to disable linq expressions/compiled lambda (better performance) instead of method.invoke().
|
||||
// define if you are using .net framework <= 3.0 or < WP7.5
|
||||
//#define SIMPLE_JSON_NO_LINQ_EXPRESSION
|
||||
@@ -512,6 +515,22 @@ namespace $rootnamespace$
|
||||
private const int TOKEN_NULL = 11;
|
||||
private const int BUILDER_CAPACITY = 2000;
|
||||
|
||||
private static readonly char[] EscapeTable;
|
||||
private static readonly char[] EscapeCharacters = new char[] { '"', '\\', '\b', '\f', '\n', '\r', '\t' };
|
||||
private static readonly string EscapeCharactersString = new string(EscapeCharacters);
|
||||
|
||||
static SimpleJson()
|
||||
{
|
||||
EscapeTable = new char[93];
|
||||
EscapeTable['"'] = '"';
|
||||
EscapeTable['\\'] = '\\';
|
||||
EscapeTable['\b'] = 'b';
|
||||
EscapeTable['\f'] = 'f';
|
||||
EscapeTable['\n'] = 'n';
|
||||
EscapeTable['\r'] = 'r';
|
||||
EscapeTable['\t'] = 't';
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parses the string json into a value
|
||||
/// </summary>
|
||||
@@ -1073,29 +1092,50 @@ namespace $rootnamespace$
|
||||
|
||||
static bool SerializeString(string aString, StringBuilder builder)
|
||||
{
|
||||
builder.Append("\"");
|
||||
// Happy path if there's nothing to be escaped. IndexOfAny is highly optimized (and unmanaged)
|
||||
if (aString.IndexOfAny(EscapeCharacters) == -1)
|
||||
{
|
||||
builder.Append('"');
|
||||
builder.Append(aString);
|
||||
builder.Append('"');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
builder.Append('"');
|
||||
int safeCharacterCount = 0;
|
||||
char[] charArray = aString.ToCharArray();
|
||||
|
||||
for (int i = 0; i < charArray.Length; i++)
|
||||
{
|
||||
char c = charArray[i];
|
||||
if (c == '"')
|
||||
builder.Append("\\\"");
|
||||
else if (c == '\\')
|
||||
builder.Append("\\\\");
|
||||
else if (c == '\b')
|
||||
builder.Append("\\b");
|
||||
else if (c == '\f')
|
||||
builder.Append("\\f");
|
||||
else if (c == '\n')
|
||||
builder.Append("\\n");
|
||||
else if (c == '\r')
|
||||
builder.Append("\\r");
|
||||
else if (c == '\t')
|
||||
builder.Append("\\t");
|
||||
|
||||
// Non ascii characters are fine, buffer them up and send them to the builder
|
||||
// in larger chunks if possible. The escape table is a 1:1 translation table
|
||||
// with \0 [default(char)] denoting a safe character.
|
||||
if (c >= EscapeTable.Length || EscapeTable[c] == default(char))
|
||||
{
|
||||
safeCharacterCount++;
|
||||
}
|
||||
else
|
||||
builder.Append(c);
|
||||
{
|
||||
if (safeCharacterCount > 0)
|
||||
{
|
||||
builder.Append(charArray, i - safeCharacterCount, safeCharacterCount);
|
||||
safeCharacterCount = 0;
|
||||
}
|
||||
|
||||
builder.Append('\\');
|
||||
builder.Append(EscapeTable[c]);
|
||||
}
|
||||
}
|
||||
builder.Append("\"");
|
||||
|
||||
if (safeCharacterCount > 0)
|
||||
{
|
||||
builder.Append(charArray, charArray.Length - safeCharacterCount, safeCharacterCount);
|
||||
}
|
||||
|
||||
builder.Append('"');
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1646,7 +1686,14 @@ namespace $rootnamespace$
|
||||
|
||||
Type genericDefinition = type.GetGenericTypeDefinition();
|
||||
|
||||
return (genericDefinition == typeof(IList<>) || genericDefinition == typeof(ICollection<>) || genericDefinition == typeof(IEnumerable<>));
|
||||
return (genericDefinition == typeof(IList<>)
|
||||
|| genericDefinition == typeof(ICollection<>)
|
||||
|| genericDefinition == typeof(IEnumerable<>)
|
||||
#if SIMPLE_JSON_READONLY_COLLECTIONS
|
||||
|| genericDefinition == typeof(IReadOnlyCollection<>)
|
||||
|| genericDefinition == typeof(IReadOnlyList<>)
|
||||
#endif
|
||||
);
|
||||
}
|
||||
|
||||
public static bool IsAssignableFrom(Type type1, Type type2)
|
||||
Reference in New Issue
Block a user