-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove options from per-target context creation. (#2655)
* Remove options from per-target context creation. * Merge from main.
- Loading branch information
1 parent
2d52c53
commit 36b4792
Showing
9 changed files
with
140 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
|
||
namespace Microsoft.CodeAnalysis.Sarif.Writers | ||
{ | ||
internal class MemoryStreamSarifLogger : SarifLogger | ||
{ | ||
protected StreamWriter writer; | ||
protected bool disposed; | ||
|
||
public MemoryStreamSarifLogger(FilePersistenceOptions logFilePersistenceOptions = FilePersistenceOptions.PrettyPrint, | ||
OptionallyEmittedData dataToInsert = OptionallyEmittedData.None, | ||
OptionallyEmittedData dataToRemove = OptionallyEmittedData.None, | ||
Run run = null, | ||
IEnumerable<string> analysisTargets = null, | ||
IEnumerable<string> invocationTokensToRedact = null, | ||
IEnumerable<string> invocationPropertiesToLog = null, | ||
string defaultFileEncoding = null, | ||
FailureLevelSet levels = null, | ||
ResultKindSet kinds = null, | ||
IEnumerable<string> insertProperties = null) : this(new StreamWriter(new MemoryStream()), | ||
logFilePersistenceOptions, | ||
dataToInsert, | ||
dataToRemove, | ||
run, | ||
analysisTargets, | ||
invocationTokensToRedact, | ||
invocationPropertiesToLog, | ||
defaultFileEncoding, | ||
levels, | ||
kinds, | ||
insertProperties) | ||
{ | ||
} | ||
|
||
internal MemoryStreamSarifLogger(StreamWriter writer, | ||
FilePersistenceOptions logFilePersistenceOptions = FilePersistenceOptions.PrettyPrint, | ||
OptionallyEmittedData dataToInsert = OptionallyEmittedData.None, | ||
OptionallyEmittedData dataToRemove = OptionallyEmittedData.None, | ||
Run run = null, | ||
IEnumerable<string> analysisTargets = null, | ||
IEnumerable<string> invocationTokensToRedact = null, | ||
IEnumerable<string> invocationPropertiesToLog = null, | ||
string defaultFileEncoding = null, | ||
FailureLevelSet levels = null, | ||
ResultKindSet kinds = null, | ||
IEnumerable<string> insertProperties = null) : base(writer, | ||
logFilePersistenceOptions, | ||
dataToInsert, | ||
dataToRemove, | ||
run, | ||
analysisTargets, | ||
invocationTokensToRedact, | ||
invocationPropertiesToLog, | ||
defaultFileEncoding, | ||
closeWriterOnDispose: false, | ||
levels, | ||
kinds, | ||
insertProperties) | ||
{ | ||
if (writer == null) | ||
{ | ||
throw new ArgumentNullException(nameof(writer)); | ||
} | ||
|
||
|
||
this.writer = writer; | ||
this.writer.AutoFlush = true; | ||
} | ||
|
||
public SarifLog ToSarifLog() | ||
{ | ||
if (!this.disposed) | ||
{ | ||
this.Dispose(); | ||
} | ||
|
||
this.writer.BaseStream.Position = 0; | ||
|
||
SarifLog log = SarifLog.Load(this.writer.BaseStream); | ||
return log; | ||
} | ||
|
||
public override void Dispose() | ||
{ | ||
if (this.disposed) | ||
{ | ||
return; | ||
} | ||
|
||
base.Dispose(); | ||
this.writer.Flush(); | ||
|
||
this.disposed = true; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters