コード例 #1
0
        public static int RunConvertFile(ConvertOptions convertOptions)
        {
            try
            {
                ToolFormatConversionOptions toolFormatConversionOptions = 0;

                if (convertOptions.PrettyPrint)
                {
                    toolFormatConversionOptions |= ToolFormatConversionOptions.PrettyPrint;
                }
                ;

                if (convertOptions.Force)
                {
                    toolFormatConversionOptions |= ToolFormatConversionOptions.OverwriteExistingOutputFile;
                }
                ;

                new ToolFormatConverter().ConvertToStandardFormat(
                    convertOptions.ToolFormat,
                    convertOptions.InputFilePath,
                    convertOptions.OutputFilePath,
                    toolFormatConversionOptions);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                return(1);
            }

            return(0);
        }
コード例 #2
0
        public static int RunConvertFile(ConvertOptions convertOptions)
        {
            try
            {
                LoggingOptions loggingOptions = LoggingOptions.None;

                if (convertOptions.PrettyPrint)
                {
                    loggingOptions |= LoggingOptions.PrettyPrint;
                }
                ;

                if (convertOptions.Force)
                {
                    loggingOptions |= LoggingOptions.OverwriteExistingOutputFile;
                }
                ;

                if (convertOptions.PersistFileContents)
                {
                    loggingOptions |= LoggingOptions.PersistFileContents;
                }

                if (string.IsNullOrEmpty(convertOptions.OutputFilePath))
                {
                    convertOptions.OutputFilePath = convertOptions.InputFilePath + ".sarif";
                }

                if (convertOptions.ToolFormat.MatchesToolFormat(ToolFormat.PREfast))
                {
                    string sarif = ToolFormatConverter.ConvertPREfastToStandardFormat(convertOptions.InputFilePath);
                    File.WriteAllText(convertOptions.OutputFilePath, sarif);
                }
                else
                {
                    new ToolFormatConverter().ConvertToStandardFormat(
                        convertOptions.ToolFormat,
                        convertOptions.InputFilePath,
                        convertOptions.OutputFilePath,
                        loggingOptions,
                        convertOptions.PluginAssemblyPath);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                return(1);
            }

            return(0);
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: kleopatra999/sarif-sdk
        public static int RunConvertFile(ConvertOptions convertOptions)
        {
            try
            {
                ToolFormatConversionOptions toolFormatConversionOptions = 0;

                if (convertOptions.PrettyPrint)
                {
                    toolFormatConversionOptions |= ToolFormatConversionOptions.PrettyPrint;
                }
                ;

                if (convertOptions.Force)
                {
                    toolFormatConversionOptions |= ToolFormatConversionOptions.OverwriteExistingOutputFile;
                }
                ;

                if (string.IsNullOrEmpty(convertOptions.OutputFilePath))
                {
                    convertOptions.OutputFilePath = convertOptions.InputFilePath + ".sarif";
                }

                if (convertOptions.ToolFormat == ToolFormat.PREfast)
                {
                    string sarif = ToolFormatConverter.ConvertPREfastToStandardFormat(convertOptions.InputFilePath);
                    File.WriteAllText(convertOptions.OutputFilePath, sarif);
                }
                else
                {
                    new ToolFormatConverter().ConvertToStandardFormat(
                        convertOptions.ToolFormat,
                        convertOptions.InputFilePath,
                        convertOptions.OutputFilePath,
                        toolFormatConversionOptions);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                return(1);
            }

            return(0);
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: Microsoft/sarif-sdk
        public static int RunConvertFile(ConvertOptions convertOptions)
        {
            try
            {
                ToolFormatConversionOptions toolFormatConversionOptions = 0;

                if (convertOptions.PrettyPrint)
                {
                    toolFormatConversionOptions |= ToolFormatConversionOptions.PrettyPrint;
                };

                if (convertOptions.Force)
                {
                    toolFormatConversionOptions |= ToolFormatConversionOptions.OverwriteExistingOutputFile;
                };

                if (string.IsNullOrEmpty(convertOptions.OutputFilePath))
                {
                    convertOptions.OutputFilePath = convertOptions.InputFilePath + ".sarif";
                }

                if (convertOptions.ToolFormat == ToolFormat.PREfast)
                {
                    string sarif = ToolFormatConverter.ConvertPREfastToStandardFormat(convertOptions.InputFilePath);
                    File.WriteAllText(convertOptions.OutputFilePath, sarif);
                }
                else
                {
                    new ToolFormatConverter().ConvertToStandardFormat(
                        convertOptions.ToolFormat,
                        convertOptions.InputFilePath,
                        convertOptions.OutputFilePath,
                        toolFormatConversionOptions);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                return 1;
            }

            return 0;
        }