1146 references to TextSpan
AnalyzerRunner (1)
CSharpSyntaxGenerator (1)
IdeBenchmarks (2)
IdeCoreBenchmarks (5)
Microsoft.Analyzers.Extra.Tests (1)
Microsoft.Analyzers.Local.Tests (1)
Microsoft.AspNetCore.App.Analyzers (20)
Infrastructure\VirtualChars\CSharpVirtualCharService.cs (6)
295charResults.Add((ch, new TextSpan(offset + index, 1)));
389result.Add((ch, new TextSpan(offset + index, 2)));
456result.Add(((char)uintChar, new TextSpan(startIndex + offset, 2 + 8)));
467result.Add(((char)highSurrogate, new TextSpan(pos, 0)));
468result.Add(((char)lowSurrogate, new TextSpan(pos, 2 + 8)));
496result.Add((character, new TextSpan(startIndex + offset, 2 + 4)));
Microsoft.AspNetCore.App.Analyzers.Test (1)
Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation.Test (3)
Microsoft.CodeAnalysis (40)
Syntax\SyntaxDiffer.cs (7)
45return new[] { new TextChange(new TextSpan(0, 0), after.GetText().ToString()) };
81return new[] { new TextSpan(0, after!.GetText().Length) };
112newSpans.Add(new TextSpan(start, change.Range.NewLength));
569RecordChange(new ChangeRecord(new TextChangeRange(new TextSpan(start, 0), newSpan.Length), null, insertedNodes));
581new TextChangeRange(new TextSpan(last.Range.Span.Start, last.Range.Span.Length + change.Range.Span.Length), last.Range.NewLength + change.Range.NewLength),
604new TextChangeRange(new TextSpan(last.Range.Span.Start, last.Range.Span.Length + textChangeRange.Span.Length), last.Range.NewLength + textChangeRange.NewLength),
763new TextSpan(range.Span.Start + commonLeadingCount, range.Span.Length - (commonLeadingCount + commonTrailingCount)),
Text\SourceText.cs (8)
534return this.GetSubText(new TextSpan(start, this.Length - start));
543this.Write(textWriter, new TextSpan(0, this.Length), cancellationToken);
710return ToString(new TextSpan(0, this.Length));
798var subText = this.GetSubText(new TextSpan(position, change.Span.Start - position));
821var subText = this.GetSubText(new TextSpan(position, this.Length - position));
869return this.Replace(new TextSpan(start, length), newText);
890return ImmutableArray.Create(new TextChangeRange(new TextSpan(0, oldText.Length), this.Length));
914var span = new TextSpan(newPos, range.NewLength);
Text\TextChangeRangeExtensions.cs (4)
225addAndAdjustOldDelta(builder, ref oldDelta, new TextChangeRange(new TextSpan(oldChange.Span.Start, oldChangeLeadingDeletion), oldChangeLeadingInsertion));
226oldChange = new TextChangeRange(new TextSpan(newChange.SpanStart - oldDelta, oldChange.Span.Length - oldChangeLeadingDeletion), oldChange.NewLength - oldChangeLeadingInsertion);
380add(builder, new TextChangeRange(new TextSpan(newChange.SpanStart - oldDelta, newChange.SpanLength), newChange.NewLength));
391builder[^1] = new TextChangeRange(new TextSpan(last.Span.Start, last.Span.Length + change.Span.Length), last.NewLength + change.NewLength);
Microsoft.CodeAnalysis.CodeStyle (39)
src\Analyzers\Core\Analyzers\ValidateFormatString\AbstractValidateFormatStringDiagnosticAnalyzer.cs (1)
354new Text.TextSpan(
src\Compilers\Core\Portable\Text\TextChangeRangeExtensions.cs (4)
225addAndAdjustOldDelta(builder, ref oldDelta, new TextChangeRange(new TextSpan(oldChange.Span.Start, oldChangeLeadingDeletion), oldChangeLeadingInsertion));
226oldChange = new TextChangeRange(new TextSpan(newChange.SpanStart - oldDelta, oldChange.Span.Length - oldChangeLeadingDeletion), oldChange.NewLength - oldChangeLeadingInsertion);
380add(builder, new TextChangeRange(new TextSpan(newChange.SpanStart - oldDelta, newChange.SpanLength), newChange.NewLength));
391builder[^1] = new TextChangeRange(new TextSpan(last.Span.Start, last.Span.Length + change.Span.Length), last.NewLength + change.NewLength);
Microsoft.CodeAnalysis.CodeStyle.Fixes (3)
Microsoft.CodeAnalysis.CSharp (11)
Microsoft.CodeAnalysis.CSharp.CodeStyle (6)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\EmbeddedLanguages\VirtualChars\CSharpVirtualCharService.cs (6)
278charResults.Add((ch, new TextSpan(offset + index, 1)));
382result.Add((ch, new TextSpan(offset + index, 2)));
449result.Add(((char)uintChar, new TextSpan(startIndex + offset, 2 + 8)));
460result.Add(((char)highSurrogate, new TextSpan(pos, 0)));
461result.Add(((char)lowSurrogate, new TextSpan(pos, 2 + 8)));
489result.Add((character, new TextSpan(startIndex + offset, 2 + 4)));
Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes (5)
Microsoft.CodeAnalysis.CSharp.CommandLine.UnitTests (1)
Microsoft.CodeAnalysis.CSharp.EditorFeatures (7)
Microsoft.CodeAnalysis.CSharp.EditorFeatures.UnitTests (43)
Classification\SyntacticClassifierTests.cs (29)
6052var classifications = await GetSyntacticClassificationsAsync(document, [new TextSpan(0, source.Length)]);
6055new ClassifiedSpan(ClassificationTypeNames.XmlDocCommentDelimiter, new TextSpan(0, 3)),
6056new ClassifiedSpan(ClassificationTypeNames.XmlDocCommentText, new TextSpan(3, 1)),
6057new ClassifiedSpan(ClassificationTypeNames.XmlDocCommentDelimiter, new TextSpan(4, 1)),
6058new ClassifiedSpan(ClassificationTypeNames.XmlDocCommentName, new TextSpan(5, 5)),
6059new ClassifiedSpan(ClassificationTypeNames.XmlDocCommentAttributeName, new TextSpan(11, 4)),
6060new ClassifiedSpan(ClassificationTypeNames.XmlDocCommentDelimiter, new TextSpan(15, 1)),
6061new ClassifiedSpan(ClassificationTypeNames.XmlDocCommentAttributeQuotes, new TextSpan(16, 1)),
6062new ClassifiedSpan(ClassificationTypeNames.Identifier, new TextSpan(17, 5)),
6063new ClassifiedSpan(ClassificationTypeNames.XmlDocCommentAttributeQuotes, new TextSpan(22, 1)),
6064new ClassifiedSpan(ClassificationTypeNames.XmlDocCommentDelimiter, new TextSpan(23, 1)),
6065new ClassifiedSpan(ClassificationTypeNames.XmlDocCommentDelimiter, new TextSpan(24, 2)),
6066new ClassifiedSpan(ClassificationTypeNames.XmlDocCommentName, new TextSpan(26, 5)),
6067new ClassifiedSpan(ClassificationTypeNames.XmlDocCommentDelimiter, new TextSpan(31, 1))
6082var classifications = await GetSyntacticClassificationsAsync(document, [new TextSpan(0, source.Length)]);
6085new ClassifiedSpan(ClassificationTypeNames.XmlDocCommentDelimiter, new TextSpan(2, 3)),
6086new ClassifiedSpan(ClassificationTypeNames.XmlDocCommentText, new TextSpan(5, 1)),
6087new ClassifiedSpan(ClassificationTypeNames.XmlDocCommentDelimiter, new TextSpan(6, 1)),
6088new ClassifiedSpan(ClassificationTypeNames.XmlDocCommentName, new TextSpan(7, 5)),
6089new ClassifiedSpan(ClassificationTypeNames.XmlDocCommentDelimiter, new TextSpan(14, 3)),
6090new ClassifiedSpan(ClassificationTypeNames.XmlDocCommentAttributeName, new TextSpan(18, 4)),
6091new ClassifiedSpan(ClassificationTypeNames.XmlDocCommentDelimiter, new TextSpan(22, 1)),
6092new ClassifiedSpan(ClassificationTypeNames.XmlDocCommentAttributeQuotes, new TextSpan(23, 1)),
6093new ClassifiedSpan(ClassificationTypeNames.Identifier, new TextSpan(24, 5)),
6094new ClassifiedSpan(ClassificationTypeNames.XmlDocCommentAttributeQuotes, new TextSpan(29, 1)),
6095new ClassifiedSpan(ClassificationTypeNames.XmlDocCommentDelimiter, new TextSpan(30, 1)),
6096new ClassifiedSpan(ClassificationTypeNames.XmlDocCommentDelimiter, new TextSpan(31, 2)),
6097new ClassifiedSpan(ClassificationTypeNames.XmlDocCommentName, new TextSpan(33, 5)),
6098new ClassifiedSpan(ClassificationTypeNames.XmlDocCommentDelimiter, new TextSpan(38, 1))
Diagnostics\DiagnosticAnalyzerDriver\DiagnosticAnalyzerDriverTests.cs (5)
65await DiagnosticProviderTestUtilities.GetAllDiagnosticsAsync(workspace, document, new TextSpan(0, document.GetTextAsync().Result.Length));
93await DiagnosticProviderTestUtilities.GetAllDiagnosticsAsync(ideEngineWorkspace, ideEngineDocument, new TextSpan(0, ideEngineDocument.GetTextAsync().Result.Length));
175await DiagnosticProviderTestUtilities.GetAllDiagnosticsAsync(workspace, sourceDocument, new TextSpan(0, sourceDocument.GetTextAsync().Result.Length));
205var diagnostics = await DiagnosticProviderTestUtilities.GetAllDiagnosticsAsync(workspace, ideEngineDocument, new TextSpan(0, ideEngineDocument.GetTextAsync().Result.Length));
261var diagnostics = await DiagnosticProviderTestUtilities.GetAllDiagnosticsAsync(ideEngineWorkspace, ideEngineDocument, new TextSpan(0, ideEngineDocument.GetTextAsync().Result.Length));
NavigateTo\NavigateToSearcherTests.cs (5)
124var results = ImmutableArray.Create<INavigateToSearchResult>(new TestNavigateToSearchResult(workspace, new TextSpan(0, 0)));
159var results = ImmutableArray.Create<INavigateToSearchResult>(new TestNavigateToSearchResult(workspace, new TextSpan(0, 0)));
236var results = ImmutableArray.Create<INavigateToSearchResult>(new TestNavigateToSearchResult(workspace, new TextSpan(0, 0)));
272var results = ImmutableArray.Create<INavigateToSearchResult>(new TestNavigateToSearchResult(workspace, new TextSpan(0, 0)));
320var results = ImmutableArray.Create<INavigateToSearchResult>(new TestNavigateToSearchResult(workspace, new TextSpan(0, 0)));
Microsoft.CodeAnalysis.CSharp.Emit.UnitTests (7)
CodeGen\CodeGenTupleTest.cs (7)
5799var loc1 = Location.Create(tree, new TextSpan(0, 1));
5910var loc1 = Location.Create(tree, new TextSpan(0, 1));
5911var loc2 = Location.Create(tree, new TextSpan(1, 1));
6351var loc1 = Location.Create(syntaxTree, new TextSpan(0, 1));
6387var loc1 = Location.Create(syntaxTree, new TextSpan(0, 1));
6388var loc2 = Location.Create(syntaxTree, new TextSpan(1, 1));
22617var newText = text.WithChanges(new TextChange(new TextSpan(pos, 0), " ")); // add space before closing-paren
Microsoft.CodeAnalysis.CSharp.Emit3.UnitTests (4)
Microsoft.CodeAnalysis.CSharp.Features (25)
Microsoft.CodeAnalysis.CSharp.Features.UnitTests (2)
Microsoft.CodeAnalysis.CSharp.Semantic.UnitTests (3)
Microsoft.CodeAnalysis.CSharp.Symbol.UnitTests (6)
Microsoft.CodeAnalysis.CSharp.Syntax.UnitTests (152)
Diagnostics\DiagnosticTest.cs (7)
83Location l1 = new SourceLocation(syntaxTree, new TextSpan(5, 8));
87Assert.Equal(new TextSpan(5, 8), d1.Location.SourceSpan);
98DiagnosticInfo di3 = new CustomErrorInfo(provider, "OtherSymbol", new SourceLocation(syntaxTree, new TextSpan(14, 8)));
99var d3 = new CSDiagnostic(di3, new SourceLocation(syntaxTree, new TextSpan(1, 1)));
101Assert.Equal(new TextSpan(1, 1), d3.Location.SourceSpan);
103Assert.Equal(new TextSpan(14, 8), d3.AdditionalLocations.First().SourceSpan);
2409return new TextSpan(index, textToFind.Length);
Diagnostics\LocationsTests.cs (9)
71return new TextSpan(index, textToFind.Length);
89TextSpan xSpan = new TextSpan(sampleProgram.IndexOf("x;", StringComparison.Ordinal), 2);
90TextSpan xToCloseBraceSpan = new TextSpan(xSpan.Start, sampleProgram.IndexOf('}') - xSpan.Start + 1);
429SourceLocation loc1 = new SourceLocation(syntaxTree, new TextSpan(3, 4));
430SourceLocation loc2 = new SourceLocation(syntaxTree, new TextSpan(3, 4));
431SourceLocation loc3 = new SourceLocation(syntaxTree, new TextSpan(3, 7));
432SourceLocation loc4 = new SourceLocation(tree2, new TextSpan(3, 4));
490TextSpan span1 = new TextSpan(sampleProgram.IndexOf("i;", StringComparison.Ordinal), 2);
491TextSpan span2 = new TextSpan(sampleProgram.IndexOf("c;", StringComparison.Ordinal), 2);
IncrementalParsing\IncrementalParsingTests.cs (43)
496var span = new TextSpan(source.IndexOf("]") + 1, length: 1);
528var span = new TextSpan(source.IndexOf("."), length: 1);
573var prefixSpan = new TextSpan(source.IndexOf(prefix), length: prefix.Length);
574var suffixSpan = new TextSpan(source.IndexOf(suffix), length: suffix.Length);
965var newText = text.WithChanges(new TextChange(new TextSpan(0, 8), ""));
979var newText = text.WithChanges(new TextChange(new TextSpan(0, 8), ""));
2748new TextChange(new TextSpan(str.IndexOf(" abc", StringComparison.Ordinal), 0), "//"),
2749new TextChange(new TextSpan(str.IndexOf(" 123", StringComparison.Ordinal), 0), "//"),
2750new TextChange(new TextSpan(str.IndexOf(" def", StringComparison.Ordinal), 0), "//"));
2770var newText = oldText.WithChanges(new TextChange(new TextSpan(0, 0), "{"));
2786var newText = oldText.WithChanges(new TextChange(new TextSpan(0, 0), @"System.Console.WriteLine(false)
2845var newText = oldText.WithChanges(new TextChange(new TextSpan(0, 0), @"if (false)
2900var span = new TextSpan(oldIText.Length, 0);
2914span = new TextSpan(oldIText.Length, 0);
2983var span = new TextSpan(currLen, 0);
3020var span = new TextSpan(text.LastIndexOf('x'), 0);
3100var change = new TextChange(new TextSpan(0, 0), items[1]); // Prepend
3198var span = new TextSpan(source.IndexOf(" A[]?"), 0);
3219var span = new TextSpan(src.IndexOf(":"), 1);
3240var span = new TextSpan(source.IndexOf(";"), 0);
3261var span = new TextSpan(source.IndexOf(";") + 1, 0);
3282var span = new TextSpan(source.IndexOf(";") + 1, 0);
3304var span = new TextSpan(source.IndexOf(substring) + substring.Length, 0);
3328var span = new TextSpan(source.IndexOf(substring) + substring.Length, 0);
3352var span = new TextSpan(source.IndexOf(substring) + substring.Length, 0);
3376var span = new TextSpan(source.IndexOf(substring) + substring.Length, 0);
3400var span = new TextSpan(source.IndexOf(substring) + substring.Length, 0);
3424var span = new TextSpan(source.IndexOf(substring) + substring.Length, 1);
3450var span = new TextSpan(source.IndexOf(substring) + substring.Length, 0);
3475var span = new TextSpan(source.IndexOf(substring), 0);
3501var span = new TextSpan(source.IndexOf(substring) + substring.Length, 0);
3527var span = new TextSpan(source.IndexOf(substring) + substring.Length, 0);
3545var span = new TextSpan(source.IndexOf(substring) + substring.Length, 0);
3563var span = new TextSpan(source.IndexOf(substring) + substring.Length, 0);
3581var span = new TextSpan(source.IndexOf(substring) + substring.Length, 0);
3595var span = new TextSpan(start: 0, length: 1); // delete first character
3609var span = new TextSpan(start: 0, length: 0);
3624var span = new TextSpan(start: source.IndexOf(substring), length: 3); // Goo[Goo] -> [Goo]
3661var span = new TextSpan(start: source.IndexOf(":") + 1, length: 0);
3691new TextChange(new TextSpan(locationOfChange, 0), "/*"),
3692new TextChange(new TextSpan(locationOfChange + widthOfChange, 0), "*/")
3701var newText = oldText.WithChanges(new TextChange(new TextSpan(locationOfChange, widthOfChange), ""));
3727var newText = oldText.WithChanges(new TextChange(new TextSpan(oldText.Length, 0), newChar.ToString()));
LexicalAndXml\SyntaxTokenParserTests.cs (50)
39AssertToken(expectedKind: SyntaxKind.ClassKeyword, expectedContextualKind: SyntaxKind.None, new TextSpan(0, 22), """
44AssertToken(expectedKind: SyntaxKind.IdentifierToken, expectedContextualKind: SyntaxKind.None, new TextSpan(22, 3), """
49AssertToken(expectedKind: SyntaxKind.OpenBraceToken, expectedContextualKind: SyntaxKind.None, new TextSpan(25, 3), """
54AssertToken(expectedKind: SyntaxKind.CloseBraceToken, expectedContextualKind: SyntaxKind.None, new TextSpan(28, 3), """
59AssertToken(expectedKind: SyntaxKind.EndOfFileToken, expectedContextualKind: SyntaxKind.None, new TextSpan(31, 0), "", parser.ParseNextToken());
60AssertToken(expectedKind: SyntaxKind.EndOfFileToken, expectedContextualKind: SyntaxKind.None, new TextSpan(31, 0), "", parser.ParseNextToken());
78AssertToken(expectedKind: SyntaxKind.ClassKeyword, expectedContextualKind: SyntaxKind.None, new TextSpan(0, 54), """
89AssertToken(expectedKind: SyntaxKind.IdentifierToken, expectedContextualKind: SyntaxKind.None, new TextSpan(54, 3), """
94AssertToken(expectedKind: SyntaxKind.OpenBraceToken, expectedContextualKind: SyntaxKind.None, new TextSpan(57, 3), """
99AssertToken(expectedKind: SyntaxKind.CloseBraceToken, expectedContextualKind: SyntaxKind.None, new TextSpan(60, 3), """
104AssertToken(expectedKind: SyntaxKind.EndOfFileToken, expectedContextualKind: SyntaxKind.None, new TextSpan(63, 0), "", parser.ParseNextToken());
121AssertToken(expectedKind: SyntaxKind.ClassKeyword, expectedContextualKind: SyntaxKind.None, new TextSpan(0, 16), """
126AssertToken(expectedKind: SyntaxKind.IdentifierToken, expectedContextualKind: SyntaxKind.None, new TextSpan(16, 3), """
131AssertToken(expectedKind: SyntaxKind.OpenBraceToken, expectedContextualKind: SyntaxKind.None, new TextSpan(19, 3), """
136AssertToken(expectedKind: SyntaxKind.EndOfFileToken, expectedContextualKind: SyntaxKind.None, new TextSpan(22, 18), """
143AssertToken(expectedKind: SyntaxKind.EndOfFileToken, expectedContextualKind: SyntaxKind.None, new TextSpan(40, 0), "", parser.ParseNextToken());
162AssertToken(expectedKind: SyntaxKind.ClassKeyword, expectedContextualKind: SyntaxKind.None, new TextSpan(18, 22), """
169AssertToken(expectedKind: SyntaxKind.OpenBraceToken, expectedContextualKind: SyntaxKind.None, new TextSpan(43, 3), """
174AssertToken(expectedKind: SyntaxKind.CloseBraceToken, expectedContextualKind: SyntaxKind.None, new TextSpan(46, 3), """
187AssertToken(expectedKind: SyntaxKind.IdentifierToken, expectedContextualKind: SyntaxKind.None, new TextSpan(1, 4), """lass""", parser.ParseNextToken());
196AssertToken(expectedKind: SyntaxKind.EndOfFileToken, expectedContextualKind: SyntaxKind.None, new TextSpan(100, 0), "", parser.ParseNextToken());
205AssertToken(expectedKind: SyntaxKind.ClassKeyword, expectedContextualKind: SyntaxKind.None, new TextSpan(0, 6), "class ", parser.ParseNextToken());
223AssertToken(expectedKind: SyntaxKind.ClassKeyword, expectedContextualKind: SyntaxKind.None, new TextSpan(0, 16), """
229AssertToken(expectedKind: SyntaxKind.IdentifierToken, expectedContextualKind: SyntaxKind.None, new TextSpan(16, 3), """
244AssertToken(expectedKind: SyntaxKind.OpenBraceToken, expectedContextualKind: SyntaxKind.None, new TextSpan(19, 3), """
249AssertToken(expectedKind: SyntaxKind.EndOfFileToken, expectedContextualKind: SyntaxKind.None, new TextSpan(22, 18), """
264AssertToken(expectedKind: SyntaxKind.IdentifierToken, expectedContextualKind: SyntaxKind.WhenKeyword, new TextSpan(0, 5), "when ", parser.ParseNextToken());
265AssertToken(expectedKind: SyntaxKind.IdentifierToken, expectedContextualKind: SyntaxKind.None, new TextSpan(5, 11), "identifier ", parser.ParseNextToken());
266AssertToken(expectedKind: SyntaxKind.ClassKeyword, expectedContextualKind: SyntaxKind.None, new TextSpan(16, 5), "class", parser.ParseNextToken());
276AssertToken(expectedKind: SyntaxKind.None, expectedContextualKind: SyntaxKind.None, new TextSpan(0, 0), "", result);
281AssertToken(expectedKind: SyntaxKind.None, expectedContextualKind: SyntaxKind.None, new TextSpan(0, 0), "", result);
285AssertToken(expectedKind: SyntaxKind.ClassKeyword, expectedContextualKind: SyntaxKind.None, new TextSpan(0, 6), "class ", parser.ParseNextToken());
295AssertToken(expectedKind: SyntaxKind.None, expectedContextualKind: SyntaxKind.None, new TextSpan(0, 11), "/* test */ ", result);
302AssertToken(expectedKind: SyntaxKind.None, expectedContextualKind: SyntaxKind.None, new TextSpan(11, 0), "", intermediateResult);
307AssertToken(expectedKind: SyntaxKind.None, expectedContextualKind: SyntaxKind.None, new TextSpan(11, 0), "", intermediateResult);
311AssertToken(expectedKind: SyntaxKind.ClassKeyword, expectedContextualKind: SyntaxKind.None, new TextSpan(11, 6), "class ", parser.ParseNextToken());
314AssertToken(expectedKind: SyntaxKind.ClassKeyword, expectedContextualKind: SyntaxKind.None, new TextSpan(0, 17), "/* test */ class ", parser.ParseNextToken());
328AssertToken(expectedKind: SyntaxKind.None, expectedContextualKind: SyntaxKind.None, new TextSpan(0, 14), $"/* test */\r\n\r\n", result);
336AssertToken(expectedKind: SyntaxKind.None, expectedContextualKind: SyntaxKind.None, new TextSpan(14, 0), "", intermediateResult);
341AssertToken(expectedKind: SyntaxKind.None, expectedContextualKind: SyntaxKind.None, new TextSpan(14, 0), "", intermediateResult);
345AssertToken(expectedKind: SyntaxKind.ClassKeyword, expectedContextualKind: SyntaxKind.None, new TextSpan(14, 6), "class ", parser.ParseNextToken());
348AssertToken(expectedKind: SyntaxKind.ClassKeyword, expectedContextualKind: SyntaxKind.None, new TextSpan(0, 20), "/* test */\r\n\r\nclass ", parser.ParseNextToken());
358AssertToken(expectedKind: SyntaxKind.None, expectedContextualKind: SyntaxKind.None, new TextSpan(0, 0), "", result);
362AssertToken(expectedKind: SyntaxKind.ClassKeyword, expectedContextualKind: SyntaxKind.None, new TextSpan(0, 6), "class ", parser.ParseNextToken());
372AssertToken(expectedKind: SyntaxKind.None, expectedContextualKind: SyntaxKind.None, new TextSpan(0, 11), "/* test */ ", result);
378AssertToken(expectedKind: SyntaxKind.ClassKeyword, expectedContextualKind: SyntaxKind.None, new TextSpan(11, 6), "class ", parser.ParseNextToken());
381AssertToken(expectedKind: SyntaxKind.ClassKeyword, expectedContextualKind: SyntaxKind.None, new TextSpan(0, 17), "/* test */ class ", parser.ParseNextToken());
395AssertToken(expectedKind: SyntaxKind.None, expectedContextualKind: SyntaxKind.None, new TextSpan(0, 12), $"/* test */\r\n", result);
401AssertToken(expectedKind: SyntaxKind.ClassKeyword, expectedContextualKind: SyntaxKind.None, new TextSpan(12, 8), "\r\nclass ", parser.ParseNextToken());
404AssertToken(expectedKind: SyntaxKind.ClassKeyword, expectedContextualKind: SyntaxKind.None, new TextSpan(0, 20), "/* test */\r\n\r\nclass ", parser.ParseNextToken());
Syntax\SyntaxDiffingTests.cs (23)
33Assert.Equal(new TextSpan(0, 0), changes[0].Span);
53Assert.Equal(new TextSpan(6, 1), changes[0].Span);
75Assert.Equal(new TextSpan(6, 1), changes[0].Span);
77Assert.Equal(new TextSpan(18, 1), changes[1].Span);
90Assert.Equal(new TextSpan(0, 6), spans[0]);
95Assert.Equal(new TextSpan(0, 0), changes[0].Span);
108Assert.Equal(new TextSpan(0, 8), spans[0]);
113Assert.Equal(new TextSpan(0, 0), changes[0].Span);
127Assert.Equal(new TextSpan(11, 11), spans[0]); // its going to pick one of the two spans.
132Assert.Equal(new TextSpan(11, 0), changes[0].Span);
147Assert.Equal(new TextSpan(10, 12), spans[0]);
152Assert.Equal(new TextSpan(10, 0), changes[0].Span);
165Assert.Equal(new TextSpan(0, 14), spans[0]);
170Assert.Equal(new TextSpan(0, 0), changes[0].Span);
183Assert.Equal(new TextSpan(10, 7), spans[0]); // int X;
188Assert.Equal(new TextSpan(10, 0), changes[0].Span);
205Assert.Equal(new TextSpan(10, 7), changes[0].Span);
222Assert.Equal(new TextSpan(24, 7), changes[0].Span);
239Assert.Equal(new TextSpan(14, 1), changes[0].Span);
252Assert.Equal(new TextSpan(14, 6), spans[0]); // 'struct'
257Assert.Equal(new TextSpan(14, 5), changes[0].Span);
307var span = new TextSpan(index, 4);
372var span = new TextSpan(index, 6);
Syntax\SyntaxNodeTests.cs (13)
578var tokens = t1.GetCompilationUnitRoot().DescendantTokens(new TextSpan(0, 16)).ToList();
590var tokens = t1.GetCompilationUnitRoot().DescendantTokens(new TextSpan(1, 14)).ToList();
602var tokens = t1.GetCompilationUnitRoot().DescendantTokens(new TextSpan(7, 17)).ToList();
615var tokens = t1.GetCompilationUnitRoot().DescendantTokens(new TextSpan(8, 15)).ToList();
664var node = t1.GetCompilationUnitRoot().DescendantTokens(new TextSpan(6, 3)).First();
745var EOFSpan = new TextSpan(root.FullSpan.End, 0);
754var nodeEndPositionSpan = new TextSpan(classDecl.FullSpan.End, 0);
764var invalidSpan = new TextSpan(100, 100);
766invalidSpan = new TextSpan(root.FullSpan.End - 1, 2);
768invalidSpan = new TextSpan(classDecl2.FullSpan.Start - 1, root.FullSpan.End);
770invalidSpan = new TextSpan(classDecl.FullSpan.End, root.FullSpan.End);
920var tree2 = tree1.WithChangedText(tree1.GetText().WithChanges(new TextChange(new TextSpan(22, 0), " return; ")));
2092var textSpan = new TextSpan(5, 10);
Microsoft.CodeAnalysis.CSharp.Test.Utilities (2)
Microsoft.CodeAnalysis.CSharp.Workspaces (9)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\EmbeddedLanguages\VirtualChars\CSharpVirtualCharService.cs (6)
278charResults.Add((ch, new TextSpan(offset + index, 1)));
382result.Add((ch, new TextSpan(offset + index, 2)));
449result.Add(((char)uintChar, new TextSpan(startIndex + offset, 2 + 8)));
460result.Add(((char)highSurrogate, new TextSpan(pos, 0)));
461result.Add(((char)lowSurrogate, new TextSpan(pos, 2 + 8)));
489result.Add((character, new TextSpan(startIndex + offset, 2 + 4)));
Microsoft.CodeAnalysis.CSharp.Workspaces.UnitTests (2)
Formatting\CSharpFormattingTestBase.cs (2)
31return AssertFormatAsync(code, code, [new TextSpan(0, code.Length)], changedOptionSet, testWithTransformation, parseOptions);
41return AssertFormatAsync(expected, code, [new TextSpan(0, code.Length)], changedOptionSet, testWithTransformation, parseOptions);
Microsoft.CodeAnalysis.EditorFeatures (12)
EditorConfigSettings\Updater\SettingsUpdateHelper.cs (3)
306return (editorConfigText.WithChanges(new TextChange(new TextSpan(lastValidSpecificHeaderSpanEnd.Value.Span.End, 0), newEntry)), lastValidHeaderSpanEnd, lastValidSpecificHeaderSpanEnd);
315return (editorConfigText.WithChanges(new TextChange(new TextSpan(lastValidHeaderSpanEnd.Value.Span.End, 0), newEntry)), lastValidHeaderSpanEnd, lastValidSpecificHeaderSpanEnd);
349var result = editorConfigText.WithChanges(new TextChange(new TextSpan(editorConfigText.Length, 0), prefix + newEntry));
Microsoft.CodeAnalysis.EditorFeatures.Test.Utilities (19)
BraceHighlighting\MultiCharacterBraceHighlightingTests.cs (8)
59return new BraceMatchingResult(new TextSpan(position, 2), new TextSpan(secondAt, 2));
68return new BraceMatchingResult(new TextSpan(position - 1, 2), new TextSpan(secondAt, 2));
74return new BraceMatchingResult(new TextSpan(lessThan, 2), new TextSpan(position, 2));
83return new BraceMatchingResult(new TextSpan(lessThan, 2), new TextSpan(position - 1, 2));
Microsoft.CodeAnalysis.EditorFeatures.Text (6)
Microsoft.CodeAnalysis.EditorFeatures.UnitTests (105)
CommentSelection\CommentUncommentSelectionCommandHandlerTests.cs (78)
103new TextChange(new TextSpan(8, 0), "/*"),
104new TextChange(new TextSpan(14, 0), "*/"),
117new TextChange(new TextSpan(0, 0), "//"),
118new TextChange(new TextSpan(16, 0), "//"),
145new TextChange(new TextSpan(20, 0), "//"),
146new TextChange(new TextSpan(34, 0), "//"),
147new TextChange(new TextSpan(41, 0), "//"),
171new TextChange(new TextSpan(0, 0), "//"),
172new TextChange(new TextSpan(9, 0), "//"),
173new TextChange(new TextSpan(12, 0), "//"),
174new TextChange(new TextSpan(30, 0), "//"),
185new TextChange(new TextSpan(0, 0), "//"),
186new TextChange(new TextSpan(11, 0), "//"),
187new TextChange(new TextSpan(16, 0), "//"),
188new TextChange(new TextSpan(36, 0), "//"),
211new TextChange(new TextSpan(20, 0), "//"),
212new TextChange(new TextSpan(34, 0), "//"),
213new TextChange(new TextSpan(41, 0), "//"),
232new TextChange(new TextSpan(20, 0), "//"),
233new TextChange(new TextSpan(34, 0), "//"),
234new TextChange(new TextSpan(41, 0), "//"),
254new TextChange(new TextSpan(20, 0), "//"),
255new TextChange(new TextSpan(34, 0), "//"),
256new TextChange(new TextSpan(41, 0), "//"),
277new TextChange(new TextSpan(20, 0), "/*"),
278new TextChange(new TextSpan(21, 0), "*/"),
279new TextChange(new TextSpan(34, 0), "//"),
280new TextChange(new TextSpan(41, 0), "/*"),
281new TextChange(new TextSpan(42, 0), "*/"),
282new TextChange(new TextSpan(52, 0), "//"),
302new TextChange(new TextSpan(20, 0), "//"),
303new TextChange(new TextSpan(34, 0), "//"),
304new TextChange(new TextSpan(41, 0), "//"),
313UncommentSelection(code, new[] { new TextChange(new TextSpan(0, 2), string.Empty) }, Span.FromBounds(0, 6), supportBlockComments: true);
322new TextChange(new TextSpan(7, 2), string.Empty),
323new TextChange(new TextSpan(30, 2), string.Empty),
335new TextChange(new TextSpan(11, 2), string.Empty),
336new TextChange(new TextSpan(34, 2), string.Empty),
359new TextChange(new TextSpan(18, 2), string.Empty),
360new TextChange(new TextSpan(34, 2), string.Empty),
361new TextChange(new TextSpan(47, 2), string.Empty),
362new TextChange(new TextSpan(68, 2), string.Empty),
363new TextChange(new TextSpan(119, 2), string.Empty),
364new TextChange(new TextSpan(128, 2), string.Empty),
385new TextChange(new TextSpan(20, 2), string.Empty),
386new TextChange(new TextSpan(23, 2), string.Empty),
387new TextChange(new TextSpan(38, 2), string.Empty),
388new TextChange(new TextSpan(49, 2), string.Empty),
389new TextChange(new TextSpan(52, 2), string.Empty),
390new TextChange(new TextSpan(64, 2), string.Empty),
411new TextChange(new TextSpan(2, 2), string.Empty),
412new TextChange(new TextSpan(19, 2), string.Empty),
413new TextChange(new TextSpan(26, 2), string.Empty),
433new TextChange(new TextSpan(6, 2), string.Empty),
434new TextChange(new TextSpan(16, 2), string.Empty)
447new TextChange(new TextSpan(19, 2), string.Empty),
448new TextChange(new TextSpan(29, 2), string.Empty)
461new TextChange(new TextSpan(0, 2), string.Empty),
462new TextChange(new TextSpan(15, 2), string.Empty)
475new TextChange(new TextSpan(0, 2), string.Empty),
476new TextChange(new TextSpan(15, 2), string.Empty)
513new TextChange(new TextSpan(18, 2), string.Empty),
514new TextChange(new TextSpan(112, 2), string.Empty),
544new TextChange(new TextSpan(20, 2), string.Empty),
545new TextChange(new TextSpan(114, 2), string.Empty),
573new TextChange(new TextSpan(18, 2), string.Empty),
574new TextChange(new TextSpan(112, 2), string.Empty),
602new TextChange(new TextSpan(18, 2), string.Empty),
603new TextChange(new TextSpan(112, 2), string.Empty),
631new TextChange(new TextSpan(55, 2), string.Empty),
659new TextChange(new TextSpan(55, 2), string.Empty),
687new TextChange(new TextSpan(18, 2), string.Empty),
688new TextChange(new TextSpan(28, 2), string.Empty),
689new TextChange(new TextSpan(44, 2), string.Empty),
690new TextChange(new TextSpan(53, 2), string.Empty),
691new TextChange(new TextSpan(78, 2), string.Empty),
692new TextChange(new TextSpan(109, 2), string.Empty),
693new TextChange(new TextSpan(118, 2), string.Empty),
Diagnostics\DiagnosticDataTests.cs (10)
28await VerifyTextSpanAsync(code, 10, 10, 20, 20, new TextSpan(0, 0));
37await VerifyTextSpanAsync(code, 30, 30, 40, 40, new TextSpan(code.Length, 0));
46await VerifyTextSpanAsync(code, 0, 30, 40, 40, new TextSpan(code.Length, 0));
55await VerifyTextSpanAsync(code, 0, 30, 0, 40, new TextSpan(code.Length, 0));
64await VerifyTextSpanAsync(code, 1, 30, 1, 40, new TextSpan(code.Length, 0));
73await VerifyTextSpanAsync(code, 1, 30, 1, 40, new TextSpan(code.Length, 0));
82await VerifyTextSpanAsync(code, 1, 30, 2, 40, new TextSpan(code.Length, 0));
91await VerifyTextSpanAsync(code, 1, 0, 1, 2, new TextSpan(code.Length, 0));
106await VerifyTextSpanAsync(code, 3, 10, 3, 11, new TextSpan(28, 1));
189await VerifyTextSpanAsync(content, 3, 10, 3, 11, new TextSpan(28, 1));
Snippets\RoslynLSPSnippetConvertTests.cs (3)
404ImmutableArray<SnippetPlaceholder>.Empty, new TextChange(new TextSpan(8, 0), "quux"), triggerLocation: 12, CancellationToken.None).Result;
415ImmutableArray<SnippetPlaceholder>.Empty, new TextChange(new TextSpan(4, 4), "bar quux"), triggerLocation: 12, CancellationToken.None).Result;
492var textChange = new TextChange(new TextSpan(stringSpan.Start, 0), text.Substring(stringSpan.Start, stringSpan.Length));
Microsoft.CodeAnalysis.EditorFeatures2.UnitTests (9)
Microsoft.CodeAnalysis.Features (39)
Navigation\IDocumentNavigationService.cs (2)
37=> CanNavigateToSpanAsync(workspace, documentId, new TextSpan(position, 0), allowInvalidSpan: allowInvalidPosition, cancellationToken);
43=> GetLocationForSpanAsync(workspace, documentId, new TextSpan(position, 0), allowInvalidSpan: allowInvalidPosition, cancellationToken);
src\Analyzers\Core\Analyzers\ValidateFormatString\AbstractValidateFormatStringDiagnosticAnalyzer.cs (1)
354new Text.TextSpan(
Microsoft.CodeAnalysis.Features.Test.Utilities (3)
Microsoft.CodeAnalysis.LanguageServer.Protocol (12)
Handler\InlineCompletions\InlineCompletionsHandler.cs (6)
197snippetEndPosition = GetAdjustedSpan(formattingChanges, new TextSpan(snippetEndPosition, 0)).Start;
231return new TextSpan(originalSpan.Start + amountToAdjust, originalSpan.Length);
236var offsetInSnippet = new TextSpan(positionInFullText - snippetPositionInFullText, length);
279part = await functionPart.WithSnippetFunctionResultAsync(documentWithDefaultSnippet, new TextSpan(locationInDefaultSnippet, part.DefaultText.Length), simplifierOptions, cancellationToken).ConfigureAwait(false);
285var fieldSpan = new TextSpan(locationInFinalSnippet, part.DefaultText.Length);
290caretSpan = new TextSpan(locationInFinalSnippet, cursorPart.DefaultText.Length);
Microsoft.CodeAnalysis.LanguageServer.Protocol.UnitTests (7)
Microsoft.CodeAnalysis.Remote.ServiceHub (1)
Microsoft.CodeAnalysis.Test.Utilities (3)
Microsoft.CodeAnalysis.UnitTests (301)
Text\StringText_LineTest.cs (11)
20var span = new TextSpan(0, 3);
53var line = TextLine.FromSpan(text, new TextSpan(0, 3));
62Assert.Throws<ArgumentOutOfRangeException>(() => TextLine.FromSpan(text, new TextSpan(0, 0)));
69Assert.Throws<ArgumentOutOfRangeException>(() => TextLine.FromSpan(text, new TextSpan(0, 3)));
76Assert.Throws<ArgumentOutOfRangeException>(() => TextLine.FromSpan(text, new TextSpan(1, 5)));
84var line = TextLine.FromSpan(text, new TextSpan(start, 0));
98var line = TextLine.FromSpan(text, new TextSpan(0, 0));
107Assert.Throws<ArgumentOutOfRangeException>(() => TextLine.FromSpan(text, new TextSpan(1, 10)));
114Assert.Throws<ArgumentOutOfRangeException>(() => TextLine.FromSpan(text, new TextSpan(-1, 2)));
121Assert.Throws<ArgumentOutOfRangeException>(() => TextLine.FromSpan(text, new TextSpan(7, 0)));
128Assert.Throws<ArgumentNullException>(() => TextLine.FromSpan(null, new TextSpan(0, 2)));
Text\TextChangeRangeTest.cs (7)
26var span = new TextSpan(2, 50);
39EqualityUnit.Create(new TextChangeRange(new TextSpan(42, 2), 13)).WithEqualValues(new TextChangeRange(new TextSpan(42, 2), 13)),
40EqualityUnit.Create(new TextChangeRange(new TextSpan(42, 2), 13)).WithNotEqualValues(new TextChangeRange(new TextSpan(42, 2), 5)),
41EqualityUnit.Create(new TextChangeRange(new TextSpan(42, 2), 13)).WithNotEqualValues(new TextChangeRange(new TextSpan(42, 4), 13)));
Text\TextChangeTests.cs (193)
41var subText = text.GetSubText(new TextSpan(0, 5));
49var subText = text.GetSubText(new TextSpan(6, 5));
57var subText = text.GetSubText(new TextSpan(4, 3));
88new TextChange(new TextSpan(0, 5), "Halo"),
89new TextChange(new TextSpan(6, 5), "Universe"));
100new TextChange(new TextSpan(0, 5), "Halo"),
101new TextChange(new TextSpan(3, 5), "Universe")
113new TextChange(new TextSpan(6, 5), "Universe"),
114new TextChange(new TextSpan(0, 5), "Halo")
127new TextChange(new TextSpan(6, 7), "Universe"),
128new TextChange(new TextSpan(0, 5), "Halo")
142new TextChange(new TextSpan(6, 0), "Super "),
143new TextChange(new TextSpan(6, 0), "Spectacular "));
154new TextChange(new TextSpan(6, 0), "Super "),
155new TextChange(new TextSpan(6, 2), "Vu"));
166new TextChange(new TextSpan(6, 2), "Vu"),
167new TextChange(new TextSpan(6, 0), "Super ")
180new TextChange(new TextSpan(4, 1), string.Empty),
181new TextChange(new TextSpan(5, 1), string.Empty));
191new TextChange(new TextSpan(4, 1), string.Empty),
192new TextChange(new TextSpan(6, 5), "Universe"));
194var subText = newText.GetSubText(new TextSpan(3, 4));
206new TextChange(new TextSpan(4, 1), string.Empty));
216new TextChange(new TextSpan(6, 5), "Universe"));
233new TextChange(new TextSpan(0, 1), "[1]"),
234new TextChange(new TextSpan(1, 1), "[2]"),
235new TextChange(new TextSpan(5, 0), "[3]"),
236new TextChange(new TextSpan(25, 2), "[4]")
278new TextChange(new TextSpan(8, 2), "IN"),
279new TextChange(new TextSpan(15, 2), "IN"));
286new TextChange(new TextSpan(8, 2), new string('a', 10)),
287new TextChange(new TextSpan(15, 2), new string('a', 10)));
294new TextChange(new TextSpan(8, 2), "\r\n"),
295new TextChange(new TextSpan(15, 2), "\r\n"));
302new TextChange(new TextSpan(6, 0), "aa\r"),
303new TextChange(new TextSpan(11, 0), "aa\r"));
310new TextChange(new TextSpan(6, 0), "aa\n"),
311new TextChange(new TextSpan(11, 0), "aa\n"));
318new TextChange(new TextSpan(4, 4), "aaaaaa"),
319new TextChange(new TextSpan(15, 4), "aaaaaa"));
326new TextChange(new TextSpan(5, 0), "aaaaaa"));
333new TextChange(new TextSpan(5, 0), "\naaaaaa\r"));
340new TextChange(new TextSpan(21, 0), "Line4\r\n"),
341new TextChange(new TextSpan(21, 0), "Line5\r\n"));
392var subtext = text.GetSubText(new TextSpan(5, 10));
403var newText = text.Replace(new TextSpan(0, 20), "");
414var newText = text.Replace(new TextSpan(10, 6), "");
426var newText = text.Replace(new TextSpan(10, 1), "");
442var textWithSegments = text.Replace(new TextSpan(10, 0), "*");
459var textWithSegments = text.Replace(new TextSpan(10, 0), "*");
463var textWithFewerSegments = textWithSegments.Replace(new TextSpan(9, 3), "");
479var textWithSegments = text.Replace(new TextSpan(0, text.Length), "");
636var change1 = original.WithChanges(new TextChange(new TextSpan(5, 6), string.Empty)); // prepare a ChangedText instance
647var change1 = original.WithChanges(new TextChange(new TextSpan(5, 6), string.Empty)); // prepare a ChangedText instance
648var change2 = change1.WithChanges(new TextChange(new TextSpan(2, 0), string.Empty)); // this should not cause exception
657var change1 = original.WithChanges(new TextChange(new TextSpan(6, 0), "Cruel "));
658var change2 = change1.WithChanges(new TextChange(new TextSpan(7, 3), "oo"));
663Assert.Equal(new TextSpan(6, 0), changes[0].Span);
672var change1 = original.WithChanges(new TextChange(new TextSpan(1, 3), "aa"));
673var change2 = change1.WithChanges(new TextChange(new TextSpan(2, 0), "bb"));
678Assert.Equal(new[] { new TextChange(new TextSpan(1, 3), "abba") }, changes);
686var change1 = original.WithChanges(new TextChange(new TextSpan(1, 1), "aaa"));
687var change2 = change1.WithChanges(new TextChange(new TextSpan(3, 0), "bb"));
692Assert.Equal(new[] { new TextChange(new TextSpan(1, 1), "aabba") }, changes);
700var change1 = original.WithChanges(new TextChange(new TextSpan(1, 3), "aa"));
701var change2 = change1.WithChanges(new TextChange(new TextSpan(2, 1), "bb"));
706Assert.Equal(new[] { new TextChange(new TextSpan(1, 3), "abb") }, changes);
713var change1 = original.WithChanges(new TextChange(new TextSpan(6, 0), "Cruel "));
714var change2 = change1.WithChanges(new TextChange(new TextSpan(2, 14), "ar"));
719Assert.Equal(new TextSpan(2, 8), changes[0].Span);
727var change1 = original.WithChanges(new TextChange(new TextSpan(6, 0), "Cruel "));
728var change2 = change1.WithChanges(new TextChange(new TextSpan(4, 6), " Bel"));
733Assert.Equal(new TextSpan(4, 2), changes[0].Span);
741var change1 = original.WithChanges(new TextChange(new TextSpan(6, 0), "Cruel "));
742var change2 = change1.WithChanges(new TextChange(new TextSpan(7, 6), "wazy V"));
747Assert.Equal(new TextSpan(6, 1), changes[0].Span);
755var change1 = original.WithChanges(new TextChange(new TextSpan(1, 0), "aa"));
756var change2 = change1.WithChanges(new TextChange(new TextSpan(1, 0), "bb"));
761Assert.Equal(new[] { new TextChange(new TextSpan(1, 0), "bbaa") }, changes);
768var change1 = original.WithChanges(new TextChange(new TextSpan(1, 3), "aa"));
769var change2 = change1.WithChanges(new TextChange(new TextSpan(1, 0), "bb"));
774Assert.Equal(new[] { new TextChange(new TextSpan(1, 3), "bbaa") }, changes);
781var change1 = original.WithChanges(new TextChange(new TextSpan(1, 0), "aa"));
782var change2 = change1.WithChanges(new TextChange(new TextSpan(1, 1), "bb"));
787Assert.Equal(new[] { new TextChange(new TextSpan(1, 0), "bba") }, changes);
794var change1 = original.WithChanges(new TextChange(new TextSpan(1, 0), "aa"));
795var change2 = change1.WithChanges(new TextChange(new TextSpan(1, 2), "bb"));
800Assert.Equal(new[] { new TextChange(new TextSpan(1, 0), "bb") }, changes);
807var change1 = original.WithChanges(new TextChange(new TextSpan(1, 0), "aa"));
808var change2 = change1.WithChanges(new TextChange(new TextSpan(1, 3), "bb"));
813Assert.Equal(new[] { new TextChange(new TextSpan(1, 1), "bb") }, changes);
821var change1 = original.WithChanges(new TextChange(new TextSpan(1, 3), "aa"));
822var change2 = change1.WithChanges(new TextChange(new TextSpan(1, 1), "bb"));
827Assert.Equal(new[] { new TextChange(new TextSpan(1, 3), "bba") }, changes);
835var change1 = original.WithChanges(new TextChange(new TextSpan(1, 3), "aa"));
836var change2 = change1.WithChanges(new TextChange(new TextSpan(1, 3), "bb"));
847var change1 = original.WithChanges(new TextChange(new TextSpan(4, 0), "o "));
848var change2 = change1.WithChanges(new TextChange(new TextSpan(6, 0), "World"));
853Assert.Equal(new TextSpan(4, 0), changes[0].Span);
861var change1 = original.WithChanges(new TextChange(new TextSpan(4, 0), "o"));
862var change2 = change1.WithChanges(new TextChange(new TextSpan(6, 0), "World"));
867Assert.Equal(new TextSpan(4, 0), changes[0].Span);
869Assert.Equal(new TextSpan(5, 0), changes[1].Span);
877var change1 = original.WithChanges(new TextChange(new TextSpan(8, 0), "l"));
878var change2 = change1.WithChanges(new TextChange(new TextSpan(4, 0), "o"));
883Assert.Equal(new TextSpan(4, 0), changes[0].Span);
885Assert.Equal(new TextSpan(8, 0), changes[1].Span);
893var change1 = original.WithChanges(new TextChange(new TextSpan(4, 0), " World"));
895var change2 = change1.WithChanges(new TextChange(new TextSpan(4, 0), "o"));
900Assert.Equal(new TextSpan(4, 0), changes[0].Span);
911c => c.WithChanges(new TextChange(new TextSpan(4, 0), "o ")),
912c => c.WithChanges(new TextChange(new TextSpan(6, 0), "World")));
918Assert.Equal(new TextSpan(4, 0), changes[0].Span);
926new TextChangeRange(new TextSpan(919, 10), 466),
927new TextChangeRange(new TextSpan(936, 33), 29),
928new TextChangeRange(new TextSpan(1098, 0), 70),
929new TextChangeRange(new TextSpan(1125, 4), 34),
930new TextChangeRange(new TextSpan(1138, 0), 47));
932new TextChangeRange(new TextSpan(997, 0), 2),
933new TextChangeRange(new TextSpan(1414, 0), 2),
934new TextChangeRange(new TextSpan(1419, 0), 2),
935new TextChangeRange(new TextSpan(1671, 5), 5),
936new TextChangeRange(new TextSpan(1681, 0), 4));
941new TextChangeRange(new TextSpan(919, 10), 468),
942new TextChangeRange(new TextSpan(936, 33), 33),
943new TextChangeRange(new TextSpan(1098, 0), 70),
944new TextChangeRange(new TextSpan(1125, 4), 38),
945new TextChangeRange(new TextSpan(1138, 0), 47));
954Assert.Equal("new TextChange(new TextSpan(0, 1), \"abc\")", new TextChange(new TextSpan(0, 1), "abc").GetDebuggerDisplay());
955Assert.Equal("new TextChange(new TextSpan(0, 1), (NewLength = 10))", new TextChange(new TextSpan(0, 1), "0123456789").GetDebuggerDisplay());
979var newChange = new TextChange(new TextSpan(i, length: random.Next(originalText.Length - i)), newText);
999var newChange = new TextChange(new TextSpan(i, length: random.Next(editedLength - i)), newText);
1047var change1 = originalText.WithChanges(new TextChange(new TextSpan(0, 2), "a"));
1048var change2 = change1.WithChanges(new TextChange(new TextSpan(0, 2), "bb"));
1061var change1 = original.WithChanges(new TextChange(new TextSpan(0, 0), "aa"), new TextChange(new TextSpan(1, 1), "aa"));
1062var change2 = change1.WithChanges(new TextChange(new TextSpan(0, 1), "b"), new TextChange(new TextSpan(2, 2), ""));
1075var change1 = originalText.WithChanges(new TextChange(new TextSpan(0, 0), "a"));
1076var change2 = change1.WithChanges(new TextChange(new TextSpan(0, 2), ""), new TextChange(new TextSpan(2, 0), "bb"));
1089var change1 = originalText.WithChanges(new TextChange(new TextSpan(0, 1), "aa"), new TextChange(new TextSpan(3, 1), "aa"));
1090var change2 = change1.WithChanges(new TextChange(new TextSpan(0, 0), "bbb"));
1102var change1 = originalText.WithChanges(new TextChange(new TextSpan(0, 3), "a"), new TextChange(new TextSpan(5, 0), "aaa"));
1103var change2 = change1.WithChanges(new TextChange(new TextSpan(0, 2), ""), new TextChange(new TextSpan(3, 1), "bb"));
1116var change1 = originalText.WithChanges(new TextChange(new TextSpan(0, 1), "aaaaa"), new TextChange(new TextSpan(3, 1), "aaaa"), new TextChange(new TextSpan(6, 1), "aaaaa"));
1117var change2 = change1.WithChanges(new TextChange(new TextSpan(0, 0), "b"), new TextChange(new TextSpan(2, 0), "b"), new TextChange(new TextSpan(3, 4), "bbbbb"), new TextChange(new TextSpan(9, 5), "bbbbb"), new TextChange(new TextSpan(15, 3), ""));
1130var change1 = originalText.WithChanges(new TextChange(new TextSpan(0, 1), "a"));
1131var change2 = change1.WithChanges(new TextChange(new TextSpan(0, 1), "b"), new TextChange(new TextSpan(2, 2), "b"));
1144var change1 = originalText.WithChanges(new TextChange(new TextSpan(0, 1), "aa"));
1145var change2 = change1.WithChanges(new TextChange(new TextSpan(0, 0), "b"), new TextChange(new TextSpan(1, 2), "b"));
1158var change1 = originalText.WithChanges(new TextChange(new TextSpan(0, 2), "a"), new TextChange(new TextSpan(3, 2), "a"));
1159var change2 = change1.WithChanges(new TextChange(new TextSpan(0, 3), "bbb"));
1172var change1 = originalText.WithChanges(new TextChange(new TextSpan(0, 4), ""), new TextChange(new TextSpan(5, 1), ""));
1173var change2 = change1.WithChanges(new TextChange(new TextSpan(0, 1), ""), new TextChange(new TextSpan(1, 0), ""));
1186var change1 = originalText.WithChanges(new TextChange(new TextSpan(0, 2), ""), new TextChange(new TextSpan(3, 1), ""), new TextChange(new TextSpan(4, 0), ""), new TextChange(new TextSpan(4, 0), ""), new TextChange(new TextSpan(4, 0), ""));
1187var change2 = change1.WithChanges(new TextChange(new TextSpan(0, 1), ""), new TextChange(new TextSpan(1, 1), ""), new TextChange(new TextSpan(2, 0), ""));
1200var change1 = originalText.WithChanges(new TextChange(new TextSpan(0, 1), ""), new TextChange(new TextSpan(2, 1), ""));
1201var change2 = change1.WithChanges(new TextChange(new TextSpan(0, 0), ""), new TextChange(new TextSpan(1, 1), ""));
1226new TextChange(new TextSpan(39, 0), " "),
1227new TextChange(new TextSpan(42, 0), " "),
1228new TextChange(new TextSpan(57, 0), " "),
1229new TextChange(new TextSpan(58, 0), "\r\n"),
1230new TextChange(new TextSpan(64, 2), " "),
1231new TextChange(new TextSpan(69, 0), " "),
1237new TextChange(new TextSpan(35, 4), string.Empty),
1238new TextChange(new TextSpan(46, 4), string.Empty),
1239new TextChange(new TextSpan(73, 4), string.Empty),
1240new TextChange(new TextSpan(88, 0), " "),
1241new TextChange(new TextSpan(90, 4), string.Empty),
1242new TextChange(new TextSpan(105, 4), string.Empty),
Text\TextSpanTest.cs (87)
21var span = new TextSpan(0, 42);
30var span = new TextSpan(1, 40);
42var span = new TextSpan(0, 0);
50var s1 = new TextSpan(1, 40);
51var s2 = new TextSpan(1, 40);
64var s1 = new TextSpan(1, 40);
65var s2 = new TextSpan(2, 40);
78var s1 = new TextSpan(1, 5);
79var s2 = new TextSpan(1, 40);
89TextSpan span = new TextSpan(0, 0);
100TextSpan span = new TextSpan(0, 1);
112TextSpan span = new TextSpan(15, 1485);
122TextSpan span = new TextSpan(0, int.MaxValue - 1);
131TextSpan span = new TextSpan(0, 10);
141TextSpan span_05_15 = new TextSpan(5, 10);
142TextSpan span_03_10 = new TextSpan(3, 7);
143TextSpan span_10_11 = new TextSpan(10, 1);
144TextSpan span_00_03 = new TextSpan(0, 3);
165Assert.False(new TextSpan(2, 5).Contains(new TextSpan(0, 0)));
166Assert.False(new TextSpan(2, 5).Contains(new TextSpan(10, 0)));
169Assert.True(new TextSpan(2, 5).Contains(new TextSpan(3, 0)));
172Assert.True(new TextSpan(2, 5).Contains(new TextSpan(2, 0)));
175Assert.True(new TextSpan(2, 5).Contains(new TextSpan(7, 0)));
178Assert.True(new TextSpan(2, 0).Contains(new TextSpan(2, 0)));
185Assert.False(new TextSpan(0, 0).Contains(new TextSpan(2, 5)));
186Assert.False(new TextSpan(10, 0).Contains(new TextSpan(2, 5)));
189Assert.False(new TextSpan(3, 0).Contains(new TextSpan(2, 5)));
192Assert.False(new TextSpan(2, 0).Contains(new TextSpan(2, 5)));
195Assert.False(new TextSpan(7, 0).Contains(new TextSpan(2, 5)));
201TextSpan span1 = new TextSpan(0, 10);
202TextSpan span2 = new TextSpan(0, 10);
218TextSpan span1 = new TextSpan(0, 10);
219TextSpan span2 = new TextSpan(0, 11);
220TextSpan span3 = new TextSpan(1, 11);
236TextSpan span1 = new TextSpan(10, 10); // 10..20
237TextSpan span2 = new TextSpan(5, 5); // 5..10
248TextSpan span1 = new TextSpan(10, 10); // 10..20
249TextSpan span2 = new TextSpan(5, 2); // 5..7
260TextSpan span1 = new TextSpan(10, 10); // 10..20
261TextSpan span2 = new TextSpan(5, 10); // 5..15
265Assert.Equal(span1.Overlap(span2), new TextSpan(10, 5));
266Assert.Equal(span2.Overlap(span1), new TextSpan(10, 5));
272TextSpan span1 = new TextSpan(10, 0); // [10, 10)
273TextSpan span2 = new TextSpan(10, 0); // [10, 10)
284TextSpan span1 = new TextSpan(10, 0); // [10, 10)
285TextSpan span2 = new TextSpan(5, 10); // [5, 15)
296TextSpan span1 = new TextSpan(10, 10); // 10..20
297TextSpan span2 = new TextSpan(5, 5); // 5..10
301Assert.Equal(span1.Intersection(span2), new TextSpan(10, 0));
302Assert.Equal(span2.Intersection(span1), new TextSpan(10, 0));
308TextSpan span1 = new TextSpan(10, 10); // 10..20
309TextSpan span2 = new TextSpan(5, 2); // 5..7
320TextSpan span1 = new TextSpan(10, 10); // 10..20
321TextSpan span2 = new TextSpan(5, 10); // 5..15
325Assert.Equal(span1.Intersection(span2), new TextSpan(10, 5));
326Assert.Equal(span2.Intersection(span1), new TextSpan(10, 5));
332TextSpan span1 = new TextSpan(10, 0); // [10, 10)
333TextSpan span2 = new TextSpan(10, 0); // [10, 10)
337Assert.Equal(span1.Intersection(span2), new TextSpan(10, 0));
338Assert.Equal(span2.Intersection(span1), new TextSpan(10, 0));
344TextSpan span1 = new TextSpan(2, 5); // [2, 7)
345TextSpan span2 = new TextSpan(7, 5); // [7, 12)
349Assert.Equal(span1.Intersection(span2), new TextSpan(7, 0));
350Assert.Equal(span2.Intersection(span1), new TextSpan(7, 0));
356TextSpan span1 = new TextSpan(2, 5); // [2, 7)
357TextSpan span2 = new TextSpan(3, 0); // [3, 3)
361Assert.Equal(span1.Intersection(span2), new TextSpan(3, 0));
362Assert.Equal(span2.Intersection(span1), new TextSpan(3, 0));
368TextSpan span1 = new TextSpan(2, 5); // [2, 7)
369TextSpan span2 = new TextSpan(2, 0); // [2, 2)
373Assert.Equal(span1.Intersection(span2), new TextSpan(2, 0));
374Assert.Equal(span2.Intersection(span1), new TextSpan(2, 0));
380TextSpan span1 = new TextSpan(2, 5); // [2, 7)
381TextSpan span2 = new TextSpan(7, 0); // [7, 0)
385Assert.Equal(span1.Intersection(span2), new TextSpan(7, 0));
386Assert.Equal(span2.Intersection(span1), new TextSpan(7, 0));
Microsoft.CodeAnalysis.VisualBasic (12)
Microsoft.CodeAnalysis.VisualBasic.CommandLine.UnitTests (3)
Microsoft.CodeAnalysis.VisualBasic.EditorFeatures (3)
Microsoft.CodeAnalysis.VisualBasic.Emit.UnitTests (5)
CodeGen\CodeGenTuples.vb (5)
6872Dim loc1 = Location.Create(tree, New TextSpan(0, 1))
6921Dim loc1 = Location.Create(tree, New TextSpan(0, 1))
6922Dim loc2 = Location.Create(tree, New TextSpan(1, 1))
7270Dim loc1 = Location.Create(tree, New TextSpan(0, 1))
7271Dim loc2 = Location.Create(tree, New TextSpan(1, 1))
Microsoft.CodeAnalysis.VisualBasic.Features (8)
Microsoft.CodeAnalysis.VisualBasic.Features.UnitTests (2)
Microsoft.CodeAnalysis.VisualBasic.Semantic.UnitTests (4)
Microsoft.CodeAnalysis.VisualBasic.Symbol.UnitTests (5)
Microsoft.CodeAnalysis.VisualBasic.Syntax.UnitTests (93)
IncrementalParser\IncrementalParser.vb (35)
90Dim span = New TextSpan(i, 10)
112Dim newText = text.WithChanges(New TextChange(New TextSpan(text.Length, 0), _s.Substring(i, 1)))
129Dim newText = oldText.WithChanges(New TextChange(New TextSpan(pos, 0), "'"))
138Dim anotherText = newText.WithChanges(New TextChange(New TextSpan(pos, 1), ""))
171.changeSpan = New TextSpan(code.Length, 0),
193.changeSpan = New TextSpan(code.Length, 0),
216.changeSpan = New TextSpan(code.Length, 0),
232.changeSpan = New TextSpan(code.Length, 0),
251.changeSpan = New TextSpan(code.Length, 0),
266.changeSpan = New TextSpan(code.Length, 0),
284.changeSpan = New TextSpan(0, 0),
303.changeSpan = New TextSpan(0, 0),
317.changeSpan = New TextSpan(0, 0),
329.changeSpan = New TextSpan(0, 0),
384.changeSpan = New TextSpan(0, 0),
397.changeSpan = New TextSpan(0, 0),
417.changeSpan = New TextSpan(0, 0),
432.changeSpan = New TextSpan(0, 0),
445.changeSpan = New TextSpan(0, 0),
459.changeSpan = New TextSpan(0, 0),
641.changeSpan = New TextSpan(0, 0),
653.changeSpan = New TextSpan(0, 10),
689.changeSpan = New TextSpan(0, 0),
705Dim newText = oldText.WithChanges(New TextChange(New TextSpan(22, 0), " Sub "))
744Dim newText = oldText.WithChanges(New TextChange(New TextSpan(103, 0), " "))
770Dim newText = oldText.WithChanges(New TextChange(New TextSpan(insertionPoint, 0), " "))
795Dim newText = oldText.WithChanges(New TextChange(New TextSpan(insertionPoint, replace.Length), "{"))
830Dim newText = oldText.WithChanges(New TextChange(New TextSpan(pos, 0), "'"))
852.changeSpan = New TextSpan(15, 0),
1160Dim span = New TextSpan(oldIText.Length, 0)
1166span = New TextSpan(0, code1.Length)
1206Dim span = New TextSpan(code.IndexOf("="c), 0)
1225Dim change = New TextChange(New TextSpan(position, 2), "End" + vbCrLf)
1243Dim change = New TextChange(New TextSpan(position, 0), " Select c" + vbCrLf)
1677Dim change = New TextChange(New TextSpan(position, 2), "71")
IncrementalParser\IPEndBlockStatements.vb (5)
35.changeSpan = New TextSpan(code.Length, 0),
164.changeSpan = New TextSpan(code.Length, 0),
302.changeSpan = New TextSpan(code.Length, 0),
448.changeSpan = New TextSpan(code.Length, 0),
550.changeSpan = New TextSpan(code.Length, 0),
TestSyntaxNodes.vb (47)
336VerifyListSpans(precedingTrivia, New TextSpan(tree.FullSpan.Start, (tree.SpanStart - tree.FullSpan.Start)))
342VerifyListSpans(followingTrivia, New TextSpan(tree.Span.End, (tree.FullSpan.End - tree.Span.End)))
361VerifyListSpans(precedingTrivia, New TextSpan(tree.FullSpan.Start, (tree.SpanStart - tree.FullSpan.Start)))
367VerifyListSpans(followingTrivia, New TextSpan(tree.Span.End, (tree.FullSpan.End - tree.Span.End)))
375Assert.Equal(New TextSpan(0, 1), dig1.Span)
376Assert.Equal(New TextSpan(0, 1), dig1.FullSpan)
381Assert.Equal(New TextSpan(0, 4), binop.Span)
382Assert.Equal(New TextSpan(1, 1), binop.OperatorToken.Span)
383Assert.Equal(New TextSpan(1, 2), binop.OperatorToken.FullSpan)
384Assert.Equal(New TextSpan(3, 1), binop.Right.Span)
385Assert.Equal(New TextSpan(3, 1), binop.Right.FullSpan)
388Assert.Equal(New TextSpan(0, 17), simpleTree.Span)
389Assert.Equal(New TextSpan(0, 18), simpleTree.FullSpan)
390Assert.Equal(New TextSpan(3, 14), DirectCast(simpleTree, BinaryExpressionSyntax).Right.Span)
393Assert.Equal(New TextSpan(6, 1), argList.Arguments(0).Span)
394Assert.Equal(New TextSpan(7, 1), argList.Arguments.GetWithSeparators(1).Span)
395Assert.Equal(New TextSpan(9, 4), argList.Arguments(1).Span)
396Assert.Equal(New TextSpan(13, 1), argList.Arguments.GetWithSeparators(3).Span)
397Assert.Equal(New TextSpan(15, 1), argList.Arguments(2).Span)
441Dim x As New TextSpan(-1, 0)
445Dim x As New TextSpan(0, -1)
449Dim x As New TextSpan(-1, -1)
453Dim x As New TextSpan(2, -4)
488VerifyListSpans(l, New TextSpan(0, 6))
527VerifyListSpans(l, New TextSpan(0, 21))
995CheckErrorList(kwModule, {17}, {New TextSpan(0, 6)})
1001CheckErrorList(kwModule, {17, 42}, {New TextSpan(0, 6), New TextSpan(0, 6)})
1007CheckErrorList(endModule, {101, 17, 42}, {New TextSpan(3, 3), New TextSpan(6, 6), New TextSpan(6, 6)})
1012CheckErrorList(endModule, {1, 101, 17, 42}, {New TextSpan(0, 12), New TextSpan(3, 3), New TextSpan(6, 6), New TextSpan(6, 6)})
1048{New TextSpan(26, 5), New TextSpan(26, 5), New TextSpan(71, 22), New TextSpan(94, 1), New TextSpan(96, 5)})
1825Dim resultList = identExpr.DescendantTokens(New TextSpan(3, 18))
2273Dim EOFSpan = New TextSpan(root.FullSpan.End, 0)
2283Dim nodeEndPositionSpan = New TextSpan(classDecl.FullSpan.End, 0)
2294Dim invalidSpan = New TextSpan(100, 100)
2296invalidSpan = New TextSpan(root.FullSpan.End - 1, 2)
2298invalidSpan = New TextSpan(classDecl2.FullSpan.Start - 1, root.FullSpan.End)
2300invalidSpan = New TextSpan(classDecl.FullSpan.End, root.FullSpan.End)
Microsoft.CodeAnalysis.VisualBasic.Test.Utilities (2)
Microsoft.CodeAnalysis.VisualBasic.Workspaces (5)
Microsoft.CodeAnalysis.VisualBasic.Workspaces.UnitTests (2)
Microsoft.CodeAnalysis.Workspaces (46)
src\Compilers\Core\Portable\Text\TextChangeRangeExtensions.cs (4)
225addAndAdjustOldDelta(builder, ref oldDelta, new TextChangeRange(new TextSpan(oldChange.Span.Start, oldChangeLeadingDeletion), oldChangeLeadingInsertion));
226oldChange = new TextChangeRange(new TextSpan(newChange.SpanStart - oldDelta, oldChange.Span.Length - oldChangeLeadingDeletion), oldChange.NewLength - oldChangeLeadingInsertion);
380add(builder, new TextChangeRange(new TextSpan(newChange.SpanStart - oldDelta, newChange.SpanLength), newChange.NewLength));
391builder[^1] = new TextChangeRange(new TextSpan(last.Span.Start, last.Span.Length + change.Span.Length), last.NewLength + change.NewLength);
Microsoft.CodeAnalysis.Workspaces.Test.Utilities (1)
Microsoft.CodeAnalysis.Workspaces.UnitTests (17)
Microsoft.Gen.ComplianceReports.Unit.Tests (1)
Microsoft.Gen.ContextualOptions.Unit.Tests (1)
Microsoft.Gen.Logging.Unit.Tests (1)
Microsoft.Gen.Metrics.Unit.Tests (1)
Microsoft.Gen.MetricsReports.Unit.Tests (1)
Microsoft.VisualStudio.LanguageServices (6)
Microsoft.VisualStudio.LanguageServices.UnitTests (5)
Microsoft.VisualStudio.LanguageServices.Xaml (1)
Roslyn.VisualStudio.Next.UnitTests (1)
System.Text.RegularExpressions.Generator (1)