9 overrides of Length
Microsoft.CodeAnalysis (6)
Text\ChangedText.cs (1)
112public override int Length
Text\CompositeText.cs (1)
57public override int Length
Text\LargeText.cs (1)
154public override int Length => _length;
Text\StringBuilderText.cs (1)
49public override int Length
Text\StringText.cs (1)
47public override int Length => _source.Length;
Text\SubText.cs (1)
43public override int Length => UnderlyingSpan.Length;
Microsoft.CodeAnalysis.CSharp.Features (1)
EmbeddedLanguages\CSharpTestEmbeddedLanguageClassifier.cs (1)
286public override int Length => _virtualChars.Length;
Microsoft.CodeAnalysis.EditorFeatures.Text (1)
Extensions.SnapshotSourceText.cs (1)
122public override int Length
Microsoft.CodeAnalysis.Test.Utilities (1)
Syntax\SourceUtilities.cs (1)
29public override int Length
224 references to Length
IdeCoreBenchmarks (1)
SyntacticChangeRangeBenchmark.cs (1)
81var newText = _text.WithChanges(new TextChange(new TextSpan(_text.Length - addedText.Length, addedText.Length), addedText));
Microsoft.AspNetCore.App.Analyzers (1)
Infrastructure\VirtualChars\AbstractVirtualCharService.ITextInfo.cs (1)
23public int Length(SourceText text) => text.Length;
Microsoft.CodeAnalysis (74)
DiagnosticAnalyzer\AdditionalTextComparer.cs (2)
45if (xText is null || yText is null || xText.Length != yText.Length)
EmbeddedText.cs (2)
303maxByteCount = text.Encoding.GetMaxByteCount(text.Length); 319using (var writer = new StreamWriter(builder, text.Encoding, bufferSize: Math.Max(1, text.Length), leaveOpen: true))
Syntax\SyntaxDiffer.cs (1)
81return new[] { new TextSpan(0, after!.GetText().Length) };
Syntax\SyntaxTreeExtensions.cs (2)
24var fullSpan = new TextSpan(0, text.Length); 69if (index < text.Length)
Text\ChangedText.cs (7)
40if (oldText.Length + deltaLength != newText.Length) 49if (change.Span.Start > oldText.Length) 52if (change.Span.End > oldText.Length) 114get { return _newText.Length; } 206return ImmutableArray.Create(new TextChangeRange(new TextSpan(0, oldText.Length), _newText.Length));
Text\CompositeText.cs (17)
44Debug.Assert(_segments[i].Length > 0); 45offset += _segments[i].Length; 100var copyLength = Math.Min(count, segment.Length - segOffset); 158var copyLength = Math.Min(count, segment.Length - segOffset); 211segments.RemoveWhere(static (s, _, _) => s.Length == 0, default(VoidResult)); 218if (prevSegment.Length > 0 && prevSegment[^1] == '\r' && curSegment[0] == '\n') 222segments[i - 1] = prevSegment.GetSubText(new TextSpan(0, prevSegment.Length - 1)); 224segments[i + 1] = curSegment.GetSubText(new TextSpan(1, curSegment.Length - 1)); 233segments.RemoveWhere(static (s, _, _) => s.Length == 0, default(VoidResult)); 293if (segments[i].Length <= segmentSize) 299if (segments[j].Length > segmentSize) 326if (segments[i].Length <= segmentSize) 328int combinedLength = segments[i].Length; 334if (segments[j].Length > segmentSize) 340combinedLength += segments[j].Length; 377length += segment.Length; 452Debug.Assert(segment.Length > 0);
Text\SourceText.cs (26)
407get { return this.Length; } 462/// greater than <see cref="Length"/>.</exception> 490if (span.End > this.Length) 508else if (spanLength == this.Length && span.Start == 0) 523if (start < 0 || start > this.Length) 534return this.GetSubText(new TextSpan(start, this.Length - start)); 543this.Write(textWriter, new TextSpan(0, this.Length), cancellationToken); 638for (int index = 0, length = this.Length; index < length; index += CharBufferSize) 710return ToString(new TextSpan(0, this.Length)); 725int position = Math.Max(Math.Min(span.Start, this.Length), 0); 726int length = Math.Min(span.End, this.Length) - position; 729while (position < this.Length && length > 0) 768if (change.Span.End > this.Length) 819if (position < this.Length) 821var subText = this.GetSubText(new TextSpan(position, this.Length - position)); 890return ImmutableArray.Create(new TextChangeRange(new TextSpan(0, oldText.Length), this.Length)); 988return TextLine.FromSpanUnsafe(_text, TextSpan.FromBounds(start, _text.Length)); 1000if (position < 0 || position > _text.Length) 1048var length = this.Length; 1066if (0 == this.Length) 1073var lineStarts = new SegmentedList<int>(Length / 64) 1180if (this.Length != other.Length) 1192for (int position = 0, length = this.Length; position < length; position += CharBufferSize) 1194var count = Math.Min(this.Length - position, CharBufferSize);
Text\SourceTextComparer.cs (1)
39return Hash.Combine(obj.Length,
Text\SourceTextStream.cs (3)
41_charBuffer = new char[Math.Min(bufferSize, _source.Length)]; 97while (count >= _minimumTargetBufferCount && _position < _source.Length) 134int charsToRead = Math.Min(_charBuffer.Length, _source.Length - _sourceOffset);
Text\SubText.cs (4)
26|| span.Start >= text.Length 28|| span.End > text.Length) 93int compositeStart = Math.Min(UnderlyingText.Length, UnderlyingSpan.Start + start); 94int compositeEnd = Math.Min(UnderlyingText.Length, compositeStart + length);
Text\TextLine.cs (8)
41if (span.Start > text.Length || span.Start < 0 || span.End > text.Length) 46if (text.Length > 0) 60if (!endIncludesLineBreak && span.End < text.Length) 72if (span.End < text.Length && !endIncludesLineBreak) 91Debug.Assert(span.End == text.Length || TextUtilities.IsAnyLineBreakCharacter(text[span.End - 1])); 135if (_text == null || _text.Length == 0 || _endIncludingBreaks == _start) 173if (_text == null || _text.Length == 0)
Text\TextUtilities.cs (1)
35return (next < text.Length) && '\n' == text[next] ? 2 : 1;
Microsoft.CodeAnalysis.CodeStyle (3)
src\Compilers\Core\Portable\Syntax\SyntaxTreeExtensions.cs (2)
24var fullSpan = new TextSpan(0, text.Length); 69if (index < text.Length)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EmbeddedLanguages\VirtualChars\AbstractVirtualCharService.ITextInfo.cs (1)
24public readonly int Length(SourceText text) => text.Length;
Microsoft.CodeAnalysis.CodeStyle.Fixes (1)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Utilities\ParsedDocument.cs (1)
83textChanges.Count == 1 && textChanges[0].Span != new TextSpan(0, oldDocument.Text.Length))
Microsoft.CodeAnalysis.CSharp (9)
Parser\Lexer.cs (3)
735int end = TextWindow.Text.Length; 2066if ((position + s_conflictMarkerLength) <= text.Length) 2081return (position + s_conflictMarkerLength) < text.Length &&
Parser\SlidingTextWindow.cs (2)
68_textEnd = text.Length; 183int amountToRead = Math.Min(_text.Length, position + _characterWindow.Length) - position;
Parser\SyntaxParser.cs (1)
141var size = Math.Min(CachedTokenArraySize, this.lexer.TextWindow.Text.Length / 2);
Syntax\CSharpSyntaxTree.cs (2)
550return this.WithChanges(newText, new[] { new TextChangeRange(new TextSpan(0, this.Length), newText.Length) }); 564if (workingChanges.Count == 1 && workingChanges[0].Span == new TextSpan(0, this.Length) && workingChanges[0].NewLength == newText.Length)
Syntax\CSharpSyntaxTree.LazySyntaxTree.cs (1)
62get { return _text.Length; }
Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes (4)
src\Analyzers\CSharp\CodeFixes\NewLines\ArrowExpressionClausePlacement\ArrowExpressionClausePlacementCodeFixProvider.cs (2)
84while (end < text.Length && text[end] == ' ') 87if (end < text.Length && SyntaxFacts.IsNewLine(text[end]))
src\Analyzers\CSharp\CodeFixes\NewLines\ConditionalExpressionPlacement\ConditionalExpressionPlacementCodeFixProvider.cs (2)
86while (end < text.Length && text[end] == ' ') 89if (end < text.Length && SyntaxFacts.IsNewLine(text[end]))
Microsoft.CodeAnalysis.CSharp.EditorFeatures (2)
StringCopyPaste\StringCopyPasteCommandHandler.cs (1)
300if (newTextAfterChanges.Length != snapshotAfterPaste.Length)
StringCopyPaste\StringCopyPasteHelpers.cs (1)
30=> index >= 0 && index < text.Length ? text[index] : '\0';
Microsoft.CodeAnalysis.CSharp.EditorFeatures.UnitTests (5)
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));
Microsoft.CodeAnalysis.CSharp.Features (6)
Completion\CompletionProviders\CompletionUtilities.cs (1)
137=> ch == ' ' && (characterPosition == text.Length - 1 || !IsWordStartCharacter(text[characterPosition + 1]));
DocumentationComments\CSharpDocumentationCommentSnippetService.cs (1)
231if (position >= syntaxTree.GetText(cancellationToken).Length)
src\Analyzers\CSharp\CodeFixes\NewLines\ArrowExpressionClausePlacement\ArrowExpressionClausePlacementCodeFixProvider.cs (2)
84while (end < text.Length && text[end] == ' ') 87if (end < text.Length && SyntaxFacts.IsNewLine(text[end]))
src\Analyzers\CSharp\CodeFixes\NewLines\ConditionalExpressionPlacement\ConditionalExpressionPlacementCodeFixProvider.cs (2)
86while (end < text.Length && text[end] == ' ') 89if (end < text.Length && SyntaxFacts.IsNewLine(text[end]))
Microsoft.CodeAnalysis.CSharp.Semantic.UnitTests (1)
Semantics\BindingAwaitTests.cs (1)
28TextSpan span = new TextSpan(text.Length, 0);
Microsoft.CodeAnalysis.CSharp.Symbol.UnitTests (2)
Symbols\Metadata\MetadataTypeTests.cs (2)
364var span = new TextSpan(oldIText.Length, 0); 379span = new TextSpan(oldIText.Length, 0);
Microsoft.CodeAnalysis.CSharp.Syntax.UnitTests (8)
Diagnostics\LocationsTests.cs (3)
400Assert.InRange(diag.Location.SourceSpan.End, diag.Location.SourceSpan.Start, syntaxTree.GetText().Length); 465Assert.InRange(diag.Location.SourceSpan.Start, 0, syntaxTree.GetText().Length); 466Assert.InRange(diag.Location.SourceSpan.End, 0, syntaxTree.GetText().Length);
IncrementalParsing\IncrementalParsingTests.cs (4)
2816oldText.Length, 2900var span = new TextSpan(oldIText.Length, 0); 2914span = new TextSpan(oldIText.Length, 0); 3727var newText = oldText.WithChanges(new TextChange(new TextSpan(oldText.Length, 0), newChar.ToString()));
Syntax\Mocks\MockCSharpSyntaxTree.cs (1)
47=> _sourceText.Length;
Microsoft.CodeAnalysis.EditorFeatures (5)
CommentSelection\ToggleBlockCommentCommandHandler.cs (1)
52closeIdx = allText.Length - commentInfo.BlockCommentEndString.Length;
EditorConfigSettings\Updater\NamingStyles\SourceTextExtensions.cs (1)
47var span = new TextSpan(sourceText.Length, 0);
EditorConfigSettings\Updater\SettingsUpdateHelper.cs (1)
349var result = editorConfigText.WithChanges(new TextChange(new TextSpan(editorConfigText.Length, 0), prefix + newEntry));
Remote\SolutionChecksumUpdater.cs (1)
242if (changeRanges is [{ Span.Length: var singleChangeLength }] && singleChangeLength == oldText.Length)
RenameTracking\RenameTrackingTaggerProvider.StateMachine.cs (1)
186while (rightSidePosition < beforeText.Length && IsTrackableCharacter(syntaxFactsService, beforeText[rightSidePosition]))
Microsoft.CodeAnalysis.EditorFeatures.Test.Utilities (3)
BracePairs\AbstractBracePairsTests.cs (1)
36await service.AddBracePairsAsync(document, new TextSpan(0, text.Length), bracePairs, CancellationToken.None);
ObsoleteSymbol\AbstractObsoleteSymbolTests.cs (1)
37var textSpans = ImmutableArray.Create(new TextSpan(0, text.Length));
ReassignedVariable\AbstractReassignedVariableTests.cs (1)
36var textSpans = ImmutableArray.Create(new TextSpan(0, text.Length));
Microsoft.CodeAnalysis.EditorFeatures.Text (2)
Extensions.SnapshotSourceText.cs (2)
303return [new TextChangeRange(new TextSpan(0, oldText.Length), this.Length)]; 343return GetChangeRanges(oldSnapshot, oldText.Length, newSnapshot);
Microsoft.CodeAnalysis.EditorFeatures.UnitTests (1)
EditorAdapter\TextSnapshotImplementationTest.cs (1)
33Assert.Equal(tuple.Item1.Length, text.Length);
Microsoft.CodeAnalysis.EditorFeatures2.UnitTests (1)
FindReferences\FindReferencesTests.vb (1)
416builder.Append(text.GetSubText(New TextSpan(position, text.Length - position)))
Microsoft.CodeAnalysis.Features (14)
CodeFixes\Configuration\ConfigurationUpdater.cs (1)
768var textChange = new TextChange(new TextSpan(result.Length, 0), prefix + newEntry);
Completion\CommonCompletionUtilities.cs (3)
51while (end < text.Length && isWordCharacter(text[end])) 76if (characterPosition < text.Length - 1 && 216if (characterPosition < 0 || characterPosition >= text.Length)
NavigateTo\NavigateToUtilities.cs (4)
38spanStart = spanStart > sourceText.Length ? sourceText.Length : spanStart; 39spanEnd = spanEnd > sourceText.Length ? sourceText.Length : spanEnd;
Navigation\IDefinitionLocationService.cs (1)
85=> position >= 0 && position < text.Length ? text[position] : (char)0;
ReplaceDocCommentTextWithTag\AbstractReplaceDocCommentTextWithTagCodeRefactoringProvider.cs (2)
175while (endExclusive < sourceText.Length && 197endExclusive + 1 < sourceText.Length && char.IsLetterOrDigit(sourceText[endExclusive + 1]))
SolutionCrawler\AbstractDocumentDifferenceService.cs (1)
53var incrementalParsingCandidate = range.NewLength != newText.Length;
src\Compilers\Core\Portable\Text\TextUtilities.cs (1)
35return (next < text.Length) && '\n' == text[next] ? 2 : 1;
Wrapping\AbstractCodeActionComputer.cs (1)
90new TextChange(TextSpan.FromBounds(nodeOrToken.Span.End, OriginalSourceText.Length), newLine));
Microsoft.CodeAnalysis.LanguageServer.Protocol (2)
Extensions\ProtocolConversions.cs (1)
311throw new ArgumentException($"Range={RangeToString(range)}. text.Length={text.Length}. text.Lines.Count={text.Lines.Count}", ex);
Features\Diagnostics\EngineV2\DiagnosticIncrementalAnalyzer_GetDiagnosticsForSpan.cs (1)
434Debug.Assert(span.Value.Length < _text.Length);
Microsoft.CodeAnalysis.LanguageServer.Protocol.UnitTests (1)
InlayHint\AbstractInlayHintTests.cs (1)
28var span = TextSpan.FromBounds(0, text.Length);
Microsoft.CodeAnalysis.Test.Utilities (1)
Diagnostics\CommonDiagnosticAnalyzers.cs (1)
1789return text.Length;
Microsoft.CodeAnalysis.UnitTests (39)
Text\CompositeTextTests.cs (1)
41for (var i = 0; i < sourceText.Length; i++)
Text\LargeTextTests.cs (5)
48Assert.Equal(HelloWorld.Length, text.Length); 57Assert.Equal(0, text.Length); 82text.CopyTo(0, buffer, destOffset, text.Length); 127for (int start = 0; start < text.Length; start += HelloWorld.Length) 187if (nextPosition < text.Length)
Text\SourceTextTests.cs (2)
45Assert.Equal(0, text.Length); 428sourceText.Write(writer, TextSpan.FromBounds(1, sourceText.Length));
Text\StringText_LineTest.cs (4)
31var span = TextSpan.FromBounds(0, text.Length); 42var span = TextSpan.FromBounds(0, text.Length); 45Assert.Equal(text.Length, line.End); 83var start = text.Length;
Text\StringTextDecodingTests.cs (1)
325Assert.Equal(0, encodedText.Length);
Text\StringTextTest.cs (1)
140if (nextPosition < text.Length)
Text\TextChangeTests.cs (25)
224Assert.Throws<ArgumentOutOfRangeException>(() => newText.CopyTo(newText.Length - 1, destination, 0, 2)); 360Assert.Equal(str.Length + n, text.Length); 380Assert.Equal(str.Length, text.Length); 389Assert.Equal(26, text.Length); 393Assert.Equal(10, subtext.Length); 405Assert.Equal(6, newText.Length); 416Assert.Equal(20, newText.Length); 428Assert.Equal(25, newText.Length); 444Assert.Equal(27, textWithSegments.Length); 460Assert.Equal(27, textWithSegments.Length); 465Assert.Equal(24, textWithFewerSegments.Length); 479var textWithSegments = text.Replace(new TextSpan(0, text.Length), ""); 480Assert.Equal(0, textWithSegments.Length); 491t = t.Replace(t.Length, 0, b); // add b's 502t = t.Replace(t.Length, 0, "c"); 510Assert.Equal(new string('c', t.Segments[2].Length), t.Segments[2].ToString()); 521t = t.Replace(t.Length, 0, b); // add b's 532t = t.Replace(t.Length, 0, c); // add c's that are the same segment size as the a's and b's 625Assert.Equal(text.Length + largeText.Length, newText.Length); 969var editedLength = originalText.Length; 973var oldMaxInsertLength = originalText.Length * 2; 976for (int i = 0; i < originalText.Length; i += random.Next(maxSkipLength)) 979var newChange = new TextChange(new TextSpan(i, length: random.Next(originalText.Length - i)), newText);
Microsoft.CodeAnalysis.VisualBasic (7)
CommandLine\CommandLineDiagnosticFormatter.vb (1)
39text.Length < diagnosticSpanOpt.Value.End Then
Scanner\Scanner.vb (3)
111_bufferLen = textToScan.Length 727If (position + s_conflictMarkerLength) <= text.Length Then 738Return (position + s_conflictMarkerLength) < text.Length AndAlso
Syntax\VisualBasicSyntaxTree.LazySyntaxTree.vb (1)
68Return _text.Length
Syntax\VisualBasicSyntaxTree.vb (2)
108Return Me.WithChanges(newText, {New TextChangeRange(New TextSpan(0, Me.Length), newText.Length)}) 120If changes.Length = 1 AndAlso changes(0).Span = New TextSpan(0, Me.Length) AndAlso changes(0).NewLength = newText.Length Then
Microsoft.CodeAnalysis.VisualBasic.Features (1)
DocumentationComments\VisualBasicDocumentationCommentSnippetService.vb (1)
230If position >= syntaxTree.GetText(cancellationToken).Length Then
Microsoft.CodeAnalysis.VisualBasic.Syntax.UnitTests (3)
IncrementalParser\IncrementalParser.vb (3)
89For i As Integer = 0 To text.Length - 11 112Dim newText = text.WithChanges(New TextChange(New TextSpan(text.Length, 0), _s.Substring(i, 1))) 1160Dim span = New TextSpan(oldIText.Length, 0)
Microsoft.CodeAnalysis.Workspaces (19)
CodeCleanup\CodeCleaner.cs (1)
53return await CleanupAsync(document, new TextSpan(0, text.Length), options, providers, cancellationToken: cancellationToken).ConfigureAwait(false);
Shared\Extensions\FileLinePositionSpanExtensions.cs (1)
90Contract.ThrowIfTrue(end > text.Lines.GetLinePosition(text.Length));
Shared\Extensions\SourceTextExtensions.cs (5)
80var length = text.Length - value.Length; 112startIndex = startIndex + normalized.Length > text.Length 113? text.Length - normalized.Length 147if (position + value.Length > text.Length) 179var length = sourceText.Length;
src\Compilers\Core\Portable\Syntax\SyntaxTreeExtensions.cs (2)
24var fullSpan = new TextSpan(0, text.Length); 69if (index < text.Length)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EmbeddedLanguages\VirtualChars\AbstractVirtualCharService.ITextInfo.cs (1)
24public readonly int Length(SourceText text) => text.Length;
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Utilities\ParsedDocument.cs (1)
83textChanges.Count == 1 && textChanges[0].Span != new TextSpan(0, oldDocument.Text.Length))
TemporaryStorage\TemporaryStorageService.cs (1)
113var size = Encoding.Unicode.GetMaxByteCount(text.Length);
TemporaryStorage\TrivialTemporaryStorageService.cs (1)
68Identifier = new TemporaryStorageIdentifier(Guid.NewGuid().ToString(), 0, _sourceText.Length);
Workspace\Solution\Document.cs (1)
449if (textChanges.Count > 1 || (textChanges.Count == 1 && textChanges[0].Span != new TextSpan(0, oldText.Length)))
Workspace\Solution\DocumentState.cs (5)
272if (oldText.Length < MaxTextChangeRangeLength && newText.Length < MaxTextChangeRangeLength) 279if (change.NewLength == newText.Length) 690if (newTree.Length == newText.Length) 703FatalError.ReportAndCatch(new Exception($"tree and text has different length {newTree.Length} vs {newText.Length}"), ErrorSeverity.Critical);
Microsoft.CodeAnalysis.Workspaces.MSBuild.UnitTests (1)
VisualStudioMSBuildWorkspaceTests.cs (1)
3316Assert.Equal("//\u00E2\u20AC\u0153".Length, text.Length);
Microsoft.CodeAnalysis.Workspaces.Test.Utilities (2)
Formatting\FormattingTestBase.cs (2)
111if (span.Start == 0 && span.End == inputText.Length) 114outputBuilder.Add(TextSpan.FromBounds(0, outputText.Length));
Microsoft.CodeAnalysis.Workspaces.UnitTests (3)
SolutionTests\SolutionWithSourceGeneratorTests.cs (1)
566var newText = existingText.WithChanges(new TextChange(new TextSpan(existingText.Length, length: 0), " With Change"));
SymbolKeyTests.cs (1)
1419var newTree = syntaxTree.WithChangedText(text.WithChanges(new TextChange(new TextSpan(0, text.Length), text.ToString().Replace(" ", " "))));
SyntaxPathTests.cs (1)
109var newText = text.WithChanges(new TextChange(new TextSpan(0, text.Length), ""));
Microsoft.VisualStudio.LanguageServices (2)
Workspace\VisualStudioDocumentNavigationService.cs (2)
140var boundedPosition = GetPositionWithinDocumentBounds(position, text.Length); 351var boundedTextSpan = GetSpanWithinDocumentBounds(textSpan, text.Length);