Changes recommended by Rider/Resharper
This commit is contained in:
13
.idea/.idea.VAR.Json/.idea/.gitignore
generated
vendored
Normal file
13
.idea/.idea.VAR.Json/.idea/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
||||||
|
# Rider ignored files
|
||||||
|
/contentModel.xml
|
||||||
|
/.idea.VAR.Json.iml
|
||||||
|
/modules.xml
|
||||||
|
/projectSettingsUpdater.xml
|
||||||
|
# Editor-based HTTP Client requests
|
||||||
|
/httpRequests/
|
||||||
|
# Datasource local storage ignored files
|
||||||
|
/dataSources/
|
||||||
|
/dataSources.local.xml
|
||||||
4
.idea/.idea.VAR.Json/.idea/encodings.xml
generated
Normal file
4
.idea/.idea.VAR.Json/.idea/encodings.xml
generated
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="Encoding" addBOMForNewFiles="with BOM under Windows, with no BOM otherwise" />
|
||||||
|
</project>
|
||||||
8
.idea/.idea.VAR.Json/.idea/indexLayout.xml
generated
Normal file
8
.idea/.idea.VAR.Json/.idea/indexLayout.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="UserContentModel">
|
||||||
|
<attachedFolders />
|
||||||
|
<explicitIncludes />
|
||||||
|
<explicitExcludes />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
6
.idea/.idea.VAR.Json/.idea/vcs.xml
generated
Normal file
6
.idea/.idea.VAR.Json/.idea/vcs.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
The MIT License (MIT)
|
The MIT License (MIT)
|
||||||
|
|
||||||
Copyright (c) 2016-2021 Valeriano Alfonso Rodriguez
|
Copyright (c) 2016-2022 Valeriano Alfonso Rodriguez
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
### VAR.Json
|
### VAR.Json
|
||||||
|
|
||||||
Add the resulting assembly as reference in your projects, and this line on code:
|
Add the resulting assembly as reference in your projects, and this line on code:
|
||||||
|
|
||||||
```csharp
|
```csharp
|
||||||
@@ -10,18 +11,20 @@ using VAR.Json;
|
|||||||
```
|
```
|
||||||
|
|
||||||
Parse any string with JSON content:
|
Parse any string with JSON content:
|
||||||
|
|
||||||
```csharp
|
```csharp
|
||||||
object result = JsonParser.ParseText("{\"Test\": 1}");
|
object result = JsonParser.ParseText("{\"Test\": 1}");
|
||||||
```
|
```
|
||||||
|
|
||||||
Serialize any object to JSON:
|
Serialize any object to JSON:
|
||||||
|
|
||||||
```csharp
|
```csharp
|
||||||
string jsonText = JsonWriter.WriteObject(new List<int>{1, 2, 3, 4});
|
string jsonText = JsonWriter.WriteObject(new List<int>{1, 2, 3, 4});
|
||||||
```
|
```
|
||||||
|
|
||||||
### VAR.Json.JsonParser
|
### VAR.Json.JsonParser
|
||||||
This object can be invoked with a list of types used to cast the json objects.
|
|
||||||
|
|
||||||
|
This object can be invoked with a list of types used to cast the json objects.
|
||||||
|
|
||||||
```csharp
|
```csharp
|
||||||
|
|
||||||
@@ -37,13 +40,14 @@ jsonParser.KnownTypes.Add(typeof(Person));
|
|||||||
Person jsonText = jsonParser.Parse("{ \"Name\": \"John", \"Surname\": \"Doe\", \"DateOfBirth\": \"1970-01-01\"}") as Person;
|
Person jsonText = jsonParser.Parse("{ \"Name\": \"John", \"Surname\": \"Doe\", \"DateOfBirth\": \"1970-01-01\"}") as Person;
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
## Building
|
## Building
|
||||||
|
|
||||||
A Visual Studio solution is provided. Simply, click build on the IDE.
|
A Visual Studio solution is provided. Simply, click build on the IDE.
|
||||||
|
|
||||||
The build generates a DLL and a Nuget package.
|
The build generates a DLL and a Nuget package.
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
1. Fork it!
|
1. Fork it!
|
||||||
2. Create your feature branch: `git checkout -b my-new-feature`
|
2. Create your feature branch: `git checkout -b my-new-feature`
|
||||||
3. Commit your changes: `git commit -am 'Add some feature'`
|
3. Commit your changes: `git commit -am 'Add some feature'`
|
||||||
@@ -51,4 +55,5 @@ The build generates a DLL and a Nuget package.
|
|||||||
5. Submit a pull request :D
|
5. Submit a pull request :D
|
||||||
|
|
||||||
## Credits
|
## Credits
|
||||||
|
|
||||||
* Valeriano Alfonso Rodriguez.
|
* Valeriano Alfonso Rodriguez.
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ namespace VAR.Json.Tests
|
|||||||
{
|
{
|
||||||
#region Parse
|
#region Parse
|
||||||
|
|
||||||
public class SwallowObject
|
private class SwallowObject
|
||||||
{
|
{
|
||||||
public string Text { get; set; }
|
public string Text { get; set; }
|
||||||
public int Number { get; set; }
|
public int Number { get; set; }
|
||||||
@@ -20,11 +20,11 @@ namespace VAR.Json.Tests
|
|||||||
parser.KnownTypes.Add(typeof(SwallowObject));
|
parser.KnownTypes.Add(typeof(SwallowObject));
|
||||||
SwallowObject result = parser.Parse(@"{""Text"": ""AAAA"", ""Number"": 42}") as SwallowObject;
|
SwallowObject result = parser.Parse(@"{""Text"": ""AAAA"", ""Number"": 42}") as SwallowObject;
|
||||||
Assert.False(parser.Tainted);
|
Assert.False(parser.Tainted);
|
||||||
Assert.Equal("AAAA", result.Text);
|
Assert.Equal("AAAA", result?.Text);
|
||||||
Assert.Equal(42, result.Number);
|
Assert.Equal(42, result.Number);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class DeeperObject_L1
|
private class DeeperObject_L1
|
||||||
{
|
{
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public SwallowObject Object { get; set; }
|
public SwallowObject Object { get; set; }
|
||||||
@@ -36,14 +36,16 @@ namespace VAR.Json.Tests
|
|||||||
JsonParser parser = new JsonParser();
|
JsonParser parser = new JsonParser();
|
||||||
parser.KnownTypes.Add(typeof(SwallowObject));
|
parser.KnownTypes.Add(typeof(SwallowObject));
|
||||||
parser.KnownTypes.Add(typeof(DeeperObject_L1));
|
parser.KnownTypes.Add(typeof(DeeperObject_L1));
|
||||||
DeeperObject_L1 result = parser.Parse(@"{""Name"": ""Thing"", ""Object"": {""Text"": ""AAAA"", ""Number"": 42}}") as DeeperObject_L1;
|
DeeperObject_L1 result =
|
||||||
|
parser.Parse(@"{""Name"": ""Thing"", ""Object"": {""Text"": ""AAAA"", ""Number"": 42}}") as
|
||||||
|
DeeperObject_L1;
|
||||||
Assert.False(parser.Tainted);
|
Assert.False(parser.Tainted);
|
||||||
Assert.Equal("Thing", result.Name);
|
Assert.Equal("Thing", result.Name);
|
||||||
Assert.Equal("AAAA", result.Object.Text);
|
Assert.Equal("AAAA", result.Object.Text);
|
||||||
Assert.Equal(42, result.Object.Number);
|
Assert.Equal(42, result.Object.Number);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class DeeperObject_L2
|
private class DeeperObject_L2
|
||||||
{
|
{
|
||||||
public int Count { get; set; }
|
public int Count { get; set; }
|
||||||
public DeeperObject_L1 Object { get; set; }
|
public DeeperObject_L1 Object { get; set; }
|
||||||
@@ -56,7 +58,10 @@ namespace VAR.Json.Tests
|
|||||||
parser.KnownTypes.Add(typeof(SwallowObject));
|
parser.KnownTypes.Add(typeof(SwallowObject));
|
||||||
parser.KnownTypes.Add(typeof(DeeperObject_L1));
|
parser.KnownTypes.Add(typeof(DeeperObject_L1));
|
||||||
parser.KnownTypes.Add(typeof(DeeperObject_L2));
|
parser.KnownTypes.Add(typeof(DeeperObject_L2));
|
||||||
DeeperObject_L2 result = parser.Parse(@"{""Count"": 1, ""Object"": {""Name"": ""Thing"", ""Object"": {""Text"": ""AAAA"", ""Number"": 42}}}") as DeeperObject_L2;
|
DeeperObject_L2 result =
|
||||||
|
parser.Parse(
|
||||||
|
@"{""Count"": 1, ""Object"": {""Name"": ""Thing"", ""Object"": {""Text"": ""AAAA"", ""Number"": 42}}}")
|
||||||
|
as DeeperObject_L2;
|
||||||
Assert.False(parser.Tainted);
|
Assert.False(parser.Tainted);
|
||||||
Assert.Equal(1, result.Count);
|
Assert.Equal(1, result.Count);
|
||||||
Assert.Equal("Thing", result.Object.Name);
|
Assert.Equal("Thing", result.Object.Name);
|
||||||
@@ -76,7 +81,7 @@ namespace VAR.Json.Tests
|
|||||||
Assert.Equal(42, result[0].Number);
|
Assert.Equal(42, result[0].Number);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class DeeperObjectArray_L1
|
private class DeeperObjectArray_L1
|
||||||
{
|
{
|
||||||
public int Count { get; set; }
|
public int Count { get; set; }
|
||||||
public List<SwallowObject> Array { get; set; }
|
public List<SwallowObject> Array { get; set; }
|
||||||
@@ -88,14 +93,16 @@ namespace VAR.Json.Tests
|
|||||||
JsonParser parser = new JsonParser();
|
JsonParser parser = new JsonParser();
|
||||||
parser.KnownTypes.Add(typeof(SwallowObject));
|
parser.KnownTypes.Add(typeof(SwallowObject));
|
||||||
parser.KnownTypes.Add(typeof(DeeperObjectArray_L1));
|
parser.KnownTypes.Add(typeof(DeeperObjectArray_L1));
|
||||||
DeeperObjectArray_L1 result = parser.Parse(@"{""Count"": 1, ""Array"": [{""Text"": ""AAAA"", ""Number"": 42}]}") as DeeperObjectArray_L1;
|
DeeperObjectArray_L1 result =
|
||||||
|
parser.Parse(@"{""Count"": 1, ""Array"": [{""Text"": ""AAAA"", ""Number"": 42}]}") as
|
||||||
|
DeeperObjectArray_L1;
|
||||||
Assert.False(parser.Tainted);
|
Assert.False(parser.Tainted);
|
||||||
Assert.Equal(1, result.Count);
|
Assert.Equal(1, result.Count);
|
||||||
Assert.Equal("AAAA", result.Array[0].Text);
|
Assert.Equal("AAAA", result.Array[0].Text);
|
||||||
Assert.Equal(42, result.Array[0].Number);
|
Assert.Equal(42, result.Array[0].Number);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class DeeperObjectArray_L2
|
private class DeeperObjectArray_L2
|
||||||
{
|
{
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public List<DeeperObjectArray_L1> Objects { get; set; }
|
public List<DeeperObjectArray_L1> Objects { get; set; }
|
||||||
@@ -108,7 +115,10 @@ namespace VAR.Json.Tests
|
|||||||
parser.KnownTypes.Add(typeof(SwallowObject));
|
parser.KnownTypes.Add(typeof(SwallowObject));
|
||||||
parser.KnownTypes.Add(typeof(DeeperObjectArray_L1));
|
parser.KnownTypes.Add(typeof(DeeperObjectArray_L1));
|
||||||
parser.KnownTypes.Add(typeof(DeeperObjectArray_L2));
|
parser.KnownTypes.Add(typeof(DeeperObjectArray_L2));
|
||||||
DeeperObjectArray_L2 result = parser.Parse(@"{""Name"": ""Thing"", ""Objects"": [{""Count"": 1, ""Array"": [{""Text"": ""AAAA"", ""Number"": 42}]}]}") as DeeperObjectArray_L2;
|
DeeperObjectArray_L2 result =
|
||||||
|
parser.Parse(
|
||||||
|
@"{""Name"": ""Thing"", ""Objects"": [{""Count"": 1, ""Array"": [{""Text"": ""AAAA"", ""Number"": 42}]}]}")
|
||||||
|
as DeeperObjectArray_L2;
|
||||||
Assert.False(parser.Tainted);
|
Assert.False(parser.Tainted);
|
||||||
Assert.Equal("Thing", result.Name);
|
Assert.Equal("Thing", result.Name);
|
||||||
Assert.Equal(1, result.Objects[0].Count);
|
Assert.Equal(1, result.Objects[0].Count);
|
||||||
@@ -124,7 +134,7 @@ namespace VAR.Json.Tests
|
|||||||
public void Parse__Validity_Fail01()
|
public void Parse__Validity_Fail01()
|
||||||
{
|
{
|
||||||
JsonParser parser = new JsonParser();
|
JsonParser parser = new JsonParser();
|
||||||
object result = parser.Parse(@"""A JSON payload should be an object or array, not a string.""");
|
parser.Parse(@"""A JSON payload should be an object or array, not a string.""");
|
||||||
Assert.True(parser.Tainted);
|
Assert.True(parser.Tainted);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -132,7 +142,7 @@ namespace VAR.Json.Tests
|
|||||||
public void Parse__Validity_Fail02()
|
public void Parse__Validity_Fail02()
|
||||||
{
|
{
|
||||||
JsonParser parser = new JsonParser();
|
JsonParser parser = new JsonParser();
|
||||||
object result = parser.Parse(@"[""Unclosed array""");
|
parser.Parse(@"[""Unclosed array""");
|
||||||
Assert.True(parser.Tainted);
|
Assert.True(parser.Tainted);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -140,7 +150,7 @@ namespace VAR.Json.Tests
|
|||||||
public void Parse__Validity_Fail03()
|
public void Parse__Validity_Fail03()
|
||||||
{
|
{
|
||||||
JsonParser parser = new JsonParser();
|
JsonParser parser = new JsonParser();
|
||||||
object result = parser.Parse(@"{unquoted_key: ""keys must be quoted""}");
|
parser.Parse(@"{unquoted_key: ""keys must be quoted""}");
|
||||||
Assert.True(parser.Tainted);
|
Assert.True(parser.Tainted);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -148,7 +158,7 @@ namespace VAR.Json.Tests
|
|||||||
public void Parse__Validity_Fail04()
|
public void Parse__Validity_Fail04()
|
||||||
{
|
{
|
||||||
JsonParser parser = new JsonParser();
|
JsonParser parser = new JsonParser();
|
||||||
object result = parser.Parse(@"[""extra comma"",]");
|
parser.Parse(@"[""extra comma"",]");
|
||||||
Assert.True(parser.Tainted);
|
Assert.True(parser.Tainted);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -156,7 +166,7 @@ namespace VAR.Json.Tests
|
|||||||
public void Parse__Validity_Fail05()
|
public void Parse__Validity_Fail05()
|
||||||
{
|
{
|
||||||
JsonParser parser = new JsonParser();
|
JsonParser parser = new JsonParser();
|
||||||
object result = parser.Parse(@"[""double extra comma"",,]");
|
parser.Parse(@"[""double extra comma"",,]");
|
||||||
Assert.True(parser.Tainted);
|
Assert.True(parser.Tainted);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -164,7 +174,7 @@ namespace VAR.Json.Tests
|
|||||||
public void Parse__Validity_Fail06()
|
public void Parse__Validity_Fail06()
|
||||||
{
|
{
|
||||||
JsonParser parser = new JsonParser();
|
JsonParser parser = new JsonParser();
|
||||||
object result = parser.Parse(@"[ , ""<-- missing value""]");
|
parser.Parse(@"[ , ""<-- missing value""]");
|
||||||
Assert.True(parser.Tainted);
|
Assert.True(parser.Tainted);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -172,7 +182,7 @@ namespace VAR.Json.Tests
|
|||||||
public void Parse__Validity_Fail07()
|
public void Parse__Validity_Fail07()
|
||||||
{
|
{
|
||||||
JsonParser parser = new JsonParser();
|
JsonParser parser = new JsonParser();
|
||||||
object result = parser.Parse(@"[""Comma after the close""],");
|
parser.Parse(@"[""Comma after the close""],");
|
||||||
Assert.True(parser.Tainted);
|
Assert.True(parser.Tainted);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -180,7 +190,7 @@ namespace VAR.Json.Tests
|
|||||||
public void Parse__Validity_Fail08()
|
public void Parse__Validity_Fail08()
|
||||||
{
|
{
|
||||||
JsonParser parser = new JsonParser();
|
JsonParser parser = new JsonParser();
|
||||||
object result = parser.Parse(@"[""Extra close""]]");
|
parser.Parse(@"[""Extra close""]]");
|
||||||
Assert.True(parser.Tainted);
|
Assert.True(parser.Tainted);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -188,7 +198,7 @@ namespace VAR.Json.Tests
|
|||||||
public void Parse__Validity_Fail09()
|
public void Parse__Validity_Fail09()
|
||||||
{
|
{
|
||||||
JsonParser parser = new JsonParser();
|
JsonParser parser = new JsonParser();
|
||||||
object result = parser.Parse(@"{""Extra comma"": true,}");
|
parser.Parse(@"{""Extra comma"": true,}");
|
||||||
Assert.True(parser.Tainted);
|
Assert.True(parser.Tainted);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -196,7 +206,7 @@ namespace VAR.Json.Tests
|
|||||||
public void Parse__Validity_Fail10()
|
public void Parse__Validity_Fail10()
|
||||||
{
|
{
|
||||||
JsonParser parser = new JsonParser();
|
JsonParser parser = new JsonParser();
|
||||||
object result = parser.Parse(@"{""Extra value after close"": true} ""misplaced quoted value""");
|
parser.Parse(@"{""Extra value after close"": true} ""misplaced quoted value""");
|
||||||
Assert.True(parser.Tainted);
|
Assert.True(parser.Tainted);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -204,7 +214,7 @@ namespace VAR.Json.Tests
|
|||||||
public void Parse__Validity_Fail11()
|
public void Parse__Validity_Fail11()
|
||||||
{
|
{
|
||||||
JsonParser parser = new JsonParser();
|
JsonParser parser = new JsonParser();
|
||||||
object result = parser.Parse(@"{""Illegal expression"": 1 + 2}");
|
parser.Parse(@"{""Illegal expression"": 1 + 2}");
|
||||||
Assert.True(parser.Tainted);
|
Assert.True(parser.Tainted);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -212,7 +222,7 @@ namespace VAR.Json.Tests
|
|||||||
public void Parse__Validity_Fail12()
|
public void Parse__Validity_Fail12()
|
||||||
{
|
{
|
||||||
JsonParser parser = new JsonParser();
|
JsonParser parser = new JsonParser();
|
||||||
object result = parser.Parse(@"{""Illegal invocation"": alert()}");
|
parser.Parse(@"{""Illegal invocation"": alert()}");
|
||||||
Assert.True(parser.Tainted);
|
Assert.True(parser.Tainted);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -220,7 +230,7 @@ namespace VAR.Json.Tests
|
|||||||
public void Parse__Validity_Fail13()
|
public void Parse__Validity_Fail13()
|
||||||
{
|
{
|
||||||
JsonParser parser = new JsonParser();
|
JsonParser parser = new JsonParser();
|
||||||
object result = parser.Parse(@"{""Numbers cannot have leading zeroes"": 013}");
|
parser.Parse(@"{""Numbers cannot have leading zeroes"": 013}");
|
||||||
Assert.True(parser.Tainted);
|
Assert.True(parser.Tainted);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -228,7 +238,7 @@ namespace VAR.Json.Tests
|
|||||||
public void Parse__Validity_Fail14()
|
public void Parse__Validity_Fail14()
|
||||||
{
|
{
|
||||||
JsonParser parser = new JsonParser();
|
JsonParser parser = new JsonParser();
|
||||||
object result = parser.Parse(@"{""Numbers cannot be hex"": 0x14}");
|
parser.Parse(@"{""Numbers cannot be hex"": 0x14}");
|
||||||
Assert.True(parser.Tainted);
|
Assert.True(parser.Tainted);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -236,7 +246,7 @@ namespace VAR.Json.Tests
|
|||||||
public void Parse__Validity_Fail15()
|
public void Parse__Validity_Fail15()
|
||||||
{
|
{
|
||||||
JsonParser parser = new JsonParser();
|
JsonParser parser = new JsonParser();
|
||||||
object result = parser.Parse(@"[""Illegal backslash escape: \x15""]");
|
parser.Parse(@"[""Illegal backslash escape: \x15""]");
|
||||||
Assert.True(parser.Tainted);
|
Assert.True(parser.Tainted);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -244,7 +254,7 @@ namespace VAR.Json.Tests
|
|||||||
public void Parse__Validity_Fail16()
|
public void Parse__Validity_Fail16()
|
||||||
{
|
{
|
||||||
JsonParser parser = new JsonParser();
|
JsonParser parser = new JsonParser();
|
||||||
object result = parser.Parse(@"[\naked]");
|
parser.Parse(@"[\naked]");
|
||||||
Assert.True(parser.Tainted);
|
Assert.True(parser.Tainted);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -252,7 +262,7 @@ namespace VAR.Json.Tests
|
|||||||
public void Parse__Validity_Fail17()
|
public void Parse__Validity_Fail17()
|
||||||
{
|
{
|
||||||
JsonParser parser = new JsonParser();
|
JsonParser parser = new JsonParser();
|
||||||
object result = parser.Parse(@"[""Illegal backslash escape: \017""]");
|
parser.Parse(@"[""Illegal backslash escape: \017""]");
|
||||||
Assert.True(parser.Tainted);
|
Assert.True(parser.Tainted);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -260,7 +270,7 @@ namespace VAR.Json.Tests
|
|||||||
public void Parse__Validity_Fail18()
|
public void Parse__Validity_Fail18()
|
||||||
{
|
{
|
||||||
JsonParser parser = new JsonParser();
|
JsonParser parser = new JsonParser();
|
||||||
object result = parser.Parse(@"[[[[[[[[[[[[[[[[[[[[""Too deep""]]]]]]]]]]]]]]]]]]]]");
|
parser.Parse(@"[[[[[[[[[[[[[[[[[[[[""Too deep""]]]]]]]]]]]]]]]]]]]]");
|
||||||
Assert.True(parser.Tainted);
|
Assert.True(parser.Tainted);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -268,7 +278,7 @@ namespace VAR.Json.Tests
|
|||||||
public void Parse__Validity_Fail19()
|
public void Parse__Validity_Fail19()
|
||||||
{
|
{
|
||||||
JsonParser parser = new JsonParser();
|
JsonParser parser = new JsonParser();
|
||||||
object result = parser.Parse(@"{""Missing colon"" null}");
|
parser.Parse(@"{""Missing colon"" null}");
|
||||||
Assert.True(parser.Tainted);
|
Assert.True(parser.Tainted);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -276,7 +286,7 @@ namespace VAR.Json.Tests
|
|||||||
public void Parse__Validity_Fail20()
|
public void Parse__Validity_Fail20()
|
||||||
{
|
{
|
||||||
JsonParser parser = new JsonParser();
|
JsonParser parser = new JsonParser();
|
||||||
object result = parser.Parse(@"{""Double colon"":: null}");
|
parser.Parse(@"{""Double colon"":: null}");
|
||||||
Assert.True(parser.Tainted);
|
Assert.True(parser.Tainted);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -284,7 +294,7 @@ namespace VAR.Json.Tests
|
|||||||
public void Parse__Validity_Fail21()
|
public void Parse__Validity_Fail21()
|
||||||
{
|
{
|
||||||
JsonParser parser = new JsonParser();
|
JsonParser parser = new JsonParser();
|
||||||
object result = parser.Parse(@"{""Comma instead of colon"", null}");
|
parser.Parse(@"{""Comma instead of colon"", null}");
|
||||||
Assert.True(parser.Tainted);
|
Assert.True(parser.Tainted);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -292,7 +302,7 @@ namespace VAR.Json.Tests
|
|||||||
public void Parse__Validity_Fail22()
|
public void Parse__Validity_Fail22()
|
||||||
{
|
{
|
||||||
JsonParser parser = new JsonParser();
|
JsonParser parser = new JsonParser();
|
||||||
object result = parser.Parse(@"[""Colon instead of comma"": false]");
|
parser.Parse(@"[""Colon instead of comma"": false]");
|
||||||
Assert.True(parser.Tainted);
|
Assert.True(parser.Tainted);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -300,7 +310,7 @@ namespace VAR.Json.Tests
|
|||||||
public void Parse__Validity_Fail23()
|
public void Parse__Validity_Fail23()
|
||||||
{
|
{
|
||||||
JsonParser parser = new JsonParser();
|
JsonParser parser = new JsonParser();
|
||||||
object result = parser.Parse(@"[""Bad value"", truth]");
|
parser.Parse(@"[""Bad value"", truth]");
|
||||||
Assert.True(parser.Tainted);
|
Assert.True(parser.Tainted);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -308,7 +318,7 @@ namespace VAR.Json.Tests
|
|||||||
public void Parse__Validity_Fail24()
|
public void Parse__Validity_Fail24()
|
||||||
{
|
{
|
||||||
JsonParser parser = new JsonParser();
|
JsonParser parser = new JsonParser();
|
||||||
object result = parser.Parse(@"['single quote']");
|
parser.Parse(@"['single quote']");
|
||||||
Assert.True(parser.Tainted);
|
Assert.True(parser.Tainted);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -316,7 +326,7 @@ namespace VAR.Json.Tests
|
|||||||
public void Parse__Validity_Fail25()
|
public void Parse__Validity_Fail25()
|
||||||
{
|
{
|
||||||
JsonParser parser = new JsonParser();
|
JsonParser parser = new JsonParser();
|
||||||
object result = parser.Parse(@"["" tab character in string ""]");
|
parser.Parse(@"["" tab character in string ""]");
|
||||||
Assert.True(parser.Tainted);
|
Assert.True(parser.Tainted);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -324,7 +334,7 @@ namespace VAR.Json.Tests
|
|||||||
public void Parse__Validity_Fail26()
|
public void Parse__Validity_Fail26()
|
||||||
{
|
{
|
||||||
JsonParser parser = new JsonParser();
|
JsonParser parser = new JsonParser();
|
||||||
object result = parser.Parse(@"[""tab\ character\ in\ string\ ""]");
|
parser.Parse(@"[""tab\ character\ in\ string\ ""]");
|
||||||
Assert.True(parser.Tainted);
|
Assert.True(parser.Tainted);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -332,7 +342,7 @@ namespace VAR.Json.Tests
|
|||||||
public void Parse__Validity_Fail27()
|
public void Parse__Validity_Fail27()
|
||||||
{
|
{
|
||||||
JsonParser parser = new JsonParser();
|
JsonParser parser = new JsonParser();
|
||||||
object result = parser.Parse(@"[""line
|
parser.Parse(@"[""line
|
||||||
break""]");
|
break""]");
|
||||||
Assert.True(parser.Tainted);
|
Assert.True(parser.Tainted);
|
||||||
}
|
}
|
||||||
@@ -341,7 +351,7 @@ break""]");
|
|||||||
public void Parse__Validity_Fail28()
|
public void Parse__Validity_Fail28()
|
||||||
{
|
{
|
||||||
JsonParser parser = new JsonParser();
|
JsonParser parser = new JsonParser();
|
||||||
object result = parser.Parse(@"[""line\
|
parser.Parse(@"[""line\
|
||||||
break""]");
|
break""]");
|
||||||
Assert.True(parser.Tainted);
|
Assert.True(parser.Tainted);
|
||||||
}
|
}
|
||||||
@@ -350,7 +360,7 @@ break""]");
|
|||||||
public void Parse__Validity_Fail29()
|
public void Parse__Validity_Fail29()
|
||||||
{
|
{
|
||||||
JsonParser parser = new JsonParser();
|
JsonParser parser = new JsonParser();
|
||||||
object result = parser.Parse(@"[0e]");
|
parser.Parse(@"[0e]");
|
||||||
Assert.True(parser.Tainted);
|
Assert.True(parser.Tainted);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -358,7 +368,7 @@ break""]");
|
|||||||
public void Parse__Validity_Fail30()
|
public void Parse__Validity_Fail30()
|
||||||
{
|
{
|
||||||
JsonParser parser = new JsonParser();
|
JsonParser parser = new JsonParser();
|
||||||
object result = parser.Parse(@"[0e+]");
|
parser.Parse(@"[0e+]");
|
||||||
Assert.True(parser.Tainted);
|
Assert.True(parser.Tainted);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -366,7 +376,7 @@ break""]");
|
|||||||
public void Parse__Validity_Fail31()
|
public void Parse__Validity_Fail31()
|
||||||
{
|
{
|
||||||
JsonParser parser = new JsonParser();
|
JsonParser parser = new JsonParser();
|
||||||
object result = parser.Parse(@"[0e+-1]");
|
parser.Parse(@"[0e+-1]");
|
||||||
Assert.True(parser.Tainted);
|
Assert.True(parser.Tainted);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -374,7 +384,7 @@ break""]");
|
|||||||
public void Parse__Validity_Fail32()
|
public void Parse__Validity_Fail32()
|
||||||
{
|
{
|
||||||
JsonParser parser = new JsonParser();
|
JsonParser parser = new JsonParser();
|
||||||
object result = parser.Parse(@"{""Comma instead if closing brace"": true,");
|
parser.Parse(@"{""Comma instead if closing brace"": true,");
|
||||||
Assert.True(parser.Tainted);
|
Assert.True(parser.Tainted);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -382,7 +392,7 @@ break""]");
|
|||||||
public void Parse__Validity_Fail33()
|
public void Parse__Validity_Fail33()
|
||||||
{
|
{
|
||||||
JsonParser parser = new JsonParser();
|
JsonParser parser = new JsonParser();
|
||||||
object result = parser.Parse(@"[""mismatch""}");
|
parser.Parse(@"[""mismatch""}");
|
||||||
Assert.True(parser.Tainted);
|
Assert.True(parser.Tainted);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -390,7 +400,7 @@ break""]");
|
|||||||
public void Parse__Validity_Pass01()
|
public void Parse__Validity_Pass01()
|
||||||
{
|
{
|
||||||
JsonParser parser = new JsonParser();
|
JsonParser parser = new JsonParser();
|
||||||
object result = parser.Parse(@"[
|
parser.Parse(@"[
|
||||||
""JSON Test Pattern pass1"",
|
""JSON Test Pattern pass1"",
|
||||||
{""object with 1 member"":[""array with 1 element""]},
|
{""object with 1 member"":[""array with 1 element""]},
|
||||||
{},
|
{},
|
||||||
@@ -455,7 +465,7 @@ break""]");
|
|||||||
public void Parse__Validity_Pass02()
|
public void Parse__Validity_Pass02()
|
||||||
{
|
{
|
||||||
JsonParser parser = new JsonParser();
|
JsonParser parser = new JsonParser();
|
||||||
object result = parser.Parse(@"[[[[[[[[[[[[[[[[[[[""Not too deep""]]]]]]]]]]]]]]]]]]]");
|
parser.Parse(@"[[[[[[[[[[[[[[[[[[[""Not too deep""]]]]]]]]]]]]]]]]]]]");
|
||||||
Assert.False(parser.Tainted);
|
Assert.False(parser.Tainted);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -463,7 +473,7 @@ break""]");
|
|||||||
public void Parse__Validity_Pass03()
|
public void Parse__Validity_Pass03()
|
||||||
{
|
{
|
||||||
JsonParser parser = new JsonParser();
|
JsonParser parser = new JsonParser();
|
||||||
object result = parser.Parse(@"{
|
parser.Parse(@"{
|
||||||
""JSON Test Pattern pass3"": {
|
""JSON Test Pattern pass3"": {
|
||||||
""The outermost value"": ""must be an object or array."",
|
""The outermost value"": ""must be an object or array."",
|
||||||
""In this test"": ""It is an object.""
|
""In this test"": ""It is an object.""
|
||||||
|
|||||||
@@ -1,26 +1,26 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net5.0</TargetFramework>
|
<TargetFramework>net5.0</TargetFramework>
|
||||||
|
|
||||||
<IsPackable>false</IsPackable>
|
<IsPackable>false</IsPackable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0" />
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0"/>
|
||||||
<PackageReference Include="xunit" Version="2.4.1" />
|
<PackageReference Include="xunit" Version="2.4.1"/>
|
||||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
|
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="coverlet.collector" Version="3.0.3">
|
<PackageReference Include="coverlet.collector" Version="3.0.3">
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\VAR.Json\VAR.Json.csproj" />
|
<ProjectReference Include="..\VAR.Json\VAR.Json.csproj"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
55
VAR.Json.sln.DotSettings
Normal file
55
VAR.Json.sln.DotSettings
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||||
|
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/BRACES_FOR_IFELSE/@EntryValue">NotRequired</s:String>
|
||||||
|
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/TRAILING_COMMA_IN_MULTILINE_LISTS/@EntryValue">True</s:Boolean>
|
||||||
|
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/TRAILING_COMMA_IN_SINGLELINE_LISTS/@EntryValue">True</s:Boolean>
|
||||||
|
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/EMPTY_BLOCK_STYLE/@EntryValue">TOGETHER_SAME_LINE</s:String>
|
||||||
|
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/KEEP_EXISTING_EMBEDDED_BLOCK_ARRANGEMENT/@EntryValue">True</s:Boolean>
|
||||||
|
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_SIMPLE_EMBEDDED_BLOCK_ON_SAME_LINE/@EntryValue">True</s:Boolean>
|
||||||
|
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SPACE_AFTER_TYPECAST_PARENTHESES/@EntryValue">False</s:Boolean>
|
||||||
|
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SPACE_WITHIN_SINGLE_LINE_ARRAY_INITIALIZER_BRACES/@EntryValue">True</s:Boolean>
|
||||||
|
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/HtmlFormatter/ALLOW_FAR_ALIGNMENT/@EntryValue">True</s:Boolean>
|
||||||
|
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/HtmlFormatter/NormalizeTagNames/@EntryValue">True</s:Boolean>
|
||||||
|
<s:String x:Key="/Default/CodeStyle/CodeFormatting/HtmlFormatter/ProcessingInstructionAttributeIndenting/@EntryValue">OneStep</s:String>
|
||||||
|
<s:String x:Key="/Default/CodeStyle/CodeFormatting/HtmlFormatter/TagAttributeIndenting/@EntryValue">OneStep</s:String>
|
||||||
|
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/HtmlFormatter/TagSpaceBeforeHeaderEnd1/@EntryValue">True</s:Boolean>
|
||||||
|
<s:String x:Key="/Default/CodeStyle/CSharpVarKeywordUsage/ForBuiltInTypes/@EntryValue">UseVarWhenEvident</s:String>
|
||||||
|
<s:String x:Key="/Default/CodeStyle/CSharpVarKeywordUsage/ForOtherTypes/@EntryValue">UseVarWhenEvident</s:String>
|
||||||
|
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=AES/@EntryIndexedValue">AES</s:String>
|
||||||
|
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=AM/@EntryIndexedValue">AM</s:String>
|
||||||
|
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=AUX/@EntryIndexedValue">AUX</s:String>
|
||||||
|
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=CYC/@EntryIndexedValue">CYC</s:String>
|
||||||
|
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=DC/@EntryIndexedValue">DC</s:String>
|
||||||
|
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=DES/@EntryIndexedValue">DES</s:String>
|
||||||
|
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=EPM/@EntryIndexedValue">EPM</s:String>
|
||||||
|
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=GDI/@EntryIndexedValue">GDI</s:String>
|
||||||
|
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=ID/@EntryIndexedValue">ID</s:String>
|
||||||
|
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=IP/@EntryIndexedValue">IP</s:String>
|
||||||
|
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=RECT/@EntryIndexedValue">RECT</s:String>
|
||||||
|
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=RGB/@EntryIndexedValue">RGB</s:String>
|
||||||
|
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=SCART/@EntryIndexedValue">SCART</s:String>
|
||||||
|
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=SPDIF/@EntryIndexedValue">SPDIF</s:String>
|
||||||
|
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=SQL/@EntryIndexedValue">SQL</s:String>
|
||||||
|
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=SRCCOPY/@EntryIndexedValue">SRCCOPY</s:String>
|
||||||
|
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=TCP/@EntryIndexedValue">TCP</s:String>
|
||||||
|
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=URL/@EntryIndexedValue">URL</s:String>
|
||||||
|
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=USB/@EntryIndexedValue">USB</s:String>
|
||||||
|
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=VAR/@EntryIndexedValue">VAR</s:String>
|
||||||
|
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=WMIC/@EntryIndexedValue">WMIC</s:String>
|
||||||
|
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=YRYBY/@EntryIndexedValue">YRYBY</s:String>
|
||||||
|
<s:Boolean x:Key="/Default/CodeStyle/Naming/CSharpNaming/ApplyAutoDetectedRules/@EntryValue">False</s:Boolean>
|
||||||
|
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=Constants/@EntryIndexedValue"><Policy Inspect="True" Prefix="" Suffix="" Style="AaBb_AaBb" /></s:String>
|
||||||
|
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=EnumMember/@EntryIndexedValue"><Policy Inspect="True" Prefix="" Suffix="" Style="AaBb_AaBb"><ExtraRule Prefix="T" Suffix="" Style="AaBb_AaBb" /></Policy></s:String>
|
||||||
|
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=Interfaces/@EntryIndexedValue"><Policy Inspect="True" Prefix="I" Suffix="" Style="AaBb_AaBb" /></s:String>
|
||||||
|
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=LocalConstants/@EntryIndexedValue"><Policy Inspect="True" Prefix="" Suffix="" Style="AaBb_AaBb" /></s:String>
|
||||||
|
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=Locals/@EntryIndexedValue"><Policy Inspect="True" Prefix="" Suffix="" Style="aaBb_AaBb" /></s:String>
|
||||||
|
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=Method/@EntryIndexedValue"><Policy Inspect="True" Prefix="" Suffix="" Style="AaBb_AaBb" /></s:String>
|
||||||
|
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=Parameters/@EntryIndexedValue"><Policy Inspect="True" Prefix="" Suffix="" Style="aaBb_AaBb" /></s:String>
|
||||||
|
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateConstants/@EntryIndexedValue"><Policy Inspect="True" Prefix="" Suffix="" Style="AaBb_AaBb" /></s:String>
|
||||||
|
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateInstanceFields/@EntryIndexedValue"><Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb_AaBb" /></s:String>
|
||||||
|
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateStaticFields/@EntryIndexedValue"><Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb_AaBb" /></s:String>
|
||||||
|
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateStaticReadonly/@EntryIndexedValue"><Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb_AaBb" /></s:String>
|
||||||
|
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=Property/@EntryIndexedValue"><Policy Inspect="True" Prefix="" Suffix="" Style="AaBb_AaBb" /></s:String>
|
||||||
|
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PublicFields/@EntryIndexedValue"><Policy Inspect="True" Prefix="" Suffix="" Style="AaBb_AaBb" /></s:String>
|
||||||
|
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=StaticReadonly/@EntryIndexedValue"><Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /></s:String>
|
||||||
|
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=TypesAndNamespaces/@EntryIndexedValue"><Policy Inspect="True" Prefix="" Suffix="" Style="AaBb_AaBb" /></s:String>
|
||||||
|
</wpf:ResourceDictionary>
|
||||||
@@ -13,7 +13,7 @@ namespace VAR.Json
|
|||||||
private const int MaxRecursiveCount = 20;
|
private const int MaxRecursiveCount = 20;
|
||||||
|
|
||||||
private ParserContext _ctx;
|
private ParserContext _ctx;
|
||||||
private bool _tainted = false;
|
private bool _tainted;
|
||||||
|
|
||||||
private readonly List<Type> _knownTypes = new List<Type>();
|
private readonly List<Type> _knownTypes = new List<Type>();
|
||||||
|
|
||||||
@@ -21,38 +21,31 @@ namespace VAR.Json
|
|||||||
|
|
||||||
#region Properties
|
#region Properties
|
||||||
|
|
||||||
public bool Tainted
|
public bool Tainted => _tainted;
|
||||||
{
|
|
||||||
get { return _tainted; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Type> KnownTypes
|
public List<Type> KnownTypes => _knownTypes;
|
||||||
{
|
|
||||||
get { return _knownTypes; }
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion Properties
|
#endregion Properties
|
||||||
|
|
||||||
#region Private methods
|
#region Private methods
|
||||||
|
|
||||||
private static readonly Dictionary<Type, PropertyInfo[]> _dictProperties = new Dictionary<Type, PropertyInfo[]>();
|
private static readonly Dictionary<Type, PropertyInfo[]> _dictProperties =
|
||||||
|
new Dictionary<Type, PropertyInfo[]>();
|
||||||
|
|
||||||
private PropertyInfo[] Type_GetProperties(Type type)
|
private PropertyInfo[] Type_GetProperties(Type type)
|
||||||
{
|
{
|
||||||
PropertyInfo[] typeProperties = null;
|
PropertyInfo[] typeProperties;
|
||||||
if (_dictProperties.ContainsKey(type)) { typeProperties = _dictProperties[type]; }
|
lock (_dictProperties)
|
||||||
else
|
|
||||||
{
|
{
|
||||||
lock (_dictProperties)
|
if (_dictProperties.ContainsKey(type)) { typeProperties = _dictProperties[type]; }
|
||||||
|
else
|
||||||
{
|
{
|
||||||
if (_dictProperties.ContainsKey(type)) { typeProperties = _dictProperties[type]; }
|
typeProperties = type.GetProperties(BindingFlags.Public | BindingFlags.OptionalParamBinding |
|
||||||
else
|
BindingFlags.Instance);
|
||||||
{
|
_dictProperties.Add(type, typeProperties);
|
||||||
typeProperties = type.GetProperties(BindingFlags.Public | BindingFlags.OptionalParamBinding | BindingFlags.Instance);
|
|
||||||
_dictProperties.Add(type, typeProperties);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return typeProperties;
|
return typeProperties;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,7 +60,8 @@ namespace VAR.Json
|
|||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ((float)count / (float)typeProperties.Length);
|
|
||||||
|
return count / (float)typeProperties.Length;
|
||||||
}
|
}
|
||||||
|
|
||||||
private object ConvertToType(Dictionary<string, object> obj, Type type)
|
private object ConvertToType(Dictionary<string, object> obj, Type type)
|
||||||
@@ -86,9 +80,9 @@ namespace VAR.Json
|
|||||||
{
|
{
|
||||||
valueDest = null;
|
valueDest = null;
|
||||||
}
|
}
|
||||||
else if (effectiveType == typeof(Guid) && valueOrig is string)
|
else if (effectiveType == typeof(Guid) && valueOrig is string valGuid)
|
||||||
{
|
{
|
||||||
valueDest = new Guid((string)valueOrig);
|
valueDest = new Guid(valGuid);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -101,9 +95,11 @@ namespace VAR.Json
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
prop.SetValue(newObj, valueDest, null);
|
prop.SetValue(newObj, valueDest, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return newObj;
|
return newObj;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -120,6 +116,7 @@ namespace VAR.Json
|
|||||||
bestMatchFactor = matchFactor;
|
bestMatchFactor = matchFactor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bestMatch != null)
|
if (bestMatch != null)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -127,8 +124,12 @@ namespace VAR.Json
|
|||||||
object newObj = ConvertToType(obj, bestMatch);
|
object newObj = ConvertToType(obj, bestMatch);
|
||||||
return newObj;
|
return newObj;
|
||||||
}
|
}
|
||||||
catch (Exception) { } /* Nom Nom */
|
catch (Exception)
|
||||||
|
{
|
||||||
|
// ignored
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -151,6 +152,7 @@ namespace VAR.Json
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -162,6 +164,7 @@ namespace VAR.Json
|
|||||||
{
|
{
|
||||||
c = _ctx.Next();
|
c = _ctx.Next();
|
||||||
}
|
}
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if (c == '\\')
|
if (c == '\\')
|
||||||
@@ -208,6 +211,7 @@ namespace VAR.Json
|
|||||||
// StrictRules: Mark as tainted on unknown escaped character
|
// StrictRules: Mark as tainted on unknown escaped character
|
||||||
_tainted = true;
|
_tainted = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
c = _ctx.Next();
|
c = _ctx.Next();
|
||||||
}
|
}
|
||||||
else if (c == '"')
|
else if (c == '"')
|
||||||
@@ -217,13 +221,14 @@ namespace VAR.Json
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// StrictRules: Mark as tainted on ilegal characters
|
// StrictRules: Mark as tainted on illegal characters
|
||||||
if (c == '\t' || c == '\n') { _tainted = true; }
|
if (c == '\t' || c == '\n') { _tainted = true; }
|
||||||
|
|
||||||
scratch.Append(c);
|
scratch.Append(c);
|
||||||
c = _ctx.Next();
|
c = _ctx.Next();
|
||||||
}
|
}
|
||||||
} while (!_ctx.AtEnd());
|
} while (!_ctx.AtEnd());
|
||||||
|
|
||||||
return scratch.ToString();
|
return scratch.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -235,6 +240,7 @@ namespace VAR.Json
|
|||||||
{
|
{
|
||||||
c = _ctx.Next();
|
c = _ctx.Next();
|
||||||
}
|
}
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if (c == '\\')
|
if (c == '\\')
|
||||||
@@ -281,6 +287,7 @@ namespace VAR.Json
|
|||||||
// StrictRules: Mark as tainted on unknown escaped character
|
// StrictRules: Mark as tainted on unknown escaped character
|
||||||
_tainted = true;
|
_tainted = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
c = _ctx.Next();
|
c = _ctx.Next();
|
||||||
}
|
}
|
||||||
else if (c == '\'')
|
else if (c == '\'')
|
||||||
@@ -290,13 +297,14 @@ namespace VAR.Json
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// StrictRules: Mark as tainted on ilegal characters
|
// StrictRules: Mark as tainted on illegal characters
|
||||||
if (c == '\t' || c == '\n') { _tainted = true; }
|
if (c == '\t' || c == '\n') { _tainted = true; }
|
||||||
|
|
||||||
scratch.Append(c);
|
scratch.Append(c);
|
||||||
c = _ctx.Next();
|
c = _ctx.Next();
|
||||||
}
|
}
|
||||||
} while (!_ctx.AtEnd());
|
} while (!_ctx.AtEnd());
|
||||||
|
|
||||||
return scratch.ToString();
|
return scratch.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -307,16 +315,19 @@ namespace VAR.Json
|
|||||||
{
|
{
|
||||||
return ParseQuotedString();
|
return ParseQuotedString();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (c == '\'')
|
if (c == '\'')
|
||||||
{
|
{
|
||||||
_tainted = true;
|
_tainted = true;
|
||||||
return ParseSingleQuotedString();
|
return ParseSingleQuotedString();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mustBeQuoted) { _tainted = true; }
|
if (mustBeQuoted) { _tainted = true; }
|
||||||
|
|
||||||
StringBuilder scratch = new StringBuilder();
|
StringBuilder scratch = new StringBuilder();
|
||||||
|
|
||||||
while (!_ctx.AtEnd()
|
while (!_ctx.AtEnd()
|
||||||
&& (char.IsLetter(c) || char.IsDigit(c) || c == '_'))
|
&& (char.IsLetter(c) || char.IsDigit(c) || c == '_'))
|
||||||
{
|
{
|
||||||
scratch.Append(c);
|
scratch.Append(c);
|
||||||
c = _ctx.Next();
|
c = _ctx.Next();
|
||||||
@@ -332,8 +343,7 @@ namespace VAR.Json
|
|||||||
bool isExp = false;
|
bool isExp = false;
|
||||||
int numberLenght = 0;
|
int numberLenght = 0;
|
||||||
int expLenght = 0;
|
int expLenght = 0;
|
||||||
char c;
|
char c = _ctx.SkipWhite();
|
||||||
c = _ctx.SkipWhite();
|
|
||||||
|
|
||||||
// Sign
|
// Sign
|
||||||
if (c == '-')
|
if (c == '-')
|
||||||
@@ -394,6 +404,7 @@ namespace VAR.Json
|
|||||||
scratch.Append(c);
|
scratch.Append(c);
|
||||||
c = _ctx.Next();
|
c = _ctx.Next();
|
||||||
}
|
}
|
||||||
|
|
||||||
while (char.IsDigit(c))
|
while (char.IsDigit(c))
|
||||||
{
|
{
|
||||||
scratch.Append(c);
|
scratch.Append(c);
|
||||||
@@ -443,6 +454,7 @@ namespace VAR.Json
|
|||||||
{
|
{
|
||||||
_ctx.Next();
|
_ctx.Next();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool? expectValue = null;
|
bool? expectValue = null;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
@@ -451,6 +463,7 @@ namespace VAR.Json
|
|||||||
{
|
{
|
||||||
// StrictRules: Mark as tainted when unexpected end of array
|
// StrictRules: Mark as tainted when unexpected end of array
|
||||||
if (expectValue == true) { _tainted = true; }
|
if (expectValue == true) { _tainted = true; }
|
||||||
|
|
||||||
correct = true;
|
correct = true;
|
||||||
_ctx.Next();
|
_ctx.Next();
|
||||||
break;
|
break;
|
||||||
@@ -467,6 +480,7 @@ namespace VAR.Json
|
|||||||
{
|
{
|
||||||
// StrictRules: Mark as tainted when unexpected value on array
|
// StrictRules: Mark as tainted when unexpected value on array
|
||||||
if (expectValue == false) { _tainted = true; }
|
if (expectValue == false) { _tainted = true; }
|
||||||
|
|
||||||
object value = ParseValue(recursiveCount + 1);
|
object value = ParseValue(recursiveCount + 1);
|
||||||
array.Add(value);
|
array.Add(value);
|
||||||
expectValue = false;
|
expectValue = false;
|
||||||
@@ -475,6 +489,7 @@ namespace VAR.Json
|
|||||||
{
|
{
|
||||||
Type valueType = value?.GetType();
|
Type valueType = value?.GetType();
|
||||||
if (valueType == null) { hasNulls = true; }
|
if (valueType == null) { hasNulls = true; }
|
||||||
|
|
||||||
if (arrayContentType == null || arrayContentType == valueType)
|
if (arrayContentType == null || arrayContentType == valueType)
|
||||||
{
|
{
|
||||||
arrayContentType = valueType;
|
arrayContentType = valueType;
|
||||||
@@ -486,21 +501,24 @@ namespace VAR.Json
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while (!_ctx.AtEnd());
|
} while (!_ctx.AtEnd());
|
||||||
|
|
||||||
if (correct == false)
|
if (correct == false)
|
||||||
{
|
{
|
||||||
_tainted = true;
|
_tainted = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
object result = array;
|
object result = array;
|
||||||
bool isNullableType = arrayContentType?.IsClass == true;
|
bool isNullableType = arrayContentType?.IsClass == true;
|
||||||
if (hasSameType && arrayContentType != null && (isNullableType == true || (isNullableType == false && hasNulls == false)))
|
if (hasSameType && arrayContentType != null && (isNullableType || (hasNulls == false)))
|
||||||
{
|
{
|
||||||
var enumerableType = typeof(System.Linq.Enumerable);
|
var enumerableType = typeof(System.Linq.Enumerable);
|
||||||
var castMethod = enumerableType.GetMethod("Cast").MakeGenericMethod(arrayContentType);
|
var castMethod = enumerableType.GetMethod("Cast")?.MakeGenericMethod(arrayContentType);
|
||||||
var toListMethod = enumerableType.GetMethod("ToList").MakeGenericMethod(arrayContentType);
|
var toListMethod = enumerableType.GetMethod("ToList")?.MakeGenericMethod(arrayContentType);
|
||||||
IEnumerable<object> itemsToCast = array;
|
IEnumerable<object> itemsToCast = array;
|
||||||
var castedItems = castMethod.Invoke(null, new[] { itemsToCast });
|
var castedItems = castMethod?.Invoke(null, new object[] { itemsToCast });
|
||||||
result = toListMethod.Invoke(null, new[] { castedItems });
|
result = toListMethod?.Invoke(null, new[] { castedItems });
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -516,8 +534,8 @@ namespace VAR.Json
|
|||||||
{
|
{
|
||||||
_ctx.Next();
|
_ctx.Next();
|
||||||
}
|
}
|
||||||
|
|
||||||
string attributeName = null;
|
string attributeName = null;
|
||||||
object attributeValue;
|
|
||||||
bool? expectedKey = null;
|
bool? expectedKey = null;
|
||||||
bool? expectedValue = null;
|
bool? expectedValue = null;
|
||||||
do
|
do
|
||||||
@@ -528,7 +546,7 @@ namespace VAR.Json
|
|||||||
_ctx.Next();
|
_ctx.Next();
|
||||||
if (expectedValue == true)
|
if (expectedValue == true)
|
||||||
{
|
{
|
||||||
attributeValue = ParseValue(recursiveCount + 1);
|
object attributeValue = ParseValue(recursiveCount + 1);
|
||||||
obj.Add(attributeName, attributeValue);
|
obj.Add(attributeName, attributeValue);
|
||||||
expectedKey = null;
|
expectedKey = null;
|
||||||
expectedValue = false;
|
expectedValue = false;
|
||||||
@@ -548,6 +566,7 @@ namespace VAR.Json
|
|||||||
{
|
{
|
||||||
_tainted = true;
|
_tainted = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
correct = true;
|
correct = true;
|
||||||
_ctx.Next();
|
_ctx.Next();
|
||||||
break;
|
break;
|
||||||
@@ -569,15 +588,17 @@ namespace VAR.Json
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while (!_ctx.AtEnd());
|
} while (!_ctx.AtEnd());
|
||||||
|
|
||||||
if (correct == false)
|
if (correct == false)
|
||||||
{
|
{
|
||||||
_tainted = true;
|
_tainted = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
object result = TryConvertToTypes(obj);
|
object result = TryConvertToTypes(obj);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private object ParseValue(int recusiveCount = 1)
|
private object ParseValue(int recursiveCount = 1)
|
||||||
{
|
{
|
||||||
char c = _ctx.SkipWhite();
|
char c = _ctx.SkipWhite();
|
||||||
object token;
|
object token;
|
||||||
@@ -594,11 +615,11 @@ namespace VAR.Json
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case '{':
|
case '{':
|
||||||
token = ParseObject(recusiveCount);
|
token = ParseObject(recursiveCount);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '[':
|
case '[':
|
||||||
token = ParseArray(recusiveCount);
|
token = ParseArray(recursiveCount);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -609,15 +630,15 @@ namespace VAR.Json
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
string aux = ParseString();
|
string aux = ParseString();
|
||||||
if (aux.CompareTo("true") == 0)
|
if (aux.Equals("true"))
|
||||||
{
|
{
|
||||||
token = true;
|
token = true;
|
||||||
}
|
}
|
||||||
else if (aux.CompareTo("false") == 0)
|
else if (aux.Equals("false"))
|
||||||
{
|
{
|
||||||
token = false;
|
token = false;
|
||||||
}
|
}
|
||||||
else if (aux.CompareTo("null") == 0)
|
else if (aux.Equals("null"))
|
||||||
{
|
{
|
||||||
token = null;
|
token = null;
|
||||||
}
|
}
|
||||||
@@ -628,12 +649,15 @@ namespace VAR.Json
|
|||||||
{
|
{
|
||||||
_ctx.Next();
|
_ctx.Next();
|
||||||
}
|
}
|
||||||
|
|
||||||
_tainted = true;
|
_tainted = true;
|
||||||
token = null;
|
token = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return token;
|
return token;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -666,7 +690,7 @@ namespace VAR.Json
|
|||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static JsonParser _currentInstance = null;
|
private static JsonParser _currentInstance;
|
||||||
|
|
||||||
public static object ParseText(string text, params Type[] knownTypes)
|
public static object ParseText(string text, params Type[] knownTypes)
|
||||||
{
|
{
|
||||||
@@ -674,6 +698,7 @@ namespace VAR.Json
|
|||||||
{
|
{
|
||||||
_currentInstance = new JsonParser();
|
_currentInstance = new JsonParser();
|
||||||
}
|
}
|
||||||
|
|
||||||
_currentInstance.KnownTypes.Clear();
|
_currentInstance.KnownTypes.Clear();
|
||||||
_currentInstance.KnownTypes.AddRange(knownTypes);
|
_currentInstance.KnownTypes.AddRange(knownTypes);
|
||||||
return _currentInstance.Parse(text);
|
return _currentInstance.Parse(text);
|
||||||
|
|||||||
@@ -2,34 +2,39 @@
|
|||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
|
||||||
namespace VAR.Json
|
namespace VAR.Json
|
||||||
{
|
{
|
||||||
public class JsonWriterConfiguration
|
public class JsonWriterConfiguration
|
||||||
{
|
{
|
||||||
private bool _indent;
|
private readonly bool _indent;
|
||||||
public bool Indent { get { return _indent; } }
|
|
||||||
|
|
||||||
private bool _useTabForIndent;
|
public bool Indent => _indent;
|
||||||
public bool UseTabForIndent { get { return _useTabForIndent; } }
|
|
||||||
|
|
||||||
private int _indentChars;
|
private readonly bool _useTabForIndent;
|
||||||
public int IndentChars { get { return _indentChars; } }
|
|
||||||
|
|
||||||
private int _indentThresold;
|
public bool UseTabForIndent => _useTabForIndent;
|
||||||
public int IndentThresold { get { return _indentThresold; } }
|
|
||||||
|
private readonly int _indentChars;
|
||||||
|
|
||||||
|
public int IndentChars => _indentChars;
|
||||||
|
|
||||||
|
private readonly int _indentThreshold;
|
||||||
|
|
||||||
|
public int IndentThreshold => _indentThreshold;
|
||||||
|
|
||||||
public JsonWriterConfiguration(
|
public JsonWriterConfiguration(
|
||||||
bool indent = false,
|
bool indent = false,
|
||||||
bool useTabForIndent = false,
|
bool useTabForIndent = false,
|
||||||
int indentChars = 4,
|
int indentChars = 4,
|
||||||
int indentThresold = 3)
|
int indentThreshold = 3)
|
||||||
{
|
{
|
||||||
_indent = indent;
|
_indent = indent;
|
||||||
_useTabForIndent = useTabForIndent;
|
_useTabForIndent = useTabForIndent;
|
||||||
_indentChars = indentChars;
|
_indentChars = indentChars;
|
||||||
_indentThresold = indentThresold;
|
_indentThreshold = indentThreshold;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Equals(JsonWriterConfiguration other)
|
public bool Equals(JsonWriterConfiguration other)
|
||||||
@@ -38,22 +43,24 @@ namespace VAR.Json
|
|||||||
other.Indent == Indent &&
|
other.Indent == Indent &&
|
||||||
other.UseTabForIndent == UseTabForIndent &&
|
other.UseTabForIndent == UseTabForIndent &&
|
||||||
other.IndentChars == IndentChars &&
|
other.IndentChars == IndentChars &&
|
||||||
other.IndentThresold == IndentThresold &&
|
other.IndentThreshold == IndentThreshold &&
|
||||||
true;
|
true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool Equals(object other)
|
public override bool Equals(object other)
|
||||||
{
|
{
|
||||||
if (other is JsonWriterConfiguration)
|
if (other is JsonWriterConfiguration configuration)
|
||||||
{
|
{
|
||||||
return Equals(other as JsonWriterConfiguration);
|
return Equals(configuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override int GetHashCode()
|
public override int GetHashCode()
|
||||||
{
|
{
|
||||||
return _indent.GetHashCode() ^ _useTabForIndent.GetHashCode() ^ _indentChars.GetHashCode() ^ _indentThresold.GetHashCode();
|
return _indent.GetHashCode() ^ _useTabForIndent.GetHashCode() ^ _indentChars.GetHashCode() ^
|
||||||
|
_indentThreshold.GetHashCode();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,7 +68,7 @@ namespace VAR.Json
|
|||||||
{
|
{
|
||||||
#region Declarations
|
#region Declarations
|
||||||
|
|
||||||
private JsonWriterConfiguration _config = null;
|
private readonly JsonWriterConfiguration _config;
|
||||||
|
|
||||||
#endregion Declarations
|
#endregion Declarations
|
||||||
|
|
||||||
@@ -69,11 +76,7 @@ namespace VAR.Json
|
|||||||
|
|
||||||
public JsonWriter(JsonWriterConfiguration config = null)
|
public JsonWriter(JsonWriterConfiguration config = null)
|
||||||
{
|
{
|
||||||
_config = config;
|
_config = config ?? new JsonWriterConfiguration();
|
||||||
if (_config == null)
|
|
||||||
{
|
|
||||||
_config = new JsonWriterConfiguration();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion Creator
|
#endregion Creator
|
||||||
@@ -86,6 +89,7 @@ namespace VAR.Json
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
(obj is float) ||
|
(obj is float) ||
|
||||||
(obj is double) ||
|
(obj is double) ||
|
||||||
@@ -98,6 +102,7 @@ namespace VAR.Json
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,6 +112,7 @@ namespace VAR.Json
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
textWriter.Write('\n');
|
textWriter.Write('\n');
|
||||||
if (_config.UseTabForIndent)
|
if (_config.UseTabForIndent)
|
||||||
{
|
{
|
||||||
@@ -122,11 +128,10 @@ namespace VAR.Json
|
|||||||
private void WriteString(TextWriter textWriter, string str)
|
private void WriteString(TextWriter textWriter, string str)
|
||||||
{
|
{
|
||||||
textWriter.Write('"');
|
textWriter.Write('"');
|
||||||
char c;
|
|
||||||
int n = str.Length;
|
int n = str.Length;
|
||||||
for (int i = 0; i < n; i++)
|
for (int i = 0; i < n; i++)
|
||||||
{
|
{
|
||||||
c = str[i];
|
char c = str[i];
|
||||||
if (c == '"') { textWriter.Write("\\\""); }
|
if (c == '"') { textWriter.Write("\\\""); }
|
||||||
else if (c == '\\') { textWriter.Write("\\\\"); }
|
else if (c == '\\') { textWriter.Write("\\\\"); }
|
||||||
else if (c == '/') { textWriter.Write("\\/"); }
|
else if (c == '/') { textWriter.Write("\\/"); }
|
||||||
@@ -138,6 +143,7 @@ namespace VAR.Json
|
|||||||
else if (c < 32 || c >= 127) { textWriter.Write("\\u{0:X04}", (int)c); }
|
else if (c < 32 || c >= 127) { textWriter.Write("\\u{0:X04}", (int)c); }
|
||||||
else { textWriter.Write(c); }
|
else { textWriter.Write(c); }
|
||||||
}
|
}
|
||||||
|
|
||||||
textWriter.Write('"');
|
textWriter.Write('"');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,43 +165,41 @@ namespace VAR.Json
|
|||||||
// Numbers
|
// Numbers
|
||||||
textWriter.Write(obj.ToString());
|
textWriter.Write(obj.ToString());
|
||||||
}
|
}
|
||||||
else if (obj is string)
|
|
||||||
{
|
|
||||||
// Strings
|
|
||||||
WriteString(textWriter, (string)obj);
|
|
||||||
}
|
|
||||||
else if (obj is bool)
|
|
||||||
{
|
|
||||||
// Booleans
|
|
||||||
textWriter.Write(((bool)obj) ? "true" : "false");
|
|
||||||
}
|
|
||||||
else if (obj is DateTime)
|
|
||||||
{
|
|
||||||
// DateTime
|
|
||||||
textWriter.Write('"');
|
|
||||||
textWriter.Write(((DateTime)obj).ToString("yyyy-MM-ddTHH:mm:ss"));
|
|
||||||
textWriter.Write('"');
|
|
||||||
}
|
|
||||||
else if (obj is IDictionary)
|
|
||||||
{
|
|
||||||
// Objects
|
|
||||||
WriteObject(textWriter, obj, parentLevels);
|
|
||||||
}
|
|
||||||
else if (obj is IEnumerable)
|
|
||||||
{
|
|
||||||
// Array/List
|
|
||||||
WriteList(textWriter, obj, parentLevels);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
switch (obj)
|
||||||
// Reflected object
|
{
|
||||||
WriteReflectedObject(textWriter, obj, parentLevels);
|
case string valString:
|
||||||
}
|
// Strings
|
||||||
|
WriteString(textWriter, valString);
|
||||||
|
break;
|
||||||
|
case bool valBool:
|
||||||
|
// Booleans
|
||||||
|
textWriter.Write(valBool ? "true" : "false");
|
||||||
|
break;
|
||||||
|
case DateTime valDateTime:
|
||||||
|
// DateTime
|
||||||
|
textWriter.Write('"');
|
||||||
|
textWriter.Write(valDateTime.ToString("yyyy-MM-ddTHH:mm:ss"));
|
||||||
|
textWriter.Write('"');
|
||||||
|
break;
|
||||||
|
case IDictionary _:
|
||||||
|
// Objects
|
||||||
|
WriteObject(textWriter, obj, parentLevels);
|
||||||
|
break;
|
||||||
|
case IEnumerable _:
|
||||||
|
// Array/List
|
||||||
|
WriteList(textWriter, obj, parentLevels);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
// Reflected object
|
||||||
|
WriteReflectedObject(textWriter, obj, parentLevels);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void WriteList(TextWriter textWriter, object obj, List<object> parentLevels)
|
private void WriteList(TextWriter textWriter, object obj, List<object> parentLevels)
|
||||||
{
|
{
|
||||||
IEnumerable list = (IEnumerable)obj;
|
IEnumerable list = ((IEnumerable)obj).Cast<object>().ToList();
|
||||||
int n = 0;
|
int n = 0;
|
||||||
|
|
||||||
// Check if it is a leaf object
|
// Check if it is a leaf object
|
||||||
@@ -206,6 +210,7 @@ namespace VAR.Json
|
|||||||
{
|
{
|
||||||
isLeaf = false;
|
isLeaf = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
n++;
|
n++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -219,29 +224,33 @@ namespace VAR.Json
|
|||||||
// Write array
|
// Write array
|
||||||
bool first = true;
|
bool first = true;
|
||||||
textWriter.Write("[ ");
|
textWriter.Write("[ ");
|
||||||
if (!isLeaf || n > _config.IndentThresold)
|
if (!isLeaf || n > _config.IndentThreshold)
|
||||||
{
|
{
|
||||||
WriteIndent(textWriter, parentLevels.Count + 1);
|
WriteIndent(textWriter, parentLevels.Count + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (object childObj in list)
|
foreach (object childObj in list)
|
||||||
{
|
{
|
||||||
if (!first)
|
if (!first)
|
||||||
{
|
{
|
||||||
textWriter.Write(", ");
|
textWriter.Write(", ");
|
||||||
if (!isLeaf || n > _config.IndentThresold)
|
if (!isLeaf || n > _config.IndentThreshold)
|
||||||
{
|
{
|
||||||
WriteIndent(textWriter, parentLevels.Count + 1);
|
WriteIndent(textWriter, parentLevels.Count + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
first = false;
|
first = false;
|
||||||
parentLevels.Add(obj);
|
parentLevels.Add(obj);
|
||||||
WriteValue(textWriter, childObj, parentLevels);
|
WriteValue(textWriter, childObj, parentLevels);
|
||||||
parentLevels.Remove(obj);
|
parentLevels.Remove(obj);
|
||||||
}
|
}
|
||||||
if (!isLeaf || n > _config.IndentThresold)
|
|
||||||
|
if (!isLeaf || n > _config.IndentThreshold)
|
||||||
{
|
{
|
||||||
WriteIndent(textWriter, parentLevels.Count);
|
WriteIndent(textWriter, parentLevels.Count);
|
||||||
}
|
}
|
||||||
|
|
||||||
textWriter.Write(" ]");
|
textWriter.Write(" ]");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -271,21 +280,23 @@ namespace VAR.Json
|
|||||||
// Write object
|
// Write object
|
||||||
bool first = true;
|
bool first = true;
|
||||||
textWriter.Write("{ ");
|
textWriter.Write("{ ");
|
||||||
if (!isLeaf || n > _config.IndentThresold)
|
if (!isLeaf || n > _config.IndentThreshold)
|
||||||
{
|
{
|
||||||
WriteIndent(textWriter, parentLevels.Count + 1);
|
WriteIndent(textWriter, parentLevels.Count + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (object key in map.Keys)
|
foreach (object key in map.Keys)
|
||||||
{
|
{
|
||||||
object value = map[key];
|
object value = map[key];
|
||||||
if (!first)
|
if (!first)
|
||||||
{
|
{
|
||||||
textWriter.Write(", ");
|
textWriter.Write(", ");
|
||||||
if (!isLeaf || n > _config.IndentThresold)
|
if (!isLeaf || n > _config.IndentThreshold)
|
||||||
{
|
{
|
||||||
WriteIndent(textWriter, parentLevels.Count + 1);
|
WriteIndent(textWriter, parentLevels.Count + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
first = false;
|
first = false;
|
||||||
WriteString(textWriter, Convert.ToString(key));
|
WriteString(textWriter, Convert.ToString(key));
|
||||||
textWriter.Write(": ");
|
textWriter.Write(": ");
|
||||||
@@ -293,10 +304,12 @@ namespace VAR.Json
|
|||||||
WriteValue(textWriter, value, parentLevels);
|
WriteValue(textWriter, value, parentLevels);
|
||||||
parentLevels.Remove(obj);
|
parentLevels.Remove(obj);
|
||||||
}
|
}
|
||||||
if (!isLeaf || n > _config.IndentThresold)
|
|
||||||
|
if (!isLeaf || n > _config.IndentThreshold)
|
||||||
{
|
{
|
||||||
WriteIndent(textWriter, parentLevels.Count);
|
WriteIndent(textWriter, parentLevels.Count);
|
||||||
}
|
}
|
||||||
|
|
||||||
textWriter.Write(" }");
|
textWriter.Write(" }");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -311,6 +324,7 @@ namespace VAR.Json
|
|||||||
|
|
||||||
properties.Add(property);
|
properties.Add(property);
|
||||||
}
|
}
|
||||||
|
|
||||||
int n = properties.Count;
|
int n = properties.Count;
|
||||||
|
|
||||||
// Empty
|
// Empty
|
||||||
@@ -335,10 +349,11 @@ namespace VAR.Json
|
|||||||
// Write object
|
// Write object
|
||||||
bool first = true;
|
bool first = true;
|
||||||
textWriter.Write("{ ");
|
textWriter.Write("{ ");
|
||||||
if (!isLeaf || n > _config.IndentThresold)
|
if (!isLeaf || n > _config.IndentThreshold)
|
||||||
{
|
{
|
||||||
WriteIndent(textWriter, parentLevels.Count + 1);
|
WriteIndent(textWriter, parentLevels.Count + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (PropertyInfo property in properties)
|
foreach (PropertyInfo property in properties)
|
||||||
{
|
{
|
||||||
object value = null;
|
object value = null;
|
||||||
@@ -348,14 +363,16 @@ namespace VAR.Json
|
|||||||
{
|
{
|
||||||
value = property.GetValue(obj, null);
|
value = property.GetValue(obj, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!first)
|
if (!first)
|
||||||
{
|
{
|
||||||
textWriter.Write(", ");
|
textWriter.Write(", ");
|
||||||
if (!isLeaf || n > _config.IndentThresold)
|
if (!isLeaf || n > _config.IndentThreshold)
|
||||||
{
|
{
|
||||||
WriteIndent(textWriter, parentLevels.Count + 1);
|
WriteIndent(textWriter, parentLevels.Count + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
first = false;
|
first = false;
|
||||||
WriteString(textWriter, property.Name);
|
WriteString(textWriter, property.Name);
|
||||||
textWriter.Write(": ");
|
textWriter.Write(": ");
|
||||||
@@ -368,12 +385,15 @@ namespace VAR.Json
|
|||||||
{
|
{
|
||||||
WriteValue(textWriter, null, parentLevels);
|
WriteValue(textWriter, null, parentLevels);
|
||||||
}
|
}
|
||||||
|
|
||||||
parentLevels.Remove(obj);
|
parentLevels.Remove(obj);
|
||||||
}
|
}
|
||||||
if (!isLeaf || n > _config.IndentThresold)
|
|
||||||
|
if (!isLeaf || n > _config.IndentThreshold)
|
||||||
{
|
{
|
||||||
WriteIndent(textWriter, parentLevels.Count);
|
WriteIndent(textWriter, parentLevels.Count);
|
||||||
}
|
}
|
||||||
|
|
||||||
textWriter.Write(" }");
|
textWriter.Write(" }");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -387,6 +407,7 @@ namespace VAR.Json
|
|||||||
{
|
{
|
||||||
textWriter = new StringWriter();
|
textWriter = new StringWriter();
|
||||||
}
|
}
|
||||||
|
|
||||||
WriteValue(textWriter, obj, new List<object>());
|
WriteValue(textWriter, obj, new List<object>());
|
||||||
return textWriter;
|
return textWriter;
|
||||||
}
|
}
|
||||||
@@ -398,14 +419,15 @@ namespace VAR.Json
|
|||||||
return textWriter.ToString();
|
return textWriter.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Dictionary<JsonWriterConfiguration, JsonWriter> _dictInstances = new Dictionary<JsonWriterConfiguration, JsonWriter>();
|
private static readonly Dictionary<JsonWriterConfiguration, JsonWriter> _dictInstances =
|
||||||
|
new Dictionary<JsonWriterConfiguration, JsonWriter>();
|
||||||
|
|
||||||
public static string WriteObject(object obj,
|
public static string WriteObject(object obj,
|
||||||
JsonWriterConfiguration config = null,
|
JsonWriterConfiguration config = null,
|
||||||
bool indent = false,
|
bool indent = false,
|
||||||
bool useTabForIndent = false,
|
bool useTabForIndent = false,
|
||||||
int indentChars = 4,
|
int indentChars = 4,
|
||||||
int indentThresold = 3)
|
int indentThreshold = 3)
|
||||||
{
|
{
|
||||||
JsonWriter jsonWriter = null;
|
JsonWriter jsonWriter = null;
|
||||||
|
|
||||||
@@ -420,6 +442,7 @@ namespace VAR.Json
|
|||||||
{
|
{
|
||||||
jsonWriter = _dictInstances[config];
|
jsonWriter = _dictInstances[config];
|
||||||
}
|
}
|
||||||
|
|
||||||
return jsonWriter.Write(obj);
|
return jsonWriter.Write(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -429,13 +452,14 @@ namespace VAR.Json
|
|||||||
pair.Key.Indent == indent &&
|
pair.Key.Indent == indent &&
|
||||||
pair.Key.UseTabForIndent == useTabForIndent &&
|
pair.Key.UseTabForIndent == useTabForIndent &&
|
||||||
pair.Key.IndentChars == indentChars &&
|
pair.Key.IndentChars == indentChars &&
|
||||||
pair.Key.IndentThresold == indentThresold &&
|
pair.Key.IndentThreshold == indentThreshold &&
|
||||||
true)
|
true)
|
||||||
{
|
{
|
||||||
jsonWriter = pair.Value;
|
jsonWriter = pair.Value;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (jsonWriter != null)
|
if (jsonWriter != null)
|
||||||
{
|
{
|
||||||
return jsonWriter.Write(obj);
|
return jsonWriter.Write(obj);
|
||||||
@@ -445,7 +469,7 @@ namespace VAR.Json
|
|||||||
indent: indent,
|
indent: indent,
|
||||||
useTabForIndent: useTabForIndent,
|
useTabForIndent: useTabForIndent,
|
||||||
indentChars: indentChars,
|
indentChars: indentChars,
|
||||||
indentThresold: indentThresold);
|
indentThreshold: indentThreshold);
|
||||||
jsonWriter = new JsonWriter(jsonWriterConfiguration);
|
jsonWriter = new JsonWriter(jsonWriterConfiguration);
|
||||||
_dictInstances.Add(jsonWriterConfiguration, jsonWriter);
|
_dictInstances.Add(jsonWriterConfiguration, jsonWriter);
|
||||||
|
|
||||||
|
|||||||
@@ -4,17 +4,12 @@ using System.Linq.Expressions;
|
|||||||
|
|
||||||
namespace VAR.Json
|
namespace VAR.Json
|
||||||
{
|
{
|
||||||
public class ObjectActivator
|
public static class ObjectActivator
|
||||||
{
|
{
|
||||||
private static readonly Dictionary<Type, Func<object>> _creators = new Dictionary<Type, Func<object>>();
|
private static readonly Dictionary<Type, Func<object>> _creators = new Dictionary<Type, Func<object>>();
|
||||||
|
|
||||||
public static Func<object> GetLambdaNew(Type type)
|
private static Func<object> GetLambdaNew(Type type)
|
||||||
{
|
{
|
||||||
if (_creators.ContainsKey(type))
|
|
||||||
{
|
|
||||||
return _creators[type];
|
|
||||||
}
|
|
||||||
|
|
||||||
lock (_creators)
|
lock (_creators)
|
||||||
{
|
{
|
||||||
if (_creators.ContainsKey(type))
|
if (_creators.ContainsKey(type))
|
||||||
@@ -37,4 +32,4 @@ namespace VAR.Json
|
|||||||
return creator();
|
return creator();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,13 +1,11 @@
|
|||||||
using System;
|
namespace VAR.Json
|
||||||
|
|
||||||
namespace VAR.Json
|
|
||||||
{
|
{
|
||||||
public class ParserContext
|
public class ParserContext
|
||||||
{
|
{
|
||||||
#region Declarations
|
#region Declarations
|
||||||
|
|
||||||
private string _text;
|
private readonly string _text;
|
||||||
private int _length;
|
private readonly int _length;
|
||||||
private int _i;
|
private int _i;
|
||||||
private int _markStart;
|
private int _markStart;
|
||||||
|
|
||||||
@@ -33,10 +31,12 @@ namespace VAR.Json
|
|||||||
{
|
{
|
||||||
_i++;
|
_i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (AtEnd())
|
if (AtEnd())
|
||||||
{
|
{
|
||||||
return (char)0;
|
return (char)0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return _text[_i];
|
return _text[_i];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,6 +47,7 @@ namespace VAR.Json
|
|||||||
{
|
{
|
||||||
return (char)0;
|
return (char)0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return _text[_i];
|
return _text[_i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,31 +1,31 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netstandard2.0</TargetFramework>
|
<TargetFramework>netstandard2.0</TargetFramework>
|
||||||
<OutputType>Library</OutputType>
|
<OutputType>Library</OutputType>
|
||||||
<IsPackable>true</IsPackable>
|
<IsPackable>true</IsPackable>
|
||||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<PackageId>VAR.Json</PackageId>
|
<PackageId>VAR.Json</PackageId>
|
||||||
<Title>VAR.Json</Title>
|
<Title>VAR.Json</Title>
|
||||||
<Version>1.2.2</Version>
|
<Version>1.2.2</Version>
|
||||||
<Description>.Net library for JSON parsing</Description>
|
<Description>.Net library for JSON parsing</Description>
|
||||||
<Authors>VAR</Authors>
|
<Authors>VAR</Authors>
|
||||||
<Company>VAR</Company>
|
<Company>VAR</Company>
|
||||||
<Copyright>Copyright © VAR 2016-2021</Copyright>
|
<Copyright>Copyright © VAR 2016-2022</Copyright>
|
||||||
<RequireLicenseAcceptance>false</RequireLicenseAcceptance>
|
<RequireLicenseAcceptance>false</RequireLicenseAcceptance>
|
||||||
<PackageLicenseFile>LICENSE.txt</PackageLicenseFile>
|
<PackageLicenseFile>LICENSE.txt</PackageLicenseFile>
|
||||||
<PackageProjectUrl>https://github.com/Kableado/VAR.Json</PackageProjectUrl>
|
<PackageProjectUrl>https://github.com/Kableado/VAR.Json</PackageProjectUrl>
|
||||||
<PackageTags>JSON;JSON Library</PackageTags>
|
<PackageTags>JSON;JSON Library</PackageTags>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Include="..\LICENSE.txt" Link="LICENSE.txt" Pack="true" PackagePath=""/>
|
<Content Include="..\LICENSE.txt" Link="LICENSE.txt" Pack="true" PackagePath=""/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Target Name="CopyPackage" AfterTargets="Pack">
|
<Target Name="CopyPackage" AfterTargets="Pack">
|
||||||
<Copy
|
<Copy
|
||||||
SourceFiles="$(OutputPath)..\$(PackageId).$(PackageVersion).nupkg"
|
SourceFiles="$(OutputPath)..\$(PackageId).$(PackageVersion).nupkg"
|
||||||
DestinationFolder="Nuget\"
|
DestinationFolder="Nuget\"
|
||||||
/>
|
/>
|
||||||
</Target>
|
</Target>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
Reference in New Issue
Block a user