public async Task LoadSarifLogAsync(IEnumerable <Stream> streams) { foreach (Stream stream in streams) { await ErrorListService.ProcessSarifLogAsync(stream, logId : null, cleanErrors : false, openInEditor : false).ConfigureAwait(continueOnCapturedContext: false); } }
public void ErrorListService_ProcessSarifLogAsync_InvalidJson() { // unhook original event handler and hook test event ErrorListService.LogProcessed -= ErrorListService.ErrorListService_LogProcessed; ErrorListService.LogProcessed += ErrorListServiceTest_LogProcessed; // invalid Json syntax, a separate comma in line 4 // {"Invalid property identifier character: ,. Path '$schema', line 4, position 2."} string invalidJson = @" { ""$schema"": ""https://schemastore.azurewebsites.net/schemas/json/sarif-2.1.0-rtm.4.json"", , ""version"": ""2.1.0"", ""runs"": [ { ""tool"": { ""name"": ""CodeScanner"" }, ""results"": [ ] } ] } "; int numberOfException = numberOfExceptionLogged; using var stream = new MemoryStream(Encoding.UTF8.GetBytes(invalidJson)); ErrorListService.ProcessSarifLogAsync(stream, "logId", false, false).ConfigureAwait(false); // 1 exception logged numberOfExceptionLogged.Should().Be(numberOfException + 1); }
public void ErrorListService_ProcessSarifLogAsync_JsonNotCompatibleWithSarifShema() { // unhook original event handler and hook test event ErrorListService.LogProcessed -= ErrorListService.ErrorListService_LogProcessed; ErrorListService.LogProcessed += ErrorListServiceTest_LogProcessed; // valid Json syntax, but not satisfy schema, missing required property driver // {"Required property 'text' not found in JSON. Path 'runs[0].tool.driver.rules[0].fullDescription', line 14, position 36."} string jsonNotCompatible = @" { ""$schema"": ""https://schemastore.azurewebsites.net/schemas/json/sarif-2.1.0-rtm.4.json"", ""version"": ""2.1.0"", ""runs"": [ { ""tool"": { ""driver"": { ""name"": ""CodeScanner"", ""rules"": [ { ""id"": ""Intrafile1001"", ""name"": ""IntrafileRule"", ""fullDescription"": { }, ""helpUri"": ""https://github.com/microsoft/sarif-pattern-matcher"" } ] }, ""results"": [ ] } ] } "; int numberOfException = this.numberOfExceptionLogged; using var stream = new MemoryStream(Encoding.UTF8.GetBytes(jsonNotCompatible)); ErrorListService.ProcessSarifLogAsync(stream, "logId", false, false).ConfigureAwait(false); // 1 exception logged this.numberOfExceptionLogged.Should().Be(numberOfException + 1); }
public static async Task InitializeTestEnvironmentAsync(SarifLog sarifLog, string logFile = "", bool cleanErrors = true) { InitializeTestEnvironment(); await ErrorListService.ProcessSarifLogAsync(sarifLog, logFile, cleanErrors : cleanErrors, openInEditor : false); }
private async Task LoadSarifLogAsync(Stream stream, string logId) { await ErrorListService.ProcessSarifLogAsync(stream, logId : logId, cleanErrors : false, openInEditor : false).ConfigureAwait(continueOnCapturedContext: false); }
public static async Task InitializeTestEnvironmentAsync(SarifLog sarifLog) { InitializeTestEnvironment(); await ErrorListService.ProcessSarifLogAsync(sarifLog, string.Empty, cleanErrors : true, openInEditor : false); }