public ImmutableArray <AnalyzerConfigOptionsResult> BuildAnalyzerConfigs() { var cmdLineArgs = Helpers.GetReproCommandLineArgs(); var analyzerConfigs = cmdLineArgs.AnalyzerConfigPaths .SelectAsArray(p => AnalyzerConfig.Parse(File.ReadAllText(p), p)); var set = AnalyzerConfigSet.Create(analyzerConfigs); return(cmdLineArgs.SourceFiles .SelectAsArray(s => set.GetOptionsForSourcePath(s.Path))); }
private async Task <SyntaxTreeAnalysisContext> CreateAnalysisContextFromEditorConfigAsync(string editorConfig) { var projectId = ProjectId.CreateNewId(); var documentId = DocumentId.CreateNewId(projectId); var analyzerConfigDocumentId = DocumentId.CreateNewId(projectId); var solution = GenericAnalyzerTest.CreateWorkspace() .CurrentSolution .AddProject(projectId, TestProjectName, TestProjectName, LanguageNames.CSharp) .AddDocument(documentId, "/0/Test0.cs", SourceText.From(string.Empty)) .AddAnalyzerConfigDocument(analyzerConfigDocumentId, "/.editorconfig", SourceText.From(editorConfig), filePath: "/.editorconfig"); var document = solution.GetDocument(documentId); var syntaxTree = await document.GetSyntaxTreeAsync(CancellationToken.None).ConfigureAwait(false); var analyzerConfigSet = AnalyzerConfigSet.Create(new[] { AnalyzerConfig.Parse(SourceText.From(editorConfig), "/.editorconfig") }); var additionalFiles = ImmutableArray <AdditionalText> .Empty; var optionsProvider = this.CreateAnalyzerConfigOptionsProvider(analyzerConfigSet); var analyzerOptions = new AnalyzerOptions(additionalFiles, optionsProvider); return(new SyntaxTreeAnalysisContext(syntaxTree, analyzerOptions, reportDiagnostic: _ => { }, isSupportedDiagnostic: _ => true, CancellationToken.None)); }