Ejemplo n.º 1
0
        public static void VerifyNoIssueReported(string path, SonarDiagnosticAnalyzer diagnosticAnalyzer,
                                                 IEnumerable <ParseOptions> options = null, CompilationErrorBehavior checkMode = CompilationErrorBehavior.Default,
                                                 IEnumerable <MetadataReference> additionalReferences = null)
        {
            var projectBuilder = SolutionBuilder.Create()
                                 .AddProject(AnalyzerLanguage.FromPath(path))
                                 .AddReferences(additionalReferences)
                                 .AddDocument(path);


            if (options == null)
            {
                var compilation = projectBuilder.GetCompilation(null);
                DiagnosticVerifier.VerifyNoIssueReported(compilation, diagnosticAnalyzer, checkMode);
            }
            else
            {
                foreach (var option in options)
                {
                    var compilation = projectBuilder.GetCompilation(option);
                    DiagnosticVerifier.VerifyNoIssueReported(compilation, diagnosticAnalyzer, checkMode);
                }
            }
        }