public void AddRange(OptionsCollection options) { foreach (var(key, value) in options) { _options.Add(key, value); } }
internal TestParameters( ParseOptions parseOptions = null, CompilationOptions compilationOptions = null, OptionsCollection options = null, OptionsCollection globalOptions = null, object fixProviderData = null, int index = 0, CodeActionPriority?priority = null, bool retainNonFixableDiagnostics = false, bool includeDiagnosticsOutsideSelection = false, string title = null, TestHost testHost = TestHost.InProcess, string workspaceKind = null) { this.parseOptions = parseOptions; this.compilationOptions = compilationOptions; this.options = options; this.globalOptions = globalOptions; this.fixProviderData = fixProviderData; this.index = index; this.priority = priority; this.retainNonFixableDiagnostics = retainNonFixableDiagnostics; this.includeDiagnosticsOutsideSelection = includeDiagnosticsOutsideSelection; this.title = title; this.testHost = testHost; this.workspaceKind = workspaceKind; }
internal TestParameters( ParseOptions parseOptions = null, CompilationOptions compilationOptions = null, OptionsCollection options = null, CodeActionOptions?codeActionOptions = null, IdeAnalyzerOptions?ideAnalyzerOptions = null, object fixProviderData = null, int index = 0, CodeActionPriority?priority = null, bool retainNonFixableDiagnostics = false, bool includeDiagnosticsOutsideSelection = false, string title = null, TestHost testHost = TestHost.InProcess, string workspaceKind = null) { this.parseOptions = parseOptions; this.compilationOptions = compilationOptions; this.options = options; this.codeActionOptions = codeActionOptions ?? CodeActionOptions.Default; #if CODE_STYLE this.ideAnalyzerOptions = ideAnalyzerOptions ?? IdeAnalyzerOptions.CodeStyleDefault; #else this.ideAnalyzerOptions = ideAnalyzerOptions ?? IdeAnalyzerOptions.Default; #endif this.fixProviderData = fixProviderData; this.index = index; this.priority = priority; this.retainNonFixableDiagnostics = retainNonFixableDiagnostics; this.includeDiagnosticsOutsideSelection = includeDiagnosticsOutsideSelection; this.title = title; this.testHost = testHost; this.workspaceKind = workspaceKind; }
private void AddAnalyzerConfigDocumentWithOptions(TestWorkspace workspace, OptionsCollection options) { Debug.Assert(options != null); var analyzerConfigText = GenerateAnalyzerConfigText(options); var newSolution = workspace.CurrentSolution; foreach (var project in workspace.Projects) { Assert.True(PathUtilities.IsAbsolute(project.FilePath)); var projectRootFilePath = PathUtilities.GetPathRoot(project.FilePath); var documentId = DocumentId.CreateNewId(project.Id); newSolution = newSolution.AddAnalyzerConfigDocument( documentId, ".editorconfig", SourceText.From(analyzerConfigText), filePath: Path.Combine(projectRootFilePath, ".editorconfig")); } var applied = workspace.TryApplyChanges(newSolution); Assert.True(applied); return; string GenerateAnalyzerConfigText(OptionsCollection options) { var textBuilder = new StringBuilder(); // Add an auto-generated header at the top so we can skip this file in expected baseline validation. textBuilder.AppendLine(AutoGeneratedAnalyzerConfigHeader); textBuilder.AppendLine(); textBuilder.AppendLine(options.GetEditorConfigText()); return(textBuilder.ToString()); } }
internal Task TestAsync( string initialMarkup, string expectedMarkup, ParseOptions parseOptions, CompilationOptions compilationOptions = null, int index = 0, OptionsCollection options = null, object fixProviderData = null, CodeActionPriority?priority = null, TestHost testHost = TestHost.InProcess ) { return(TestAsync( initialMarkup, expectedMarkup, new TestParameters( parseOptions, compilationOptions, options, fixProviderData, index, priority, testHost: testHost ) )); }
internal TestParameters WithOptions(OptionsCollection options) => new TestParameters( parseOptions, compilationOptions, options, fixProviderData, index, priority, retainNonFixableDiagnostics, includeDiagnosticsOutsideSelection, title, testHost, workspaceKind );
private OptionsCollection GetSingleRequireOption(PerLanguageOption2 <CodeStyleOption2 <ParenthesesPreference> > option) { var optionsCollection = new OptionsCollection(_language); foreach (var o in GetAllParenthesesOptions()) { if (o != option) { optionsCollection.Add(o, RemoveIfUnnecessaryPreference); } } optionsCollection.Add(option, RequireForPrecedenceClarityPreference); return(optionsCollection); }
internal Task TestInRegularAndScriptAsync( string initialMarkup, string expectedMarkup, int index = 0, CodeActionPriority?priority = null, CompilationOptions compilationOptions = null, OptionsCollection options = null, object fixProviderData = null, ParseOptions parseOptions = null, string title = null) { return(TestInRegularAndScript1Async( initialMarkup, expectedMarkup, index, new TestParameters(parseOptions, compilationOptions, options, fixProviderData, index, priority, title: title))); }
internal TestParameters( ParseOptions parseOptions = null, CompilationOptions compilationOptions = null, OptionsCollection options = null, object fixProviderData = null, int index = 0, CodeActionPriority?priority = null, bool retainNonFixableDiagnostics = false, bool includeDiagnosticsOutsideSelection = false, string title = null, bool runProviderOutOfProc = false) { this.parseOptions = parseOptions; this.compilationOptions = compilationOptions; this.options = options; this.fixProviderData = fixProviderData; this.index = index; this.priority = priority; this.retainNonFixableDiagnostics = retainNonFixableDiagnostics; this.includeDiagnosticsOutsideSelection = includeDiagnosticsOutsideSelection; this.title = title; this.runProviderOutOfProc = runProviderOutOfProc; }
// 📝 This can be removed if/when collection initializers support AddRange. public void Add(OptionsCollection options) => AddRange(options);
public SharedVerifierState(AnalyzerTest <XUnitVerifier> test, string defaultFileExt) { _test = test; _defaultFileExt = defaultFileExt; Options = new OptionsCollection(test.Language); }