Skip to content
This repository was archived by the owner on Dec 17, 2024. It is now read-only.

Commit df8361c

Browse files
fix: json validation
See merge request Linaro/WindowsPerf/wpa-plugin!20 === ChangeLog === * fix: json validation
1 parent edd38a7 commit df8361c

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

WPAPlugin/WperfProcessingSourceWithSourceParser.cs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@
2929
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3030

3131

32-
using Microsoft.Performance.SDK.Processing;
33-
using NJsonSchema;
3432
using System.Collections.Generic;
3533
using System.IO;
3634
using System.Linq;
35+
using Microsoft.Performance.SDK.Processing;
36+
using NJsonSchema;
3737
using WPAPlugin.Schemas;
3838

3939
namespace WPAPlugin
@@ -64,7 +64,7 @@ public override ProcessingSourceInfo GetAboutInfo()
6464
new ContactInfo
6565
{
6666
Name = "Alaaeddine Chakroun",
67-
EmailAddresses = new[]{ "alaaeddine.chakroun@daydevs.com" }
67+
EmailAddresses = new[] { "alaaeddine.chakroun@daydevs.com" }
6868
},
6969
},
7070
ProjectInfo = new ProjectInfo
@@ -92,6 +92,7 @@ ProcessorOptions options
9292

9393
timelinePathList.Clear();
9494
countingPathList.Clear();
95+
validationCache.Clear();
9596
return new WperfCustomDataProcessorWithSourceParser(
9697
parser,
9798
options,
@@ -100,9 +101,8 @@ ProcessorOptions options
100101
);
101102
}
102103

103-
104-
private static Dictionary<(string, string), bool> validationCache = new Dictionary<(string, string), bool>();
105-
104+
private static Dictionary<(string, string), bool> validationCache =
105+
new Dictionary<(string, string), bool>();
106106

107107
private static bool ValidateJson(string sourcePath, JsonSchemas.Schemas schema)
108108
{
@@ -111,7 +111,8 @@ private static bool ValidateJson(string sourcePath, JsonSchemas.Schemas schema)
111111
{
112112
return validationCache[cacheKey];
113113
}
114-
var parsedSchema = JsonSchema.FromSampleJson(JsonSchemas.GetSchemaByKey(schema));
114+
var selectedSchema = JsonSchemas.GetSchemaByKey(schema);
115+
var parsedSchema = JsonSchema.FromJsonAsync(selectedSchema).Result;
115116
var jsonContent = File.ReadAllText(sourcePath);
116117
var errors = parsedSchema.Validate(jsonContent);
117118

0 commit comments

Comments
 (0)