Skip to content

Commit fc1cf57

Browse files
committed
New JSON parser
1 parent 684c2bf commit fc1cf57

32 files changed

Lines changed: 2547 additions & 116 deletions

LICENSE

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,25 @@ Code Cracker
4545
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
4646
CONDITIONS OF ANY KIND, either express or implied. See the License for the
4747
specific language governing permissions and limitations under the License.
48+
49+
LightJson
50+
51+
Copyright (c) 2017 Marcos L�pez C.
52+
53+
Permission is hereby granted, free of charge, to any person obtaining a copy
54+
of this software and associated documentation files (the "Software"), to deal
55+
in the Software without restriction, including without limitation the rights
56+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
57+
copies of the Software, and to permit persons to whom the Software is
58+
furnished to do so, subject to the following conditions:
59+
60+
The above copyright notice and this permission notice shall be included in
61+
all copies or substantial portions of the Software.
62+
63+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
64+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
65+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
66+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
67+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
68+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
69+
THE SOFTWARE.

StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/StyleCop.Analyzers.CodeFixes.csproj

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,10 +183,6 @@
183183
<HintPath>..\..\packages\Microsoft.CodeAnalysis.Workspaces.Common.1.0.0\lib\portable-net45+win8\Microsoft.CodeAnalysis.Workspaces.dll</HintPath>
184184
<Private>True</Private>
185185
</Reference>
186-
<Reference Include="Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
187-
<HintPath>..\..\packages\Newtonsoft.Json.7.0.1\lib\portable-net40+sl5+wp80+win8+wpa81\Newtonsoft.Json.dll</HintPath>
188-
<Private>True</Private>
189-
</Reference>
190186
<Reference Include="System.Collections.Immutable, Version=1.1.36.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
191187
<HintPath>..\..\packages\System.Collections.Immutable.1.1.36\lib\portable-net45+win8+wp8+wpa81\System.Collections.Immutable.dll</HintPath>
192188
<Private>True</Private>

StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/StyleCop.Analyzers.nuspec

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
<file src="bin\$Configuration$\StyleCop.Analyzers.pdb" target="analyzers\dotnet\cs" />
2323
<file src="bin\$Configuration$\StyleCop.Analyzers.CodeFixes.dll" target="analyzers\dotnet\cs" />
2424
<file src="bin\$Configuration$\StyleCop.Analyzers.CodeFixes.pdb" target="analyzers\dotnet\cs" />
25-
<file src="..\..\packages\Newtonsoft.Json.7.0.1\lib\portable-net40+sl5+wp80+win8+wpa81\Newtonsoft.Json.dll" target="analyzers\dotnet\cs" />
2625

2726
<!-- Scripts -->
2827
<file src="tools\install.ps1" target="tools\" />

StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/packages.config

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
<package id="Microsoft.CodeAnalysis.CSharp.Workspaces" version="1.0.0" targetFramework="portable45-net45+win8" />
88
<package id="Microsoft.CodeAnalysis.Workspaces.Common" version="1.0.0" targetFramework="portable45-net45+win8" />
99
<package id="Microsoft.Composition" version="1.0.27" targetFramework="portable-net45+win8" />
10-
<package id="Newtonsoft.Json" version="7.0.1" targetFramework="portable45-net45+win8" />
1110
<package id="NuGet.CommandLine" version="2.8.3" targetFramework="portable45-net45+win8" />
1211
<package id="StyleCop.Analyzers" version="1.0.0-rc3" targetFramework="portable45-net45+win8" developmentDependency="true" />
1312
<package id="System.Collections.Immutable" version="1.1.36" targetFramework="portable45-net45+win8" />

StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/NoXmlFileHeaderUnitTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public class NoXmlFileHeaderUnitTests : CodeFixVerifier
2525
""copyrightText"": ""Copyright (c) {companyName}. All rights reserved.\nLicensed under the {licenseName} license. See {licenseFile} file in the project root for full license information."",
2626
""variables"": {
2727
""licenseName"": ""???"",
28-
""licenseFile"": ""LICENSE"",
28+
""licenseFile"": ""LICENSE""
2929
},
3030
""xmlHeader"": false
3131
}

StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1203UnitTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ protected override string GetSettings()
448448
""kind"",
449449
""constant"",
450450
""static"",
451-
""readonly"",
451+
""readonly""
452452
]
453453
}
454454
}

StyleCop.Analyzers/StyleCop.Analyzers.Test/StyleCop.Analyzers.Test.csproj

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3-
<Import Project="..\..\packages\xunit.runner.visualstudio.2.1.0-beta4-build1109\build\net20\xunit.runner.visualstudio.props" Condition="Exists('..\..\packages\xunit.runner.visualstudio.2.1.0-beta4-build1109\build\net20\xunit.runner.visualstudio.props')" />
3+
<Import Project="..\..\packages\xunit.runner.visualstudio.2.3.0-beta1-build1309\build\net20\xunit.runner.visualstudio.props" Condition="Exists('..\..\packages\xunit.runner.visualstudio.2.3.0-beta1-build1309\build\net20\xunit.runner.visualstudio.props')" />
44
<Import Project="..\..\packages\xunit.core.2.1.0-beta4-build3109\build\portable-net45+netcore45+wp8+wpa81\xunit.core.props" Condition="Exists('..\..\packages\xunit.core.2.1.0-beta4-build3109\build\portable-net45+netcore45+wp8+wpa81\xunit.core.props')" />
55
<PropertyGroup>
66
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -16,6 +16,8 @@
1616
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
1717
<FileAlignment>512</FileAlignment>
1818
<TargetFrameworkProfile />
19+
<NuGetPackageImportStamp>
20+
</NuGetPackageImportStamp>
1921
</PropertyGroup>
2022
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
2123
<DebugSymbols>true</DebugSymbols>
@@ -65,10 +67,6 @@
6567
<HintPath>..\..\packages\Microsoft.CodeAnalysis.Workspaces.Common.1.0.0\lib\net45\Microsoft.CodeAnalysis.Workspaces.Desktop.dll</HintPath>
6668
<Private>True</Private>
6769
</Reference>
68-
<Reference Include="Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
69-
<HintPath>..\..\packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
70-
<Private>True</Private>
71-
</Reference>
7270
<Reference Include="System" />
7371
<Reference Include="System.Collections.Immutable, Version=1.1.36.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
7472
<HintPath>..\..\packages\System.Collections.Immutable.1.1.36\lib\portable-net45+win8+wp8+wpa81\System.Collections.Immutable.dll</HintPath>
@@ -404,7 +402,7 @@
404402
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
405403
</PropertyGroup>
406404
<Error Condition="!Exists('..\..\packages\xunit.core.2.1.0-beta4-build3109\build\portable-net45+netcore45+wp8+wpa81\xunit.core.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\xunit.core.2.1.0-beta4-build3109\build\portable-net45+netcore45+wp8+wpa81\xunit.core.props'))" />
407-
<Error Condition="!Exists('..\..\packages\xunit.runner.visualstudio.2.1.0-beta4-build1109\build\net20\xunit.runner.visualstudio.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\xunit.runner.visualstudio.2.1.0-beta4-build1109\build\net20\xunit.runner.visualstudio.props'))" />
405+
<Error Condition="!Exists('..\..\packages\xunit.runner.visualstudio.2.3.0-beta1-build1309\build\net20\xunit.runner.visualstudio.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\xunit.runner.visualstudio.2.3.0-beta1-build1309\build\net20\xunit.runner.visualstudio.props'))" />
408406
</Target>
409407
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
410408
Other similar extension points exist, see Microsoft.Common.targets.

StyleCop.Analyzers/StyleCop.Analyzers.Test/packages.config

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
<package id="Microsoft.CodeAnalysis.CSharp.Workspaces" version="1.0.0" targetFramework="net452" />
88
<package id="Microsoft.CodeAnalysis.Workspaces.Common" version="1.0.0" targetFramework="net452" />
99
<package id="Microsoft.Composition" version="1.0.27" targetFramework="net452" />
10-
<package id="Newtonsoft.Json" version="7.0.1" targetFramework="net45" />
1110
<package id="StyleCop.Analyzers" version="1.0.0-rc3" targetFramework="net452" developmentDependency="true" />
1211
<package id="System.Collections.Immutable" version="1.1.36" targetFramework="net452" />
1312
<package id="System.Reflection.Metadata" version="1.0.21" targetFramework="net452" />
@@ -16,5 +15,5 @@
1615
<package id="xunit.assert" version="2.1.0-beta4-build3109" targetFramework="net452" />
1716
<package id="xunit.core" version="2.1.0-beta4-build3109" targetFramework="net452" />
1817
<package id="xunit.extensibility.core" version="2.1.0-beta4-build3109" targetFramework="net452" />
19-
<package id="xunit.runner.visualstudio" version="2.1.0-beta4-build1109" targetFramework="net452" />
18+
<package id="xunit.runner.visualstudio" version="2.3.0-beta1-build1309" targetFramework="net452" developmentDependency="true" />
2019
</packages>
Lines changed: 186 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,186 @@
1+
// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
2+
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
3+
4+
namespace LightJson
5+
{
6+
using System.Collections.Generic;
7+
using System.Diagnostics;
8+
9+
/// <summary>
10+
/// Represents an ordered collection of JsonValues.
11+
/// </summary>
12+
[DebuggerDisplay("Count = {Count}")]
13+
[DebuggerTypeProxy(typeof(JsonArrayDebugView))]
14+
internal sealed class JsonArray : IEnumerable<JsonValue>
15+
{
16+
private IList<JsonValue> items;
17+
18+
/// <summary>
19+
/// Initializes a new instance of the <see cref="JsonArray"/> class.
20+
/// </summary>
21+
public JsonArray()
22+
{
23+
this.items = new List<JsonValue>();
24+
}
25+
26+
/// <summary>
27+
/// Initializes a new instance of the <see cref="JsonArray"/> class, adding the given values to the collection.
28+
/// </summary>
29+
/// <param name="values">The values to be added to this collection.</param>
30+
public JsonArray(params JsonValue[] values)
31+
: this()
32+
{
33+
foreach (var value in values)
34+
{
35+
this.items.Add(value);
36+
}
37+
}
38+
39+
/// <summary>
40+
/// Gets the number of values in this collection.
41+
/// </summary>
42+
/// <value>The number of values in this collection.</value>
43+
public int Count
44+
{
45+
get
46+
{
47+
return this.items.Count;
48+
}
49+
}
50+
51+
/// <summary>
52+
/// Gets or sets the value at the given index.
53+
/// </summary>
54+
/// <param name="index">The zero-based index of the value to get or set.</param>
55+
/// <remarks>
56+
/// The getter will return JsonValue.Null if the given index is out of range.
57+
/// </remarks>
58+
public JsonValue this[int index]
59+
{
60+
get
61+
{
62+
if (index >= 0 && index < this.items.Count)
63+
{
64+
return this.items[index];
65+
}
66+
else
67+
{
68+
return JsonValue.Null;
69+
}
70+
}
71+
72+
set
73+
{
74+
this.items[index] = value;
75+
}
76+
}
77+
78+
/// <summary>
79+
/// Adds the given value to this collection.
80+
/// </summary>
81+
/// <param name="value">The value to be added.</param>
82+
/// <returns>Returns this collection.</returns>
83+
public JsonArray Add(JsonValue value)
84+
{
85+
this.items.Add(value);
86+
return this;
87+
}
88+
89+
/// <summary>
90+
/// Inserts the given value at the given index in this collection.
91+
/// </summary>
92+
/// <param name="index">The index where the given value will be inserted.</param>
93+
/// <param name="value">The value to be inserted into this collection.</param>
94+
/// <returns>Returns this collection.</returns>
95+
public JsonArray Insert(int index, JsonValue value)
96+
{
97+
this.items.Insert(index, value);
98+
return this;
99+
}
100+
101+
/// <summary>
102+
/// Removes the value at the given index.
103+
/// </summary>
104+
/// <param name="index">The index of the value to be removed.</param>
105+
/// <returns>Return this collection.</returns>
106+
public JsonArray Remove(int index)
107+
{
108+
this.items.RemoveAt(index);
109+
return this;
110+
}
111+
112+
/// <summary>
113+
/// Clears the contents of this collection.
114+
/// </summary>
115+
/// <returns>Returns this collection.</returns>
116+
public JsonArray Clear()
117+
{
118+
this.items.Clear();
119+
return this;
120+
}
121+
122+
/// <summary>
123+
/// Determines whether the given item is in the JsonArray.
124+
/// </summary>
125+
/// <param name="item">The item to locate in the JsonArray.</param>
126+
/// <returns>Returns true if the item is found; otherwise, false.</returns>
127+
public bool Contains(JsonValue item)
128+
{
129+
return this.items.Contains(item);
130+
}
131+
132+
/// <summary>
133+
/// Determines the index of the given item in this JsonArray.
134+
/// </summary>
135+
/// <param name="item">The item to locate in this JsonArray.</param>
136+
/// <returns>The index of the item, if found. Otherwise, returns -1.</returns>
137+
public int IndexOf(JsonValue item)
138+
{
139+
return this.items.IndexOf(item);
140+
}
141+
142+
/// <summary>
143+
/// Returns an enumerator that iterates through the collection.
144+
/// </summary>
145+
/// <returns>The enumerator that iterates through the collection.</returns>
146+
public IEnumerator<JsonValue> GetEnumerator()
147+
{
148+
return this.items.GetEnumerator();
149+
}
150+
151+
/// <summary>
152+
/// Returns an enumerator that iterates through the collection.
153+
/// </summary>
154+
/// <returns>The enumerator that iterates through the collection.</returns>
155+
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
156+
{
157+
return this.GetEnumerator();
158+
}
159+
160+
private class JsonArrayDebugView
161+
{
162+
private JsonArray jsonArray;
163+
164+
public JsonArrayDebugView(JsonArray jsonArray)
165+
{
166+
this.jsonArray = jsonArray;
167+
}
168+
169+
[DebuggerBrowsable(DebuggerBrowsableState.RootHidden)]
170+
public JsonValue[] Items
171+
{
172+
get
173+
{
174+
var items = new JsonValue[this.jsonArray.Count];
175+
176+
for (int i = 0; i < this.jsonArray.Count; i += 1)
177+
{
178+
items[i] = this.jsonArray[i];
179+
}
180+
181+
return items;
182+
}
183+
}
184+
}
185+
}
186+
}

0 commit comments

Comments
 (0)