public static void VerifyCodeFix(string path, string pathToExpected, string pathToBatchExpected, SonarDiagnosticAnalyzer diagnosticAnalyzer, SonarCodeFixProvider codeFixProvider, string codeFixTitle, IEnumerable <ParseOptions> options = null, IEnumerable <MetadataReference> additionalReferences = null) { var parseOptions = options ?? ParseOptionsHelper.GetParseOptionsByFileExtension(Path.GetExtension(path)); foreach (var parseOption in parseOptions) { RunCodeFixWhileDocumentChanges(diagnosticAnalyzer, codeFixProvider, codeFixTitle, CreateDocument(path, additionalReferences), parseOption, pathToExpected); } var fixAllProvider = codeFixProvider.GetFixAllProvider(); if (fixAllProvider == null) { return; } foreach (var parseOption in parseOptions) { RunFixAllProvider(diagnosticAnalyzer, codeFixProvider, codeFixTitle, fixAllProvider, CreateDocument(path, additionalReferences), parseOption, pathToBatchExpected); } }
public static void VerifyCodeFix(string path, string pathToExpected, string pathToBatchExpected, SonarDiagnosticAnalyzer diagnosticAnalyzer, SonarCodeFixProvider codeFixProvider, string codeFixTitle, IEnumerable <ParseOptions> options = null, OutputKind outputKind = OutputKind.DynamicallyLinkedLibrary, IEnumerable <MetadataReference> additionalReferences = null) { var document = CreateDocument(path, outputKind, additionalReferences); var parseOptions = ParseOptionsHelper.GetParseOptionsOrDefault(options) .Where(ParseOptionsHelper.GetFilterByLanguage(document.Project.Language)) .ToArray(); foreach (var parseOption in parseOptions) { RunCodeFixWhileDocumentChanges(diagnosticAnalyzer, codeFixProvider, codeFixTitle, document, parseOption, pathToExpected); } var fixAllProvider = codeFixProvider.GetFixAllProvider(); if (fixAllProvider == null) { return; } foreach (var parseOption in parseOptions) { RunFixAllProvider(diagnosticAnalyzer, codeFixProvider, codeFixTitle, fixAllProvider, document, parseOption, pathToBatchExpected); } }