/// <summary>Converts a tool log file represented as a stream into the SARIF format.</summary> /// <exception cref="ArgumentNullException">Thrown when one or more required arguments are null.</exception> /// <exception cref="ArgumentException">Thrown when one or more arguments have unsupported or /// illegal values.</exception> /// <param name="toolFormat">The tool format of the input file.</param> /// <param name="inputStream">A stream that contains tool log contents.</param> /// <param name="outputStream">A stream to which the converted output should be written.</param> /// <param name="pluginAssemblyPath">Path to plugin assembly containing converter types.</param> public void ConvertToStandardFormat( string toolFormat, Stream inputStream, IResultLogWriter outputStream, LoggingOptions loggingOptions = LoggingOptions.None, string pluginAssemblyPath = null) { if (inputStream == null) { throw new ArgumentNullException(nameof(inputStream)); } if (outputStream == null) { throw new ArgumentNullException(nameof(outputStream)); } ConverterFactory factory = CreateConverterFactory(pluginAssemblyPath); ToolFileConverterBase converter = factory.CreateConverter(toolFormat); if (converter != null) { converter.Convert(inputStream, outputStream, loggingOptions); } else { throw new ArgumentException("Unrecognized tool specified: " + toolFormat, nameof(toolFormat)); } }
public static ResultLogObjectWriter GetConverterObjects(ToolFileConverterBase converter, byte[] inputData) { var result = new ResultLogObjectWriter(); using (var input = new MemoryStream(inputData)) { converter.Convert(input, result); } return result; }
public static string GetConverterJson(ToolFileConverterBase converter, byte[] inputData) { using (var input = new MemoryStream(inputData)) { using (var output = new StringWriter()) { var json = new JsonTextWriter(output); json.Formatting = Newtonsoft.Json.Formatting.Indented; json.CloseOutput = false; using (var outputWriter = new ResultLogJsonWriter(json)) { converter.Convert(input, outputWriter); } return output.ToString(); } } }
public static ResultLogObjectWriter GetConverterObjects(ToolFileConverterBase converter, string inputData) { return GetConverterObjects(converter, Encoding.UTF8.GetBytes(inputData)); }
public static string GetConverterJson(ToolFileConverterBase converter, string inputData) { return GetConverterJson(converter, Encoding.UTF8.GetBytes(inputData)); }