23 overrides of Length
GenerateDocumentationAndConfigFiles (1)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EmbeddedLanguages\VirtualChars\VirtualCharSequenceSourceText.cs (1)
27public override int Length => _virtualChars.Count;
Metrics (1)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EmbeddedLanguages\VirtualChars\VirtualCharSequenceSourceText.cs (1)
27public override int Length => _virtualChars.Count;
Metrics.Legacy (1)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EmbeddedLanguages\VirtualChars\VirtualCharSequenceSourceText.cs (1)
27public override int Length => _virtualChars.Count;
Microsoft.CodeAnalysis (7)
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\SourceText.cs (1)
1391public override int Length => _underlying.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.Analyzers (1)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EmbeddedLanguages\VirtualChars\VirtualCharSequenceSourceText.cs (1)
27public override int Length => _virtualChars.Count;
Microsoft.CodeAnalysis.AnalyzerUtilities (1)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EmbeddedLanguages\VirtualChars\VirtualCharSequenceSourceText.cs (1)
27public override int Length => _virtualChars.Count;
Microsoft.CodeAnalysis.BannedApiAnalyzers (1)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EmbeddedLanguages\VirtualChars\VirtualCharSequenceSourceText.cs (1)
27public override int Length => _virtualChars.Count;
Microsoft.CodeAnalysis.CodeStyle (1)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EmbeddedLanguages\VirtualChars\VirtualCharSequenceSourceText.cs (1)
27public override int Length => _virtualChars.Count;
Microsoft.CodeAnalysis.EditorFeatures.Text (1)
Extensions.SnapshotSourceText.cs (1)
121public override int Length
Microsoft.CodeAnalysis.PerformanceSensitiveAnalyzers (1)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EmbeddedLanguages\VirtualChars\VirtualCharSequenceSourceText.cs (1)
27public override int Length => _virtualChars.Count;
Microsoft.CodeAnalysis.PublicApiAnalyzers (1)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EmbeddedLanguages\VirtualChars\VirtualCharSequenceSourceText.cs (1)
27public override int Length => _virtualChars.Count;
Microsoft.CodeAnalysis.ResxSourceGenerator (1)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EmbeddedLanguages\VirtualChars\VirtualCharSequenceSourceText.cs (1)
27public override int Length => _virtualChars.Count;
Microsoft.CodeAnalysis.Test.Utilities (1)
Syntax\SourceUtilities.cs (1)
29public override int Length
Microsoft.CodeAnalysis.Workspaces (1)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EmbeddedLanguages\VirtualChars\VirtualCharSequenceSourceText.cs (1)
27public override int Length => _virtualChars.Count;
Roslyn.Diagnostics.Analyzers (1)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EmbeddedLanguages\VirtualChars\VirtualCharSequenceSourceText.cs (1)
27public override int Length => _virtualChars.Count;
Test.Utilities (1)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EmbeddedLanguages\VirtualChars\VirtualCharSequenceSourceText.cs (1)
27public override int Length => _virtualChars.Count;
Text.Analyzers (1)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EmbeddedLanguages\VirtualChars\VirtualCharSequenceSourceText.cs (1)
27public override int Length => _virtualChars.Count;
386 references to Length
GenerateDocumentationAndConfigFiles (4)
src\Compilers\Core\Portable\Syntax\SyntaxTreeExtensions.cs (2)
29var fullSpan = new TextSpan(0, text.Length); 74if (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)
79textChanges.Count == 1 && textChanges[0].Span != new TextSpan(0, oldDocument.Text.Length))
IdeCoreBenchmarks (1)
SyntacticChangeRangeBenchmark.cs (1)
81var newText = _text.WithChanges(new TextChange(new TextSpan(_text.Length - addedText.Length, addedText.Length), addedText));
Metrics (3)
src\Compilers\Core\Portable\Syntax\SyntaxTreeExtensions.cs (2)
29var fullSpan = new TextSpan(0, text.Length); 74if (index < text.Length)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EmbeddedLanguages\VirtualChars\AbstractVirtualCharService.ITextInfo.cs (1)
24public readonly int Length(SourceText text) => text.Length;
Metrics.Legacy (3)
src\Compilers\Core\Portable\Syntax\SyntaxTreeExtensions.cs (2)
29var fullSpan = new TextSpan(0, text.Length); 74if (index < text.Length)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EmbeddedLanguages\VirtualChars\AbstractVirtualCharService.ITextInfo.cs (1)
24public readonly int Length(SourceText text) => text.Length;
Microsoft.AspNetCore.App.Analyzers (1)
Infrastructure\VirtualChars\AbstractVirtualCharService.ITextInfo.cs (1)
23public int Length(SourceText text) => text.Length;
Microsoft.AspNetCore.Razor.Test.Common (2)
Language\SyntaxTreeVerifier.cs (2)
28var builder = new StringBuilder(sourceText.Length); 29for (var i = 0; i < sourceText.Length; i++)
Microsoft.CodeAnalysis (70)
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)
82return new[] { new TextSpan(0, after!.GetText().Length) };
Syntax\SyntaxTreeExtensions.cs (2)
29var fullSpan = new TextSpan(0, text.Length); 74if (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.RemoveAll(static (s, _, _) => s.Length == 0, arg: 0); 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.RemoveAll(static (s, _, _) => s.Length == 0, arg: 0); 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) 712return ToString(new TextSpan(0, this.Length)); 727int position = Math.Max(Math.Min(span.Start, this.Length), 0); 728int length = Math.Min(span.End, this.Length) - position; 791if (change.Span.End > this.Length) 842if (position < this.Length) 844var subText = this.GetSubText(new TextSpan(position, this.Length - position)); 913return ImmutableArray.Create(new TextChangeRange(new TextSpan(0, oldText.Length), this.Length)); 1043return TextLine.FromSpanUnsafe(_text, TextSpan.FromBounds(start, _text.Length), lineBreakLength: 0); 1057if (position < 0 || position > _text.Length) 1105var length = this.Length; 1123if (0 == this.Length) 1130var lineStarts = new SegmentedList<uint>(Length / 64) 1243if (this.Length != other.Length) 1255for (int position = 0, length = this.Length; position < length; position += CharBufferSize) 1257var count = Math.Min(this.Length - position, CharBufferSize); 1391public override int Length => _underlying.Length;
Text\SourceTextStream.cs (2)
112while (count >= _minimumTargetBufferCount && _position < _source.Length) 149int charsToRead = Math.Min(_charBuffer.Length, _source.Length - _sourceOffset);
Text\SubText.cs (3)
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 (7)
52if (span.Start > text.Length || span.Start < 0 || span.End > text.Length) 57if (text.Length > 0) 71else if (span.End < text.Length) 82if (span.End < text.Length && lineBreakLen == 0) 101Debug.Assert(span.End == text.Length || TextUtilities.IsAnyLineBreakCharacter(text[span.End - 1])); 175if (_text == null || _text.Length == 0)
Text\TextUtilities.cs (1)
35return (next < text.Length) && '\n' == text[next] ? 2 : 1;
Microsoft.CodeAnalysis.Analyzers (5)
MetaAnalyzers\Fixers\AnalyzerReleaseTrackingFix.cs (1)
434return unshippedText.Replace(new TextSpan(0, unshippedText.Length), builder.ToString());
src\Compilers\Core\Portable\Syntax\SyntaxTreeExtensions.cs (2)
29var fullSpan = new TextSpan(0, text.Length); 74if (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)
79textChanges.Count == 1 && textChanges[0].Span != new TextSpan(0, oldDocument.Text.Length))
Microsoft.CodeAnalysis.AnalyzerUtilities (3)
src\Compilers\Core\Portable\Syntax\SyntaxTreeExtensions.cs (2)
29var fullSpan = new TextSpan(0, text.Length); 74if (index < text.Length)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EmbeddedLanguages\VirtualChars\AbstractVirtualCharService.ITextInfo.cs (1)
24public readonly int Length(SourceText text) => text.Length;
Microsoft.CodeAnalysis.BannedApiAnalyzers (4)
src\Compilers\Core\Portable\Syntax\SyntaxTreeExtensions.cs (2)
29var fullSpan = new TextSpan(0, text.Length); 74if (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)
79textChanges.Count == 1 && textChanges[0].Span != new TextSpan(0, oldDocument.Text.Length))
Microsoft.CodeAnalysis.CodeStyle (3)
src\Compilers\Core\Portable\Syntax\SyntaxTreeExtensions.cs (2)
29var fullSpan = new TextSpan(0, text.Length); 74if (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)
79textChanges.Count == 1 && textChanges[0].Span != new TextSpan(0, oldDocument.Text.Length))
Microsoft.CodeAnalysis.CSharp (8)
Parser\Lexer.cs (3)
719int end = TextWindow.Text.Length; 2072if ((position + s_conflictMarkerLength) <= text.Length) 2087return (position + s_conflictMarkerLength) < text.Length &&
Parser\SlidingTextWindow.cs (1)
108_textEnd = text.Length;
Parser\SyntaxParser.cs (1)
141var size = Math.Min(CachedTokenArraySize, this.lexer.TextWindow.Text.Length / 2);
Syntax\CSharpSyntaxTree.cs (2)
551return this.WithChanges(newText, new[] { new TextChangeRange(new TextSpan(0, this.Length), newText.Length) }); 565if (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 (5)
src\Analyzers\CSharp\CodeFixes\ConvertNamespace\ConvertNamespaceTransform.cs (1)
401|| document.Text.Lines.GetLinePosition(document.Text.Length).Character == 0)
src\Analyzers\CSharp\CodeFixes\NewLines\ArrowExpressionClausePlacement\ArrowExpressionClausePlacementCodeFixProvider.cs (2)
82while (end < text.Length && text[end] == ' ') 85if (end < text.Length && SyntaxFacts.IsNewLine(text[end]))
src\Analyzers\CSharp\CodeFixes\NewLines\ConditionalExpressionPlacement\ConditionalExpressionPlacementCodeFixProvider.cs (2)
84while (end < text.Length && text[end] == ' ') 87if (end < text.Length && SyntaxFacts.IsNewLine(text[end]))
Microsoft.CodeAnalysis.CSharp.EditorFeatures (2)
StringCopyPaste\StringCopyPasteCommandHandler.cs (1)
295if (newTextAfterChanges.Length != snapshotAfterPaste.Length)
StringCopyPaste\StringCopyPasteHelpers.cs (1)
31=> index >= 0 && index < text.Length ? text[index] : '\0';
Microsoft.CodeAnalysis.CSharp.EditorFeatures.UnitTests (6)
Diagnostics\DiagnosticAnalyzerDriver\DiagnosticAnalyzerDriverTests.cs (6)
55await DiagnosticProviderTestUtilities.GetAllDiagnosticsAsync(workspace, document, new TextSpan(0, document.GetTextAsync().Result.Length)); 83await DiagnosticProviderTestUtilities.GetAllDiagnosticsAsync(ideEngineWorkspace, ideEngineDocument, new TextSpan(0, ideEngineDocument.GetTextAsync().Result.Length)); 119return await DiagnosticProviderTestUtilities.GetAllDiagnosticsAsync(workspace, document, new TextSpan(0, document.GetTextAsync().Result.Length)); 165await DiagnosticProviderTestUtilities.GetAllDiagnosticsAsync(workspace, sourceDocument, new TextSpan(0, sourceDocument.GetTextAsync().Result.Length)); 195var diagnostics = await DiagnosticProviderTestUtilities.GetAllDiagnosticsAsync(workspace, ideEngineDocument, new TextSpan(0, ideEngineDocument.GetTextAsync().Result.Length)); 251var diagnostics = await DiagnosticProviderTestUtilities.GetAllDiagnosticsAsync(ideEngineWorkspace, ideEngineDocument, new TextSpan(0, ideEngineDocument.GetTextAsync().Result.Length));
Microsoft.CodeAnalysis.CSharp.Features (10)
Completion\CompletionProviders\CompletionUtilities.cs (1)
137=> ch == ' ' && (characterPosition == text.Length - 1 || !IsWordStartCharacter(text[characterPosition + 1]));
DocumentationComments\CSharpDocumentationCommentSnippetService.cs (1)
238if (position >= syntaxTree.GetText(cancellationToken).Length)
RawStringLiteral\CSharpRawStringLiteralOnAutoInsertService.cs (3)
40if (position + 1 < text.Length && text[position + 1] == '"') 91while (end < text.Length && text[end] == '"') 139if (position < text.Length && text[position] == '"')
src\Analyzers\CSharp\CodeFixes\ConvertNamespace\ConvertNamespaceTransform.cs (1)
401|| document.Text.Lines.GetLinePosition(document.Text.Length).Character == 0)
src\Analyzers\CSharp\CodeFixes\NewLines\ArrowExpressionClausePlacement\ArrowExpressionClausePlacementCodeFixProvider.cs (2)
82while (end < text.Length && text[end] == ' ') 85if (end < text.Length && SyntaxFacts.IsNewLine(text[end]))
src\Analyzers\CSharp\CodeFixes\NewLines\ConditionalExpressionPlacement\ConditionalExpressionPlacementCodeFixProvider.cs (2)
84while (end < text.Length && text[end] == ' ') 87if (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)
3246oldText.Length, 3330var span = new TextSpan(oldIText.Length, 0); 3344span = new TextSpan(oldIText.Length, 0); 4194var newText = oldText.WithChanges(new TextChange(new TextSpan(oldText.Length, 0), newChar.ToString()));
Syntax\Mocks\MockCSharpSyntaxTree.cs (1)
47=> _sourceText.Length;
Microsoft.CodeAnalysis.EditorFeatures (7)
CommentSelection\ToggleBlockCommentCommandHandler.cs (1)
50closeIdx = allText.Length - commentInfo.BlockCommentEndString.Length;
EditorConfigSettings\Updater\NamingStyles\SourceTextExtensions.cs (1)
46var span = new TextSpan(sourceText.Length, 0);
EditorConfigSettings\Updater\SettingsUpdateHelper.cs (1)
349var result = editorConfigText.WithChanges(new TextChange(new TextSpan(editorConfigText.Length, 0), prefix + newEntry));
GoOrFind\AbstractGoOrFindNavigationService.cs (1)
283position = Math.Min(text.Length, position);
InlineRename\InlineRenameSession.OpenTextBufferManager.cs (1)
566if (textChanges.Count != 1 || textChanges[0].Span != new TextSpan(0, oldText.Length))
Remote\SolutionChecksumUpdater.cs (1)
241if (changeRanges is [{ Span.Length: var singleChangeLength }] && singleChangeLength == oldText.Length)
RenameTracking\RenameTrackingTaggerProvider.StateMachine.cs (1)
184while (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 (5)
Extensions.SnapshotSourceText.cs (2)
302return [new TextChangeRange(new TextSpan(0, oldText.Length), this.Length)]; 342return GetChangeRanges(oldSnapshot, oldText.Length, newSnapshot);
Implementation\SourceTextReader.cs (3)
17return _position == _sourceText.Length 24return _position == _sourceText.Length 31var charsToCopy = Math.Min(count, _sourceText.Length - _position);
Microsoft.CodeAnalysis.EditorFeatures.UnitTests (1)
EditorAdapter\TextSnapshotImplementationTest.cs (1)
33Assert.Equal(tuple.Item1.Length, text.Length);
Microsoft.CodeAnalysis.ExternalAccess.HotReload (1)
Api\HotReloadMSBuildWorkspace.cs (1)
225if (!zeroLengthRetryPerformed && sourceText.Length == 0)
Microsoft.CodeAnalysis.Features (32)
AddFileBanner\AbstractAddFileBannerCodeRefactoringProvider.cs (1)
137if (text.Length == 0 || !IsCommentStartCharacter(text[0]))
BraceMatching\AbstractBraceMatcher.cs (1)
68if (position < text.Length && this.IsBrace(text[position]))
BraceMatching\BraceMatchingService.cs (1)
27if (position < 0 || position > text.Length)
CodeFixes\Configuration\ConfigurationUpdater.cs (1)
768var textChange = new TextChange(new TextSpan(result.Length, 0), prefix + newEntry);
CodeFixes\Service\CodeFixService.cs (1)
295textSpan = new TextSpan(0, text.Length);
CodeRefactorings\SyncNamespace\AbstractChangeNamespaceService.cs (1)
715[new TextSpan(0, text.Length)],
Completion\CommonCompletionUtilities.cs (3)
51while (end < text.Length && isWordCharacter(text[end])) 76if (characterPosition < text.Length - 1 && 194if (characterPosition < 0 || characterPosition >= text.Length)
Completion\Providers\AbstractDocCommentCompletionProvider.cs (1)
310if (text.Length > replacementSpan.End + 1
Completion\Providers\AbstractMemberInsertingCompletionProvider.cs (1)
238if (targetSelectionSpan.Start > 0 && targetSelectionSpan.End <= text.Length)
Completion\Providers\CompletionUtilities.cs (1)
88while (end < text.Length && syntaxFacts.IsIdentifierPartCharacter(text[end]))
Copilot\ICopilotChangeAnalysisService.cs (4)
128OldDocumentLength: oldText.Length, 129NewDocumentLength: newText.Length, 130TextChangeDelta: newText.Length - oldText.Length,
Copilot\IProposalAdjusterService.cs (2)
207if (span.Start < originalText.Length && originalText[span.Start] == '\n') 218span.End < originalText.Length &&
Diagnostics\Service\DiagnosticAnalyzerService_GetDiagnosticsForSpan.cs (1)
56if (range == new TextSpan(0, text.Length))
Diagnostics\Service\DocumentAnalysisExecutor_Helpers.cs (1)
180if (location.SourceSpan.End > text.Length)
EditAndContinue\DocumentSemanticModel.cs (1)
29Debug.Assert(syntaxTree.GetText().Length == 0);
ExternalAccess\VSTypeScript\VSTypeScriptTaskListService.cs (1)
40var textSpan = new TextSpan(Math.Min(text.Length, Math.Max(0, d.Position)), 0);
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)
181while (endExclusive < sourceText.Length && 203endExclusive + 1 < sourceText.Length && char.IsLetterOrDigit(sourceText[endExclusive + 1]))
SolutionCrawler\AbstractDocumentDifferenceService.cs (1)
54var 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)
91new TextChange(TextSpan.FromBounds(nodeOrToken.Span.End, OriginalSourceText.Length), newLine));
Microsoft.CodeAnalysis.LanguageServer.Protocol (4)
Extensions\ProtocolConversions.cs (3)
352throw new ArgumentException($"Range={RangeToString(range)}. text.Length={text.Length}. text.Lines.Count={text.Lines.Count}", ex); 607Math.Min(text.Length, span.Start), 608Math.Min(text.Length, span.End));
Handler\SemanticTokens\SemanticTokensHelpers.cs (1)
36ranges ??= [ProtocolConversions.TextSpanToRange(new TextSpan(0, text.Length), text)];
Microsoft.CodeAnalysis.LanguageServer.Protocol.UnitTests (9)
Diagnostics\PullDiagnosticTests.cs (3)
336await InsertTextAsync(testLspServer, document, text.Length, "}"); 825var originalSpan = originalText.Lines.GetLinePositionSpan(new TextSpan(0, originalText.Length)); 2396position ??= text.Length;
InlayHint\AbstractInlayHintTests.cs (1)
28var span = TextSpan.FromBounds(0, text.Length);
InlayHint\CSharpInlayHintTests.cs (1)
115var span = TextSpan.FromBounds(0, sourceText.Length);
ProtocolConversionsTests.cs (1)
294Assert.Equal(sourceText.Length, textSpan.End);
SemanticTokens\SemanticTokensRangeTests.cs (1)
492document, spans: [text.Lines.GetLinePositionSpan(new(0, text.Length))], isVS, options: options, cancellationToken: CancellationToken.None);
SpellCheck\SpellCheckTests.cs (2)
208await InsertTextAsync(testLspServer, document, sourceText.Length, "// comment"); 256await InsertTextAsync(testLspServer, document, sourceText.Length, text: " ");
Microsoft.CodeAnalysis.PerformanceSensitiveAnalyzers (4)
src\Compilers\Core\Portable\Syntax\SyntaxTreeExtensions.cs (2)
29var fullSpan = new TextSpan(0, text.Length); 74if (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)
79textChanges.Count == 1 && textChanges[0].Span != new TextSpan(0, oldDocument.Text.Length))
Microsoft.CodeAnalysis.PublicApiAnalyzers (3)
src\Compilers\Core\Portable\Syntax\SyntaxTreeExtensions.cs (2)
29var fullSpan = new TextSpan(0, text.Length); 74if (index < text.Length)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EmbeddedLanguages\VirtualChars\AbstractVirtualCharService.ITextInfo.cs (1)
24public readonly int Length(SourceText text) => text.Length;
Microsoft.CodeAnalysis.PublicApiAnalyzers.CodeFixes (6)
AnnotatePublicApiFix.cs (1)
99SourceText newSourceText = sourceText.Replace(new TextSpan(0, sourceText.Length), string.Join(endOfLine, lines) + sourceText.GetEndOfFileText(endOfLine));
DeclarePublicApiFix.cs (4)
116Debug.Assert(unshippedText.Length > 0); 146return sourceText?.Replace(new TextSpan(0, sourceText.Length), newText) ?? SourceText.From(newText); 175SourceText newSourceText = sourceText.Replace(new TextSpan(0, sourceText.Length), string.Join(endOfLine, newLines) + sourceText.GetEndOfFileText(endOfLine)); 317else if (newSourceText.Length > 0)
PublicApiFixHelpers.cs (1)
78if (sourceText == null || sourceText.Length == 0)
Microsoft.CodeAnalysis.Razor.Compiler (15)
Language\Legacy\SeekableTextReader.cs (3)
37public int Length => SourceText.Length; 74if (_position < SourceText.Length) 118if (SourceText.Length == 0)
Language\RazorHtmlWriter.cs (6)
54source.Text.Length == text.Length, 55$"The backing HTML document should be the same length as the original document. Expected: {source.Text.Length} Actual: {text.Length}"); 311Debug.Assert(nextIndex <= text.Length, "The next index should not exceed the length of the source text."); 313if (nextIndex >= text.Length || text[nextIndex] != '>')
Language\Syntax\SyntaxNodeExtensions.cs (6)
52if (source.Text.Length == 0) 57if (node.Position == source.Text.Length) 60var lastPosition = source.Text.Length - 1; 87if (source.Text.Length == 0) 92if (token.Position == source.Text.Length) 95var lastPosition = source.Text.Length - 1;
Microsoft.CodeAnalysis.Razor.Workspaces (45)
CodeActions\CSharp\TypeAccessibilityCodeActionProvider.cs (1)
101if (diagnosticSpan.End > context.SourceText.Length)
Diagnostics\RazorDiagnosticHelper.cs (2)
80var spanStartIndex = Math.Min(sourceSpan.AbsoluteIndex, sourceText.Length); 81var spanEndIndex = Math.Min(sourceSpan.AbsoluteIndex + sourceSpan.Length, sourceText.Length);
Diagnostics\RazorTranslateDiagnosticsService.cs (1)
280if (absoluteIndex == sourceText.Length)
Diagnostics\TaskListDiagnosticProvider.cs (1)
70if (source.Length < i + j)
DocumentMapping\AbstractDocumentMappingService.cs (2)
394Debug.Assert(sourceDocument.Text.Length > 0, "Source document length should be greater than 0 here because there's a mapping before us"); 396var endOfDocumentPosition = sourceDocument.Text.GetLinePosition(sourceDocument.Text.Length);
DocumentMapping\IDocumentMappingServiceExtensions.cs (1)
27if (sourceText.Length == 0)
DocumentMapping\RazorEditService.cs (2)
231if (spanStart <= 0 || spanStart >= csharpSourceText.Length || spanEnd <= 0 || spanEnd >= csharpSourceText.Length)
DocumentMapping\RazorEditService_UsingDirectives.cs (2)
241if (endPosition >= text.Length) 251if (endPosition >= text.Length)
Extensions\RazorCodeDocumentExtensions.cs (1)
105var documentLength = codeDocument.Source.Text.Length;
Extensions\RazorSyntaxNodeExtensions.cs (3)
208Debug.Assert(start <= sourceText.Length && end <= sourceText.Length, "Node position exceeds source length."); 210if (start == sourceText.Length && node.Width == 0)
Extensions\RazorSyntaxTokenExtensions.cs (3)
63Debug.Assert(start <= sourceText.Length && end <= sourceText.Length, "Node position exceeds source length."); 65if (start == sourceText.Length && token.Width == 0)
Extensions\SourceTextExtensions.cs (5)
76var changedEnd = textEnd + (changedText.Length - text.Length); 126=> text.TryGetFirstNonWhitespaceOffset(new TextSpan(0, text.Length), out offset); 177var indexableSpanEnd = Math.Min(span.End, text.Length - 1); 229absoluteIndex = text.Length;
Extensions\TextLineExtensions.cs (1)
18Debug.Assert(index < text.Length, "This should be impossible as we validated offset against the line length above.");
Formatting\Passes\CSharpFormattingPass.CSharpDocumentGenerator.cs (1)
1140for (i++; i < _sourceText.Length; i++)
Formatting\Passes\CSharpOnTypeFormattingPass.cs (1)
94var count = csharpText.Length;
Formatting\Passes\HtmlFormattingPass.cs (1)
137Debug.Assert(originalPosition < originalText.Length);
Formatting\Passes\HtmlOnTypeFormattingPass.cs (1)
119line.Text?.Length > 1 &&
Formatting\SnippetFormatter.cs (1)
34if (lineText.Length == 0)
Formatting\UsingDirectiveHelper.cs (1)
173if (endIndex < codeDocument.Source.Text.Length)
TextDifferencing\SourceTextDiffer.CharDiffer.cs (7)
51OldText.CopyTo(0, _oldBuffer.Array, 0, Math.Min(OldText.Length, BufferSize)); 54NewText.CopyTo(0, _newBuffer.Array, 0, Math.Min(NewText.Length, BufferSize)); 56OldSourceLength = oldText.Length; 57NewSourceLength = newText.Length; 76Debug.Assert(text.Length >= BufferSize); 80if (start + BufferSize > text.Length) 82start = text.Length - BufferSize;
TextDifferencing\SourceTextDiffer.cs (2)
106else if (oldText.Length == 0 || newText.Length == 0)
TextDifferencing\SourceTextDiffer.TextSpanDiffer.cs (2)
31if (oldText.Length > 0) 36if (newText.Length > 0)
TextDifferencing\SourceTextDiffer.WordDiffer.cs (3)
27for (var index = 1; index < text.Length; index++) 40Debug.Assert(currentSpanStart < text.Length); 41builder.Add(TextSpan.FromBounds(currentSpanStart, text.Length));
Microsoft.CodeAnalysis.Razor.Workspaces.UnitTests (2)
Formatting\FormattingUtilitiesTest.cs (2)
26var actual = FormattingUtilities.GetIndentationLevel(text.Lines[0], text.Length, insertSpaces: true, tabSize, out var additionalIndentation); 45var actual = FormattingUtilities.GetIndentationLevel(text.Lines[0], text.Length, insertSpaces: false, tabSize: 4, out var additionalIndentation);
Microsoft.CodeAnalysis.Remote.Razor (2)
Hover\RemoteHoverService.cs (2)
107adjustedStart = Math.Min(adjustedStart + offset, sourceText.Length - 1); 108adjustedEnd = Math.Min(adjustedEnd + offset, sourceText.Length - 1);
Microsoft.CodeAnalysis.Remote.ServiceHub (1)
Services\SemanticClassification\RemoteSemanticClassificationService.Caching.cs (1)
153var fullSpan = new TextSpan(0, text.Length);
Microsoft.CodeAnalysis.ResxSourceGenerator (4)
AbstractResxGenerator.cs (1)
937var remaining = _text.Length - _position;
src\Compilers\Core\Portable\Syntax\SyntaxTreeExtensions.cs (2)
29var fullSpan = new TextSpan(0, text.Length); 74if (index < text.Length)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EmbeddedLanguages\VirtualChars\AbstractVirtualCharService.ITextInfo.cs (1)
24public readonly int Length(SourceText text) => text.Length;
Microsoft.CodeAnalysis.Test.Utilities (1)
Diagnostics\CommonDiagnosticAnalyzers.cs (1)
1789return text.Length;
Microsoft.CodeAnalysis.UnitTests (47)
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); 442sourceText.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 (2)
325Assert.Equal(0, encodedText.Length); 356Assert.Equal(2, sourceText.Length);
Text\StringTextTest.cs (1)
140if (nextPosition < text.Length)
Text\SubTextTests.cs (2)
36Assert.Equal(stringText.Length, subText.Length); 37for (var i = 0; i < stringText.Length; i++)
Text\TextChangeTests.cs (27)
69Assert.Equal(0, subSubText.Length); 78var subSubText = subText.GetSubText(subText.Length); 81Assert.Equal(0, subSubText.Length); 247Assert.Throws<ArgumentOutOfRangeException>(() => newText.CopyTo(newText.Length - 1, destination, 0, 2)); 383Assert.Equal(str.Length + n, text.Length); 403Assert.Equal(str.Length, text.Length); 412Assert.Equal(26, text.Length); 416Assert.Equal(10, subtext.Length); 428Assert.Equal(6, newText.Length); 439Assert.Equal(20, newText.Length); 451Assert.Equal(25, newText.Length); 467Assert.Equal(27, textWithSegments.Length); 483Assert.Equal(27, textWithSegments.Length); 488Assert.Equal(24, textWithFewerSegments.Length); 502var textWithSegments = text.Replace(new TextSpan(0, text.Length), ""); 503Assert.Equal(0, textWithSegments.Length); 514t = t.Replace(t.Length, 0, b); // add b's 525t = t.Replace(t.Length, 0, "c"); 533Assert.Equal(new string('c', t.Segments[2].Length), t.Segments[2].ToString()); 544t = t.Replace(t.Length, 0, b); // add b's 555t = t.Replace(t.Length, 0, c); // add c's that are the same segment size as the a's and b's 648Assert.Equal(text.Length + largeText.Length, newText.Length); 992var editedLength = originalText.Length; 996var oldMaxInsertLength = originalText.Length * 2; 999for (int i = 0; i < originalText.Length; i += random.Next(maxSkipLength)) 1002var newChange = new TextChange(new TextSpan(i, length: random.Next(originalText.Length - i)), newText);
Text\TextLineNewLineTests.cs (3)
230Assert.Equal(reference.Length, actual.Length); 245for (var pos = 0; pos < reference.Length; pos++)
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)
109Return Me.WithChanges(newText, {New TextChangeRange(New TextSpan(0, Me.Length), newText.Length)}) 121If changes.Length = 1 AndAlso changes(0).Span = New TextSpan(0, Me.Length) AndAlso changes(0).NewLength = newText.Length Then
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)
89Contract.ThrowIfTrue(end > text.Lines.GetLinePosition(text.Length));
Shared\Extensions\SourceTextExtensions.cs (5)
81var length = text.Length - value.Length; 113startIndex = startIndex + normalized.Length > text.Length 114? text.Length - normalized.Length 148if (position + value.Length > text.Length) 180var length = sourceText.Length;
src\Compilers\Core\Portable\Syntax\SyntaxTreeExtensions.cs (2)
29var fullSpan = new TextSpan(0, text.Length); 74if (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)
79textChanges.Count == 1 && textChanges[0].Span != new TextSpan(0, oldDocument.Text.Length))
TemporaryStorage\TemporaryStorageService.cs (1)
114var size = Encoding.Unicode.GetMaxByteCount(text.Length);
TemporaryStorage\TrivialTemporaryStorageService.cs (1)
69Identifier = new TemporaryStorageIdentifier(Guid.NewGuid().ToString(), 0, _sourceText.Length);
Workspace\Solution\Document.cs (1)
486if (textChanges.Length > 1 || (textChanges.Length == 1 && textChanges[0].Span != new TextSpan(0, oldText.Length)))
Workspace\Solution\DocumentState.cs (5)
270if (oldText.Length < MaxTextChangeRangeLength && newText.Length < MaxTextChangeRangeLength) 277if (change.NewLength == newText.Length) 677if (newTree.Length == newText.Length) 690FatalError.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)
3322Assert.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)
565var newText = existingText.WithChanges(new TextChange(new TextSpan(existingText.Length, length: 0), " With Change"));
SymbolKeyTests.cs (1)
1418var 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 (3)
Workspace\VisualStudioDocumentNavigationService.cs (3)
79var boundedPosition = GetPositionWithinDocumentBounds(position, text.Length); 139var boundedPosition = GetPositionWithinDocumentBounds(position, text.Length); 351var boundedTextSpan = GetSpanWithinDocumentBounds(textSpan, text.Length);
Microsoft.VisualStudio.LanguageServices.CSharp (1)
LanguageService\CSharpHelpContextService.cs (1)
82while (end < text.Length - 1 && syntaxFacts.IsIdentifierPartCharacter(text[end]))
Microsoft.VisualStudio.LanguageServices.CSharp.UnitTests (1)
CodeModel\MockTextManagerAdapter.TextPoint.cs (1)
30get { return _point.Position == _point.Text.Length; }
Microsoft.VisualStudio.LanguageServices.Razor.UnitTests (2)
src\Razor\src\Razor\test\Microsoft.CodeAnalysis.Razor.CohostingShared.UnitTests\Diagnostics\RazorDiagnosticHelperTest.cs (2)
96var sourceSpan = new SourceSpan(sourceText.Length + 5, 0, sourceText.Length + 5, 4);
Microsoft.VisualStudioCode.RazorExtension.UnitTests (2)
src\Razor\src\Razor\test\Microsoft.CodeAnalysis.Razor.CohostingShared.UnitTests\Diagnostics\RazorDiagnosticHelperTest.cs (2)
96var sourceSpan = new SourceSpan(sourceText.Length + 5, 0, sourceText.Length + 5, 4);
Roslyn.Diagnostics.Analyzers (4)
src\Compilers\Core\Portable\Syntax\SyntaxTreeExtensions.cs (2)
29var fullSpan = new TextSpan(0, text.Length); 74if (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)
79textChanges.Count == 1 && textChanges[0].Span != new TextSpan(0, oldDocument.Text.Length))
Test.Utilities (3)
src\Compilers\Core\Portable\Syntax\SyntaxTreeExtensions.cs (2)
29var fullSpan = new TextSpan(0, text.Length); 74if (index < text.Length)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EmbeddedLanguages\VirtualChars\AbstractVirtualCharService.ITextInfo.cs (1)
24public readonly int Length(SourceText text) => text.Length;
Text.Analyzers (4)
src\Compilers\Core\Portable\Syntax\SyntaxTreeExtensions.cs (2)
29var fullSpan = new TextSpan(0, text.Length); 74if (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)
79textChanges.Count == 1 && textChanges[0].Span != new TextSpan(0, oldDocument.Text.Length))