How to use SarifLog.Save(outputFilePath) to output a sarif file in SARIF v2.1.0 format?
ledung0609 opened this issue · 2 comments
I used sarif sdk to read a sample sarif file (sarif-tutorials\samples\Baseline.sarif) and save it to another one as following simple code :
SarifLog sarifLog = SarifLog.Load(@"Baseline.sarif");
sarifLog.Save(@"mysarif.sarif");
But the result file "mysarif.sarif" that I got is not the same as the original one.
Did I missing something else?Thank you for your information.
Regards,
Le
I think you could use this example, except remove the ContractResolver assignment:
Lines 20 to 29 in 025f64c
Alternatively, call SarifLog.Save(Stream) with a MemoryStream and then reformat that using JSON reader and writer classes.
(Why does SarifLog define public void Save(StreamWriter streamWriter)
? It would be more useful to define public void Save(TextWriter textWriter)
, which would allow StringWriter too.)
@KalleOlaviNiemitalo
Thank you for your suggestion.
After load sarif contents by SarifLog.Load, I used Json.Net to serialize the contents then write to file as your advice.
The result i got is as same as the original one.