public static void VerifyNoIssueReportedInTest(string path, SonarDiagnosticAnalyzer diagnosticAnalyzer)
 {
     VerifyNoIssueReported(path, TestAssemblyName, diagnosticAnalyzer);
 }
示例#2
0
 public static void VerifyAnalyzer(string path, SonarDiagnosticAnalyzer diagnosticAnalyzer,
                                   ParseOptions options = null, params AssemblyReference[] additionalReferences)
 {
     VerifyAnalyzer(new[] { path }, diagnosticAnalyzer, null, options, additionalReferences);
 }
示例#3
0
 public static void VerifyAnalyzer(string path, SonarDiagnosticAnalyzer diagnosticAnalyzer,
                                   IEnumerable <ParseOptions> options = null, CompilationErrorBehavior checkMode = CompilationErrorBehavior.Default,
                                   IEnumerable <MetadataReference> additionalReferences = null)
 {
     VerifyAnalyzer(new[] { path }, diagnosticAnalyzer, options, checkMode, additionalReferences);
 }
示例#4
0
 public static void VerifyNoIssueReported(string path, SonarDiagnosticAnalyzer diagnosticAnalyzer, ParseOptions options = null,
                                          params AssemblyReference[] additionalReferences)
 {
     VerifyNoIssueReported(path, GeneratedAssemblyName, diagnosticAnalyzer, additionalReferences, options);
 }
示例#5
0
 public static void VerifyVisualBasicAnalyzer(string snippet, SonarDiagnosticAnalyzer diagnosticAnalyzer,
                                              ParseOptions options = null, params AssemblyReference[] additionalReferences)
 {
     VerifyAnalyzer(new[] { new DocumentInfo($"file1{VisualBasicFileExtension}", snippet) },
                    VisualBasicFileExtension, diagnosticAnalyzer, options, null, additionalReferences);
 }
示例#6
0
        public static void VerifyCodeFix(string path, string pathToExpected, string pathToBatchExpected, SonarDiagnosticAnalyzer diagnosticAnalyzer,
                                         SonarCodeFixProvider codeFixProvider, string codeFixTitle)
        {
            using (var workspace = new AdhocWorkspace())
            {
                var file         = new FileInfo(path);
                var parseOptions = GetParseOptionsWithDifferentLanguageVersions(null, file.Extension);

                foreach (var parseOption in parseOptions)
                {
                    var document = GetDocument(file, GeneratedAssemblyName, workspace, removeAnalysisComments: true);
                    RunCodeFixWhileDocumentChanges(diagnosticAnalyzer, codeFixProvider, codeFixTitle, document, parseOption, pathToExpected);
                }
            }

            VerifyFixAllCodeFix(path, pathToBatchExpected, diagnosticAnalyzer, codeFixProvider, codeFixTitle);
        }
示例#7
0
 public static void VerifyNoIssueReportedInTest(string path, SonarDiagnosticAnalyzer diagnosticAnalyzer,
                                                params AssemblyReference[] additionalReferences)
 {
     VerifyNoIssueReported(path, TestAssemblyName, diagnosticAnalyzer, additionalReferences);
 }
示例#8
0
 public static void VerifyCodeFix(string path, string pathToExpected, string pathToBatchExpected, SonarDiagnosticAnalyzer diagnosticAnalyzer,
                                  SonarCodeFixProvider codeFixProvider)
 {
     VerifyCodeFix(path, pathToExpected, pathToBatchExpected, diagnosticAnalyzer, codeFixProvider, null);
 }
示例#9
0
 public static void VerifyCodeFix(string path, string pathToExpected, SonarDiagnosticAnalyzer diagnosticAnalyzer,
                                  SonarCodeFixProvider codeFixProvider, string codeFixTitle)
 {
     VerifyCodeFix(path, pathToExpected, pathToExpected, diagnosticAnalyzer, codeFixProvider, codeFixTitle);
 }
示例#10
0
 /// <summary>
 /// Verify analyzer from C# 9 with top level statements.
 /// </summary>
 public static void VerifyAnalyzerFromCSharp9Console(string path, SonarDiagnosticAnalyzer diagnosticAnalyzer, IEnumerable <MetadataReference> additionalReferences = null) =>
 VerifyAnalyzer(new[] { path }, diagnosticAnalyzer, ParseOptionsHelper.FromCSharp9, CompilationErrorBehavior.Default, OutputKind.ConsoleApplication, additionalReferences);
示例#11
0
 // This method is checking only the expected issues from the first file path provided. The rest of the paths are added to the
 // project for enabling testing of different scenarios.
 public static void VerifyAnalyzer(IEnumerable <string> paths, SonarDiagnosticAnalyzer diagnosticAnalyzer,
                                   IEnumerable <ParseOptions> options = null, CompilationErrorBehavior checkMode = CompilationErrorBehavior.Default,
                                   OutputKind outputKind = OutputKind.DynamicallyLinkedLibrary,
                                   IEnumerable <MetadataReference> additionalReferences = null) =>
 VerifyAnalyzer(paths, new[] { diagnosticAnalyzer }, options, checkMode, outputKind, additionalReferences);
示例#12
0
 public static void VerifyCodeFix(string path, string pathToExpected,
                                  SonarDiagnosticAnalyzer diagnosticAnalyzer, SonarCodeFixProvider codeFixProvider, string codeFixTitle,
                                  IEnumerable <ParseOptions> options = null, IEnumerable <MetadataReference> additionalReferences = null)
 {
     CodeFixVerifier.VerifyCodeFix(path, pathToExpected, pathToExpected, diagnosticAnalyzer, codeFixProvider, codeFixTitle, options, additionalReferences);
 }
示例#13
0
 public TestSetup(string testCase, SonarDiagnosticAnalyzer analyzer, IEnumerable <MetadataReference> additionalReferences)
 {
     Path                 = System.IO.Path.Combine("TestCases", testCase);
     Analyzer             = analyzer;
     AdditionalReferences = additionalReferences.Concat(MetadataReferenceFacade.SystemComponentModelPrimitives).Concat(NetStandardMetadataReference.Netstandard);
 }
示例#14
0
 public TestSetup(string testCase, SonarDiagnosticAnalyzer analyzer) : this(testCase, analyzer, Enumerable.Empty <MetadataReference>())
 {
 }