public async Task CSharpOutliningTagger(bool collapseRegionsWhenCollapsingToDefinitions) { var code = @"using System; namespace MyNamespace { #region MyRegion public class MyClass { static void Main(string[] args) { int x = 5; } } #endregion }"; using var workspace = TestWorkspace.CreateCSharp( code, composition: EditorTestCompositions.EditorFeaturesWpf ); workspace.TryApplyChanges( workspace.CurrentSolution.WithOptions( workspace.Options.WithChangedOption( BlockStructureOptions.CollapseRegionsWhenCollapsingToDefinitions, LanguageNames.CSharp, collapseRegionsWhenCollapsingToDefinitions ) ) ); var tags = await GetTagsFromWorkspaceAsync(workspace); Assert.Collection( tags, namespaceTag => { Assert.False(namespaceTag.IsImplementation); Assert.Equal(12, GetCollapsedHintLineCount(namespaceTag)); Assert.Equal("namespace MyNamespace", GetHeaderText(namespaceTag)); }, regionTag => { Assert.Equal( collapseRegionsWhenCollapsingToDefinitions, regionTag.IsImplementation ); Assert.Equal(9, GetCollapsedHintLineCount(regionTag)); Assert.Equal("#region MyRegion", GetHeaderText(regionTag)); }, classTag => { Assert.False(classTag.IsImplementation); Assert.Equal(7, GetCollapsedHintLineCount(classTag)); Assert.Equal("public class MyClass", GetHeaderText(classTag)); }, methodTag => { Assert.True(methodTag.IsImplementation); Assert.Equal(4, GetCollapsedHintLineCount(methodTag)); Assert.Equal("static void Main(string[] args)", GetHeaderText(methodTag)); } ); }
protected override TestWorkspace CreateWorkspace(string content, ExportProvider exportProvider) => TestWorkspace.CreateCSharp(content, exportProvider: exportProvider);
internal async Task TestWithMockedGenerateTypeDialog( string initial, string languageName, string typeName, string expected = null, bool isMissing = false, Accessibility accessibility = Accessibility.NotApplicable, TypeKind typeKind = TypeKind.Class, string projectName = null, bool isNewFile = false, string existingFilename = null, ImmutableArray <string> newFileFolderContainers = default, string fullFilePath = null, string newFileName = null, string assertClassName = null, bool checkIfUsingsIncluded = false, bool checkIfUsingsNotIncluded = false, string expectedTextWithUsings = null, string defaultNamespace = "", bool areFoldersValidIdentifiers = true, GenerateTypeDialogOptions assertGenerateTypeDialogOptions = null, IList <TypeKindOptions> assertTypeKindPresent = null, IList <TypeKindOptions> assertTypeKindAbsent = null, bool isCancelled = false) { var workspace = TestWorkspace.IsWorkspaceElement(initial) ? TestWorkspace.Create(initial, composition: s_composition) : languageName == LanguageNames.CSharp ? TestWorkspace.CreateCSharp(initial, composition: s_composition) : TestWorkspace.CreateVisualBasic(initial, composition: s_composition); var testOptions = new TestParameters(); var(diagnostics, actions, _) = await GetDiagnosticAndFixesAsync(workspace, testOptions); using var testState = new GenerateTypeTestState(workspace, projectToBeModified: projectName, typeName, existingFilename); // Initialize the viewModel values testState.TestGenerateTypeOptionsService.SetGenerateTypeOptions( accessibility: accessibility, typeKind: typeKind, typeName: testState.TypeName, project: testState.ProjectToBeModified, isNewFile: isNewFile, newFileName: newFileName, folders: newFileFolderContainers, fullFilePath: fullFilePath, existingDocument: testState.ExistingDocument, areFoldersValidIdentifiers: areFoldersValidIdentifiers, isCancelled: isCancelled); testState.TestProjectManagementService.SetDefaultNamespace( defaultNamespace: defaultNamespace); var generateTypeDiagFixes = diagnostics.SingleOrDefault(df => GenerateTypeTestState.FixIds.Contains(df.Id)); if (isMissing) { Assert.Empty(actions); return; } var fixActions = MassageActions(actions); Assert.False(fixActions.IsDefault); // Since the dialog option is always fed as the last CodeAction var index = fixActions.Count() - 1; var action = fixActions.ElementAt(index); Assert.Equal(action.Title, FeaturesResources.Generate_new_type); var operations = await action.GetOperationsAsync(CancellationToken.None); Tuple <Solution, Solution> oldSolutionAndNewSolution = null; if (!isNewFile) { oldSolutionAndNewSolution = await TestOperationsAsync( testState.Workspace, expected, operations, conflictSpans : ImmutableArray <TextSpan> .Empty, renameSpans : ImmutableArray <TextSpan> .Empty, warningSpans : ImmutableArray <TextSpan> .Empty, navigationSpans : ImmutableArray <TextSpan> .Empty, expectedChangedDocumentId : testState.ExistingDocument.Id); } else { oldSolutionAndNewSolution = await TestAddDocument( testState.Workspace, expected, operations, projectName != null, testState.ProjectToBeModified.Id, newFileFolderContainers, newFileName); } if (checkIfUsingsIncluded) { Assert.NotNull(expectedTextWithUsings); await TestOperationsAsync(testState.Workspace, expectedTextWithUsings, operations, conflictSpans : ImmutableArray <TextSpan> .Empty, renameSpans : ImmutableArray <TextSpan> .Empty, warningSpans : ImmutableArray <TextSpan> .Empty, navigationSpans : ImmutableArray <TextSpan> .Empty, expectedChangedDocumentId : testState.InvocationDocument.Id); } if (checkIfUsingsNotIncluded) { var oldSolution = oldSolutionAndNewSolution.Item1; var newSolution = oldSolutionAndNewSolution.Item2; var changedDocumentIds = SolutionUtilities.GetChangedDocuments(oldSolution, newSolution); Assert.False(changedDocumentIds.Contains(testState.InvocationDocument.Id)); } // Added into a different project than the triggering project if (projectName != null) { var appliedChanges = ApplyOperationsAndGetSolution(testState.Workspace, operations); var newSolution = appliedChanges.Item2; var triggeredProject = newSolution.GetProject(testState.TriggeredProject.Id); // Make sure the Project reference is present Assert.True(triggeredProject.ProjectReferences.Any(pr => pr.ProjectId == testState.ProjectToBeModified.Id)); } // Assert Option Calculation if (assertClassName != null) { Assert.True(assertClassName == testState.TestGenerateTypeOptionsService.ClassName); } if (assertGenerateTypeDialogOptions != null || assertTypeKindPresent != null || assertTypeKindAbsent != null) { var generateTypeDialogOptions = testState.TestGenerateTypeOptionsService.GenerateTypeDialogOptions; if (assertGenerateTypeDialogOptions != null) { Assert.True(assertGenerateTypeDialogOptions.IsPublicOnlyAccessibility == generateTypeDialogOptions.IsPublicOnlyAccessibility); Assert.True(assertGenerateTypeDialogOptions.TypeKindOptions == generateTypeDialogOptions.TypeKindOptions); Assert.True(assertGenerateTypeDialogOptions.IsAttribute == generateTypeDialogOptions.IsAttribute); } if (assertTypeKindPresent != null) { foreach (var typeKindPresentEach in assertTypeKindPresent) { Assert.True((typeKindPresentEach & generateTypeDialogOptions.TypeKindOptions) != 0); } } if (assertTypeKindAbsent != null) { foreach (var typeKindPresentEach in assertTypeKindAbsent) { Assert.True((typeKindPresentEach & generateTypeDialogOptions.TypeKindOptions) == 0); } } } }
public async Task FormatSpansWithCollapsing() { var code = @"class C { public void M() { [|if(true){}|] [|if(true){}|] [|if(true){}|] [|if(true){}|] [|if(true){}|] [|if(true){}|] [|if(true){}|] [|if(true){}|] [|if(true){}|] [|if(true){}|] [|if(true){}|] [|if(true){}|] [|if(true){}|] [|if(true){}|] [|if(true){}|] [|if(true){}|] [|if(true){}|] [|if(true){}|] [|if(true){}|] [|if(true){}|] [|if(true){}|] [|if(true){}|] [|if(true){}|] [|if(true){}|] [|if(true){}|] [|if(true){}|] [|if(true){}|] [|if(true){}|] [|if(true){}|] [|if(true){}|] [|if(true){}|] while(true){} [|if(true){}|] } }"; var expected = @"class C { public void M() { if (true) { } if (true) { } if (true) { } if (true) { } if (true) { } if (true) { } if (true) { } if (true) { } if (true) { } if (true) { } if (true) { } if (true) { } if (true) { } if (true) { } if (true) { } if (true) { } if (true) { } if (true) { } if (true) { } if (true) { } if (true) { } if (true) { } if (true) { } if (true) { } if (true) { } if (true) { } if (true) { } if (true) { } if (true) { } if (true) { } if (true) { } while (true) { } if (true) { } } }"; using (var workspace = TestWorkspace.CreateCSharp(code)) { var subjectDocument = workspace.Documents.Single(); var spans = subjectDocument.SelectedSpans; workspace.Options = workspace.Options.WithChangedOption(FormattingOptions.AllowDisjointSpanMerging, true); var document = workspace.CurrentSolution.Projects.Single().Documents.Single(); var syntaxRoot = await document.GetSyntaxRootAsync(); var node = Formatter.Format(syntaxRoot, spans, workspace); Assert.Equal(expected, node.ToFullString()); } }
protected override TestWorkspace CreateTestWorkspace(string code) => TestWorkspace.CreateCSharp(code);
public async Task ProjectProperties() { using var workspace = TestWorkspace.CreateCSharp("");
private async Task<ImmutableArray<ITagSpan<IErrorTag>>> GetTagSpansAsync(string content) { using var workspace = TestWorkspace.CreateCSharp(content); return (await _producer.GetDiagnosticsAndErrorSpans(workspace)).Item2; }
public async Task AnalyzeDocumentAsync_InsignificantChangesInMethodBody() { var source1 = @" class C { public static void Main() { // comment System.Console.WriteLine(1); } } "; var source2 = @" class C { public static void Main() { System.Console.WriteLine(1); } } "; using var workspace = TestWorkspace.CreateCSharp(source1, composition: s_composition); var oldSolution = workspace.CurrentSolution; var oldProject = oldSolution.Projects.Single(); var oldDocument = oldProject.Documents.Single(); var oldText = await oldDocument.GetTextAsync(); var oldSyntaxRoot = await oldDocument.GetSyntaxRootAsync(); var documentId = oldDocument.Id; var newSolution = workspace.CurrentSolution.WithDocumentText(documentId, SourceText.From(source2)); var newDocument = newSolution.GetDocument(documentId); var newText = await newDocument.GetTextAsync(); var newSyntaxRoot = await newDocument.GetSyntaxRootAsync(); const string oldStatementSource = "System.Console.WriteLine(1);"; var oldStatementPosition = source1.IndexOf(oldStatementSource, StringComparison.Ordinal); var oldStatementTextSpan = new TextSpan(oldStatementPosition, oldStatementSource.Length); var oldStatementSpan = oldText.Lines.GetLinePositionSpan(oldStatementTextSpan); var oldStatementSyntax = oldSyntaxRoot.FindNode(oldStatementTextSpan); var baseActiveStatements = ImmutableArray.Create(ActiveStatementsDescription.CreateActiveStatement(ActiveStatementFlags.IsLeafFrame, oldStatementSpan, DocumentId.CreateNewId(ProjectId.CreateNewId()))); var analyzer = new CSharpEditAndContinueAnalyzer(); var result = await analyzer.AnalyzeDocumentAsync(oldProject, baseActiveStatements, newDocument, ImmutableArray <TextSpan> .Empty, CancellationToken.None); Assert.True(result.HasChanges); var syntaxMap = result.SemanticEdits[0].SyntaxMap; Assert.NotNull(syntaxMap); var newStatementSpan = result.ActiveStatements[0].Span; var newStatementTextSpan = newText.Lines.GetTextSpan(newStatementSpan); var newStatementSyntax = newSyntaxRoot.FindNode(newStatementTextSpan); var oldStatementSyntaxMapped = syntaxMap(newStatementSyntax); Assert.Same(oldStatementSyntax, oldStatementSyntaxMapped); }
protected override TestWorkspace CreateWorkspace(string content, ExportProvider exportProvider) => TestWorkspace.CreateCSharp(content, parseOptions: Options.Script);
protected override TestWorkspace CreateTestWorkspace(string testCode, ParseOptions?parseOptions) => TestWorkspace.CreateCSharp(testCode, parseOptions);
internal Holder CreateSession(string code) { return(CreateSession( TestWorkspace.CreateCSharp(code), BraceCompletionSessionProvider.Bracket.OpenCharacter, BraceCompletionSessionProvider.Bracket.CloseCharacter)); }
protected override TestWorkspace CreateWorkspaceFromFile(string initialMarkup, TestParameters parameters) => TestWorkspace.CreateCSharp(initialMarkup, parameters.parseOptions, parameters.compilationOptions, exportProvider: CSharpExportProviderFactory.CreateExportProvider());
internal static Holder CreateSession(string code, OptionsCollection?globalOptions = null) { return(CreateSession( TestWorkspace.CreateCSharp(code), CurlyBrace.OpenCharacter, CurlyBrace.CloseCharacter, globalOptions)); }
public async Task CSharpOutliningTagger( bool collapseRegionsWhenCollapsingToDefinitions, bool showBlockStructureGuidesForDeclarationLevelConstructs, bool showBlockStructureGuidesForCodeLevelConstructs) { var code = @"using System; namespace MyNamespace { #region MyRegion public class MyClass { static void Main(string[] args) { if (false) { return; } int x = 5; } } #endregion }"; using var workspace = TestWorkspace.CreateCSharp(code, composition: EditorTestCompositions.EditorFeaturesWpf); var globalOptions = workspace.GlobalOptions; globalOptions.SetGlobalOption(new OptionKey(BlockStructureOptionsStorage.CollapseRegionsWhenCollapsingToDefinitions, LanguageNames.CSharp), collapseRegionsWhenCollapsingToDefinitions); globalOptions.SetGlobalOption(new OptionKey(BlockStructureOptionsStorage.ShowBlockStructureGuidesForDeclarationLevelConstructs, LanguageNames.CSharp), showBlockStructureGuidesForDeclarationLevelConstructs); globalOptions.SetGlobalOption(new OptionKey(BlockStructureOptionsStorage.ShowBlockStructureGuidesForCodeLevelConstructs, LanguageNames.CSharp), showBlockStructureGuidesForCodeLevelConstructs); var tags = await GetTagsFromWorkspaceAsync(workspace); Assert.Collection(tags, namespaceTag => { Assert.False(namespaceTag.IsImplementation); Assert.Equal(17, GetCollapsedHintLineCount(namespaceTag)); Assert.Equal(showBlockStructureGuidesForDeclarationLevelConstructs ? PredefinedStructureTagTypes.Namespace : PredefinedStructureTagTypes.Nonstructural, namespaceTag.Type); Assert.Equal("namespace MyNamespace", GetHeaderText(namespaceTag)); }, regionTag => { Assert.Equal(collapseRegionsWhenCollapsingToDefinitions, regionTag.IsImplementation); Assert.Equal(14, GetCollapsedHintLineCount(regionTag)); Assert.Equal(PredefinedStructureTagTypes.Nonstructural, regionTag.Type); Assert.Equal("#region MyRegion", GetHeaderText(regionTag)); }, classTag => { Assert.False(classTag.IsImplementation); Assert.Equal(12, GetCollapsedHintLineCount(classTag)); Assert.Equal(showBlockStructureGuidesForDeclarationLevelConstructs ? PredefinedStructureTagTypes.Type : PredefinedStructureTagTypes.Nonstructural, classTag.Type); Assert.Equal("public class MyClass", GetHeaderText(classTag)); }, methodTag => { Assert.True(methodTag.IsImplementation); Assert.Equal(9, GetCollapsedHintLineCount(methodTag)); Assert.Equal(showBlockStructureGuidesForDeclarationLevelConstructs ? PredefinedStructureTagTypes.Member : PredefinedStructureTagTypes.Nonstructural, methodTag.Type); Assert.Equal("static void Main(string[] args)", GetHeaderText(methodTag)); }, ifTag => { Assert.False(ifTag.IsImplementation); Assert.Equal(4, GetCollapsedHintLineCount(ifTag)); Assert.Equal(showBlockStructureGuidesForCodeLevelConstructs ? PredefinedStructureTagTypes.Conditional : PredefinedStructureTagTypes.Nonstructural, ifTag.Type); Assert.Equal("if (false)", GetHeaderText(ifTag)); }); }
protected override TestWorkspace CreateWorkspaceFromFile(string initialMarkup, TestParameters parameters) { return(TestWorkspace.IsWorkspaceElement(initialMarkup) ? TestWorkspace.Create(initialMarkup) : TestWorkspace.CreateCSharp(initialMarkup, parameters.parseOptions, parameters.compilationOptions)); }
protected override TestWorkspace CreateTestWorkspace(string initialMarkup) => TestWorkspace.CreateCSharp(initialMarkup);
protected sealed override TestWorkspace CreateWorkspaceFromFile(string initialMarkup, TestParameters parameters) => TestWorkspace.CreateCSharp(initialMarkup, parameters.parseOptions, (parameters.compilationOptions ?? TestOptions.DebugDll).WithReportSuppressedDiagnostics(true));
internal static Holder CreateSessionSingleQuote(string code) { return(CreateSession( TestWorkspace.CreateCSharp(code), SingleQuote.OpenCharacter, SingleQuote.CloseCharacter)); }
protected override TestWorkspace CreateWorkspace(string fileContents) => TestWorkspace.CreateCSharp(fileContents);
internal static Holder CreateSessionDoubleQuote(string code) { return(CreateSession( TestWorkspace.CreateCSharp(code), BraceCompletionSessionProvider.DoubleQuote.OpenCharacter, BraceCompletionSessionProvider.DoubleQuote.CloseCharacter)); }
public async Task FormatSpansIndividuallyWithoutCollapsing() { var code = @"class C { public void M() { [|if(true){}|] [|if(true){}|] [|if(true){}|] [|if(true){}|] [|if(true){}|] [|if(true){}|] [|if(true){}|] [|if(true){}|] [|if(true){}|] [|if(true){}|] [|if(true){}|] [|if(true){}|] [|if(true){}|] [|if(true){}|] [|if(true){}|] [|if(true){}|] [|if(true){}|] [|if(true){}|] [|if(true){}|] [|if(true){}|] [|if(true){}|] [|if(true){}|] [|if(true){}|] [|if(true){}|] [|if(true){}|] [|if(true){}|] [|if(true){}|] [|if(true){}|] [|if(true){}|] [|if(true){}|] [|if(true){}|] if(true){} [|if(true){}|] } }"; var expected = @"class C { public void M() { if (true) { } if (true) { } if (true) { } if (true) { } if (true) { } if (true) { } if (true) { } if (true) { } if (true) { } if (true) { } if (true) { } if (true) { } if (true) { } if (true) { } if (true) { } if (true) { } if (true) { } if (true) { } if (true) { } if (true) { } if (true) { } if (true) { } if (true) { } if (true) { } if (true) { } if (true) { } if (true) { } if (true) { } if (true) { } if (true) { } if (true) { } if(true){} if (true) { } } }"; using (var workspace = TestWorkspace.CreateCSharp(code)) { var subjectDocument = workspace.Documents.Single(); var spans = subjectDocument.SelectedSpans; var document = workspace.CurrentSolution.Projects.Single().Documents.Single(); var syntaxRoot = await document.GetSyntaxRootAsync(); var node = Formatter.Format(syntaxRoot, spans, workspace); Assert.Equal(expected, node.ToFullString()); } }
internal override TestWorkspace GetWorkspace(string markup, TestComposition composition) => TestWorkspace.CreateCSharp(markup, composition: composition);
private static TestWorkspace CreateWorkspaceFromFile(string file, bool isVisualBasic, ParseOptions parseOptions, CompilationOptions compilationOptions) { return(isVisualBasic ? TestWorkspace.CreateVisualBasic(file, (VB.VisualBasicParseOptions)parseOptions, (VB.VisualBasicCompilationOptions)compilationOptions) : TestWorkspace.CreateCSharp(file, (CS.CSharpParseOptions)parseOptions, (CS.CSharpCompilationOptions)compilationOptions)); }
internal Holder CreateSession(string code, Dictionary <OptionKey, object> optionSet = null) { return(CreateSession( TestWorkspace.CreateCSharp(code), BraceCompletionSessionProvider.CurlyBrace.OpenCharacter, BraceCompletionSessionProvider.CurlyBrace.CloseCharacter, optionSet)); }
protected override TestWorkspace CreateWorkspace(string markup, ParseOptions options) => TestWorkspace.CreateCSharp(markup, parseOptions: options);
private static void TestWorker( string inputMarkup, string expectedOutputMarkup, Action callback, bool verifyUndo = true, IndentStyle indentStyle = IndentStyle.Smart, bool useTabs = false) { using var workspace = TestWorkspace.CreateCSharp(inputMarkup); // TODO: set SmartIndent to textView.Options (https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1412138) workspace.GlobalOptions.SetGlobalOption(new OptionKey(IndentationOptionsStorage.SmartIndent, LanguageNames.CSharp), indentStyle); if (useTabs && expectedOutputMarkup != null) { Assert.Contains("\t", expectedOutputMarkup); } var document = workspace.Documents.Single(); var view = document.GetTextView(); view.Options.SetOptionValue(DefaultOptions.ConvertTabsToSpacesOptionId, !useTabs); view.Options.SetOptionValue(DefaultOptions.TabSizeOptionId, 4); var originalSnapshot = view.TextBuffer.CurrentSnapshot; var originalSelections = document.SelectedSpans; var snapshotSpans = new List <SnapshotSpan>(); foreach (var selection in originalSelections) { snapshotSpans.Add(selection.ToSnapshotSpan(originalSnapshot)); } view.SetMultiSelection(snapshotSpans); var undoHistoryRegistry = workspace.GetService <ITextUndoHistoryRegistry>(); var commandHandler = workspace.ExportProvider.GetCommandHandler <SplitStringLiteralCommandHandler>(nameof(SplitStringLiteralCommandHandler)); if (!commandHandler.ExecuteCommand(new ReturnKeyCommandArgs(view, view.TextBuffer), TestCommandExecutionContext.Create())) { callback(); } if (expectedOutputMarkup != null) { MarkupTestFile.GetSpans(expectedOutputMarkup, out var expectedOutput, out ImmutableArray <TextSpan> expectedSpans); Assert.Equal(expectedOutput, view.TextBuffer.CurrentSnapshot.AsText().ToString()); Assert.Equal(expectedSpans.First().Start, view.Caret.Position.BufferPosition.Position); if (verifyUndo) { // Ensure that after undo we go back to where we were to begin with. var history = undoHistoryRegistry.GetHistory(document.GetTextBuffer()); history.Undo(count: originalSelections.Count); var currentSnapshot = document.GetTextBuffer().CurrentSnapshot; Assert.Equal(originalSnapshot.GetText(), currentSnapshot.GetText()); Assert.Equal(originalSelections.First().Start, view.Caret.Position.BufferPosition.Position); } } }
protected override TestWorkspace CreateWorkspaceFromFile(string initialMarkup, TestParameters parameters) => TestWorkspace.CreateCSharp(initialMarkup, parameters.parseOptions, parameters.compilationOptions);
internal static Holder CreateSession(string code) { return(CreateSession( TestWorkspace.CreateCSharp(code), BraceCompletionSessionProvider.LessAndGreaterThan.OpenCharacter, BraceCompletionSessionProvider.LessAndGreaterThan.CloseCharacter)); }
public async Task LargeNumberOfSpans() { using (var workspace = TestWorkspace.CreateCSharp(@"class Program { void M() { int z = 0; z = z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z; } }")) { List <ITagSpan <TestTag> > tagProducer(SnapshotSpan span, CancellationToken cancellationToken) { return(new List <ITagSpan <TestTag> >() { new TagSpan <TestTag>(span, new TestTag()) }); } var asyncListener = new AsynchronousOperationListener(); WpfTestCase.RequireWpfFact($"{nameof(AsynchronousTaggerTests)}.{nameof(LargeNumberOfSpans)} creates asynchronous taggers"); var notificationService = workspace.GetService <IForegroundNotificationService>(); var eventSource = CreateEventSource(); var taggerProvider = new TestTaggerProvider( tagProducer, eventSource, workspace, asyncListener, notificationService); var document = workspace.Documents.First(); var textBuffer = document.TextBuffer; var snapshot = textBuffer.CurrentSnapshot; var tagger = taggerProvider.CreateTagger <TestTag>(textBuffer); using (IDisposable disposable = (IDisposable)tagger) { var spans = Enumerable.Range(0, 101).Select(i => new Span(i * 4, 1)); var snapshotSpans = new NormalizedSnapshotSpanCollection(snapshot, spans); eventSource.SendUpdateEvent(); await asyncListener.CreateWaitTask(); var tags = tagger.GetTags(snapshotSpans); Assert.Equal(1, tags.Count()); } } }
internal static Holder CreateSession(string code) { return(CreateSession( TestWorkspace.CreateCSharp(code), Parenthesis.OpenCharacter, Parenthesis.CloseCharacter)); }