14 types derived from SourceText
GenerateDocumentationAndConfigFiles (1)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EmbeddedLanguages\VirtualChars\VirtualCharSequenceSourceText.cs (1)
15internal sealed class VirtualCharSequenceSourceText : SourceText
Microsoft.CodeAnalysis (7)
Text\ChangedText.cs (1)
14internal sealed class ChangedText : SourceText
Text\CompositeText.cs (1)
20internal sealed class CompositeText : SourceText
Text\LargeText.cs (1)
21internal sealed class LargeText : SourceText
Text\SourceText.cs (1)
1372private sealed class SourceTextWithAlgorithm : SourceText
Text\StringBuilderText.cs (1)
15internal sealed partial class StringBuilderText : SourceText
Text\StringText.cs (1)
18internal sealed class StringText : SourceText
Text\SubText.cs (1)
15internal sealed class SubText : SourceText
Microsoft.CodeAnalysis.Analyzers (1)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EmbeddedLanguages\VirtualChars\VirtualCharSequenceSourceText.cs (1)
15internal sealed class VirtualCharSequenceSourceText : SourceText
Microsoft.CodeAnalysis.AnalyzerUtilities (1)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EmbeddedLanguages\VirtualChars\VirtualCharSequenceSourceText.cs (1)
15internal sealed class VirtualCharSequenceSourceText : SourceText
Microsoft.CodeAnalysis.CodeStyle (1)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EmbeddedLanguages\VirtualChars\VirtualCharSequenceSourceText.cs (1)
15internal sealed class VirtualCharSequenceSourceText : SourceText
Microsoft.CodeAnalysis.ResxSourceGenerator (1)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EmbeddedLanguages\VirtualChars\VirtualCharSequenceSourceText.cs (1)
15internal sealed class VirtualCharSequenceSourceText : SourceText
Microsoft.CodeAnalysis.Workspaces (1)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EmbeddedLanguages\VirtualChars\VirtualCharSequenceSourceText.cs (1)
15internal sealed class VirtualCharSequenceSourceText : SourceText
Roslyn.Diagnostics.Analyzers (1)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EmbeddedLanguages\VirtualChars\VirtualCharSequenceSourceText.cs (1)
15internal sealed class VirtualCharSequenceSourceText : SourceText
2117 references to SourceText
ConfigurationSchemaGenerator.Tests (2)
GeneratorTests.cs (2)
30private static readonly SyntaxTree s_implicitUsingsSyntaxTree = SyntaxFactory.ParseSyntaxTree(SourceText.From( 1561var sourceSyntaxTree = SyntaxFactory.ParseSyntaxTree(SourceText.From(sourceText));
dotnet (1)
Commands\Run\FileBasedAppSourceEditor.cs (1)
61static string GetNewLine(SourceText text)
dotnet-format (39)
Formatters\CharsetFormatter.cs (4)
22internal override Task<SourceText> FormatFileAsync( 24SourceText sourceText, 40return SourceText.From(sourceText.ToString(), encoding, sourceText.ChecksumAlgorithm); 44private static bool IsEncodingEquivalent(SourceText sourceText, Encoding encoding)
Formatters\DocumentFormatter.cs (19)
46/// Applies formatting and returns the changed <see cref="SourceText"/> for a <see cref="Document"/>. 48internal abstract Task<SourceText> FormatFileAsync( 50SourceText sourceText, 58/// Applies formatting and returns the changed <see cref="SourceText"/> for each <see cref="Document"/>. 60private ImmutableArray<(Document, Task<(SourceText originalText, SourceText? formattedText)>)> FormatFiles( 67var formattedDocuments = ImmutableArray.CreateBuilder<(Document, Task<(SourceText originalText, SourceText? formattedText)>)>(formattableDocuments.Length); 79var originalSourceText = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); 100/// Get formatted <see cref="SourceText"/> for a <see cref="Document"/>. 102private async Task<(SourceText originalText, SourceText? formattedText)> GetFormattedSourceTextAsync( 110var originalSourceText = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); 111var formattedSourceText = await FormatFileAsync(document, originalSourceText, optionSet, analyzerConfigOptions, formatOptions, logger, cancellationToken).ConfigureAwait(false); 119/// Applies the changed <see cref="SourceText"/> to each formatted <see cref="Document"/>. 123ImmutableArray<(Document, Task<(SourceText originalText, SourceText? formattedText)>)> formattedDocuments, 159private ImmutableArray<FileChange> GetFileChanges(FormatOptions formatOptions, Document document, SourceText originalText, SourceText formattedText, bool changesAreErrors, ILogger logger)
Formatters\EndOfLineFormatter.cs (3)
19internal override Task<SourceText> FormatFileAsync( 21SourceText sourceText, 35var newSourceText = sourceText;
Formatters\FinalNewlineFormatter.cs (2)
18internal override async Task<SourceText> FormatFileAsync( 20SourceText sourceText,
Formatters\OrganizeImportsFormatter.cs (3)
23internal override async Task<SourceText> FormatFileAsync( 25SourceText sourceText, 51var organizedSourceText = await organizedDocument.GetTextAsync(cancellationToken).ConfigureAwait(false);
Formatters\WhitespaceFormatter.cs (6)
22internal override async Task<SourceText> FormatFileAsync( 24SourceText sourceText, 42/// Returns a formatted <see cref="SourceText"/> with a single <see cref="TextChange"/> that encompasses the entire document. 44private static async Task<SourceText> GetFormattedDocument(Document document, OptionSet optionSet, CancellationToken cancellationToken) 53private static async Task<SourceText> GetFormattedDocumentWithDetailedChanges(Document document, SourceText sourceText, OptionSet optionSet, CancellationToken cancellationToken)
Workspaces\FolderWorkspace.cs (2)
52protected override void ApplyDocumentTextChanged(DocumentId documentId, SourceText text) 62private void SaveDocumentText(DocumentId id, string fullPath, SourceText newText, Encoding encoding)
EventSourceGenerator (1)
EventSourceGenerator.Emitter.cs (1)
33context.AddSource($"{ec.ClassName}.g.cs", SourceText.From(sb.ToString(), Encoding.UTF8));
GenerateDocumentationAndConfigFiles (102)
Program.cs (4)
933var sourceText = SourceText.From(fileStream); 943var sourceTextUnshipped = SourceText.From(fileStreamUnshipped);
src\roslyn\src\Compilers\Core\Portable\EncodedStringText.cs (11)
72/// Initializes an instance of <see cref="SourceText"/> from the provided stream. This version differs 73/// from <see cref="SourceText.From(Stream, Encoding, SourceHashAlgorithm, bool)"/> in two ways: 91internal static SourceText Create(Stream stream, 103internal static SourceText Create(Stream stream, 136/// Try to create a <see cref="SourceText"/> from the given stream using the given encoding. 143/// <returns>The <see cref="SourceText"/> decoded from the stream.</returns> 146private static SourceText Decode( 165return SourceText.From(bytes.Array, 175return SourceText.From(data, encoding, checksumAlgorithm, throwIfBinaryDetected, canBeEmbedded); 249internal static SourceText Create(Stream stream, Lazy<Encoding> getEncoding, Encoding defaultEncoding, SourceHashAlgorithm checksumAlgorithm, bool canBeEmbedded) 252internal static SourceText Decode(Stream data, Encoding encoding, SourceHashAlgorithm checksumAlgorithm, bool throwIfBinaryDetected, bool canBeEmbedded)
src\roslyn\src\Compilers\Core\Portable\Syntax\SyntaxTreeExtensions.cs (1)
27internal static void VerifySource(SourceText text, SyntaxNode root, IEnumerable<TextChangeRange>? changes = null)
src\roslyn\src\RoslynAnalyzers\Microsoft.CodeAnalysis.Analyzers\Core\MetaAnalyzers\ReleaseTrackingHelper.cs (8)
46SourceText sourceText, 47Action<string, Version, string, SourceText, TextLine> onDuplicateEntryInRelease, 48Action<TextLine, InvalidEntryKind, string, SourceText> onInvalidEntry, 440public SourceText SourceText { get; } 449TextSpan span, SourceText sourceText, 458TextSpan span, SourceText sourceText, 478TextSpan span, SourceText sourceText, 497TextSpan span, SourceText sourceText,
src\roslyn\src\RoslynAnalyzers\Utilities\Compiler\Extensions\AdditionalTextExtensions.cs (3)
15private static readonly SourceText s_emptySourceText = SourceText.From("", s_utf8bom, SourceHashAlgorithm.Sha256); 17public static SourceText GetTextOrEmpty(this AdditionalText text, CancellationToken cancellationToken)
src\roslyn\src\RoslynAnalyzers\Utilities\Compiler\Extensions\SourceTextExtensions.cs (2)
13/// Class that contains extensions to <see cref="SourceText"/>. 25public static T Parse<T>(this SourceText text, Func<StreamReader, T> parser)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EditorConfig\Parsing\EditorConfigParser.cs (2)
40return Parse<TEditorConfigFile, TResult, TAccumulator>(SourceText.From(text), pathToFile, accumulator); 43public static TEditorConfigFile Parse<TEditorConfigFile, TEditorConfigOption, TAccumulator>(SourceText text, string? pathToFile, TAccumulator accumulator)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EditorConfig\Parsing\NamingStyles\EditorConfigNamingStylesParser.cs (5)
18=> Parse(SourceText.From(editorConfigText), pathToEditorConfigFile); 21/// Parses a <see cref="SourceText"/> and returns all discovered naming style options and their locations 23/// <param name="editorConfigText">The <see cref="SourceText"/> contents of the editorconfig file.</param> 25/// <returns>A type that represents all discovered naming style options in the given <see cref="SourceText"/>.</returns> 26public static EditorConfigNamingStyles Parse(SourceText editorConfigText, string? pathToEditorConfigFile = null)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EmbeddedLanguages\VirtualChars\AbstractVirtualCharService.cs (1)
193protected static int ConvertTextAtIndexToVirtualChar(SourceText tokenText, int index, ImmutableSegmentedList<VirtualCharGreen>.Builder result)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EmbeddedLanguages\VirtualChars\AbstractVirtualCharService.ITextInfo.cs (4)
12/// Abstraction to allow generic algorithms to run over a string or <see cref="SourceText"/> without any 21private struct SourceTextTextInfo : ITextInfo<SourceText> 23public readonly char Get(SourceText text, int index) => text[index]; 24public readonly int Length(SourceText text) => text.Length;
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EmbeddedLanguages\VirtualChars\IVirtualCharService.cs (1)
33/// in the original <see cref="SourceText"/> that the language created that char from.
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EmbeddedLanguages\VirtualChars\VirtualChar.cs (2)
39/// The width of characters in the original <see cref="SourceText"/> that represent this <see cref="VirtualCharGreen"/>. 68/// value of <c>9</c> as well as what <see cref="TextSpan"/> in the original <see cref="SourceText"/> they occupied.
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EmbeddedLanguages\VirtualChars\VirtualCharSequenceSourceText.cs (1)
12/// Trivial implementation of a <see cref="SourceText"/> that directly maps over a <see
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EmbeddedLanguages\VirtualChars\VirtualCharUtilities.cs (2)
22/// cref="SourceText"/> (which only cares about their <see cref="char"/> value), as well as the way to then map 23/// positions/spans within that <see cref="SourceText"/> to actual full virtual char spans in the original
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\SourceTextExtensions_SharedWithCodeStyle.cs (5)
16public static string GetLeadingWhitespaceOfLineAtPosition(this SourceText text, int position) 32this SourceText text, TextSpan span, Func<int, CancellationToken, bool> isPositionHidden, CancellationToken cancellationToken) 44this SourceText text, TextSpan span, Func<int, CancellationToken, bool> isPositionHidden, 82public static bool AreOnSameLine(this SourceText text, SyntaxToken token1, SyntaxToken token2) 87public static bool AreOnSameLine(this SourceText text, int pos1, int pos2)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\SyntaxTreeExtensions.cs (2)
27var text = tree.GetText(cancellationToken); 105var text = tree.GetText(cancellationToken);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\TextLineExtensions.cs (3)
14var text = line.Text!; 46var text = line.Text; 67var text = line.Text;
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Engine\TreeData.cs (1)
20if (root.SyntaxTree == null || !root.SyntaxTree.TryGetText(out var text))
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Engine\TreeData.Debug.cs (1)
11private sealed class Debug(SyntaxNode root, SourceText text) : NodeAndText(root, text)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Engine\TreeData.NodeAndText.cs (2)
14private readonly SourceText _text; 16public NodeAndText(SyntaxNode root, SourceText text)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Engine\TreeData.StructuredTrivia.cs (2)
26var text = GetText(); 47private SourceText? GetText()
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Indentation\AbstractIndentation.cs (1)
29TSyntaxRoot root, SourceText text, TextLine lineToBeIndented, IndentationOptions options, AbstractFormattingRule baseFormattingRule);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Indentation\AbstractIndentation.Indenter.cs (3)
35public readonly SourceText Text; 43SourceText text, 172var updatedSourceText = Text.WithChanges(changes);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Services\RefactoringHelpers\AbstractRefactoringHelpers.cs (6)
25public abstract bool IsBetweenTypeMembers(SourceText sourceText, SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? typeDeclaration); 42private static TextSpan GetTrimmedTextSpan(SourceText sourceText, TextSpan span) 60SourceText sourceText, SyntaxNode root, TextSpan selectionRaw, bool allowEmptyNodes, int maxCount, ref TemporaryArray<TSyntaxNode> result, CancellationToken cancellationToken) where TSyntaxNode : SyntaxNode 179SourceText sourceText, SyntaxNode root, int location) 251SourceText sourceText, SyntaxToken tokenOnLocation, int location) 533SourceText sourceText,
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Services\RefactoringHelpers\IRefactoringHelpers.cs (2)
23bool IsBetweenTypeMembers(SourceText sourceText, SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? typeDeclaration); 55SourceText sourceText, SyntaxNode root, TextSpan selection, bool allowEmptyNodes, int maxCount, ref TemporaryArray<TSyntaxNode> result, CancellationToken cancellationToken) where TSyntaxNode : SyntaxNode;
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Services\SelectedMembers\AbstractSelectedMembers.cs (3)
45var text = await tree.GetTextAsync(cancellationToken).ConfigureAwait(false); 77SyntaxNode root, SourceText text, TextSpan textSpan, 164SourceText text, SyntaxNode root, SyntaxNode member, int position)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\CommonFormattingHelpers.cs (1)
156public static string GetText(this SourceText text, SyntaxToken token1, SyntaxToken token2)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\InterceptsLocationUtilities.cs (1)
16/// (See <see cref="SourceText.GetContentHash()"/>)</param>
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeRefactorings\AbstractRefactoringHelpersService.cs (2)
21public bool IsBetweenTypeMembers(SourceText sourceText, SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? typeDeclaration) 24public void AddRelevantNodes<TSyntaxNode>(SourceText sourceText, SyntaxNode root, TextSpan selection, bool allowEmptyNodes, int maxCount, ref TemporaryArray<TSyntaxNode> result, CancellationToken cancellationToken) where TSyntaxNode : SyntaxNode
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Editing\AddParameterEditor.cs (2)
25var sourceText = declaration.SyntaxTree.GetText(cancellationToken); 159var text = parameters[0].SyntaxTree.GetText(cancellationToken);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Extensions\TextDocumentExtensions.cs (5)
15public static async ValueTask<SourceText> GetValueTextAsync(this TextDocument document, CancellationToken cancellationToken) 17if (document.TryGetText(out var text)) 27public static TextDocument WithText(this TextDocument textDocument, SourceText text) 48public static TextDocument WithAdditionalDocumentText(this TextDocument textDocument, SourceText text) 57public static TextDocument WithAnalyzerConfigDocumentText(this TextDocument textDocument, SourceText text)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Indentation\IIndentationService.cs (3)
66public static string GetIndentationString(this IndentationResult indentationResult, SourceText sourceText, bool useTabs, int tabSize) 77public static string GetIndentationString(this IndentationResult indentationResult, SourceText sourceText, SyntaxFormattingOptions options) 80public static string GetIndentationString(this IndentationResult indentationResult, SourceText sourceText, IndentationOptions options)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Utilities\ParsedDocument.cs (5)
18/// Used to front-load <see cref="SyntaxTree"/> parsing and <see cref="SourceText"/> retrieval to a caller that has knowledge of whether or not these operations 24internal readonly record struct ParsedDocument(DocumentId Id, SourceText Text, SyntaxNode Root, HostLanguageServices HostLanguageServices) 33var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false); 47public ParsedDocument WithChangedText(SourceText text, CancellationToken cancellationToken) 55var text = root.SyntaxTree.GetText(cancellationToken);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Utilities\SemanticDocument.cs (2)
13internal sealed class SemanticDocument(Document document, SourceText text, SyntaxNode root, SemanticModel semanticModel) 20var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Utilities\SyntacticDocument.cs (3)
15public readonly SourceText Text; 18protected SyntacticDocument(Document document, SourceText text, SyntaxNode root) 30var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false);
Microsoft.Analyzers.Extra.Tests (10)
Resources\FileVisibleToAnalyzer.cs (2)
26public override SourceText? GetText(CancellationToken cancellationToken = default) => SourceText.From(File.ReadAllText(Path));
Resources\RoslynTestUtils.cs (8)
379var s = await proj.FindDocument(l[i]).GetTextAsync().ConfigureAwait(false); 387var s = await proj.FindDocument($"src-{i}.cs").GetTextAsync().ConfigureAwait(false); 394var s = await proj.FindDocument(extraFile).GetTextAsync().ConfigureAwait(false); 470var s = await proj.FindDocument(l[i]).GetTextAsync().ConfigureAwait(false); 478var s = await proj.FindDocument($"src-{i}.cs").GetTextAsync().ConfigureAwait(false); 485var s = await proj.FindDocument(extraFile).GetTextAsync().ConfigureAwait(false); 506var newText = await document.GetTextAsync().ConfigureAwait(false); 507return document.WithText(SourceText.From(newText.ToString(), newText.Encoding, newText.ChecksumAlgorithm));
Microsoft.Analyzers.Local.Tests (10)
Resources\FileVisibleToAnalyzer.cs (2)
26public override SourceText? GetText(CancellationToken cancellationToken = default) => SourceText.From(File.ReadAllText(Path));
Resources\RoslynTestUtils.cs (8)
380var s = await proj.FindDocument(l[i]).GetTextAsync().ConfigureAwait(false); 388var s = await proj.FindDocument($"src-{i}.cs").GetTextAsync().ConfigureAwait(false); 395var s = await proj.FindDocument(extraFile).GetTextAsync().ConfigureAwait(false); 471var s = await proj.FindDocument(l[i]).GetTextAsync().ConfigureAwait(false); 479var s = await proj.FindDocument($"src-{i}.cs").GetTextAsync().ConfigureAwait(false); 486var s = await proj.FindDocument(extraFile).GetTextAsync().ConfigureAwait(false); 507var newText = await document.GetTextAsync().ConfigureAwait(false); 508return document.WithText(SourceText.From(newText.ToString(), newText.Encoding, newText.ChecksumAlgorithm));
Microsoft.AspNetCore.App.Analyzers (14)
Infrastructure\VirtualChars\AbstractVirtualCharService.cs (1)
193protected static int ConvertTextAtIndexToRune(SourceText tokenText, int index, ImmutableList<VirtualChar>.Builder result, int offset)
Infrastructure\VirtualChars\AbstractVirtualCharService.ITextInfo.cs (4)
11/// Abstraction to allow generic algorithms to run over a string or <see cref="SourceText"/> without any 20private struct SourceTextTextInfo : ITextInfo<SourceText> 22public char Get(SourceText text, int index) => text[index]; 23public int Length(SourceText text) => text.Length;
Infrastructure\VirtualChars\CSharpVirtualCharService.cs (3)
199var parentSourceText = parentExpression.SyntaxTree.GetText(); 204var tokenSourceText = SourceText.From(token.Text);
Infrastructure\VirtualChars\IVirtualCharService.cs (1)
33/// in the original <see cref="SourceText"/> that the language created that char from.
Infrastructure\VirtualChars\TextLineExtensions.cs (1)
12var text = line.Text;
Infrastructure\VirtualChars\VirtualChar.cs (2)
16/// value of <c>9</c> as well as what <see cref="TextSpan"/> in the original <see cref="SourceText"/> they occupied. 43/// The span of characters in the original <see cref="SourceText"/> that represent this <see
RouteEmbeddedLanguage\FrameworkParametersCompletionProvider.cs (1)
51public override bool ShouldTriggerCompletion(SourceText text, int caretPosition, CompletionTrigger trigger, OptionSet options)
RouteEmbeddedLanguage\RoutePatternCompletionProvider.cs (1)
45public override bool ShouldTriggerCompletion(SourceText text, int caretPosition, CompletionTrigger trigger, OptionSet options)
Microsoft.AspNetCore.OpenApi.SourceGenerators (1)
XmlCommentGenerator.Parser.cs (1)
46var text = additionalText.GetText(cancellationToken);
Microsoft.CodeAnalysis (265)
AdditionalTextFile.cs (6)
21private readonly Lazy<SourceText?> _text; 34_text = new Lazy<SourceText?>(ReadText); 37private SourceText? ReadText() 40var text = _compiler.TryReadFileContent(_sourceFile, diagnostics); 51/// Returns a <see cref="SourceText"/> with the contents of this file, or <c>null</c> if 54public override SourceText? GetText(CancellationToken cancellationToken = default) => _text.Value;
CommandLine\AnalyzerConfig.cs (2)
180return Parse(SourceText.From(text), pathToFile); 187public static AnalyzerConfig Parse(SourceText text, string? pathToFile)
CommandLine\CommonCompiler.cs (3)
244internal SourceText? TryReadFileContent(CommandLineSourceFile file, IList<DiagnosticInfo> diagnostics) 256internal SourceText? TryReadFileContent(CommandLineSourceFile file, IList<DiagnosticInfo> diagnostics, out string? normalizedFilePath) 1169var sourceText = tree.GetText(cancellationToken);
Compilation\DeterministicKey.cs (2)
24public abstract SourceText GetText(CancellationToken cancellationToken = default); 44public override SourceText GetText(CancellationToken cancellationToken = default)
Compilation\DeterministicKeyBuilder.cs (2)
330private static void WriteSourceText(JsonWriter writer, SourceText? sourceText) 355var checksum = SourceText.CalculateChecksum(stream, checksumAlgorithm);
Compilation\SourceReferenceResolver.cs (2)
62/// Reads the contents of <paramref name="resolvedPath"/> and returns a <see cref="SourceText"/>. 65public virtual SourceText ReadText(string resolvedPath)
DiagnosticAnalyzer\AdditionalText.cs (2)
21/// Returns a <see cref="SourceText"/> with the contents of this file, or <c>null</c> if 24public abstract SourceText? GetText(CancellationToken cancellationToken = default);
DiagnosticAnalyzer\AdditionalTextComparer.cs (3)
35var xText = GetTextOrNullIfBinary(x); 36var yText = GetTextOrNullIfBinary(y); 59private static SourceText? GetTextOrNullIfBinary(AdditionalText text)
DiagnosticAnalyzer\AnalysisContextInfo.cs (1)
111var text = _file.Value.SourceTree.GetText();
DiagnosticAnalyzer\DiagnosticAnalysisContext.cs (6)
237/// <param name="text"><see cref="SourceText"/> for which the value is queried.</param> 241public bool TryGetValue<TValue>(SourceText text, SourceTextValueProvider<TValue> valueProvider, [MaybeNullWhen(false)] out TValue value) 501/// <param name="text"><see cref="SourceText"/> for which the value is queried.</param> 505public bool TryGetValue<TValue>(SourceText text, SourceTextValueProvider<TValue> valueProvider, [MaybeNullWhen(false)] out TValue value) 623/// <param name="text"><see cref="SourceText"/> for which the value is queried.</param> 627public bool TryGetValue<TValue>(SourceText text, SourceTextValueProvider<TValue> valueProvider, [MaybeNullWhen(false)] out TValue value)
DiagnosticAnalyzer\SourceTextValueProvider.cs (8)
12/// Provides custom values associated with <see cref="SourceText"/> instances using the given computeValue delegate. 16internal AnalysisValueProvider<SourceText, TValue> CoreValueProvider { get; private set; } 19/// Provides custom values associated with <see cref="SourceText"/> instances using the given <paramref name="computeValue"/>. 21/// <param name="computeValue">Delegate to compute the value associated with a given <see cref="SourceText"/> instance.</param> 22/// <param name="sourceTextComparer">Optional equality comparer to determine equivalent <see cref="SourceText"/> instances that have the same value. 24public SourceTextValueProvider(Func<SourceText, TValue> computeValue, IEqualityComparer<SourceText>? sourceTextComparer = null) 26CoreValueProvider = new AnalysisValueProvider<SourceText, TValue>(computeValue, sourceTextComparer ?? SourceTextComparer.Instance);
EmbeddedText.cs (8)
85/// Constructs a <see cref="EmbeddedText"/> for embedding the given <see cref="SourceText"/>. 95/// <paramref name="text"/> cannot be embedded (see <see cref="SourceText.CanBeEmbedded"/>). 97public static EmbeddedText FromSource(string filePath, SourceText text) 150SourceText.ValidateChecksumAlgorithm(checksumAlgorithm); 154SourceText.CalculateChecksum(stream, checksumAlgorithm), 184SourceText.ValidateChecksumAlgorithm(checksumAlgorithm); 188SourceText.CalculateChecksum(bytes.Array, bytes.Offset, bytes.Count, checksumAlgorithm), 293private static ImmutableArray<byte> CreateBlob(SourceText text)
EncodedStringText.cs (11)
72/// Initializes an instance of <see cref="SourceText"/> from the provided stream. This version differs 73/// from <see cref="SourceText.From(Stream, Encoding, SourceHashAlgorithm, bool)"/> in two ways: 91internal static SourceText Create(Stream stream, 103internal static SourceText Create(Stream stream, 136/// Try to create a <see cref="SourceText"/> from the given stream using the given encoding. 143/// <returns>The <see cref="SourceText"/> decoded from the stream.</returns> 146private static SourceText Decode( 165return SourceText.From(bytes.Array, 175return SourceText.From(data, encoding, checksumAlgorithm, throwIfBinaryDetected, canBeEmbedded); 249internal static SourceText Create(Stream stream, Lazy<Encoding> getEncoding, Encoding defaultEncoding, SourceHashAlgorithm checksumAlgorithm, bool canBeEmbedded) 252internal static SourceText Decode(Stream data, Encoding encoding, SourceHashAlgorithm checksumAlgorithm, bool throwIfBinaryDetected, bool canBeEmbedded)
SourceGeneration\AdditionalSourcesCollection.cs (1)
44public void Add(string hintName, SourceText source)
SourceGeneration\CompilationCache.cs (3)
180/// same <see cref="SourceText"/> reference, so reference equality is the right level here. 184public PreCompCacheKey(int generatorIndex, string hintName, SourceText text, ParseOptions options) 194public SourceText Text { get; }
SourceGeneration\GeneratedSourceText.cs (2)
16public SourceText Text { get; } 20public GeneratedSourceText(string hintName, SourceText text)
SourceGeneration\GeneratedSyntaxTree.cs (2)
14public SourceText Text { get; } 20public GeneratedSyntaxTree(string hintName, SourceText text, SyntaxTree tree)
SourceGeneration\GeneratorContexts.cs (8)
85public void AddSource(string hintName, string source) => AddSource(hintName, SourceText.From(source, Encoding.UTF8, checksumAlgorithm: _checksumAlgorithm == SourceHashAlgorithm.None ? SourceHashAlgorithms.Default : _checksumAlgorithm)); 88/// Adds a <see cref="SourceText"/> to the compilation 91/// <param name="sourceText">The <see cref="SourceText"/> to add to the compilation</param> 95public void AddSource(string hintName, SourceText sourceText) => _additionalSources.Add(hintName, sourceText.WithChecksumAlgorithmIfAny(_checksumAlgorithm)); 277public void AddSource(string hintName, string source) => AddSource(hintName, SourceText.From(source, Encoding.UTF8)); 280/// Adds a <see cref="SourceText"/> to the compilation that will be available during subsequent phases 283/// <param name="sourceText">The <see cref="SourceText"/> to add to the compilation</param> 287public void AddSource(string hintName, SourceText sourceText) => _additionalSources.Add(hintName, sourceText);
SourceGeneration\GeneratorDriver.cs (1)
519/// has the same <see cref="Microsoft.CodeAnalysis.Text.SourceText"/> reference and hint name at the same position --
SourceGeneration\GeneratorDriverOptions.cs (2)
27/// When specified, overrides the <see cref="SourceText.ChecksumAlgorithm"/> given in <see cref="SourceProductionContext.AddSource(string, SourceText)"/>.
SourceGeneration\IncrementalContexts.cs (14)
243public void AddSource(string hintName, string source) => AddSource(hintName, SourceText.From(source, Encoding.UTF8)); 246/// Adds a <see cref="SourceText"/> to the compilation that will be available during subsequent phases 249/// <param name="sourceText">The <see cref="SourceText"/> to add to the compilation</param> 253public void AddSource(string hintName, SourceText sourceText) => AdditionalSources.Add(hintName, sourceText); 256/// Adds a <see cref="SourceText" /> to the compilation containing the definition of <c>Microsoft.CodeAnalysis.EmbeddedAttribute</c>. 263public void AddEmbeddedAttributeDefinition() => AddSource("Microsoft.CodeAnalysis.EmbeddedAttribute", SourceText.From(_embeddedAttributeDefinition, encoding: Encoding.UTF8)); 292public void AddSource(string hintName, string source) => AddSource(hintName, SourceText.From(source, Encoding.UTF8, checksumAlgorithm: ChecksumAlgorithm == SourceHashAlgorithm.None ? SourceHashAlgorithms.Default : ChecksumAlgorithm)); 295/// Adds a <see cref="SourceText"/> to the compilation 298/// <param name="sourceText">The <see cref="SourceText"/> to add to the compilation</param> 302public void AddSource(string hintName, SourceText sourceText) => Sources.Add(hintName, sourceText.WithChecksumAlgorithmIfAny(ChecksumAlgorithm)); 351public void AddSource(string hintName, string source) => AddSource(hintName, SourceText.From(source, Encoding.UTF8, checksumAlgorithm: ChecksumAlgorithm == SourceHashAlgorithm.None ? SourceHashAlgorithms.Default : ChecksumAlgorithm)); 354/// Adds a <see cref="SourceText"/> to the compilation 357/// <param name="sourceText">The <see cref="SourceText"/> to add to the compilation</param> 361public void AddSource(string hintName, SourceText sourceText) => Sources.Add(hintName, sourceText.WithChecksumAlgorithmIfAny(ChecksumAlgorithm));
SourceGeneration\ISourceGenerator.cs (1)
36/// to add source files via the <see cref="GeneratorExecutionContext.AddSource(string, SourceText)"/>
SourceGeneration\RunResults.cs (4)
58/// The <see cref="SyntaxTree"/>s produced during this generation pass by parsing each <see cref="SourceText"/> added by each generator. 166/// Represents the results of an <see cref="ISourceGenerator"/> calling <see cref="GeneratorExecutionContext.AddSource(string, SourceText)"/>. 173internal GeneratedSourceResult(SyntaxTree tree, SourceText text, string hintName) 188public SourceText SourceText { get; }
Syntax\ICompilationUnitSyntax.cs (1)
16/// <see cref="EndOfFileToken"/> that is needed to store all final trivia in a <see cref="SourceText"/>
Syntax\LineDirectiveMap.cs (5)
31protected abstract LineMappingEntry GetEntry(TDirective directive, SourceText sourceText, LineMappingEntry previous); 49public FileLinePositionSpan TranslateSpan(SourceText sourceText, string treeFilePath, TextSpan span) 106public abstract LineVisibility GetLineVisibility(SourceText sourceText, int position); 111internal abstract FileLinePositionSpan TranslateSpanAndVisibility(SourceText sourceText, string treeFilePath, TextSpan span, out bool isHiddenPosition); 148var sourceText = tree.GetText();
Syntax\SyntaxNode.cs (4)
315/// Gets the full text of this node as a new <see cref="SourceText"/> instance. 320/// If the encoding is not specified the <see cref="SourceText"/> isn't debuggable. 321/// If an encoding-less <see cref="SourceText"/> is written to a file a <see cref="Encoding.UTF8"/> shall be used as a default. 327public SourceText GetText(Encoding? encoding = null, SourceHashAlgorithm checksumAlgorithm = SourceHashAlgorithm.Sha1)
Syntax\SyntaxTree.cs (6)
94public abstract bool TryGetText([NotNullWhen(true)] out SourceText? text); 99public abstract SourceText GetText(CancellationToken cancellationToken = default); 120public virtual Task<SourceText> GetTextAsync(CancellationToken cancellationToken = default) 122return Task.FromResult(this.TryGetText(out SourceText? text) ? text : this.GetText(cancellationToken)); 172public abstract SyntaxTree WithChangedText(SourceText newText); 375var text = this.GetText();
Syntax\SyntaxTreeExtensions.cs (1)
27internal static void VerifySource(SourceText text, SyntaxNode root, IEnumerable<TextChangeRange>? changes = null)
Text\ChangedText.cs (19)
16private readonly SourceText _newText; 19public ChangedText(SourceText oldText, SourceText newText, ImmutableArray<TextChangeRange> changeRanges) 30_info = new ChangeInfo(changeRanges, new WeakReference<SourceText>(oldText), (oldText as ChangedText)?._info); 34SourceText oldText, SourceText newText, ImmutableArray<TextChangeRange> changeRanges) 65public WeakReference<SourceText> WeakOldText { get; } 69public ChangeInfo(ImmutableArray<TextChangeRange> changeRanges, WeakReference<SourceText> weakOldText, ChangeInfo? previous) 84SourceText? tmp; 122internal override ImmutableArray<SourceText> Segments 127internal override SourceText StorageKey 142public override SourceText GetSubText(TextSpan span) 152public override SourceText WithChanges(IEnumerable<TextChange> changes) 169public override IReadOnlyList<TextChangeRange> GetChangeRanges(SourceText oldText) 182SourceText? actualOldText; 209private bool IsChangedFrom(SourceText oldText) 213SourceText? text; 223private static IReadOnlyList<ImmutableArray<TextChangeRange>> GetChangesBetween(SourceText oldText, ChangedText newText) 232SourceText? actualOldText;
Text\CompositeText.cs (37)
18/// A composite of a sequence of <see cref="SourceText"/>s. 22private readonly ImmutableArray<SourceText> _segments; 28private CompositeText(ImmutableArray<SourceText> segments, Encoding? encoding, SourceHashAlgorithm checksumAlgorithm) 67internal override ImmutableArray<SourceText> Segments 83public override SourceText GetSubText(TextSpan span) 94var newSegments = ArrayBuilder<SourceText>.GetInstance(); 99var segment = _segments[segIndex]; 157var segment = _segments[segIndex]; 169internal static void AddSegments(ArrayBuilder<SourceText> segments, SourceText text) 182internal static SourceText ToSourceText(ArrayBuilder<SourceText> segments, SourceText original, bool adjustSegments) 194return SourceText.From(string.Empty, original.Encoding, original.ChecksumAlgorithm); 206private static void RemoveSplitLineBreaksAndEmptySegments(ArrayBuilder<SourceText> segments) 216var prevSegment = segments[i - 1]; 217var curSegment = segments[i]; 223segments.Insert(i, SourceText.From("\r\n")); 246private static void ReduceSegmentCountIfNecessary(ArrayBuilder<SourceText> segments) 267private static int GetMinimalSegmentSizeToUseForCombining(ArrayBuilder<SourceText> segments) 287private static int GetSegmentCountIfCombined(ArrayBuilder<SourceText> segments, int segmentSize) 322private static void CombineSegments(ArrayBuilder<SourceText> segments, int segmentSize) 354var newText = writer.ToSourceText(); 363private static readonly ObjectPool<HashSet<SourceText>> s_uniqueSourcesPool 364= new ObjectPool<HashSet<SourceText>>(() => new HashSet<SourceText>(), 5); 369private static void ComputeLengthAndStorageSize(IReadOnlyList<SourceText> segments, out int length, out int size) 376var segment = segments[i]; 382foreach (var segment in uniqueSources) 394private static void TrimInaccessibleText(ArrayBuilder<SourceText> segments) 406foreach (var segment in segments) 446var segment = compositeText.Segments[i]; 480var segment = _compositeText.Segments[segmentIndex]; 500var firstSegment = _compositeText.Segments[firstSegmentIndexInclusive]; 510var nextSegment = _compositeText.Segments[nextSegmentIndex]; 523var lastSegment = _compositeText.Segments[lastSegmentIndexInclusive]; 561var previousSegment = _compositeText.Segments[firstSegmentIndexInclusive - 1];
Text\LargeText.cs (7)
18/// A <see cref="SourceText"/> optimized for very large sources. The text is stored as 26internal const int ChunkSize = SourceText.LargeObjectHeapLimitInChars; // 40K Unicode chars is 80KB which is less than the large object heap limit. 55internal static SourceText Decode(Stream stream, Encoding encoding, SourceHashAlgorithm checksumAlgorithm, bool throwIfBinaryDetected, bool canBeEmbedded) 62return SourceText.From(string.Empty, encoding, checksumAlgorithm); 81internal static SourceText Decode(TextReader reader, int length, Encoding? encodingOpt, SourceHashAlgorithm checksumAlgorithm) 85return SourceText.From(string.Empty, encodingOpt, checksumAlgorithm); 228/// Called from <see cref="SourceText.Lines"/> to initialize the <see cref="TextLineCollection"/>. Thereafter,
Text\LargeTextWriter.cs (1)
30public override SourceText ToSourceText()
Text\SourceText.cs (58)
93/// Constructs a <see cref="SourceText"/> from text in a string. 99/// If the encoding is not specified the resulting <see cref="SourceText"/> isn't debuggable. 100/// If an encoding-less <see cref="SourceText"/> is written to a file a <see cref="Encoding.UTF8"/> shall be used as a default. 107public static SourceText From(string text, Encoding? encoding = null, SourceHashAlgorithm checksumAlgorithm = SourceHashAlgorithm.Sha1) 118/// Constructs a <see cref="SourceText"/> from text in a string. 125/// If the encoding is not specified the resulting <see cref="SourceText"/> isn't debuggable. 126/// If an encoding-less <see cref="SourceText"/> is written to a file a <see cref="Encoding.UTF8"/> shall be used as a default. 133public static SourceText From( 156public static SourceText From(Stream stream, Encoding? encoding, SourceHashAlgorithm checksumAlgorithm, bool throwIfBinaryDetected) 160/// Constructs a <see cref="SourceText"/> from stream content. 182public static SourceText From( 227public static SourceText From(byte[] buffer, int length, Encoding? encoding, SourceHashAlgorithm checksumAlgorithm, bool throwIfBinaryDetected) 231/// Constructs a <see cref="SourceText"/> from a byte array. 251public static SourceText From( 394/// If an encoding-less <see cref="SourceText"/> is written to a file a <see cref="Encoding.UTF8"/> shall be used as a default. 412internal virtual ImmutableArray<SourceText> Segments 414get { return ImmutableArray<SourceText>.Empty; } 417internal virtual SourceText StorageKey 473/// The container of this <see cref="SourceText"/>. 499/// Gets a <see cref="SourceText"/> that contains the characters in the specified span of this text. 501public virtual SourceText GetSubText(TextSpan span) 508return SourceText.From(string.Empty, this.Encoding, this.ChecksumAlgorithm); 521/// Returns a <see cref="SourceText"/> that has the contents of this text including and after the start position. 523public SourceText GetSubText(int start) 541/// Write this <see cref="SourceText"/> to a text writer. 578/// that were used to produce this <see cref="SourceText"/> (if any of the <c>From</c> methods were used that 579/// take a <c>byte[]</c> or <see cref="Stream"/>). Otherwise, computed by writing this <see cref="SourceText"/> 584/// Two different <see cref="SourceText"/> instances with the same content (see <see cref="ContentEquals"/>) may 590/// Similarly, two different <see cref="SourceText"/> instances with <em>different</em> contents can have the 611/// Produces a hash of this <see cref="SourceText"/> based solely on the contents it contains. Two different 612/// <see cref="SourceText"/> instances that are <see cref="ContentEquals"/> will have the same content hash. Two 613/// instances of <see cref="SourceText"/> with different content are virtually certain to not have the same 767public virtual SourceText WithChanges(IEnumerable<TextChange> changes) 779var segments = ArrayBuilder<SourceText>.GetInstance(); 817var subText = this.GetSubText(new TextSpan(position, change.Span.Start - position)); 823var segment = SourceText.From(change.NewText!, this.Encoding, this.ChecksumAlgorithm); 840var subText = this.GetSubText(new TextSpan(position, this.Length - position)); 844var newText = CompositeText.ToSourceText(segments, this, adjustSegments: true); 868/// <exception cref="ArgumentException">If any changes are not in bounds of this <see cref="SourceText"/>.</exception> 870public SourceText WithChanges(params TextChange[] changes) 878public SourceText Replace(TextSpan span, string newText) 886public SourceText Replace(int start, int length, string newText) 896public virtual IReadOnlyList<TextChangeRange> GetChangeRanges(SourceText oldText) 918public virtual IReadOnlyList<TextChange> GetTextChanges(SourceText oldText) 1015private readonly SourceText _text; 1019public LineInfo(SourceText text, SegmentedList<uint> lineStarts) 1198/// Compares the content with content of another <see cref="SourceText"/>. 1200public bool ContentEquals(SourceText other) 1225/// Implements equality comparison of the content of two different instances of <see cref="SourceText"/>. 1227protected virtual bool ContentEqualsImpl(SourceText other) 1321private readonly SourceText _text; 1323public StaticContainer(SourceText text) 1328public override SourceText CurrentText => _text; 1362/// Otherwise, returns a <see cref="SourceText"/> with the same <see cref="ChecksumAlgorithm"/> as <paramref name="checksumAlgorithm"/>, potentially by wrapping this instance. 1364internal SourceText WithChecksumAlgorithmIfAny(SourceHashAlgorithm checksumAlgorithm) 1374private readonly SourceText _underlying; 1376public SourceTextWithAlgorithm(SourceText underlying, SourceHashAlgorithm checksumAlgorithm) : base(checksumAlgorithm: checksumAlgorithm)
Text\SourceTextComparer.cs (4)
10internal class SourceTextComparer : IEqualityComparer<SourceText?> 14public bool Equals(SourceText? x, SourceText? y) 28public int GetHashCode(SourceText? obj)
Text\SourceTextContainer.cs (1)
18public abstract SourceText CurrentText { get; }
Text\SourceTextStream.cs (3)
14/// A read-only, non-seekable <see cref="Stream"/> over a <see cref="SourceText"/>. 18private readonly SourceText _source; 37public SourceTextStream(SourceText source, bool useDefaultEncodingIfNull = false)
Text\SourceTextWriter.cs (2)
12public abstract SourceText ToSourceText(); 16if (length < SourceText.LargeObjectHeapLimitInChars)
Text\StringBuilderText.cs (1)
13/// Implementation of <see cref="SourceText"/> based on a <see cref="StringBuilder"/> input
Text\StringTextWriter.cs (1)
36public override SourceText ToSourceText()
Text\SubText.cs (6)
13/// A <see cref="SourceText"/> that represents a subrange of another <see cref="SourceText"/>. 17public SubText(SourceText text, TextSpan span) 39public SourceText UnderlyingText { get; } 50internal override SourceText StorageKey 78public override SourceText GetSubText(TextSpan span)
Text\TextChangeEventArgs.cs (6)
24public TextChangeEventArgs(SourceText oldText, SourceText newText, IEnumerable<TextChangeRange> changes) 42public TextChangeEventArgs(SourceText oldText, SourceText newText, params TextChangeRange[] changes) 50public SourceText OldText { get; } 55public SourceText NewText { get; }
Text\TextLine.cs (5)
16private readonly SourceText? _text; 29private TextLine(SourceText text, ulong data) 45public static TextLine FromSpan(SourceText text, TextSpan span) 98internal static TextLine FromSpanUnsafe(SourceText text, TextSpan span, int lineBreakLength) 109public SourceText? Text
Text\TextUtilities.cs (3)
14internal static int GetLengthOfLineBreak(SourceText text, int index) 30private static int GetLengthOfLineBreakSlow(SourceText text, int index, char c) 52public static void GetStartAndLengthOfLineBreakEndingAt(SourceText text, int index, out int startLinebreak, out int lengthLinebreak)
Microsoft.CodeAnalysis.Analyzers (121)
MetaAnalyzers\DiagnosticDescriptorCreationAnalyzer_ReleaseTracking.cs (2)
190void OnDuplicateEntryInRelease(string ruleId, Version currentVersion, string path, SourceText sourceText, TextLine line) 210void OnInvalidEntry(TextLine line, InvalidEntryKind invalidEntryKind, string path, SourceText sourceText)
MetaAnalyzers\DiagnosticDescriptorCreationAnalyzer_ResourceStringsFormat.cs (1)
73var sourceText = file.GetTextOrEmpty(cancellationToken);
MetaAnalyzers\Fixers\AnalyzerReleaseTrackingFix.cs (7)
177var newText = await AddEntriesToUnshippedFileAsync(unshippedDataDocument, [entryToAdd], cancellationToken).ConfigureAwait(false); 181private static Task<SourceText> AddEntriesToUnshippedFileAsync( 195var newText = await UpdateEntriesInUnshippedFileAsync(unshippedDataDocument, new Dictionary<string, string>() { { ruleId, entryToUpdate } }, cancellationToken).ConfigureAwait(false); 199private static Task<SourceText> UpdateEntriesInUnshippedFileAsync( 205private static Task<SourceText> AddOrUpdateEntriesToUnshippedFileAsync( 249private static async Task<SourceText> AddOrUpdateEntriesToUnshippedFileAsync( 256var unshippedText = await unshippedDataDocument.GetTextAsync(cancellationToken).ConfigureAwait(false);
MetaAnalyzers\Fixers\AnalyzerReleaseTrackingFix.FixAllProvider.cs (5)
92var updatedUnshippedText = new List<(DocumentId, SourceText)>(); 107var newText = await AddEntriesToUnshippedFileForDiagnosticsAsync(unshippedDocument, diagnostics, cancellationToken).ConfigureAwait(false); 112var newText = await UpdateEntriesInUnshippedFileForDiagnosticsAsync(unshippedDocument, diagnostics, cancellationToken).ConfigureAwait(false); 130private static async Task<SourceText> AddEntriesToUnshippedFileForDiagnosticsAsync(TextDocument unshippedDataDocument, ImmutableArray<Diagnostic> diagnostics, CancellationToken cancellationToken) 144private static async Task<SourceText> UpdateEntriesInUnshippedFileForDiagnosticsAsync(TextDocument unshippedDataDocument, ImmutableArray<Diagnostic> diagnostics, CancellationToken cancellationToken)
MetaAnalyzers\Fixers\DefineDiagnosticDescriptorArgumentsCorrectlyFix.cs (2)
175var text = await fixInfo.AdditionalDocumentToFix.GetTextAsync(cancellationToken).ConfigureAwait(false); 177var newText = text.WithChanges(textChange);
MetaAnalyzers\Fixers\DefineDiagnosticDescriptorArgumentsCorrectlyFix.CustomFixAllProvider.cs (2)
131var text = await additionalDocument.GetTextAsync(cancellationToken).ConfigureAwait(false); 143var newText = text.WithChanges(textChanges);
MetaAnalyzers\ReleaseTrackingHelper.cs (8)
46SourceText sourceText, 47Action<string, Version, string, SourceText, TextLine> onDuplicateEntryInRelease, 48Action<TextLine, InvalidEntryKind, string, SourceText> onInvalidEntry, 440public SourceText SourceText { get; } 449TextSpan span, SourceText sourceText, 458TextSpan span, SourceText sourceText, 478TextSpan span, SourceText sourceText, 497TextSpan span, SourceText sourceText,
MetaAnalyzers\SymbolIsBannedInAnalyzersAnalyzer.cs (2)
93var source = SourceText.From(stream);
src\roslyn\src\Compilers\Core\Portable\EncodedStringText.cs (11)
72/// Initializes an instance of <see cref="SourceText"/> from the provided stream. This version differs 73/// from <see cref="SourceText.From(Stream, Encoding, SourceHashAlgorithm, bool)"/> in two ways: 91internal static SourceText Create(Stream stream, 103internal static SourceText Create(Stream stream, 136/// Try to create a <see cref="SourceText"/> from the given stream using the given encoding. 143/// <returns>The <see cref="SourceText"/> decoded from the stream.</returns> 146private static SourceText Decode( 165return SourceText.From(bytes.Array, 175return SourceText.From(data, encoding, checksumAlgorithm, throwIfBinaryDetected, canBeEmbedded); 249internal static SourceText Create(Stream stream, Lazy<Encoding> getEncoding, Encoding defaultEncoding, SourceHashAlgorithm checksumAlgorithm, bool canBeEmbedded) 252internal static SourceText Decode(Stream data, Encoding encoding, SourceHashAlgorithm checksumAlgorithm, bool throwIfBinaryDetected, bool canBeEmbedded)
src\roslyn\src\Compilers\Core\Portable\Syntax\SyntaxTreeExtensions.cs (1)
27internal static void VerifySource(SourceText text, SyntaxNode root, IEnumerable<TextChangeRange>? changes = null)
src\roslyn\src\RoslynAnalyzers\Microsoft.CodeAnalysis.BannedApiAnalyzers\Core\SymbolIsBannedAnalyzerBase.cs (2)
481public SourceText SourceText { get; } 489public BanFileEntry(Compilation compilation, string text, TextSpan span, SourceText sourceText, string path)
src\roslyn\src\RoslynAnalyzers\Utilities\Compiler\Extensions\AdditionalTextExtensions.cs (3)
15private static readonly SourceText s_emptySourceText = SourceText.From("", s_utf8bom, SourceHashAlgorithm.Sha256); 17public static SourceText GetTextOrEmpty(this AdditionalText text, CancellationToken cancellationToken)
src\roslyn\src\RoslynAnalyzers\Utilities\Compiler\Extensions\SourceTextExtensions.cs (2)
13/// Class that contains extensions to <see cref="SourceText"/>. 25public static T Parse<T>(this SourceText text, Func<StreamReader, T> parser)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EditorConfig\Parsing\EditorConfigParser.cs (2)
40return Parse<TEditorConfigFile, TResult, TAccumulator>(SourceText.From(text), pathToFile, accumulator); 43public static TEditorConfigFile Parse<TEditorConfigFile, TEditorConfigOption, TAccumulator>(SourceText text, string? pathToFile, TAccumulator accumulator)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EditorConfig\Parsing\NamingStyles\EditorConfigNamingStylesParser.cs (5)
18=> Parse(SourceText.From(editorConfigText), pathToEditorConfigFile); 21/// Parses a <see cref="SourceText"/> and returns all discovered naming style options and their locations 23/// <param name="editorConfigText">The <see cref="SourceText"/> contents of the editorconfig file.</param> 25/// <returns>A type that represents all discovered naming style options in the given <see cref="SourceText"/>.</returns> 26public static EditorConfigNamingStyles Parse(SourceText editorConfigText, string? pathToEditorConfigFile = null)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EmbeddedLanguages\VirtualChars\AbstractVirtualCharService.cs (1)
193protected static int ConvertTextAtIndexToVirtualChar(SourceText tokenText, int index, ImmutableSegmentedList<VirtualCharGreen>.Builder result)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EmbeddedLanguages\VirtualChars\AbstractVirtualCharService.ITextInfo.cs (4)
12/// Abstraction to allow generic algorithms to run over a string or <see cref="SourceText"/> without any 21private struct SourceTextTextInfo : ITextInfo<SourceText> 23public readonly char Get(SourceText text, int index) => text[index]; 24public readonly int Length(SourceText text) => text.Length;
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EmbeddedLanguages\VirtualChars\IVirtualCharService.cs (1)
33/// in the original <see cref="SourceText"/> that the language created that char from.
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EmbeddedLanguages\VirtualChars\VirtualChar.cs (2)
39/// The width of characters in the original <see cref="SourceText"/> that represent this <see cref="VirtualCharGreen"/>. 68/// value of <c>9</c> as well as what <see cref="TextSpan"/> in the original <see cref="SourceText"/> they occupied.
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EmbeddedLanguages\VirtualChars\VirtualCharSequenceSourceText.cs (1)
12/// Trivial implementation of a <see cref="SourceText"/> that directly maps over a <see
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EmbeddedLanguages\VirtualChars\VirtualCharUtilities.cs (2)
22/// cref="SourceText"/> (which only cares about their <see cref="char"/> value), as well as the way to then map 23/// positions/spans within that <see cref="SourceText"/> to actual full virtual char spans in the original
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\SourceTextExtensions_SharedWithCodeStyle.cs (5)
16public static string GetLeadingWhitespaceOfLineAtPosition(this SourceText text, int position) 32this SourceText text, TextSpan span, Func<int, CancellationToken, bool> isPositionHidden, CancellationToken cancellationToken) 44this SourceText text, TextSpan span, Func<int, CancellationToken, bool> isPositionHidden, 82public static bool AreOnSameLine(this SourceText text, SyntaxToken token1, SyntaxToken token2) 87public static bool AreOnSameLine(this SourceText text, int pos1, int pos2)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\SyntaxTreeExtensions.cs (2)
27var text = tree.GetText(cancellationToken); 105var text = tree.GetText(cancellationToken);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\TextLineExtensions.cs (3)
14var text = line.Text!; 46var text = line.Text; 67var text = line.Text;
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Engine\TreeData.cs (1)
20if (root.SyntaxTree == null || !root.SyntaxTree.TryGetText(out var text))
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Engine\TreeData.Debug.cs (1)
11private sealed class Debug(SyntaxNode root, SourceText text) : NodeAndText(root, text)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Engine\TreeData.NodeAndText.cs (2)
14private readonly SourceText _text; 16public NodeAndText(SyntaxNode root, SourceText text)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Engine\TreeData.StructuredTrivia.cs (2)
26var text = GetText(); 47private SourceText? GetText()
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Indentation\AbstractIndentation.cs (1)
29TSyntaxRoot root, SourceText text, TextLine lineToBeIndented, IndentationOptions options, AbstractFormattingRule baseFormattingRule);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Indentation\AbstractIndentation.Indenter.cs (3)
35public readonly SourceText Text; 43SourceText text, 172var updatedSourceText = Text.WithChanges(changes);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Services\RefactoringHelpers\AbstractRefactoringHelpers.cs (6)
25public abstract bool IsBetweenTypeMembers(SourceText sourceText, SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? typeDeclaration); 42private static TextSpan GetTrimmedTextSpan(SourceText sourceText, TextSpan span) 60SourceText sourceText, SyntaxNode root, TextSpan selectionRaw, bool allowEmptyNodes, int maxCount, ref TemporaryArray<TSyntaxNode> result, CancellationToken cancellationToken) where TSyntaxNode : SyntaxNode 179SourceText sourceText, SyntaxNode root, int location) 251SourceText sourceText, SyntaxToken tokenOnLocation, int location) 533SourceText sourceText,
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Services\RefactoringHelpers\IRefactoringHelpers.cs (2)
23bool IsBetweenTypeMembers(SourceText sourceText, SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? typeDeclaration); 55SourceText sourceText, SyntaxNode root, TextSpan selection, bool allowEmptyNodes, int maxCount, ref TemporaryArray<TSyntaxNode> result, CancellationToken cancellationToken) where TSyntaxNode : SyntaxNode;
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Services\SelectedMembers\AbstractSelectedMembers.cs (3)
45var text = await tree.GetTextAsync(cancellationToken).ConfigureAwait(false); 77SyntaxNode root, SourceText text, TextSpan textSpan, 164SourceText text, SyntaxNode root, SyntaxNode member, int position)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\CommonFormattingHelpers.cs (1)
156public static string GetText(this SourceText text, SyntaxToken token1, SyntaxToken token2)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\InterceptsLocationUtilities.cs (1)
16/// (See <see cref="SourceText.GetContentHash()"/>)</param>
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeRefactorings\AbstractRefactoringHelpersService.cs (2)
21public bool IsBetweenTypeMembers(SourceText sourceText, SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? typeDeclaration) 24public void AddRelevantNodes<TSyntaxNode>(SourceText sourceText, SyntaxNode root, TextSpan selection, bool allowEmptyNodes, int maxCount, ref TemporaryArray<TSyntaxNode> result, CancellationToken cancellationToken) where TSyntaxNode : SyntaxNode
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Editing\AddParameterEditor.cs (2)
25var sourceText = declaration.SyntaxTree.GetText(cancellationToken); 159var text = parameters[0].SyntaxTree.GetText(cancellationToken);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Extensions\TextDocumentExtensions.cs (5)
15public static async ValueTask<SourceText> GetValueTextAsync(this TextDocument document, CancellationToken cancellationToken) 17if (document.TryGetText(out var text)) 27public static TextDocument WithText(this TextDocument textDocument, SourceText text) 48public static TextDocument WithAdditionalDocumentText(this TextDocument textDocument, SourceText text) 57public static TextDocument WithAnalyzerConfigDocumentText(this TextDocument textDocument, SourceText text)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Indentation\IIndentationService.cs (3)
66public static string GetIndentationString(this IndentationResult indentationResult, SourceText sourceText, bool useTabs, int tabSize) 77public static string GetIndentationString(this IndentationResult indentationResult, SourceText sourceText, SyntaxFormattingOptions options) 80public static string GetIndentationString(this IndentationResult indentationResult, SourceText sourceText, IndentationOptions options)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Utilities\ParsedDocument.cs (5)
18/// Used to front-load <see cref="SyntaxTree"/> parsing and <see cref="SourceText"/> retrieval to a caller that has knowledge of whether or not these operations 24internal readonly record struct ParsedDocument(DocumentId Id, SourceText Text, SyntaxNode Root, HostLanguageServices HostLanguageServices) 33var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false); 47public ParsedDocument WithChangedText(SourceText text, CancellationToken cancellationToken) 55var text = root.SyntaxTree.GetText(cancellationToken);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Utilities\SemanticDocument.cs (2)
13internal sealed class SemanticDocument(Document document, SourceText text, SyntaxNode root, SemanticModel semanticModel) 20var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Utilities\SyntacticDocument.cs (3)
15public readonly SourceText Text; 18protected SyntacticDocument(Document document, SourceText text, SyntaxNode root) 30var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false);
Microsoft.CodeAnalysis.AnalyzerUtilities (68)
src\roslyn\src\Compilers\Core\Portable\EncodedStringText.cs (11)
72/// Initializes an instance of <see cref="SourceText"/> from the provided stream. This version differs 73/// from <see cref="SourceText.From(Stream, Encoding, SourceHashAlgorithm, bool)"/> in two ways: 91internal static SourceText Create(Stream stream, 103internal static SourceText Create(Stream stream, 136/// Try to create a <see cref="SourceText"/> from the given stream using the given encoding. 143/// <returns>The <see cref="SourceText"/> decoded from the stream.</returns> 146private static SourceText Decode( 165return SourceText.From(bytes.Array, 175return SourceText.From(data, encoding, checksumAlgorithm, throwIfBinaryDetected, canBeEmbedded); 249internal static SourceText Create(Stream stream, Lazy<Encoding> getEncoding, Encoding defaultEncoding, SourceHashAlgorithm checksumAlgorithm, bool canBeEmbedded) 252internal static SourceText Decode(Stream data, Encoding encoding, SourceHashAlgorithm checksumAlgorithm, bool throwIfBinaryDetected, bool canBeEmbedded)
src\roslyn\src\Compilers\Core\Portable\Syntax\SyntaxTreeExtensions.cs (1)
27internal static void VerifySource(SourceText text, SyntaxNode root, IEnumerable<TextChangeRange>? changes = null)
src\roslyn\src\RoslynAnalyzers\Utilities\Compiler\Extensions\AdditionalTextExtensions.cs (3)
15private static readonly SourceText s_emptySourceText = SourceText.From("", s_utf8bom, SourceHashAlgorithm.Sha256); 17public static SourceText GetTextOrEmpty(this AdditionalText text, CancellationToken cancellationToken)
src\roslyn\src\RoslynAnalyzers\Utilities\Compiler\Extensions\SourceTextExtensions.cs (2)
13/// Class that contains extensions to <see cref="SourceText"/>. 25public static T Parse<T>(this SourceText text, Func<StreamReader, T> parser)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EditorConfig\Parsing\EditorConfigParser.cs (2)
40return Parse<TEditorConfigFile, TResult, TAccumulator>(SourceText.From(text), pathToFile, accumulator); 43public static TEditorConfigFile Parse<TEditorConfigFile, TEditorConfigOption, TAccumulator>(SourceText text, string? pathToFile, TAccumulator accumulator)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EditorConfig\Parsing\NamingStyles\EditorConfigNamingStylesParser.cs (5)
18=> Parse(SourceText.From(editorConfigText), pathToEditorConfigFile); 21/// Parses a <see cref="SourceText"/> and returns all discovered naming style options and their locations 23/// <param name="editorConfigText">The <see cref="SourceText"/> contents of the editorconfig file.</param> 25/// <returns>A type that represents all discovered naming style options in the given <see cref="SourceText"/>.</returns> 26public static EditorConfigNamingStyles Parse(SourceText editorConfigText, string? pathToEditorConfigFile = null)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EmbeddedLanguages\VirtualChars\AbstractVirtualCharService.cs (1)
193protected static int ConvertTextAtIndexToVirtualChar(SourceText tokenText, int index, ImmutableSegmentedList<VirtualCharGreen>.Builder result)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EmbeddedLanguages\VirtualChars\AbstractVirtualCharService.ITextInfo.cs (4)
12/// Abstraction to allow generic algorithms to run over a string or <see cref="SourceText"/> without any 21private struct SourceTextTextInfo : ITextInfo<SourceText> 23public readonly char Get(SourceText text, int index) => text[index]; 24public readonly int Length(SourceText text) => text.Length;
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EmbeddedLanguages\VirtualChars\IVirtualCharService.cs (1)
33/// in the original <see cref="SourceText"/> that the language created that char from.
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EmbeddedLanguages\VirtualChars\VirtualChar.cs (2)
39/// The width of characters in the original <see cref="SourceText"/> that represent this <see cref="VirtualCharGreen"/>. 68/// value of <c>9</c> as well as what <see cref="TextSpan"/> in the original <see cref="SourceText"/> they occupied.
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EmbeddedLanguages\VirtualChars\VirtualCharSequenceSourceText.cs (1)
12/// Trivial implementation of a <see cref="SourceText"/> that directly maps over a <see
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EmbeddedLanguages\VirtualChars\VirtualCharUtilities.cs (2)
22/// cref="SourceText"/> (which only cares about their <see cref="char"/> value), as well as the way to then map 23/// positions/spans within that <see cref="SourceText"/> to actual full virtual char spans in the original
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\SourceTextExtensions_SharedWithCodeStyle.cs (5)
16public static string GetLeadingWhitespaceOfLineAtPosition(this SourceText text, int position) 32this SourceText text, TextSpan span, Func<int, CancellationToken, bool> isPositionHidden, CancellationToken cancellationToken) 44this SourceText text, TextSpan span, Func<int, CancellationToken, bool> isPositionHidden, 82public static bool AreOnSameLine(this SourceText text, SyntaxToken token1, SyntaxToken token2) 87public static bool AreOnSameLine(this SourceText text, int pos1, int pos2)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\SyntaxTreeExtensions.cs (2)
27var text = tree.GetText(cancellationToken); 105var text = tree.GetText(cancellationToken);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\TextLineExtensions.cs (3)
14var text = line.Text!; 46var text = line.Text; 67var text = line.Text;
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Engine\TreeData.cs (1)
20if (root.SyntaxTree == null || !root.SyntaxTree.TryGetText(out var text))
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Engine\TreeData.Debug.cs (1)
11private sealed class Debug(SyntaxNode root, SourceText text) : NodeAndText(root, text)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Engine\TreeData.NodeAndText.cs (2)
14private readonly SourceText _text; 16public NodeAndText(SyntaxNode root, SourceText text)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Engine\TreeData.StructuredTrivia.cs (2)
26var text = GetText(); 47private SourceText? GetText()
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Indentation\AbstractIndentation.cs (1)
29TSyntaxRoot root, SourceText text, TextLine lineToBeIndented, IndentationOptions options, AbstractFormattingRule baseFormattingRule);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Indentation\AbstractIndentation.Indenter.cs (3)
35public readonly SourceText Text; 43SourceText text, 172var updatedSourceText = Text.WithChanges(changes);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Services\RefactoringHelpers\AbstractRefactoringHelpers.cs (6)
25public abstract bool IsBetweenTypeMembers(SourceText sourceText, SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? typeDeclaration); 42private static TextSpan GetTrimmedTextSpan(SourceText sourceText, TextSpan span) 60SourceText sourceText, SyntaxNode root, TextSpan selectionRaw, bool allowEmptyNodes, int maxCount, ref TemporaryArray<TSyntaxNode> result, CancellationToken cancellationToken) where TSyntaxNode : SyntaxNode 179SourceText sourceText, SyntaxNode root, int location) 251SourceText sourceText, SyntaxToken tokenOnLocation, int location) 533SourceText sourceText,
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Services\RefactoringHelpers\IRefactoringHelpers.cs (2)
23bool IsBetweenTypeMembers(SourceText sourceText, SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? typeDeclaration); 55SourceText sourceText, SyntaxNode root, TextSpan selection, bool allowEmptyNodes, int maxCount, ref TemporaryArray<TSyntaxNode> result, CancellationToken cancellationToken) where TSyntaxNode : SyntaxNode;
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Services\SelectedMembers\AbstractSelectedMembers.cs (3)
45var text = await tree.GetTextAsync(cancellationToken).ConfigureAwait(false); 77SyntaxNode root, SourceText text, TextSpan textSpan, 164SourceText text, SyntaxNode root, SyntaxNode member, int position)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\CommonFormattingHelpers.cs (1)
156public static string GetText(this SourceText text, SyntaxToken token1, SyntaxToken token2)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\InterceptsLocationUtilities.cs (1)
16/// (See <see cref="SourceText.GetContentHash()"/>)</param>
Microsoft.CodeAnalysis.CodeStyle (66)
src\roslyn\src\Analyzers\Core\Analyzers\Formatting\AbstractFormattingAnalyzer.cs (3)
49var oldText = tree.GetText(cancellationToken); 72if (oldText.GetSubText(new TextSpan(change.Span.Start + offset, change.NewText.Length)).ContentEquals(SourceText.From(change.NewText))) 81if (oldText.GetSubText(new TextSpan(change.Span.Start, change.NewText.Length)).ContentEquals(SourceText.From(change.NewText)))
src\roslyn\src\Compilers\Core\Portable\EncodedStringText.cs (11)
72/// Initializes an instance of <see cref="SourceText"/> from the provided stream. This version differs 73/// from <see cref="SourceText.From(Stream, Encoding, SourceHashAlgorithm, bool)"/> in two ways: 91internal static SourceText Create(Stream stream, 103internal static SourceText Create(Stream stream, 136/// Try to create a <see cref="SourceText"/> from the given stream using the given encoding. 143/// <returns>The <see cref="SourceText"/> decoded from the stream.</returns> 146private static SourceText Decode( 165return SourceText.From(bytes.Array, 175return SourceText.From(data, encoding, checksumAlgorithm, throwIfBinaryDetected, canBeEmbedded); 249internal static SourceText Create(Stream stream, Lazy<Encoding> getEncoding, Encoding defaultEncoding, SourceHashAlgorithm checksumAlgorithm, bool canBeEmbedded) 252internal static SourceText Decode(Stream data, Encoding encoding, SourceHashAlgorithm checksumAlgorithm, bool throwIfBinaryDetected, bool canBeEmbedded)
src\roslyn\src\Compilers\Core\Portable\Syntax\SyntaxTreeExtensions.cs (1)
27internal static void VerifySource(SourceText text, SyntaxNode root, IEnumerable<TextChangeRange>? changes = null)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EditorConfig\Parsing\EditorConfigParser.cs (2)
40return Parse<TEditorConfigFile, TResult, TAccumulator>(SourceText.From(text), pathToFile, accumulator); 43public static TEditorConfigFile Parse<TEditorConfigFile, TEditorConfigOption, TAccumulator>(SourceText text, string? pathToFile, TAccumulator accumulator)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EditorConfig\Parsing\NamingStyles\EditorConfigNamingStylesParser.cs (5)
18=> Parse(SourceText.From(editorConfigText), pathToEditorConfigFile); 21/// Parses a <see cref="SourceText"/> and returns all discovered naming style options and their locations 23/// <param name="editorConfigText">The <see cref="SourceText"/> contents of the editorconfig file.</param> 25/// <returns>A type that represents all discovered naming style options in the given <see cref="SourceText"/>.</returns> 26public static EditorConfigNamingStyles Parse(SourceText editorConfigText, string? pathToEditorConfigFile = null)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EmbeddedLanguages\VirtualChars\AbstractVirtualCharService.cs (1)
193protected static int ConvertTextAtIndexToVirtualChar(SourceText tokenText, int index, ImmutableSegmentedList<VirtualCharGreen>.Builder result)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EmbeddedLanguages\VirtualChars\AbstractVirtualCharService.ITextInfo.cs (4)
12/// Abstraction to allow generic algorithms to run over a string or <see cref="SourceText"/> without any 21private struct SourceTextTextInfo : ITextInfo<SourceText> 23public readonly char Get(SourceText text, int index) => text[index]; 24public readonly int Length(SourceText text) => text.Length;
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EmbeddedLanguages\VirtualChars\IVirtualCharService.cs (1)
33/// in the original <see cref="SourceText"/> that the language created that char from.
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EmbeddedLanguages\VirtualChars\VirtualChar.cs (2)
39/// The width of characters in the original <see cref="SourceText"/> that represent this <see cref="VirtualCharGreen"/>. 68/// value of <c>9</c> as well as what <see cref="TextSpan"/> in the original <see cref="SourceText"/> they occupied.
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EmbeddedLanguages\VirtualChars\VirtualCharSequenceSourceText.cs (1)
12/// Trivial implementation of a <see cref="SourceText"/> that directly maps over a <see
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EmbeddedLanguages\VirtualChars\VirtualCharUtilities.cs (2)
22/// cref="SourceText"/> (which only cares about their <see cref="char"/> value), as well as the way to then map 23/// positions/spans within that <see cref="SourceText"/> to actual full virtual char spans in the original
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\SourceTextExtensions_SharedWithCodeStyle.cs (5)
16public static string GetLeadingWhitespaceOfLineAtPosition(this SourceText text, int position) 32this SourceText text, TextSpan span, Func<int, CancellationToken, bool> isPositionHidden, CancellationToken cancellationToken) 44this SourceText text, TextSpan span, Func<int, CancellationToken, bool> isPositionHidden, 82public static bool AreOnSameLine(this SourceText text, SyntaxToken token1, SyntaxToken token2) 87public static bool AreOnSameLine(this SourceText text, int pos1, int pos2)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\SyntaxTreeExtensions.cs (2)
27var text = tree.GetText(cancellationToken); 105var text = tree.GetText(cancellationToken);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\TextLineExtensions.cs (3)
14var text = line.Text!; 46var text = line.Text; 67var text = line.Text;
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Engine\TreeData.cs (1)
20if (root.SyntaxTree == null || !root.SyntaxTree.TryGetText(out var text))
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Engine\TreeData.Debug.cs (1)
11private sealed class Debug(SyntaxNode root, SourceText text) : NodeAndText(root, text)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Engine\TreeData.NodeAndText.cs (2)
14private readonly SourceText _text; 16public NodeAndText(SyntaxNode root, SourceText text)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Engine\TreeData.StructuredTrivia.cs (2)
26var text = GetText(); 47private SourceText? GetText()
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Indentation\AbstractIndentation.cs (1)
29TSyntaxRoot root, SourceText text, TextLine lineToBeIndented, IndentationOptions options, AbstractFormattingRule baseFormattingRule);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Indentation\AbstractIndentation.Indenter.cs (3)
35public readonly SourceText Text; 43SourceText text, 172var updatedSourceText = Text.WithChanges(changes);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Services\RefactoringHelpers\AbstractRefactoringHelpers.cs (6)
25public abstract bool IsBetweenTypeMembers(SourceText sourceText, SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? typeDeclaration); 42private static TextSpan GetTrimmedTextSpan(SourceText sourceText, TextSpan span) 60SourceText sourceText, SyntaxNode root, TextSpan selectionRaw, bool allowEmptyNodes, int maxCount, ref TemporaryArray<TSyntaxNode> result, CancellationToken cancellationToken) where TSyntaxNode : SyntaxNode 179SourceText sourceText, SyntaxNode root, int location) 251SourceText sourceText, SyntaxToken tokenOnLocation, int location) 533SourceText sourceText,
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Services\RefactoringHelpers\IRefactoringHelpers.cs (2)
23bool IsBetweenTypeMembers(SourceText sourceText, SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? typeDeclaration); 55SourceText sourceText, SyntaxNode root, TextSpan selection, bool allowEmptyNodes, int maxCount, ref TemporaryArray<TSyntaxNode> result, CancellationToken cancellationToken) where TSyntaxNode : SyntaxNode;
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Services\SelectedMembers\AbstractSelectedMembers.cs (3)
45var text = await tree.GetTextAsync(cancellationToken).ConfigureAwait(false); 77SyntaxNode root, SourceText text, TextSpan textSpan, 164SourceText text, SyntaxNode root, SyntaxNode member, int position)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\CommonFormattingHelpers.cs (1)
156public static string GetText(this SourceText text, SyntaxToken token1, SyntaxToken token2)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\InterceptsLocationUtilities.cs (1)
16/// (See <see cref="SourceText.GetContentHash()"/>)</param>
Microsoft.CodeAnalysis.CodeStyle.Fixes (39)
src\roslyn\src\Analyzers\Core\CodeFixes\ConflictMarkerResolution\AbstractConflictMarkerCodeFixProvider.cs (15)
75var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false); 85SyntaxNode root, SourceText text, int position, 146SourceText text, int position, 210var text = startLine.Text!; 228var text = startLine.Text!; 246var text = currentLine.Text!; 316Action<SourceText, ArrayBuilder<TextChange>, int, int, int, int> addEdits, 319var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false); 324var finalText = text.WithChanges(edits); 329SourceText text, ArrayBuilder<TextChange> edits, 342SourceText text, ArrayBuilder<TextChange> edits, 355SourceText text, ArrayBuilder<TextChange> edits, 389private static int GetEndIncludingLineBreak(SourceText text, int position) 405var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false); 444var finalText = text.WithChanges(edits);
src\roslyn\src\Analyzers\Core\CodeFixes\Formatting\FormattingCodeFixProvider.cs (1)
71var text = await context.Document.GetValueTextAsync(cancellationToken).ConfigureAwait(false);
src\roslyn\src\Analyzers\Core\CodeFixes\UseConditionalExpression\AbstractUseConditionalExpressionCodeFixProvider.cs (1)
158var sourceText = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeRefactorings\AbstractRefactoringHelpersService.cs (2)
21public bool IsBetweenTypeMembers(SourceText sourceText, SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? typeDeclaration) 24public void AddRelevantNodes<TSyntaxNode>(SourceText sourceText, SyntaxNode root, TextSpan selection, bool allowEmptyNodes, int maxCount, ref TemporaryArray<TSyntaxNode> result, CancellationToken cancellationToken) where TSyntaxNode : SyntaxNode
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Editing\AddParameterEditor.cs (2)
25var sourceText = declaration.SyntaxTree.GetText(cancellationToken); 159var text = parameters[0].SyntaxTree.GetText(cancellationToken);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Extensions\TextDocumentExtensions.cs (5)
15public static async ValueTask<SourceText> GetValueTextAsync(this TextDocument document, CancellationToken cancellationToken) 17if (document.TryGetText(out var text)) 27public static TextDocument WithText(this TextDocument textDocument, SourceText text) 48public static TextDocument WithAdditionalDocumentText(this TextDocument textDocument, SourceText text) 57public static TextDocument WithAnalyzerConfigDocumentText(this TextDocument textDocument, SourceText text)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Indentation\IIndentationService.cs (3)
66public static string GetIndentationString(this IndentationResult indentationResult, SourceText sourceText, bool useTabs, int tabSize) 77public static string GetIndentationString(this IndentationResult indentationResult, SourceText sourceText, SyntaxFormattingOptions options) 80public static string GetIndentationString(this IndentationResult indentationResult, SourceText sourceText, IndentationOptions options)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Utilities\ParsedDocument.cs (5)
18/// Used to front-load <see cref="SyntaxTree"/> parsing and <see cref="SourceText"/> retrieval to a caller that has knowledge of whether or not these operations 24internal readonly record struct ParsedDocument(DocumentId Id, SourceText Text, SyntaxNode Root, HostLanguageServices HostLanguageServices) 33var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false); 47public ParsedDocument WithChangedText(SourceText text, CancellationToken cancellationToken) 55var text = root.SyntaxTree.GetText(cancellationToken);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Utilities\SemanticDocument.cs (2)
13internal sealed class SemanticDocument(Document document, SourceText text, SyntaxNode root, SemanticModel semanticModel) 20var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Utilities\SyntacticDocument.cs (3)
15public readonly SourceText Text; 18protected SyntacticDocument(Document document, SourceText text, SyntaxNode root) 30var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false);
Microsoft.CodeAnalysis.CSharp (53)
Binder\Binder_InterpolatedString.cs (1)
78var text = node.SyntaxTree.GetText();
CommandLine\CSharpCompiler.cs (2)
182var content = TryReadFileContent(file, fileDiagnostics, out normalizedFilePath); 204SourceText content,
Compilation\CSharpCompilation.cs (1)
1182var text = tree.GetText();
Compilation\CSharpSemanticModel.cs (1)
5285var text = tree.GetText(cancellationToken);
Compilation\SyntaxAndDeclarationManager.cs (1)
240var code = resolver.ReadText(resolvedFilePath);
Parser\AbstractLexer.cs (1)
22protected AbstractLexer(SourceText text)
Parser\LanguageParser_InterpolatedString.cs (3)
167using var tempLexer = new Lexer(SourceText.From(originalText), this.Options, allowPreprocessorDirectives: false); 501using var tempLexer = new Lexer(SourceText.From(expressionText), options, allowPreprocessorDirectives: false, interpolationFollowedByColon: interpolation.HasColon); 592using var tempLexer = new Lexer(SourceText.From(fakeString), this.Options, allowPreprocessorDirectives: false);
Parser\Lexer.cs (3)
117public Lexer(SourceText text, CSharpParseOptions options, bool allowPreprocessorDirectives = true, bool interpolationFollowedByColon = false) 1991var text = TextWindow.Text.GetSubText(TextSpan.FromBounds(savePosition, TextWindow.Position)); 2066var text = TextWindow.Text;
Parser\SlidingTextWindow.cs (3)
65/// a portion of the file at a time (as many <see cref="SourceText"/> implementations have logarithmic 68public SourceText Text { get; } 105public SlidingTextWindow(SourceText text)
Symbols\Source\SourceNamedTypeSymbol_Extension.cs (1)
1157Text.SourceText.ReverseEndianness(shortSpan);
Syntax\CSharpLineDirectiveMap.cs (3)
28protected override LineMappingEntry GetEntry(DirectiveTriviaSyntax directiveNode, SourceText sourceText, LineMappingEntry previous) 180public override LineVisibility GetLineVisibility(SourceText sourceText, int position) 228internal override FileLinePositionSpan TranslateSpanAndVisibility(SourceText sourceText, string treeFilePath, TextSpan span, out bool isHiddenPosition)
Syntax\CSharpSyntaxTree.cs (10)
379internal static SyntaxTree CreateForDebugger(CSharpSyntaxNode root, SourceText text, CSharpParseOptions options) 415SourceText text, 459return ParseText(SourceText.From(text, encoding, SourceHashAlgorithm.Sha1), options, path, diagnosticOptions, isGeneratedCode, cancellationToken); 470SourceText text, 490SourceText text, 535public override SyntaxTree WithChangedText(SourceText newText) 538if (this.TryGetText(out SourceText? oldText)) 554private SyntaxTree WithChanges(SourceText newText, IReadOnlyList<TextChangeRange> changes) 903SourceText text, 920=> ParseText(SourceText.From(text, encoding, SourceHashAlgorithm.Sha1), options, path, diagnosticOptions, isGeneratedCode: null, cancellationToken);
Syntax\CSharpSyntaxTree.DebuggerSyntaxTree.cs (1)
16public DebuggerSyntaxTree(CSharpSyntaxNode root, SourceText text, CSharpParseOptions options)
Syntax\CSharpSyntaxTree.Dummy.cs (4)
33public override SourceText GetText(CancellationToken cancellationToken) 35return SourceText.From(string.Empty, Encoding, ChecksumAlgorithm); 38public override bool TryGetText(out SourceText text) 40text = SourceText.From(string.Empty, Encoding, ChecksumAlgorithm);
Syntax\CSharpSyntaxTree.LazySyntaxTree.cs (4)
19private readonly SourceText _text; 26SourceText text, 44public override SourceText GetText(CancellationToken cancellationToken) 49public override bool TryGetText([NotNullWhen(true)] out SourceText? text)
Syntax\CSharpSyntaxTree.ParsedSyntaxTree.cs (4)
29private SourceText? _lazyText; 32SourceText? textOpt, 62public override SourceText GetText(CancellationToken cancellationToken) 72public override bool TryGetText([NotNullWhen(true)] out SourceText? text)
Syntax\SyntaxFactory.cs (10)
1591return CSharpSyntaxTree.ParseText(SourceText.From(text, encoding, SourceHashAlgorithm.Sha1), (CSharpParseOptions?)options, path, diagnosticOptions: null, isGeneratedCode: null, cancellationToken); 1595/// <inheritdoc cref="CSharpSyntaxTree.ParseText(SourceText, CSharpParseOptions?, string, CancellationToken)"/> 1597SourceText text, 1710public static SyntaxTokenParser CreateTokenParser(SourceText sourceText, CSharpParseOptions? options = null) 1950private static SourceText MakeSourceText(string text, int offset) 1952return SourceText.From(text, Encoding.UTF8).GetSubText(offset); 2838return ParseSyntaxTree(SourceText.From(text, encoding), options, path, diagnosticOptions, isGeneratedCode: null, cancellationToken); 2845SourceText text, 2866return ParseSyntaxTree(SourceText.From(text, encoding), options, path, diagnosticOptions, isGeneratedCode, cancellationToken); 2873SourceText text,
Microsoft.CodeAnalysis.CSharp.CodeStyle (21)
src\roslyn\src\Analyzers\CSharp\Analyzers\NewLines\ConsecutiveBracePlacement\ConsecutiveBracePlacementDiagnosticAnalyzer.cs (4)
50var text = tree.GetText(cancellationToken); 77private void ProcessToken(SyntaxTreeAnalysisContext context, NotificationOption2 notificationOption, SourceText text, SyntaxToken token) 92SourceText text, SyntaxToken token, 133var text = textLine.Text!;
src\roslyn\src\Analyzers\CSharp\Analyzers\NewLines\ConstructorInitializerPlacement\ConstructorInitializerPlacementDiagnosticAnalyzer.cs (1)
73var sourceText = context.Tree.GetText(context.CancellationToken);
src\roslyn\src\Analyzers\CSharp\Analyzers\UseCollectionExpression\CSharpUseCollectionExpressionForFluentDiagnosticAnalyzer.cs (3)
93var sourceText = semanticModel.SyntaxTree.GetText(cancellationToken); 115SourceText text, 148SourceText text,
src\roslyn\src\Analyzers\CSharp\Analyzers\UseCollectionExpression\UseCollectionExpressionHelpers.cs (2)
667SourceText sourceText, 689SourceText sourceText,
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\EmbeddedLanguages\VirtualChars\CSharpVirtualCharService.cs (3)
186var parentSourceText = parentExpression.SyntaxTree.GetText(); 191var tokenSourceText = SourceText.From(token.Text);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxNodeExtensions.cs (2)
61this SyntaxNode node, SourceText? sourceText = null, 71this SyntaxToken token, SourceText? sourceText = null,
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxTokenExtensions.cs (1)
168public static bool IsFirstTokenOnLine(this SyntaxToken token, SourceText text)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxTreeExtensions.cs (1)
351var sourceText = token.SyntaxTree!.GetText(cancellationToken);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Indentation\CSharpSmartTokenFormatter.cs (2)
27private readonly SourceText _text; 33SourceText text)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\RefactoringHelpers\CSharpRefactoringHelpers.cs (1)
30public override bool IsBetweenTypeMembers(SourceText sourceText, SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? typeDeclaration)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\FormattingRangeHelper.cs (1)
279if (tree != null && tree.TryGetText(out var text))
Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes (35)
src\roslyn\src\Analyzers\CSharp\CodeFixes\AddInheritdoc\AddInheritdocCodeFixProvider.cs (1)
71var sourceText = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false);
src\roslyn\src\Analyzers\CSharp\CodeFixes\ConditionalExpressionInStringInterpolation\CSharpAddParenthesesAroundConditionalExpressionInInterpolatedStringCodeFixProvider.cs (4)
61var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false); 63var textWithOpenParenthesis = text.Replace(openParenthesisPosition, 0, "("); 84var sourceText = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false); 113var textWithCloseParenthesis = sourceText.Replace(closeParenPosition, 0, ")");
src\roslyn\src\Analyzers\CSharp\CodeFixes\ConvertNamespace\ConvertNamespaceTransform.cs (8)
62public static (SourceText text, TextSpan semicolonSpan) ConvertNamespaceDeclaration(ParsedDocument document, NamespaceDeclarationSyntax namespaceDeclaration, SyntaxFormattingOptions options, CancellationToken cancellationToken) 108private static (SourceText text, TextSpan semicolonSpan) DedentNamespace( 112var text = document.Text; 125var dedentedText = text.WithChanges(changes); 194private static SourceText IndentNamespace( 198var text = document.Text; 209var dedentedText = text.WithChanges(changes); 255var indentedText = IndentNamespace(updatedParsedDocument, indentation, annotation, cancellationToken);
src\roslyn\src\Analyzers\CSharp\CodeFixes\InlineDeclaration\CSharpInlineDeclarationCodeFixProvider.cs (2)
106var sourceText = currentRoot.GetText(); 267SourceText sourceText, IdentifierNameSyntax identifier,
src\roslyn\src\Analyzers\CSharp\CodeFixes\NewLines\ArrowExpressionClausePlacement\ArrowExpressionClausePlacementCodeFixProvider.cs (3)
45var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false); 59var changedText = text.WithChanges(edits); 64SourceText text,
src\roslyn\src\Analyzers\CSharp\CodeFixes\NewLines\ConditionalExpressionPlacement\ConditionalExpressionPlacementCodeFixProvider.cs (3)
45var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false); 60var changedText = text.WithChanges(edits); 65SourceText text,
src\roslyn\src\Analyzers\CSharp\CodeFixes\NewLines\ConsecutiveBracePlacement\ConsecutiveBracePlacementCodeFixProvider.cs (2)
48var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false); 61SyntaxNode root, SourceText text,
src\roslyn\src\Analyzers\CSharp\CodeFixes\NewLines\ConstructorInitializerPlacement\ConstructorInitializerPlacementCodeFixProvider.cs (1)
45var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false);
src\roslyn\src\Analyzers\CSharp\CodeFixes\UseCollectionExpression\CSharpCollectionExpressionRewriter.cs (1)
909var text = document.Text;
src\roslyn\src\Analyzers\CSharp\CodeFixes\UseCollectionExpression\CSharpUseCollectionExpressionForArrayCodeFixProvider.cs (2)
55var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); 96static bool IsOnSingleLine(SourceText sourceText, SyntaxNode node)
src\roslyn\src\Analyzers\CSharp\CodeFixes\UseCollectionExpression\CSharpUseCollectionExpressionForFluentCodeFixProvider.cs (2)
56var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); 148var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Indentation\CSharpIndentationService.cs (1)
144var text = node.SyntaxTree.GetText();
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Indentation\CSharpIndentationService.Indenter.cs (5)
26CompilationUnitSyntax root, SourceText text, TextLine lineToBeIndented, 76var sourceText = indenter.LineToBeIndented.Text; 346var sourceText = indenter.LineToBeIndented.Text; 384var sourceText = indenter.LineToBeIndented.Text; 470var sourceText = indenter.LineToBeIndented.Text;
Microsoft.CodeAnalysis.CSharp.Features (151)
AddImport\CSharpAddMissingImportsFeatureService.cs (1)
24protected override ImmutableArray<AbstractFormattingRule> GetFormatRules(SourceText text)
BraceCompletion\AbstractCurlyBraceOrBracketCompletionService.cs (7)
62var formattedText = context.Document.Text.WithChanges(formattingChanges); 68private static bool ContainsOnlyWhitespace(SourceText text, int openingPosition, int closingBraceEndPoint) 94var originalDocumentText = document.Text; 158var newText = oldDocument.Text.WithChanges(changes); 163static TextLine GetLineBetweenCurlys(int closingPosition, SourceText text) 169static LinePosition GetIndentedLinePosition(ParsedDocument document, SourceText sourceText, int lineNumber, IndentationOptions options, CancellationToken cancellationToken) 181static ImmutableArray<TextChange> GetMergedChanges(TextChange? newLineEdit, ImmutableArray<TextChange> formattingChanges, SourceText formattedText)
BraceCompletion\InterpolatedStringBraceCompletionService.cs (2)
42protected override bool IsValidOpenBraceTokenAtPosition(SourceText text, SyntaxToken token, int position) 50var text = document.Text;
BraceCompletion\InterpolationBraceCompletionService.cs (1)
38protected override bool IsValidOpenBraceTokenAtPosition(SourceText text, SyntaxToken token, int position)
BraceCompletion\ParenthesisBraceCompletionService.cs (1)
30protected override bool IsValidOpenBraceTokenAtPosition(SourceText text, SyntaxToken token, int position)
BraceCompletion\StringLiteralBraceCompletionService.cs (2)
32var text = document.Text; 55protected override bool IsValidOpenBraceTokenAtPosition(SourceText text, SyntaxToken token, int position)
BraceMatching\BlockCommentBraceMatcher.cs (1)
32var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false);
CodeRefactorings\InlineTemporary\InlineTemporaryCodeRefactoringProvider.cs (1)
435var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false);
Completion\CompletionProviders\AttributeNamedParameterCompletionProvider.cs (1)
46public override bool IsInsertionTrigger(SourceText text, int characterPosition, CompletionOptions options)
Completion\CompletionProviders\CompletionUtilities.cs (8)
20internal static TextSpan GetCompletionItemSpan(SourceText text, int position) 60internal static bool IsTriggerCharacter(SourceText text, int characterPosition, in CompletionOptions options) 99internal static bool IsCompilerDirectiveTriggerCharacter(SourceText text, int characterPosition) 117internal static bool IsTriggerCharacterOrArgumentListCharacter(SourceText text, int characterPosition, in CompletionOptions options) 120private static bool IsArgumentListCharacter(SourceText text, int characterPosition) 126internal static bool IsTriggerAfterSpaceOrStartOfWordCharacter(SourceText text, int characterPosition, in CompletionOptions options) 136private static bool SpaceTypedNotBeforeWord(char ch, SourceText text, int characterPosition) 139public static bool IsStartingNewWord(SourceText text, int characterPosition)
Completion\CompletionProviders\CrefCompletionProvider.cs (1)
55public override bool IsInsertionTrigger(SourceText text, int characterPosition, CompletionOptions options)
Completion\CompletionProviders\DeclarationName\DeclarationNameCompletionProvider.cs (1)
35public override bool IsInsertionTrigger(SourceText text, int insertedCharacterPosition, CompletionOptions options)
Completion\CompletionProviders\DeclarationName\DeclarationNameInfo.cs (1)
189var sourceText = semanticModel.SyntaxTree.GetText(cancellationToken);
Completion\CompletionProviders\EnumAndCompletionListTagCompletionProvider.cs (1)
42public override bool IsInsertionTrigger(SourceText text, int characterPosition, CompletionOptions options)
Completion\CompletionProviders\ExplicitInterfaceMemberCompletionProvider.cs (1)
31public override bool IsInsertionTrigger(SourceText text, int characterPosition, CompletionOptions options)
Completion\CompletionProviders\ExplicitInterfaceMemberCompletionProvider.ItemGetter.cs (3)
34SourceText text, 53var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false); 124var text = await Document.GetValueTextAsync(CancellationToken).ConfigureAwait(false);
Completion\CompletionProviders\ExplicitInterfaceTypeCompletionProvider.cs (1)
34public override bool IsInsertionTrigger(SourceText text, int insertedCharacterPosition, CompletionOptions options)
Completion\CompletionProviders\ExternAliasCompletionProvider.cs (2)
34public override bool IsInsertionTrigger(SourceText text, int characterPosition, CompletionOptions options) 80var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false);
Completion\CompletionProviders\FileBasedPrograms\AbstractAppDirectiveCompletionProvider.cs (1)
34public sealed override bool IsInsertionTrigger(SourceText text, int characterPosition, CompletionOptions options)
Completion\CompletionProviders\FunctionPointerUnmanagedCallingConventionCompletionProvider.cs (1)
36public override bool IsInsertionTrigger(SourceText text, int characterPosition, CompletionOptions options)
Completion\CompletionProviders\ImportCompletion\ExtensionMemberImportCompletionProvider.cs (1)
31public override bool IsInsertionTrigger(SourceText text, int characterPosition, CompletionOptions options)
Completion\CompletionProviders\ImportCompletion\TypeImportCompletionProvider.cs (1)
33public override bool IsInsertionTrigger(SourceText text, int characterPosition, CompletionOptions options)
Completion\CompletionProviders\InternalsVisibleToCompletionProvider.cs (1)
59protected override bool ShouldTriggerAfterQuotes(SourceText text, int insertedCharacterPosition)
Completion\CompletionProviders\KeywordCompletionProvider.cs (1)
177public override bool IsInsertionTrigger(SourceText text, int characterPosition, CompletionOptions options)
Completion\CompletionProviders\NamedParameterCompletionProvider.cs (1)
43public override bool IsInsertionTrigger(SourceText text, int characterPosition, CompletionOptions options)
Completion\CompletionProviders\ObjectAndWithInitializerCompletionProvider.cs (1)
87public override bool IsInsertionTrigger(SourceText text, int characterPosition, CompletionOptions options)
Completion\CompletionProviders\ObjectCreationCompletionProvider.cs (1)
36public override bool IsInsertionTrigger(SourceText text, int characterPosition, CompletionOptions options)
Completion\CompletionProviders\OperatorsAndIndexer\UnnamedSymbolCompletionProvider.cs (1)
64public override bool IsInsertionTrigger(SourceText text, int insertedCharacterPosition, CompletionOptions options)
Completion\CompletionProviders\OperatorsAndIndexer\UnnamedSymbolCompletionProvider_Conversions.cs (2)
80var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false); 122var newText = text.WithChanges(builder);
Completion\CompletionProviders\OperatorsAndIndexer\UnnamedSymbolCompletionProvider_Operators.cs (1)
142var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false);
Completion\CompletionProviders\OverrideCompletionProvider.cs (2)
38public override bool IsInsertionTrigger(SourceText text, int characterPosition, CompletionOptions options) 73SourceText text,
Completion\CompletionProviders\PartialMethodCompletionProvider.cs (3)
70public override bool IsInsertionTrigger(SourceText text, int characterPosition, CompletionOptions options) 86var text = tree.GetText(cancellationToken); 127private static bool IsOnSameLine(SyntaxToken syntaxToken, SyntaxToken touchingToken, SourceText text)
Completion\CompletionProviders\PartialTypeCompletionProvider.cs (1)
48public override bool IsInsertionTrigger(SourceText text, int characterPosition, CompletionOptions options)
Completion\CompletionProviders\PreprocessorCompletionProvider.cs (1)
28public override bool IsInsertionTrigger(SourceText text, int characterPosition, CompletionOptions options)
Completion\CompletionProviders\PropertySubPatternCompletionProvider.cs (1)
165public override bool IsInsertionTrigger(SourceText text, int characterPosition, CompletionOptions options)
Completion\CompletionProviders\SnippetCompletionProvider.cs (1)
64public override bool IsInsertionTrigger(SourceText text, int characterPosition, CompletionOptions options)
Completion\CompletionProviders\SpeculativeTCompletionProvider.cs (1)
33public override bool IsInsertionTrigger(SourceText text, int characterPosition, CompletionOptions options)
Completion\CompletionProviders\SymbolCompletionProvider.cs (2)
138public override bool IsInsertionTrigger(SourceText text, int characterPosition, CompletionOptions options) 177var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false);
Completion\CompletionProviders\XmlDocCommentCompletionProvider.cs (1)
63public override bool IsInsertionTrigger(SourceText text, int characterPosition, CompletionOptions options)
Completion\CSharpCompletionService.cs (1)
42public override TextSpan GetDefaultCompletionListSpan(SourceText text, int caretPosition)
ConvertToRawString\ConvertInterpolatedStringToRawStringCodeRefactoringProvider.cs (6)
292var text = stringExpression.GetText(); 350SourceText text, 468private static string GetIndentationStringForToken(SourceText text, SyntaxFormattingOptions options, SyntaxToken token) 471private static string GetIndentationStringForPosition(SourceText text, SyntaxFormattingOptions options, int position) 488SourceText? text = null; 529var text = stringExpression.GetText();
Copilot\CSharpCopilotProposalAdjusterService.cs (1)
52var newText = await forkedDocument.GetTextAsync(cancellationToken).ConfigureAwait(false);
Debugging\LocationInfoGetter.cs (1)
60var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false);
EditAndContinue\BreakpointSpans.cs (1)
21var source = tree.GetText(cancellationToken);
EmbeddedLanguages\CSharpTestEmbeddedLanguageClassifier.cs (1)
66var text = semanticModel.SyntaxTree.GetText(cancellationToken);
ExtractMethod\CSharpSelectionValidator.cs (1)
403var text = this.SemanticDocument.Text;
InvertIf\CSharpInvertIfCodeRefactoringProvider.cs (1)
141SourceText sourceText,
RawStringLiteral\CSharpRawStringLiteralOnAutoInsertService.cs (4)
21public TextChange? GetTextChangeForQuote(Document document, SourceText text, int caretPosition, CancellationToken cancellationToken) 34SourceText text, 81SourceText text, 132SourceText text,
Snippets\AbstractCSharpAutoPropertySnippetProvider.cs (1)
75protected override int GetTargetCaretPosition(PropertyDeclarationSyntax propertyDeclaration, SourceText sourceText)
Snippets\AbstractCSharpForLoopSnippetProvider.cs (1)
139protected override int GetTargetCaretPosition(ForStatementSyntax forStatement, SourceText sourceText)
Snippets\AbstractCSharpTypeSnippetProvider.cs (1)
84protected override int GetTargetCaretPosition(TTypeDeclarationSyntax typeDeclaration, SourceText sourceText)
Snippets\CSharpConstructorSnippetProvider.cs (1)
78protected override int GetTargetCaretPosition(ConstructorDeclarationSyntax constructorDeclaration, SourceText sourceText)
Snippets\CSharpDoWhileLoopSnippetProvider.cs (1)
45protected override int GetTargetCaretPosition(DoStatementSyntax doStatement, SourceText sourceText)
Snippets\CSharpElseSnippetProvider.cs (1)
63protected override int GetTargetCaretPosition(ElseClauseSyntax elseClause, SourceText sourceText)
Snippets\CSharpForEachLoopSnippetProvider.cs (1)
126protected override int GetTargetCaretPosition(ForEachStatementSyntax forEachStatement, SourceText sourceText)
Snippets\CSharpIfSnippetProvider.cs (1)
33protected override int GetTargetCaretPosition(IfStatementSyntax ifStatement, SourceText sourceText)
Snippets\CSharpIntMainSnippetProvider.cs (1)
39protected override int GetTargetCaretPosition(MethodDeclarationSyntax methodDeclaration, SourceText sourceText)
Snippets\CSharpLockSnippetProvider.cs (1)
35protected override int GetTargetCaretPosition(LockStatementSyntax lockStatement, SourceText sourceText)
Snippets\CSharpSnippetFunctionService.cs (1)
58var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false);
Snippets\CSharpSnippetHelpers.cs (1)
18public static int GetTargetCaretPositionInBlock<TTargetNode>(TTargetNode caretTarget, Func<TTargetNode, BlockSyntax> getBlock, SourceText sourceText)
Snippets\CSharpUnsafeSnippetProvider.cs (1)
29protected override int GetTargetCaretPosition(UnsafeStatementSyntax unsafeStatement, SourceText sourceText)
Snippets\CSharpUsingSnippetProvider.cs (1)
35protected override int GetTargetCaretPosition(UsingStatementSyntax usingStatement, SourceText sourceText)
Snippets\CSharpVoidMainSnippetProvider.cs (1)
36protected override int GetTargetCaretPosition(MethodDeclarationSyntax methodDeclaration, SourceText sourceText)
Snippets\CSharpWhileLoopSnippetProvider.cs (1)
33protected override int GetTargetCaretPosition(WhileStatementSyntax whileStatement, SourceText sourceText)
SplitStringLiteral\StringSplitter.cs (1)
131var newSourceText = newDocument.Text;
src\roslyn\src\Analyzers\CSharp\Analyzers\NewLines\ConsecutiveBracePlacement\ConsecutiveBracePlacementDiagnosticAnalyzer.cs (4)
50var text = tree.GetText(cancellationToken); 77private void ProcessToken(SyntaxTreeAnalysisContext context, NotificationOption2 notificationOption, SourceText text, SyntaxToken token) 92SourceText text, SyntaxToken token, 133var text = textLine.Text!;
src\roslyn\src\Analyzers\CSharp\Analyzers\NewLines\ConstructorInitializerPlacement\ConstructorInitializerPlacementDiagnosticAnalyzer.cs (1)
73var sourceText = context.Tree.GetText(context.CancellationToken);
src\roslyn\src\Analyzers\CSharp\Analyzers\UseCollectionExpression\CSharpUseCollectionExpressionForFluentDiagnosticAnalyzer.cs (3)
93var sourceText = semanticModel.SyntaxTree.GetText(cancellationToken); 115SourceText text, 148SourceText text,
src\roslyn\src\Analyzers\CSharp\Analyzers\UseCollectionExpression\UseCollectionExpressionHelpers.cs (2)
667SourceText sourceText, 689SourceText sourceText,
src\roslyn\src\Analyzers\CSharp\CodeFixes\AddInheritdoc\AddInheritdocCodeFixProvider.cs (1)
71var sourceText = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false);
src\roslyn\src\Analyzers\CSharp\CodeFixes\ConditionalExpressionInStringInterpolation\CSharpAddParenthesesAroundConditionalExpressionInInterpolatedStringCodeFixProvider.cs (4)
61var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false); 63var textWithOpenParenthesis = text.Replace(openParenthesisPosition, 0, "("); 84var sourceText = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false); 113var textWithCloseParenthesis = sourceText.Replace(closeParenPosition, 0, ")");
src\roslyn\src\Analyzers\CSharp\CodeFixes\ConvertNamespace\ConvertNamespaceTransform.cs (8)
62public static (SourceText text, TextSpan semicolonSpan) ConvertNamespaceDeclaration(ParsedDocument document, NamespaceDeclarationSyntax namespaceDeclaration, SyntaxFormattingOptions options, CancellationToken cancellationToken) 108private static (SourceText text, TextSpan semicolonSpan) DedentNamespace( 112var text = document.Text; 125var dedentedText = text.WithChanges(changes); 194private static SourceText IndentNamespace( 198var text = document.Text; 209var dedentedText = text.WithChanges(changes); 255var indentedText = IndentNamespace(updatedParsedDocument, indentation, annotation, cancellationToken);
src\roslyn\src\Analyzers\CSharp\CodeFixes\InlineDeclaration\CSharpInlineDeclarationCodeFixProvider.cs (2)
106var sourceText = currentRoot.GetText(); 267SourceText sourceText, IdentifierNameSyntax identifier,
src\roslyn\src\Analyzers\CSharp\CodeFixes\NewLines\ArrowExpressionClausePlacement\ArrowExpressionClausePlacementCodeFixProvider.cs (3)
45var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false); 59var changedText = text.WithChanges(edits); 64SourceText text,
src\roslyn\src\Analyzers\CSharp\CodeFixes\NewLines\ConditionalExpressionPlacement\ConditionalExpressionPlacementCodeFixProvider.cs (3)
45var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false); 60var changedText = text.WithChanges(edits); 65SourceText text,
src\roslyn\src\Analyzers\CSharp\CodeFixes\NewLines\ConsecutiveBracePlacement\ConsecutiveBracePlacementCodeFixProvider.cs (2)
48var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false); 61SyntaxNode root, SourceText text,
src\roslyn\src\Analyzers\CSharp\CodeFixes\NewLines\ConstructorInitializerPlacement\ConstructorInitializerPlacementCodeFixProvider.cs (1)
45var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false);
src\roslyn\src\Analyzers\CSharp\CodeFixes\UseCollectionExpression\CSharpCollectionExpressionRewriter.cs (1)
909var text = document.Text;
src\roslyn\src\Analyzers\CSharp\CodeFixes\UseCollectionExpression\CSharpUseCollectionExpressionForArrayCodeFixProvider.cs (2)
55var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); 96static bool IsOnSingleLine(SourceText sourceText, SyntaxNode node)
src\roslyn\src\Analyzers\CSharp\CodeFixes\UseCollectionExpression\CSharpUseCollectionExpressionForFluentCodeFixProvider.cs (2)
56var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); 148var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
StringIndentation\CSharpStringIndentationService.cs (5)
31var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false); 79SourceText text, SyntaxToken token, ref TemporaryArray<StringIndentationRegion> result, CancellationToken cancellationToken) 94SourceText text, InterpolatedStringExpressionSyntax interpolatedString, ref TemporaryArray<StringIndentationRegion> result, CancellationToken cancellationToken) 137private static bool IgnoreInterpolation(SourceText text, int offset, InterpolationSyntax interpolation) 158private static bool TryGetIndentSpan(SourceText text, ExpressionSyntax expression, out int offset, out TextSpan indentSpan)
Structure\Providers\ArgumentListStructureProvider.cs (1)
36var text = node.SyntaxTree.GetText(cancellationToken);
Structure\Providers\DisabledTextTriviaStructureProvider.cs (1)
70var text = syntaxTree.GetText(cancellationToken);
Structure\Providers\IfDirectiveTriviaStructureProvider.cs (1)
27SourceText? text = null;
Structure\Providers\ParameterListStructureProvider.cs (1)
36var text = node.SyntaxTree.GetText(cancellationToken);
Structure\Providers\StringLiteralExpressionStructureProvider.cs (1)
49var sourceText = node.SyntaxTree.GetText(cancellationToken);
SyncedSource\FileBasedPrograms\FileLevelDirectiveHelpers.cs (4)
26public static SyntaxTokenParser CreateTokenizer(SourceText text) 224internal readonly record struct SourceFile(string Path, SourceText Text) 230return new SourceFile(filePath, SourceText.From(stream, encoding: null)); 815internal delegate void ErrorReporter(SourceText text, string path, TextSpan textSpan, string message, Exception? innerException = null);
UseExpressionBody\UseExpressionBodyCodeRefactoringProvider.cs (2)
78var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false); 94UseExpressionBodyHelper helper, SourceText text, SyntaxNode node, int position)
Microsoft.CodeAnalysis.CSharp.Scripting (3)
CSharpScript.cs (2)
37return Script.CreateInitialScript<T>(CSharpScriptCompiler.Instance, SourceText.From(code, options?.FileEncoding, SourceHashAlgorithms.Default), options, globalsType, assemblyLoader); 54return Script.CreateInitialScript<T>(CSharpScriptCompiler.Instance, SourceText.From(code, options?.FileEncoding), options, globalsType, assemblyLoader);
CSharpScriptCompiler.cs (1)
30public override SyntaxTree ParseSubmission(SourceText text, ParseOptions parseOptions, CancellationToken cancellationToken)
Microsoft.CodeAnalysis.CSharp.Workspaces (30)
Classification\ClassificationHelpers.cs (2)
507internal static void AddLexicalClassifications(SourceText text, TextSpan textSpan, SegmentedList<ClassifiedSpan> result, CancellationToken cancellationToken) 515internal static ClassifiedSpan AdjustStaleClassification(SourceText rawText, ClassifiedSpan classifiedSpan)
Classification\CSharpClassificationService.cs (2)
30public override void AddLexicalClassifications(SourceText text, TextSpan textSpan, SegmentedList<ClassifiedSpan> result, CancellationToken cancellationToken) 33public override ClassifiedSpan AdjustStaleClassification(SourceText text, ClassifiedSpan classifiedSpan)
Classification\SyntaxClassification\CSharpSyntaxClassificationService.cs (2)
44public override void AddLexicalClassifications(SourceText text, TextSpan textSpan, SegmentedList<ClassifiedSpan> result, CancellationToken cancellationToken) 55public override ClassifiedSpan FixClassification(SourceText rawText, ClassifiedSpan classifiedSpan)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\EmbeddedLanguages\VirtualChars\CSharpVirtualCharService.cs (3)
186var parentSourceText = parentExpression.SyntaxTree.GetText(); 191var tokenSourceText = SourceText.From(token.Text);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxNodeExtensions.cs (2)
61this SyntaxNode node, SourceText? sourceText = null, 71this SyntaxToken token, SourceText? sourceText = null,
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxTokenExtensions.cs (1)
168public static bool IsFirstTokenOnLine(this SyntaxToken token, SourceText text)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxTreeExtensions.cs (1)
351var sourceText = token.SyntaxTree!.GetText(cancellationToken);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Indentation\CSharpSmartTokenFormatter.cs (2)
27private readonly SourceText _text; 33SourceText text)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\RefactoringHelpers\CSharpRefactoringHelpers.cs (1)
30public override bool IsBetweenTypeMembers(SourceText sourceText, SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? typeDeclaration)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\FormattingRangeHelper.cs (1)
279if (tree != null && tree.TryGetText(out var text))
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Indentation\CSharpIndentationService.cs (1)
144var text = node.SyntaxTree.GetText();
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Indentation\CSharpIndentationService.Indenter.cs (5)
26CompilationUnitSyntax root, SourceText text, TextLine lineToBeIndented, 76var sourceText = indenter.LineToBeIndented.Text; 346var sourceText = indenter.LineToBeIndented.Text; 384var sourceText = indenter.LineToBeIndented.Text; 470var sourceText = indenter.LineToBeIndented.Text;
Workspace\LanguageServices\CSharpSyntaxTreeFactoryService.cs (2)
58public override SyntaxTree CreateSyntaxTree(string filePath, ParseOptions options, SourceText text, Encoding encoding, SourceHashAlgorithm checksumAlgorithm, SyntaxNode root) 64public override SyntaxTree ParseSyntaxTree(string filePath, ParseOptions options, SourceText text, CancellationToken cancellationToken)
Workspace\LanguageServices\CSharpSyntaxTreeFactoryService.ParsedSyntaxTree.cs (5)
15/// Parsed <see cref="CSharpSyntaxTree"/> that creates <see cref="SourceText"/> with given encoding and checksum algorithm. 26private SourceText? _lazyText; 29SourceText? lazyText, 45public override SourceText GetText(CancellationToken cancellationToken) 55public override bool TryGetText([NotNullWhen(true)] out SourceText? text)
Microsoft.CodeAnalysis.ExternalAccess.HotReload (6)
Api\HotReloadMSBuildWorkspace.cs (6)
182var oldText = await textDocument.GetTextAsync(cancellationToken).ConfigureAwait(false); 185var newText = await GetSourceTextAsync(path, oldText.Encoding, oldText.ChecksumAlgorithm, cancellationToken).ConfigureAwait(false); 210private static async ValueTask<SourceText> GetSourceTextAsync(string filePath, Encoding encoding, SourceHashAlgorithm checksumAlgorithm, CancellationToken cancellationToken) 219SourceText sourceText; 222sourceText = SourceText.From(stream, encoding, checksumAlgorithm); 237sourceText = SourceText.From(stream, encoding, checksumAlgorithm);
Microsoft.CodeAnalysis.ExternalAccess.OmniSharp (3)
Completion\OmniSharpCompletionService.cs (1)
24var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false);
DocumentationComments\OmniSharpDocumentationCommentsSnippetService.cs (2)
19SourceText text, 31SourceText text,
Microsoft.CodeAnalysis.Features (265)
AddFileBanner\AbstractAddFileBannerCodeRefactoringProvider.cs (1)
136var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false);
AddImport\CodeActions\AddImportCodeAction.cs (2)
61var oldText = await OriginalDocument.GetValueTextAsync(cancellationToken).ConfigureAwait(false); 62var newText = oldText.WithChanges(_textChanges);
AddImport\CodeActions\InstallPackageAndAddImportCodeAction.cs (6)
86var oldText = await OriginalDocument.GetValueTextAsync(cancellationToken).ConfigureAwait(false); 87var newText = await updatedDocument.GetValueTextAsync(cancellationToken).ConfigureAwait(false); 95SourceText oldText, 96SourceText newText, 100private readonly SourceText _oldText = oldText; 101private readonly SourceText _newText = newText;
BraceCompletion\AbstractBraceCompletionService.cs (2)
114protected virtual bool IsValidOpenBraceTokenAtPosition(SourceText text, SyntaxToken token, int position) 194protected static bool CouldEscapePreviousOpenBrace(char openingBrace, int position, SourceText text)
BraceMatching\AbstractBraceMatcher.cs (1)
67var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false);
BraceMatching\BraceMatchingService.cs (1)
26var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false);
ClassifiedSpansAndHighlightSpanFactory.cs (2)
34var sourceText = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false); 44private static TextSpan GetLineSpanForReference(SourceText sourceText, TextSpan referenceSpan)
CodeFixes\Configuration\ConfigurationUpdater.cs (8)
271var originalText = await editorConfigDocument.GetValueTextAsync(cancellationToken).ConfigureAwait(false); 274var newText = GetNewAnalyzerConfigDocumentText(originalText, editorConfigDocument); 396private SourceText? GetNewAnalyzerConfigDocumentText(SourceText originalText, AnalyzerConfigDocument editorConfigDocument) 416private (SourceText? newText, TextLine? lastValidHeaderSpanEnd, TextLine? lastValidSpecificHeaderSpanEnd) CheckIfRuleExistsAndReplaceInFile( 417SourceText result, 674private SourceText? AddMissingRule( 675SourceText result,
CodeFixes\Service\CodeFixService.cs (5)
119var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false); 213var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false); 232var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false); 261SourceText text, ImmutableArray<DiagnosticData> diagnostics) 294var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false);
CodeFixes\Suppression\AbstractSuppressionBatchFixAllProvider.cs (5)
270private static async Task<ImmutableArray<(DocumentId documentId, SourceText newText)>> GetDocumentIdToFinalTextAsync( 283var documentIdToFinalText = new ConcurrentDictionary<DocumentId, SourceText>(); 298ConcurrentDictionary<DocumentId, SourceText> documentIdToFinalText, 314var finalText = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false); 336var newText = await merger.GetFinalMergedTextAsync(cancellationToken).ConfigureAwait(false);
CodeFixes\Suppression\AbstractSuppressionCodeFixProvider.AbstractGlobalSuppressMessageCodeAction.cs (2)
109var emptyText = SourceText.From("", Encoding.UTF8, SourceHashAlgorithms.Default);
CodeFixes\Suppression\AbstractSuppressionCodeFixProvider.PragmaBatchFixHelpers.cs (2)
105var currentText = await currentDocument.GetValueTextAsync(cancellationToken).ConfigureAwait(false); 107var newText = currentText.WithChanges(orderedChanges);
CodeLens\CodeLensReferencesService.cs (1)
125var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false);
CodeRefactorings\AddMissingImports\AbstractAddMissingImportsFeatureService.cs (7)
31protected abstract ImmutableArray<AbstractFormattingRule> GetFormatRules(SourceText text); 116var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false); 117var newText = text.WithChanges(insertionOnlyChanges); 153var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false); 177var newText = text.WithChanges(textChanges); 231protected sealed class CleanUpNewLinesFormatter(SourceText text) : AbstractFormattingRule 233private readonly SourceText _text = text;
CodeRefactorings\AddMissingImports\AbstractAddMissingImportsRefactoringProvider.cs (1)
32var sourceText = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false);
CodeRefactorings\SyncNamespace\AbstractChangeNamespaceService.cs (1)
711var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
CodeRefactorings\SyncNamespace\AbstractSyncNamespaceCodeRefactoringProvider.MoveFileCodeAction.cs (1)
45var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false);
Completion\CommonCompletionProvider.cs (4)
34public sealed override bool ShouldTriggerCompletion(SourceText text, int caretPosition, CompletionTrigger trigger, OptionSet options) 42internal override bool ShouldTriggerCompletion(LanguageServices languageServices, SourceText text, int caretPosition, CompletionTrigger trigger, CompletionOptions options, OptionSet passThroughOptions) 45private bool ShouldTriggerCompletionImpl(SourceText text, int caretPosition, CompletionTrigger trigger, in CompletionOptions options) 50public virtual bool IsInsertionTrigger(SourceText text, int insertedCharacterPosition, CompletionOptions options)
Completion\CommonCompletionUtilities.cs (4)
27public static TextSpan GetWordSpan(SourceText text, int position, 33public static TextSpan GetWordSpan(SourceText text, int position, 60public static bool IsStartingNewWord(SourceText text, int characterPosition, Func<char, bool> isWordStartCharacter, Func<char, bool> isWordCharacter) 185internal static bool IsTextualTriggerString(SourceText text, int characterPosition, string value)
Completion\CompletionProvider.cs (2)
36public virtual bool ShouldTriggerCompletion(SourceText text, int caretPosition, CompletionTrigger trigger, OptionSet options) 47internal virtual bool ShouldTriggerCompletion(LanguageServices languageServices, SourceText text, int caretPosition, CompletionTrigger trigger, CompletionOptions options, OptionSet passThroughOptions)
Completion\CompletionService.cs (5)
95SourceText text, 134SourceText text, 171public virtual TextSpan GetDefaultItemSpan(SourceText text, int caretPosition) 174public virtual TextSpan GetDefaultCompletionListSpan(SourceText text, int caretPosition) 415var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false);
Completion\CompletionService_GetCompletions.cs (3)
74var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false); 129Document document, ConcatImmutableArray<CompletionProvider> providers, int caretPosition, CompletionOptions options, CompletionTrigger trigger, ImmutableHashSet<string>? roles, SourceText text) 189Document document, SourceText text, int caretPosition, in CompletionOptions options)
Completion\Providers\AbstractAggregateEmbeddedLanguageCompletionProvider.cs (1)
71internal sealed override bool ShouldTriggerCompletion(LanguageServices languageServices, SourceText text, int caretPosition, CompletionTrigger trigger, CompletionOptions options, OptionSet passThroughOptions)
Completion\Providers\AbstractAwaitCompletionProvider.cs (3)
105var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); 212var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false); 243var newText = text.WithChanges(builder);
Completion\Providers\AbstractDocCommentCompletionProvider.cs (2)
91var text = await context.Document.GetTextAsync(context.CancellationToken).ConfigureAwait(false); 290var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false);
Completion\Providers\AbstractInternalsVisibleToCompletionProvider.cs (3)
26public sealed override bool IsInsertionTrigger(SourceText text, int insertedCharacterPosition, CompletionOptions options) 51protected abstract bool ShouldTriggerAfterQuotes(SourceText text, int insertedCharacterPosition); 256var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false);
Completion\Providers\AbstractMemberInsertingCompletionProvider.cs (4)
51var newText = await newDocument.GetValueTextAsync(cancellationToken).ConfigureAwait(false); 65var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false); 159private TextSpan ComputeDestinationSpan(SyntaxNode insertionRoot, SourceText text) 185var text = await memberContainingDocument.GetValueTextAsync(cancellationToken).ConfigureAwait(false);
Completion\Providers\AbstractOverrideCompletionProvider.BaseItemGetter.cs (2)
32protected readonly SourceText Text; 40SourceText text,
Completion\Providers\AbstractOverrideCompletionProvider.cs (2)
19public abstract bool TryDetermineModifiers(SyntaxToken startToken, SourceText text, int startLine, out Accessibility seenAccessibility, out DeclarationModifiers modifiers); 68protected static bool IsOnStartLine(int position, SourceText text, int startLine)
Completion\Providers\AbstractOverrideCompletionProvider.ItemGetter.cs (2)
20SourceText text, 39var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false);
Completion\Providers\AbstractPartialMethodCompletionProvider.cs (1)
96var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false);
Completion\Providers\AbstractRecommendationServiceBasedCompletionProvider.cs (1)
295var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false);
Completion\Providers\CompletionUtilities.cs (4)
73public static CompletionItem SetOriginalIdentifierEnd(CompletionItem item, int position, SourceText text, ISyntaxFactsService syntaxFacts) 82public static KeyValuePair<string, string> GetOriginalIdentifierEndProperty(int position, SourceText text, ISyntaxFactsService syntaxFacts) 85private static int ScanForwardThroughIdentifier(int start, SourceText text, ISyntaxFactsService syntaxFacts) 102public static int GetCurrentSpanEnd(CompletionItem item, SourceText text, ISyntaxFactsService syntaxFacts)
Completion\Providers\EmbeddedLanguageCompletionProvider.cs (1)
22public abstract bool ShouldTriggerCompletion(SourceText text, int caretPosition, CompletionTrigger trigger);
Completion\Providers\ImportCompletionProvider\AbstractImportCompletionProvider.cs (2)
172var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false); 173var newText = text.WithChanges(builder);
Completion\Providers\Scripting\AbstractDirectivePathCompletionProvider.cs (1)
66public sealed override bool ShouldTriggerCompletion(SourceText text, int caretPosition, CompletionTrigger trigger, OptionSet options)
Completion\Providers\Snippets\AbstractSnippetCompletionProvider.cs (3)
36var strippedText = await strippedDocument.GetValueTextAsync(cancellationToken).ConfigureAwait(false); 39var allChangesText = strippedText.WithChanges(snippetChange.TextChanges); 122var originalText = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false);
Completion\Utilities.cs (1)
18public static TextChange Collapse(SourceText newText, ImmutableArray<TextChange> changes)
ConvertTupleToStruct\AbstractConvertTupleToStructCodeRefactoringProvider.cs (1)
187var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false);
Copilot\CopilotChangeAnalysisUtilities.cs (1)
37/// passed to <see cref="SourceText.WithChanges(IEnumerable{TextChange})"/> for the text snapshot corresponding to
Copilot\CopilotUtilities.cs (4)
15/// Returns a new <see cref="SourceText"/> that represents the text after applying the specified changes to 19public static (SourceText newText, ImmutableArray<TextSpan> newSpans) GetNewTextAndChangedSpans( 20SourceText oldText, ImmutableArray<TextChange> changes) 29var newText = oldText.WithChanges(changes);
Copilot\ICopilotChangeAnalysisService.cs (1)
91var oldText = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
Copilot\IProposalAdjusterService.cs (6)
132var oldText = await originalDocument.GetTextAsync(cancellationToken).ConfigureAwait(false); 182SourceText originalText, ImmutableArray<TextChange> changes) 255SourceText originalText, ImmutableArray<TextChange> changes, TextSpan protectedSpan) 299SourceText originalText, 454SourceText originalText, ImmutableArray<TextChange> changes) 458SourceText originalText, ImmutableArray<TextChange> changes, TextSpan protectedSpan)
Diagnostics\Service\DiagnosticAnalyzerService_GetDiagnosticsForSpan.cs (1)
47var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false);
Diagnostics\Service\DocumentAnalysisExecutor.cs (1)
142var sourceText = await textDocument.GetValueTextAsync(cancellationToken).ConfigureAwait(false);
Diagnostics\Service\DocumentAnalysisExecutor_Helpers.cs (1)
179var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false);
DocumentationComments\AbstractDocumentationCommentSnippetService.cs (8)
42private bool IsAtEndOfDocCommentTriviaOnBlankLine(SourceText text, int endPosition) 79var text = document.Text; 103private List<string>? GetDocumentationCommentLines(SyntaxToken token, SourceText text, in DocumentationCommentOptions options, out string? indentText, out int caretOffset, out int spanToReplaceLength) 145private List<string>? GetDocumentationStubLines(SyntaxToken token, SourceText text, in DocumentationCommentOptions options, out int caretOffset, out int spanToReplaceLength, out string? existingCommentText) 189var text = document.Text; 264var text = document.Text; 316var text = document.Text; 356var text = document.Text;
DocumentationComments\DocumentationCommentSnippetHelpers.cs (1)
11public static bool WillBeAtEndOfDocCommentTriviaOnBlankLine(SourceText text, int currentPosition, char documentationCommentCharacter)
EditAndContinue\AbstractEditAndContinueAnalyzer.cs (9)
500private static readonly SourceText s_emptySource = SourceText.From(""); 709void LogRudeEdits(ImmutableArray<RudeEditDiagnostic> diagnostics, SourceText text, string filePath) 732private static async ValueTask<(Document? document, SourceText text)> GetDocumentContentAsync(Project project, DocumentId documentId, CancellationToken cancellationToken) 734SourceText text; 946SourceText newText, 1109SourceText newText, 1484private static bool TryGetTrackedStatement(ImmutableArray<ActiveStatementLineSpan> activeStatementSpans, ActiveStatementId id, SourceText text, MemberBody body, [NotNullWhen(true)] out SyntaxNode? trackedStatement, out int trackedStatementPart) 2702SourceText newText,
EditAndContinue\ActiveStatementsMap.cs (3)
170var oldText = await oldTree.GetTextAsync(cancellationToken).ConfigureAwait(false); 174internal ImmutableArray<UnmappedActiveStatement> GetOldActiveStatements(IEditAndContinueAnalyzer analyzer, SyntaxTree oldSyntaxTree, SourceText oldText, SyntaxNode oldRoot, CancellationToken cancellationToken) 184private ImmutableArray<UnmappedActiveStatement> CalculateOldActiveStatementsAndExceptionRegions(IEditAndContinueAnalyzer analyzer, SyntaxTree oldTree, SourceText oldText, SyntaxNode oldRoot, CancellationToken cancellationToken)
EditAndContinue\CommittedSolution.cs (12)
233var sourceText = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false); 298var matchingSourceText = maybeMatchingSourceText.Value; 325private async ValueTask<(Optional<SourceText?> matchingSourceText, bool? hasDocument)> TryGetMatchingSourceTextAsync(Document document, SourceText sourceText, Document currentDocument, CancellationToken cancellationToken) 365private static async ValueTask<Optional<SourceText?>> TryGetMatchingSourceTextAsync( 367SourceText sourceText, 383var currentDocumentSourceText = await currentDocument.GetValueTextAsync(cancellationToken).ConfigureAwait(false); 398return SourceText.From(text, defaultEncoding, checksumAlgorithm); 440private static bool IsMatchingSourceText(SourceText sourceText, ImmutableArray<byte> requiredChecksum, SourceHashAlgorithm checksumAlgorithm) 443private static Optional<SourceText?> TryGetPdbMatchingSourceTextFromDisk( 454var sourceText = SourceText.From(fileStream, defaultEncoding, checksumAlgorithm);
EditAndContinue\EditSession.cs (6)
192var oldText = await oldDocument.GetValueTextAsync(cancellationToken).ConfigureAwait(false); 193var newText = await newDocument.GetValueTextAsync(cancellationToken).ConfigureAwait(false); 207private static TextSpan GetFirstLineDifferenceSpan(SourceText oldText, SourceText newText) 328var oldSource = await oldDocument.GetValueTextAsync(cancellationToken).ConfigureAwait(false); 329var newSource = await newDocument.GetValueTextAsync(cancellationToken).ConfigureAwait(false);
EditAndContinue\PdbMatchingSourceTextProvider.cs (1)
154var text = await state.GetTextAsync(cancellationToken).ConfigureAwait(false);
EditAndContinue\TraceLog.cs (1)
115var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false);
EmbeddedLanguages\DateAndTime\DateAndTimeEmbeddedCompletionProvider.cs (2)
36public override bool ShouldTriggerCompletion(SourceText text, int caretPosition, CompletionTrigger trigger) 95var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false);
EmbeddedLanguages\DateAndTime\EmbeddedCompletionContext.cs (1)
37SourceText text,
EmbeddedLanguages\RegularExpressions\LanguageServices\RegexEmbeddedCompletionProvider.cs (1)
43public override bool ShouldTriggerCompletion(SourceText text, int caretPosition, CompletionTrigger trigger)
ExternalAccess\Pythia\Api\PythiaCompletionProviderBase.cs (2)
72public sealed override bool IsInsertionTrigger(SourceText text, int insertedCharacterPosition, CompletionOptions options) 75protected virtual bool IsInsertionTriggerWorker(SourceText text, int insertedCharacterPosition)
ExternalAccess\UnitTesting\SolutionCrawler\AbstractUnitTestingDocumentDifferenceService.cs (2)
28if (!oldDocument.TryGetText(out var oldText) || 29!newDocument.TryGetText(out var newText))
ExternalAccess\VSTypeScript\Api\VSTypeScriptCompletionProvider.cs (3)
15public sealed override bool ShouldTriggerCompletion(SourceText text, int caretPosition, CompletionTrigger trigger, OptionSet options) 21internal sealed override bool ShouldTriggerCompletion(LanguageServices languageServices, SourceText text, int caretPosition, CompletionTrigger trigger, CompletionOptions options, OptionSet passThroughOptions) 24protected abstract bool ShouldTriggerCompletionImpl(SourceText text, int caretPosition, CompletionTrigger trigger, bool triggerOnTypingLetters);
ExternalAccess\VSTypeScript\Api\VSTypeScriptDiagnosticData.cs (2)
38public LinePositionSpan GetLinePositionSpan(SourceText sourceText, bool useMapped) 45public LinePositionSpan GetLinePositionSpan(SourceText sourceText)
ExternalAccess\VSTypeScript\VSTypeScriptClassificationService.cs (2)
26public void AddLexicalClassifications(SourceText text, TextSpan textSpan, SegmentedList<ClassifiedSpan> result, CancellationToken cancellationToken) 40public ClassifiedSpan AdjustStaleClassification(SourceText text, ClassifiedSpan classifiedSpan)
ExternalAccess\VSTypeScript\VSTypeScriptTaskListService.cs (1)
36var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false);
FullyQualify\AbstractFullyQualifyCodeFixProvider.cs (2)
47var sourceText = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false); 48var newText = sourceText.WithChanges(d.TextChanges);
GenerateComparisonOperators\GenerateComparisonOperatorsCodeRefactoringProvider.cs (1)
47var sourceText = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false);
GenerateConstructors\AbstractGenerateConstructorsCodeRefactoringProvider.cs (1)
197var sourceText = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false);
GenerateEqualsAndGetHashCodeFromMembers\GenerateEqualsAndGetHashCodeFromMembersCodeRefactoringProvider.cs (1)
75var sourceText = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false);
GenerateOverrides\GenerateOverridesCodeRefactoringProvider.cs (1)
35var sourceText = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false);
ImplementInterface\ImplementInterfaceCodeRefactoringProvider.cs (1)
27var sourceText = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false);
InheritanceMargin\AbstractInheritanceMarginService_Helpers.cs (2)
92var sourceText = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false); 219var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false);
InvertIf\AbstractInvertIfCodeRefactoringProvider.cs (5)
83SourceText sourceText, 169var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); 182var newText = text.WithChanges( 404var sourceText = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false); 534SourceText text,
MetadataAsSource\DecompilationMetadataAsSourceFileProvider.cs (5)
153var text = await temporaryDocument.GetValueTextAsync(cancellationToken).ConfigureAwait(false); 353var assemblyInfoSourceText = SourceText.From(assemblyInfoString, MetadataAsSourceGeneratedFileInfo.Encoding, MetadataAsSourceGeneratedFileInfo.ChecksumAlgorithm); 363var emptySourceText = SourceText.From(string.Empty, MetadataAsSourceGeneratedFileInfo.Encoding, MetadataAsSourceGeneratedFileInfo.ChecksumAlgorithm);
MoveToNamespace\AbstractMoveToNamespaceService.cs (1)
279var formattedText = await formattedDocument.GetValueTextAsync(cancellationToken).ConfigureAwait(false);
NavigateTo\NavigateToUtilities.cs (1)
29public static TextSpan GetBoundedSpan(INavigableItem item, SourceText sourceText)
Navigation\IDefinitionLocationService.cs (1)
61var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
Navigation\INavigableItem.cs (3)
72/// Get the <see cref="SourceText"/> of the <see cref="CodeAnalysis.Document"/> within 77internal async ValueTask<SourceText> GetTextAsync(Solution solution, CancellationToken cancellationToken) 83internal SourceText? TryGetTextSynchronously(Solution solution, CancellationToken cancellationToken)
PdbSourceDocument\PdbSourceDocumentLoaderService.cs (2)
191var sourceText = SourceText.From(stream, encoding, sourceDocument.ChecksumAlgorithm, throwIfBinaryDetected: true);
QuickInfo\IndentationHelper.cs (2)
28SourceText text, 84SourceText text,
QuickInfo\Presentation\QuickInfoContentBuilder.cs (1)
136var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false);
RawStringLiteral\IRawStringLiteralOnAutoInsertService.cs (1)
25TextChange? GetTextChangeForQuote(Document document, SourceText text, int caretPosition, CancellationToken cancellationToken);
Rename\SymbolicRenameInfo.cs (1)
254var sourceText = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false);
ReplaceDocCommentTextWithTag\AbstractReplaceDocCommentTextWithTagCodeRefactoringProvider.cs (7)
45var sourceText = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false); 118var sourceText = semanticModel.SyntaxTree.GetText(cancellationToken); 160var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false); 161var newText = text.Replace(span, replacement); 166private static TextSpan ExpandSpan(SourceText sourceText, TextSpan span, bool fullyQualifiedName) 191SourceText sourceText, int endExclusive, bool fullyQualifiedName) 212SourceText sourceText, int startInclusive, bool fullyQualifiedName)
SemanticSearch\SemanticSearchDefinitionItemFactory.cs (1)
65var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
SemanticSearch\SemanticSearchWorkspace.cs (2)
43var newText = await queryDocument.GetTextAsync(cancellationToken).ConfigureAwait(false); 50protected virtual void ApplyQueryDocumentTextChanged(SourceText newText)
Snippets\RoslynLSPSnippetConverter.cs (1)
111var documentText = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false);
Snippets\SnippetFunctionService.cs (1)
45var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false);
Snippets\SnippetProviders\AbstractConsoleSnippetProvider.cs (1)
63protected sealed override int GetTargetCaretPosition(TExpressionSyntax caretTarget, SourceText sourceText)
Snippets\SnippetProviders\AbstractInlineStatementSnippetProvider.cs (2)
105var sourceText = parentNode.SyntaxTree.GetText(cancellationToken); 142var sourceText = parentNode.SyntaxTree.GetText(cancellationToken);
Snippets\SnippetProviders\AbstractSnippetProvider.cs (3)
46protected abstract int GetTargetCaretPosition(TSnippetSyntax caretTarget, SourceText sourceText); 112var sourceText = await annotatedReformattedDocument.GetValueTextAsync(cancellationToken).ConfigureAwait(false); 193var originalText = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false);
Snippets\SnippetUtilities.cs (1)
13public static bool TryGetWordOnLeft(int position, SourceText currentText, ISyntaxFactsService syntaxFactsService, [NotNullWhen(true)] out TextSpan? wordSpan)
SolutionCrawler\AbstractDocumentDifferenceService.cs (2)
31if (!oldDocument.TryGetText(out var oldText) || 32!newDocument.TryGetText(out var newText))
src\roslyn\src\Analyzers\Core\Analyzers\Formatting\AbstractFormattingAnalyzer.cs (3)
49var oldText = tree.GetText(cancellationToken); 72if (oldText.GetSubText(new TextSpan(change.Span.Start + offset, change.NewText.Length)).ContentEquals(SourceText.From(change.NewText))) 81if (oldText.GetSubText(new TextSpan(change.Span.Start, change.NewText.Length)).ContentEquals(SourceText.From(change.NewText)))
src\roslyn\src\Analyzers\Core\CodeFixes\ConflictMarkerResolution\AbstractConflictMarkerCodeFixProvider.cs (15)
75var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false); 85SyntaxNode root, SourceText text, int position, 146SourceText text, int position, 210var text = startLine.Text!; 228var text = startLine.Text!; 246var text = currentLine.Text!; 316Action<SourceText, ArrayBuilder<TextChange>, int, int, int, int> addEdits, 319var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false); 324var finalText = text.WithChanges(edits); 329SourceText text, ArrayBuilder<TextChange> edits, 342SourceText text, ArrayBuilder<TextChange> edits, 355SourceText text, ArrayBuilder<TextChange> edits, 389private static int GetEndIncludingLineBreak(SourceText text, int position) 405var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false); 444var finalText = text.WithChanges(edits);
src\roslyn\src\Analyzers\Core\CodeFixes\Formatting\FormattingCodeFixProvider.cs (1)
71var text = await context.Document.GetValueTextAsync(cancellationToken).ConfigureAwait(false);
src\roslyn\src\Analyzers\Core\CodeFixes\UseConditionalExpression\AbstractUseConditionalExpressionCodeFixProvider.cs (1)
158var sourceText = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false);
src\roslyn\src\Compilers\Core\Portable\Text\TextUtilities.cs (3)
14internal static int GetLengthOfLineBreak(SourceText text, int index) 30private static int GetLengthOfLineBreakSlow(SourceText text, int index, char c) 52public static void GetStartAndLengthOfLineBreakEndingAt(SourceText text, int index, out int startLinebreak, out int lengthLinebreak)
Structure\Syntax\AbstractBlockStructureProvider.cs (1)
52var text = context.SyntaxTree.GetText(context.CancellationToken);
TaskList\AbstractTaskListService.cs (1)
126var text = document.Text;
ValueTracking\SerializableValueTrackedItem.cs (1)
54var sourceText = await syntaxTree.GetTextAsync(cancellationToken).ConfigureAwait(false);
ValueTracking\ValueTrackedItem.cs (4)
19public SourceText SourceText { get; } 24SourceText sourceText, 40var subText = SourceText.GetSubText(Span); 50var sourceText = await syntaxTree.GetTextAsync(cancellationToken).ConfigureAwait(false);
Wrapping\AbstractCodeActionComputer.cs (3)
51protected readonly SourceText OriginalSourceText; 67SourceText originalSourceText, 90var newSourceText = OriginalSourceText.WithChanges(
Wrapping\AbstractWrapper.cs (1)
46var sourceText = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false);
Wrapping\BinaryExpression\AbstractBinaryExpressionWrapper.cs (1)
90var sourceText = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false);
Wrapping\BinaryExpression\BinaryExpressionCodeActionComputer.cs (1)
49SourceText originalSourceText,
Wrapping\ChainedExpression\AbstractChainedExpressionWrapper.cs (1)
111var sourceText = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false);
Wrapping\ChainedExpression\ChainedExpressionCodeActionComputer.cs (1)
70SourceText originalSourceText,
Wrapping\SeparatedSyntaxList\AbstractSeparatedSyntaxListWrapper.cs (1)
84var sourceText = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false);
Wrapping\SeparatedSyntaxList\SeparatedSyntaxListCodeActionComputer.cs (1)
76SourceText sourceText,
Microsoft.CodeAnalysis.Razor.Compiler (32)
CSharp\DefaultUtf8WriteLiteralFeature.cs (2)
183var probeText = SourceText.From(sb.ToString());
Language\CodeGeneration\CodeWriter.cs (2)
306public SourceText GetText() 309return SourceText.From(reader, Length, Encoding.UTF8);
Language\DefaultRazorCSharpLoweringPhase.cs (1)
50var text = context.CodeWriter.GetText();
Language\Legacy\SeekableTextReader.cs (3)
19public SeekableTextReader(string source, string filePath) : this(SourceText.From(source, checksumAlgorithm: SourceHashAlgorithm.Sha256), filePath) 27private SeekableTextReader(SourceText sourceText, string filePath) 52public SourceText SourceText { get; }
Language\RazorCSharpDocument.cs (2)
14public SourceText Text { get; } 22SourceText text,
Language\RazorHtmlDocument.cs (2)
10public SourceText Text { get; } 12public RazorHtmlDocument(SourceText text)
Language\RazorHtmlWriter.cs (2)
51var text = codeWriter.GetText(); 309var text = _source.Text;
Language\RazorSourceDocument.cs (15)
23public SourceText Text { get; } 66var sourceText = SourceText.From(stream, checksumAlgorithm: SourceHashAlgorithm.Sha256); 90var sourceText = SourceText.From(stream, encoding, checksumAlgorithm: SourceHashAlgorithm.Sha256); 118var sourceText = SourceText.From(stream, encoding, checksumAlgorithm: SourceHashAlgorithm.Sha256); 153var sourceText = SourceText.From(stream, checksumAlgorithm: SourceHashAlgorithm.Sha256); 218var sourceText = SourceText.From(content, encoding, checksumAlgorithm: SourceHashAlgorithm.Sha256); 246var sourceText = SourceText.From(content, encoding, checksumAlgorithm: SourceHashAlgorithm.Sha256); 256public static RazorSourceDocument Create(SourceText text, RazorSourceDocumentProperties properties) 271private RazorSourceDocument(SourceText sourceText, RazorSourceDocumentProperties properties)
Language\SpanComputer.cs (1)
110var text = source.Text;
SourceGenerators\SourceGeneratorProjectItem.cs (1)
32var text = AdditionalText.GetText();
SourceGenerators\SourceGeneratorText.cs (1)
8public readonly record struct SourceGeneratorText(SourceText Text)
Microsoft.CodeAnalysis.Rebuild (9)
CompilationFactory.cs (1)
43public abstract SyntaxTree CreateSyntaxTree(string filePath, SourceText sourceText);
CompilationOptionsReader.cs (4)
241var embeddedText = SourceText.From(stream, encoding: sourceTextInfo.SourceTextEncoding, checksumAlgorithm: sourceTextInfo.HashAlgorithm, canBeEmbedded: true); 294Func<string, SourceText, SyntaxTree> createSyntaxTreeFunc) 306SourceText sourceText;
CSharpCompilationFactory.cs (1)
45public override SyntaxTree CreateSyntaxTree(string filePath, SourceText sourceText)
IRebuildArtifactResolver.cs (1)
11SourceText ResolveSourceText(SourceTextInfo sourceTextInfo);
Records.cs (1)
16SourceText SourceText,
VisualBasicCompilationFactory.cs (1)
45public override SyntaxTree CreateSyntaxTree(string filePath, SourceText sourceText)
Microsoft.CodeAnalysis.ResxSourceGenerator (77)
AbstractResxGenerator.cs (9)
252var errorText = SourceText.From(text, Encoding.UTF8, SourceHashAlgorithm.Sha256); 366OutputText = SourceText.From("", Encoding.UTF8); 373public SourceText OutputText { get; private set; } 392OutputText = SourceText.From(result, Encoding.UTF8, SourceHashAlgorithm.Sha256); 436var text = ResourceInformation.ResourceFile.GetText(cancellationToken); 735OutputText = SourceText.From(result, Encoding.UTF8, SourceHashAlgorithm.Sha256); 927private readonly SourceText _text; 930public SourceTextReader(SourceText text)
src\roslyn\src\Compilers\Core\Portable\EncodedStringText.cs (11)
72/// Initializes an instance of <see cref="SourceText"/> from the provided stream. This version differs 73/// from <see cref="SourceText.From(Stream, Encoding, SourceHashAlgorithm, bool)"/> in two ways: 91internal static SourceText Create(Stream stream, 103internal static SourceText Create(Stream stream, 136/// Try to create a <see cref="SourceText"/> from the given stream using the given encoding. 143/// <returns>The <see cref="SourceText"/> decoded from the stream.</returns> 146private static SourceText Decode( 165return SourceText.From(bytes.Array, 175return SourceText.From(data, encoding, checksumAlgorithm, throwIfBinaryDetected, canBeEmbedded); 249internal static SourceText Create(Stream stream, Lazy<Encoding> getEncoding, Encoding defaultEncoding, SourceHashAlgorithm checksumAlgorithm, bool canBeEmbedded) 252internal static SourceText Decode(Stream data, Encoding encoding, SourceHashAlgorithm checksumAlgorithm, bool throwIfBinaryDetected, bool canBeEmbedded)
src\roslyn\src\Compilers\Core\Portable\Syntax\SyntaxTreeExtensions.cs (1)
27internal static void VerifySource(SourceText text, SyntaxNode root, IEnumerable<TextChangeRange>? changes = null)
src\roslyn\src\RoslynAnalyzers\Utilities\Compiler\Extensions\AdditionalTextExtensions.cs (3)
15private static readonly SourceText s_emptySourceText = SourceText.From("", s_utf8bom, SourceHashAlgorithm.Sha256); 17public static SourceText GetTextOrEmpty(this AdditionalText text, CancellationToken cancellationToken)
src\roslyn\src\RoslynAnalyzers\Utilities\Compiler\Extensions\SourceTextExtensions.cs (2)
13/// Class that contains extensions to <see cref="SourceText"/>. 25public static T Parse<T>(this SourceText text, Func<StreamReader, T> parser)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EditorConfig\Parsing\EditorConfigParser.cs (2)
40return Parse<TEditorConfigFile, TResult, TAccumulator>(SourceText.From(text), pathToFile, accumulator); 43public static TEditorConfigFile Parse<TEditorConfigFile, TEditorConfigOption, TAccumulator>(SourceText text, string? pathToFile, TAccumulator accumulator)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EditorConfig\Parsing\NamingStyles\EditorConfigNamingStylesParser.cs (5)
18=> Parse(SourceText.From(editorConfigText), pathToEditorConfigFile); 21/// Parses a <see cref="SourceText"/> and returns all discovered naming style options and their locations 23/// <param name="editorConfigText">The <see cref="SourceText"/> contents of the editorconfig file.</param> 25/// <returns>A type that represents all discovered naming style options in the given <see cref="SourceText"/>.</returns> 26public static EditorConfigNamingStyles Parse(SourceText editorConfigText, string? pathToEditorConfigFile = null)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EmbeddedLanguages\VirtualChars\AbstractVirtualCharService.cs (1)
193protected static int ConvertTextAtIndexToVirtualChar(SourceText tokenText, int index, ImmutableSegmentedList<VirtualCharGreen>.Builder result)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EmbeddedLanguages\VirtualChars\AbstractVirtualCharService.ITextInfo.cs (4)
12/// Abstraction to allow generic algorithms to run over a string or <see cref="SourceText"/> without any 21private struct SourceTextTextInfo : ITextInfo<SourceText> 23public readonly char Get(SourceText text, int index) => text[index]; 24public readonly int Length(SourceText text) => text.Length;
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EmbeddedLanguages\VirtualChars\IVirtualCharService.cs (1)
33/// in the original <see cref="SourceText"/> that the language created that char from.
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EmbeddedLanguages\VirtualChars\VirtualChar.cs (2)
39/// The width of characters in the original <see cref="SourceText"/> that represent this <see cref="VirtualCharGreen"/>. 68/// value of <c>9</c> as well as what <see cref="TextSpan"/> in the original <see cref="SourceText"/> they occupied.
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EmbeddedLanguages\VirtualChars\VirtualCharSequenceSourceText.cs (1)
12/// Trivial implementation of a <see cref="SourceText"/> that directly maps over a <see
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EmbeddedLanguages\VirtualChars\VirtualCharUtilities.cs (2)
22/// cref="SourceText"/> (which only cares about their <see cref="char"/> value), as well as the way to then map 23/// positions/spans within that <see cref="SourceText"/> to actual full virtual char spans in the original
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\SourceTextExtensions_SharedWithCodeStyle.cs (5)
16public static string GetLeadingWhitespaceOfLineAtPosition(this SourceText text, int position) 32this SourceText text, TextSpan span, Func<int, CancellationToken, bool> isPositionHidden, CancellationToken cancellationToken) 44this SourceText text, TextSpan span, Func<int, CancellationToken, bool> isPositionHidden, 82public static bool AreOnSameLine(this SourceText text, SyntaxToken token1, SyntaxToken token2) 87public static bool AreOnSameLine(this SourceText text, int pos1, int pos2)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\SyntaxTreeExtensions.cs (2)
27var text = tree.GetText(cancellationToken); 105var text = tree.GetText(cancellationToken);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\TextLineExtensions.cs (3)
14var text = line.Text!; 46var text = line.Text; 67var text = line.Text;
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Engine\TreeData.cs (1)
20if (root.SyntaxTree == null || !root.SyntaxTree.TryGetText(out var text))
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Engine\TreeData.Debug.cs (1)
11private sealed class Debug(SyntaxNode root, SourceText text) : NodeAndText(root, text)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Engine\TreeData.NodeAndText.cs (2)
14private readonly SourceText _text; 16public NodeAndText(SyntaxNode root, SourceText text)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Engine\TreeData.StructuredTrivia.cs (2)
26var text = GetText(); 47private SourceText? GetText()
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Indentation\AbstractIndentation.cs (1)
29TSyntaxRoot root, SourceText text, TextLine lineToBeIndented, IndentationOptions options, AbstractFormattingRule baseFormattingRule);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Indentation\AbstractIndentation.Indenter.cs (3)
35public readonly SourceText Text; 43SourceText text, 172var updatedSourceText = Text.WithChanges(changes);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Services\RefactoringHelpers\AbstractRefactoringHelpers.cs (6)
25public abstract bool IsBetweenTypeMembers(SourceText sourceText, SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? typeDeclaration); 42private static TextSpan GetTrimmedTextSpan(SourceText sourceText, TextSpan span) 60SourceText sourceText, SyntaxNode root, TextSpan selectionRaw, bool allowEmptyNodes, int maxCount, ref TemporaryArray<TSyntaxNode> result, CancellationToken cancellationToken) where TSyntaxNode : SyntaxNode 179SourceText sourceText, SyntaxNode root, int location) 251SourceText sourceText, SyntaxToken tokenOnLocation, int location) 533SourceText sourceText,
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Services\RefactoringHelpers\IRefactoringHelpers.cs (2)
23bool IsBetweenTypeMembers(SourceText sourceText, SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? typeDeclaration); 55SourceText sourceText, SyntaxNode root, TextSpan selection, bool allowEmptyNodes, int maxCount, ref TemporaryArray<TSyntaxNode> result, CancellationToken cancellationToken) where TSyntaxNode : SyntaxNode;
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Services\SelectedMembers\AbstractSelectedMembers.cs (3)
45var text = await tree.GetTextAsync(cancellationToken).ConfigureAwait(false); 77SyntaxNode root, SourceText text, TextSpan textSpan, 164SourceText text, SyntaxNode root, SyntaxNode member, int position)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\CommonFormattingHelpers.cs (1)
156public static string GetText(this SourceText text, SyntaxToken token1, SyntaxToken token2)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\InterceptsLocationUtilities.cs (1)
16/// (See <see cref="SourceText.GetContentHash()"/>)</param>
Microsoft.CodeAnalysis.Scripting (12)
Hosting\CommandLine\CommandLineRunner.cs (5)
108SourceText? code = null; 200private int RunScript(ScriptOptions? options, SourceText? code, ErrorLogger? errorLogger, CancellationToken cancellationToken) 231var script = Script.CreateInitialScript<object>(_scriptCompiler, SourceText.From(initialScriptCodeOpt), options, globals.GetType(), assemblyLoaderOpt: null); 258var tree = _scriptCompiler.ParseSubmission(SourceText.From(input.ToString()), options.ParseOptions, cancellationToken); 283newScript = Script.CreateInitialScript<object>(_scriptCompiler, SourceText.From(code ?? string.Empty), options, globals.GetType(), assemblyLoaderOpt: null);
Script.cs (6)
39internal Script(ScriptCompiler compiler, ScriptBuilder builder, SourceText sourceText, ScriptOptions options, Type globalsTypeOpt, Script previousOpt) 54internal static Script<T> CreateInitialScript<T>(ScriptCompiler compiler, SourceText sourceText, ScriptOptions optionsOpt, Type globalsTypeOpt, InteractiveAssemblyLoader assemblyLoaderOpt) 79internal SourceText SourceText { get; } 117return new Script<TResult>(Compiler, Builder, SourceText.From(code ?? "", options.FileEncoding), options, GlobalsType, this); 130return new Script<TResult>(Compiler, Builder, SourceText.From(code, options.FileEncoding), options, GlobalsType, this); 344internal Script(ScriptCompiler compiler, ScriptBuilder builder, SourceText sourceText, ScriptOptions options, Type globalsTypeOpt, Script previousOpt)
ScriptCompiler.cs (1)
19public abstract SyntaxTree ParseSubmission(SourceText text, ParseOptions parseOptions, CancellationToken cancellationToken);
Microsoft.CodeAnalysis.TestAnalyzerReference (6)
HelloWorldGenerator.cs (3)
27context.AddSource(GeneratedEnglishClassName, SourceText.From($$""" 38context.AddSource(GeneratedSpanishClassName, SourceText.From($$""" 48context.AddSource(GeneratedEnglishClassName + "WithTime", SourceText.From($$"""
NonSourceFileRefactoring.cs (3)
27var text = await document.GetTextAsync(ct).ConfigureAwait(false); 28var newText = SourceText.From(text.ToString() + Environment.NewLine + "# Refactored");
Microsoft.CodeAnalysis.VisualBasic (43)
Binding\Binder_Expressions.vb (1)
1102Dim tree = VisualBasicSyntaxTree.ParseText(SourceText.From(codeToParse))
CommandLine\CommandLineDiagnosticFormatter.vb (2)
34Dim text As SourceText = Nothing 130Private Function GetDiagnosticSpanAndFileText(diagnostic As Diagnostic, <Out> ByRef text As SourceText) As TextSpan?
Compilation\VisualBasicCompilation.vb (1)
269SourceText.From(text, encoding:=Nothing, SourceHashAlgorithms.Default),
OptionsValidator.vb (1)
30Dim tree = VisualBasicSyntaxTree.ParseText(SourceText.From(importFileText), VisualBasicParseOptions.Default, "")
Parser\Parser.vb (1)
52Friend Sub New(text As SourceText, options As VisualBasicParseOptions, Optional cancellationToken As CancellationToken = Nothing)
Scanner\Blender.vb (1)
184Friend Sub New(newText As SourceText,
Scanner\Scanner.vb (1)
106Friend Sub New(textToScan As SourceText, options As VisualBasicParseOptions, Optional isScanningForExpressionCompiler As Boolean = False)
Scanner\ScannerBuffer.vb (1)
71Private ReadOnly _buffer As SourceText
Symbols\EmbeddedSymbols\EmbeddedSymbolManager.vb (1)
23Return VisualBasicSyntaxTree.ParseText(SourceText.From(text, Encoding.UTF8, SourceHashAlgorithms.Default))
Symbols\Source\SynthesizedMyGroupCollectionPropertyAccessorSymbol.vb (1)
74Dim tree = VisualBasicSyntaxTree.ParseText(SourceText.From(codeToParse, Encoding.UTF8, SourceHashAlgorithms.Default))
Syntax\SyntaxNodeFactories.vb (6)
50Return ParseSyntaxTree(SourceText.From(text, encoding, SourceHashAlgorithm.Sha1), options, path, cancellationToken) 57text As SourceText, 79Return ParseSyntaxTree(SourceText.From(text, encoding), options, path, diagnosticOptions, cancellationToken) 86text As SourceText, 287Friend Shared Function MakeSourceText(text As String, offset As Integer) As SourceText 288Return SourceText.From(text, Encoding.UTF8).GetSubText(offset)
Syntax\VisualBasicLineDirectiveMap.vb (3)
29sourceText As SourceText, 147Public Overrides Function GetLineVisibility(sourceText As SourceText, position As Integer) As LineVisibility 209Friend Overrides Function TranslateSpanAndVisibility(sourceText As SourceText, treeFilePath As String, span As TextSpan, ByRef isHiddenPosition As Boolean) As FileLinePositionSpan
Syntax\VisualBasicSyntaxTree.DebuggerSyntaxTree.vb (1)
16Friend Sub New(root As VisualBasicSyntaxNode, text As SourceText, options As VisualBasicParseOptions)
Syntax\VisualBasicSyntaxTree.DummySyntaxTree.vb (5)
28Public Overrides Function GetText(Optional cancellationToken As CancellationToken = Nothing) As SourceText 29Return SourceText.From(String.Empty, Me.Encoding, ChecksumAlgorithm) 32Public Overrides Function TryGetText(ByRef text As SourceText) As Boolean 33text = SourceText.From(String.Empty, Me.Encoding, ChecksumAlgorithm) 71Public Overrides Function WithChangedText(newText As SourceText) As SyntaxTree
Syntax\VisualBasicSyntaxTree.LazySyntaxTree.vb (4)
17Private ReadOnly _text As SourceText 26Friend Sub New(text As SourceText, 51Public Overrides Function GetText(Optional cancellationToken As CancellationToken = Nothing) As SourceText 55Public Overrides Function TryGetText(ByRef text As SourceText) As Boolean
Syntax\VisualBasicSyntaxTree.ParsedSyntaxTree.vb (4)
31Private _lazyText As SourceText 36Friend Sub New(textOpt As SourceText, 75Public Overrides Function GetText(Optional cancellationToken As CancellationToken = Nothing) As SourceText 84Public Overrides Function TryGetText(ByRef text As SourceText) As Boolean
Syntax\VisualBasicSyntaxTree.vb (9)
101Public Overrides Function WithChangedText(newText As SourceText) As SyntaxTree 103Dim oldText As SourceText = Nothing 115Private Function WithChanges(newText As SourceText, changes As TextChangeRange()) As SyntaxTree 203Friend Shared Function CreateForDebugger(root As VisualBasicSyntaxNode, text As SourceText, options As VisualBasicParseOptions) As SyntaxTree 231Friend Shared Function ParseTextLazy(text As SourceText, 255SourceText.From(text, encoding), 266Public Shared Function ParseText(text As SourceText, 281text As SourceText, 626Public Shared Function ParseText(text As SourceText,
Microsoft.CodeAnalysis.VisualBasic.CodeStyle (1)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Services\RefactoringHelpers\VisualBasicRefactoringHelpers.vb (1)
23Public Overrides Function IsBetweenTypeMembers(sourceText As SourceText, root As SyntaxNode, position As Integer, ByRef typeDeclaration As SyntaxNode) As Boolean
Microsoft.CodeAnalysis.VisualBasic.CodeStyle.Fixes (1)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\Indentation\VisualBasicIndentationService.Indenter.vb (1)
42text As SourceText,
Microsoft.CodeAnalysis.VisualBasic.Features (31)
AddImport\VisualBasicAddMissingImportsFeatureService.vb (1)
25Protected Overrides Function GetFormatRules(text As SourceText) As ImmutableArray(Of AbstractFormattingRule)
BraceCompletion\BracketBraceCompletionService.vb (1)
41Protected Overrides Function IsValidOpenBraceTokenAtPosition(text As SourceText, token As SyntaxToken, position As Integer) As Boolean
BraceCompletion\InterpolatedStringBraceCompletionService.vb (1)
26Protected Overrides Function IsValidOpenBraceTokenAtPosition(text As SourceText, token As SyntaxToken, position As Integer) As Boolean
BraceCompletion\InterpolationBraceCompletionService.vb (1)
26Protected Overrides Function IsValidOpenBraceTokenAtPosition(text As SourceText, token As SyntaxToken, position As Integer) As Boolean
BraceCompletion\LessAndGreaterThanCompletionService.vb (1)
35Protected Overrides Function IsValidOpenBraceTokenAtPosition(text As SourceText, token As SyntaxToken, position As Integer) As Boolean
BraceCompletion\ParenthesisBraceCompletionService.vb (1)
36Protected Overrides Function IsValidOpenBraceTokenAtPosition(text As SourceText, token As SyntaxToken, position As Integer) As Boolean
Completion\CompletionProviders\CompletionUtilities.vb (5)
23Public Function GetCompletionItemSpan(text As SourceText, position As Integer) As TextSpan 46Public Function IsDefaultTriggerCharacter(text As SourceText, characterPosition As Integer, options As CompletionOptions) As Boolean 55Public Function IsDefaultTriggerCharacterOrParen(text As SourceText, characterPosition As Integer, options As CompletionOptions) As Boolean 64Public Function IsTriggerAfterSpaceOrStartOfWordCharacter(text As SourceText, characterPosition As Integer, options As CompletionOptions) As Boolean 71Private Function IsStartingNewWord(text As SourceText, characterPosition As Integer, options As CompletionOptions) As Boolean
Completion\CompletionProviders\CrefCompletionProvider.vb (1)
39Public Overrides Function IsInsertionTrigger(text As SourceText, characterPosition As Integer, options As CompletionOptions) As Boolean
Completion\CompletionProviders\EnumCompletionProvider.vb (1)
80Public Overrides Function IsInsertionTrigger(text As SourceText, characterPosition As Integer, options As CompletionOptions) As Boolean
Completion\CompletionProviders\HandlesClauseCompletionProvider.vb (1)
68Public Overrides Function IsInsertionTrigger(text As SourceText, characterPosition As Integer, options As CompletionOptions) As Boolean
Completion\CompletionProviders\ImplementsClauseCompletionProvider.vb (1)
29Public Overrides Function IsInsertionTrigger(text As SourceText, characterPosition As Integer, options As CompletionOptions) As Boolean
Completion\CompletionProviders\ImportCompletionProvider\ExtensionMethodImportCompletionProvider.vb (1)
31Public Overrides Function IsInsertionTrigger(text As SourceText, characterPosition As Integer, options As CompletionOptions) As Boolean
Completion\CompletionProviders\ImportCompletionProvider\TypeImportCompletionProvider.vb (1)
33Public Overrides Function IsInsertionTrigger(text As SourceText, characterPosition As Integer, options As CompletionOptions) As Boolean
Completion\CompletionProviders\InternalsVisibleToCompletionProvider.vb (1)
55Protected Overrides Function ShouldTriggerAfterQuotes(text As SourceText, insertedCharacterPosition As Integer) As Boolean
Completion\CompletionProviders\KeywordCompletionProvider.vb (1)
175Public Overrides Function IsInsertionTrigger(text As SourceText, characterPosition As Integer, options As CompletionOptions) As Boolean
Completion\CompletionProviders\NamedParameterCompletionProvider.vb (1)
38Public Overrides Function IsInsertionTrigger(text As SourceText, characterPosition As Integer, options As CompletionOptions) As Boolean
Completion\CompletionProviders\ObjectCreationCompletionProvider.vb (1)
33Public Overrides Function IsInsertionTrigger(text As SourceText, characterPosition As Integer, options As CompletionOptions) As Boolean
Completion\CompletionProviders\ObjectInitializerCompletionProvider.vb (1)
94Public Overrides Function IsInsertionTrigger(text As SourceText, characterPosition As Integer, options As CompletionOptions) As Boolean
Completion\CompletionProviders\OverrideCompletionProvider.vb (2)
64Public Overrides Function IsInsertionTrigger(text As SourceText, characterPosition As Integer, options As CompletionOptions) As Boolean 71text As SourceText, startLine As Integer,
Completion\CompletionProviders\PartialTypeCompletionProvider.vb (1)
50Public Overrides Function IsInsertionTrigger(text As SourceText, characterPosition As Integer, options As CompletionOptions) As Boolean
Completion\CompletionProviders\PreprocessorCompletionProvider.vb (1)
30Public Overrides Function IsInsertionTrigger(text As SourceText, characterPosition As Integer, options As CompletionOptions) As Boolean
Completion\CompletionProviders\SymbolCompletionProvider.vb (1)
82Public Overrides Function IsInsertionTrigger(text As SourceText, characterPosition As Integer, options As CompletionOptions) As Boolean
Completion\CompletionProviders\XmlDocCommentCompletionProvider.vb (1)
48Public Overrides Function IsInsertionTrigger(text As SourceText, characterPosition As Integer, options As CompletionOptions) As Boolean
Completion\VisualBasicCompletionService.vb (1)
123Public Overrides Function GetDefaultCompletionListSpan(text As SourceText, caretPosition As Integer) As TextSpan
InvertIf\VisualBasicInvertIfCodeRefactoringProvider.MultiLine.vb (1)
42sourceText As SourceText,
InvertIf\VisualBasicInvertIfCodeRefactoringProvider.SingleLine.vb (1)
44sourceText As SourceText,
Microsoft.CodeAnalysis.VisualBasic.Scripting (2)
VisualBasicScript.vb (1)
26Return Script.CreateInitialScript(Of T)(VisualBasicScriptCompiler.Instance, SourceText.From(If(code, String.Empty)), options, globalsType, assemblyLoader)
VisualBasicScriptCompiler.vb (1)
40Public Overrides Function ParseSubmission(text As SourceText, parseOptions As ParseOptions, cancellationToken As CancellationToken) As SyntaxTree
Microsoft.CodeAnalysis.VisualBasic.Workspaces (15)
Classification\ClassificationHelpers.vb (2)
321Friend Sub AddLexicalClassifications(text As SourceText, textSpan As TextSpan, result As SegmentedList(Of ClassifiedSpan), cancellationToken As CancellationToken) 328Friend Function AdjustStaleClassification(text As SourceText, classifiedSpan As ClassifiedSpan) As ClassifiedSpan
Classification\SyntaxClassification\VisualBasicSyntaxClassificationService.vb (2)
35Public Overrides Sub AddLexicalClassifications(text As SourceText, textSpan As TextSpan, result As SegmentedList(Of ClassifiedSpan), cancellationToken As CancellationToken) 45Public Overrides Function FixClassification(text As SourceText, classifiedSpan As ClassifiedSpan) As ClassifiedSpan
Classification\VisualBasicClassificationService.vb (2)
23Public Overrides Sub AddLexicalClassifications(text As SourceText, textSpan As TextSpan, result As SegmentedList(Of ClassifiedSpan), cancellationToken As CancellationToken) 27Public Overrides Function AdjustStaleClassification(text As SourceText, classifiedSpan As ClassifiedSpan) As ClassifiedSpan
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Services\RefactoringHelpers\VisualBasicRefactoringHelpers.vb (1)
23Public Overrides Function IsBetweenTypeMembers(sourceText As SourceText, root As SyntaxNode, position As Integer, ByRef typeDeclaration As SyntaxNode) As Boolean
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\Indentation\VisualBasicIndentationService.Indenter.vb (1)
42text As SourceText,
Workspace\LanguageServices\VisualBasicSyntaxTreeFactoryService.ParsedSyntaxTree.vb (5)
13''' Parsed <see cref="VisualBasicSyntaxTree"/> that creates <see cref="SourceText"/> with given encoding And checksum algorithm. 25Private _lazyText As SourceText 28lazyText As SourceText, 42Public Overrides Function GetText(Optional cancellationToken As CancellationToken = Nothing) As SourceText 50Public Overrides Function TryGetText(<Out> ByRef text As SourceText) As Boolean
Workspace\LanguageServices\VisualBasicSyntaxTreeFactoryService.vb (2)
64Public Overrides Function ParseSyntaxTree(filePath As String, options As ParseOptions, text As SourceText, cancellationToken As CancellationToken) As SyntaxTree 72Public Overrides Function CreateSyntaxTree(filePath As String, options As ParseOptions, text As SourceText, encoding As Encoding, checksumAlgorithm As SourceHashAlgorithm, root As SyntaxNode) As SyntaxTree
Microsoft.CodeAnalysis.Workspaces (382)
Classification\AbstractClassificationService.cs (2)
30public abstract void AddLexicalClassifications(SourceText text, TextSpan textSpan, SegmentedList<ClassifiedSpan> result, CancellationToken cancellationToken); 31public abstract ClassifiedSpan AdjustStaleClassification(SourceText text, ClassifiedSpan classifiedSpan);
Classification\Classifier.cs (2)
118var sourceText = await semanticModel.SyntaxTree.GetTextAsync(cancellationToken).ConfigureAwait(false); 124SourceText sourceText, int startPosition, IEnumerable<ClassifiedSpan> classifiedSpans)
Classification\IClassificationService.cs (2)
28void AddLexicalClassifications(SourceText text, TextSpan textSpan, SegmentedList<ClassifiedSpan> result, CancellationToken cancellationToken); 85ClassifiedSpan AdjustStaleClassification(SourceText text, ClassifiedSpan classifiedSpan);
Classification\SyntaxClassification\AbstractSyntaxClassificationService.cs (2)
18public abstract void AddLexicalClassifications(SourceText text, TextSpan textSpan, SegmentedList<ClassifiedSpan> result, CancellationToken cancellationToken); 22public abstract ClassifiedSpan FixClassification(SourceText text, ClassifiedSpan classifiedSpan);
Classification\SyntaxClassification\ISyntaxClassificationService.cs (2)
21void AddLexicalClassifications(SourceText text, 56ClassifiedSpan FixClassification(SourceText text, ClassifiedSpan classifiedSpan);
CodeCleanup\CodeCleaner.cs (1)
52var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false);
CodeCleanup\Providers\FormatCodeCleanupProvider.cs (2)
27return document.TryGetText(out var oldText) 38return (root.SyntaxTree != null && root.SyntaxTree.TryGetText(out var oldText))
CodeFixes\FixAllOccurrences\DocumentBasedFixAllProvider.cs (1)
45/// will only be examined for its content (e.g. it's <see cref="SyntaxTree"/> or <see cref="SourceText"/>. No
CodeFixes\FixAllOccurrences\FixAllProvider.cs (2)
51/// examined for its content (e.g. it's <see cref="SyntaxTree"/> or <see cref="SourceText"/>. No other aspects 65/// examined for its content (e.g. it's <see cref="SyntaxTree"/> or <see cref="SourceText"/>. No other aspects
CodeFixes\FixAllOccurrences\TextChangeMerger.cs (3)
70public async Task<SourceText> GetFinalMergedTextAsync(CancellationToken cancellationToken) 75var oldText = await _oldDocument.GetValueTextAsync(cancellationToken).ConfigureAwait(false); 76var newText = oldText.WithChanges(changesToApply);
CodeFixesAndRefactorings\DocumentBasedFixAllProviderHelpers.cs (2)
67var changedRootsAndTexts = await ProducerConsumer<(DocumentId documentId, (SyntaxNode? node, SourceText? text))>.RunParallelAsync( 88var newText = newDocument.SupportsSyntaxTree ? null : await newDocument.GetValueTextAsync(cancellationToken).ConfigureAwait(false);
CodeRefactorings\FixAllOccurences\DocumentBasedRefactorAllProvider.cs (1)
48/// it's <see cref="SyntaxTree"/> or <see cref="SourceText"/>. No other aspects of document (like it's properties),
CodeRefactorings\FixAllOccurences\RefactorAllProvider.cs (2)
51/// examined for its content (e.g. it's <see cref="SyntaxTree"/> or <see cref="SourceText"/>. No other aspects 64/// examined for its content (e.g. it's <see cref="SyntaxTree"/> or <see cref="SourceText"/>. No other aspects
Diagnostics\Extensions.cs (1)
53var text = await textDocument.GetValueTextAsync(cancellationToken).ConfigureAwait(false);
ExternalAccess\UnitTesting\Api\UnitTestingEncodedStringTextAccessor.cs (1)
13public static SourceText Create(Stream stream, Encoding defaultEncoding)
ExternalAccess\VSTypeScript\Api\VSTypeScriptTextExtensions.cs (1)
15public static Document? GetOpenDocumentInCurrentContextWithChanges(this SourceText text)
FindSymbols\FindReferences\FindReferenceCache.cs (3)
35var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false); 52public readonly SourceText Text; 75Document document, SourceText text, SemanticModel semanticModel, SemanticModel nullableEnabledSemanticModel, SyntaxNode root, SyntaxTreeIndex syntaxTreeIndex)
LinkedFileDiffMerging\AbstractLinkedFileMergeConflictCommentAdditionService.cs (6)
16public static ImmutableArray<TextChange> CreateEdits(SourceText originalSourceText, ArrayBuilder<UnmergedDocumentChanges> unmergedChanges) 31private static List<List<TextChange>> PartitionChangesForDocument(IEnumerable<TextChange> changes, SourceText originalSourceText) 62private static ImmutableArray<TextChange> GetCommentChangesForDocument(IEnumerable<IEnumerable<TextChange>> partitionedChanges, string projectName, SourceText oldDocumentText) 74var oldText = oldDocumentText.GetSubText(TextSpan.FromBounds(startLineStartPosition, endLineEndPosition)); 76var newText = oldText.WithChanges(adjustedChanges); 124private static string? TrimBlankLines(SourceText text)
LinkedFileDiffMerging\LinkedFileDiffMergingSession.cs (3)
40var newText = await newDocument.GetValueTextAsync(cancellationToken).ConfigureAwait(false); 68var firstSourceText = await firstNewDocument.GetValueTextAsync(cancellationToken).ConfigureAwait(false); 103var firstOldSourceText = await firstOldDocument.GetValueTextAsync(cancellationToken).ConfigureAwait(false);
LinkedFileDiffMerging\LinkedFileMergeResult.cs (2)
10internal readonly struct LinkedFileMergeResult(ImmutableArray<DocumentId> documentIds, SourceText mergedSourceText, ImmutableArray<TextSpan> mergeConflictResolutionSpans) 13public readonly SourceText MergedSourceText = mergedSourceText;
Remote\RemoteUtilities.cs (2)
71var oldText = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false); 72var newText = oldText.WithChanges(tuple.textChanges);
Serialization\SerializableSourceText.cs (15)
22/// Represents a <see cref="SourceText"/> which can be serialized for sending to another process. The text is not 29/// The storage location for <see cref="SourceText"/>. 37/// The <see cref="SourceText"/> in the current process. 42private readonly SourceText? _text; 48private readonly WeakReference<SourceText?> _computedText = new(target: null); 51/// Checksum of the contents (see <see cref="SourceText.GetContentHash"/>) of the text. 60public SerializableSourceText(SourceText text, ImmutableArray<byte> contentHash) 65public SerializableSourceText(SourceText text, Checksum contentChecksum) 70private SerializableSourceText(TemporaryStorageTextHandle? storageHandle, SourceText? text, Checksum contentChecksum) 88private SourceText? TryGetText() 91public async ValueTask<SourceText> GetTextAsync(CancellationToken cancellationToken) 93var text = TryGetText(); 103public SourceText GetText(CancellationToken cancellationToken) 105var text = TryGetText(); 133var text = await state.GetTextAsync(cancellationToken).ConfigureAwait(false);
Shared\Extensions\FileLinePositionSpanExtensions.cs (4)
13public static TextSpan GetClampedTextSpan(this FileLinePositionSpan span, SourceText text) 17public static LinePositionSpan GetClampedSpan(this FileLinePositionSpan span, SourceText text) 27public static TextSpan GetClampedTextSpan(this LinePositionSpan span, SourceText text) 37public static LinePositionSpan GetClampedSpan(this LinePositionSpan span, SourceText text)
Shared\Extensions\ISolutionExtensions.cs (1)
42public static Solution WithTextDocumentText(this Solution solution, DocumentId documentId, SourceText text, PreservationMode mode = PreservationMode.PreserveIdentity)
Shared\Extensions\SourceTextExtensions.cs (12)
36public static void GetLineAndOffset(this SourceText text, int position, out int lineNumber, out int offset) 44public static int GetOffset(this SourceText text, int position) 51this SourceText text, 62public static TextChangeRange GetEncompassingTextChangeRange(this SourceText newText, SourceText oldText) 79public static int IndexOf(this SourceText text, string value, int startIndex, bool caseSensitive) 110public static int LastIndexOf(this SourceText text, string value, int startIndex, bool caseSensitive) 146public static bool ContentEquals(this SourceText text, int position, string value) 164public static int IndexOfNonWhiteSpace(this SourceText text, int start, int length) 177public static void WriteTo(this SourceText sourceText, ObjectWriter writer, CancellationToken cancellationToken) 195private static void WriteChunksTo(SourceText sourceText, ObjectWriter writer, int length, CancellationToken cancellationToken) 226public static SourceText ReadFrom(ITextFactoryService textService, ObjectReader reader, Encoding? encoding, SourceHashAlgorithm checksumAlgorithm, CancellationToken cancellationToken)
SourceGeneration\IRemoteSourceGenerationService.cs (3)
80/// <param name="OriginalSourceTextContentHash">Checksum originally produced from <see cref="SourceText.GetChecksum"/> on 84/// <param name="EncodingName">Result of <see cref="SourceText.Encoding"/>'s <see cref="Encoding.WebName"/>.</param> 85/// <param name="ChecksumAlgorithm">Result of <see cref="SourceText.ChecksumAlgorithm"/>.</param>
src\roslyn\src\Compilers\Core\Portable\EncodedStringText.cs (11)
72/// Initializes an instance of <see cref="SourceText"/> from the provided stream. This version differs 73/// from <see cref="SourceText.From(Stream, Encoding, SourceHashAlgorithm, bool)"/> in two ways: 91internal static SourceText Create(Stream stream, 103internal static SourceText Create(Stream stream, 136/// Try to create a <see cref="SourceText"/> from the given stream using the given encoding. 143/// <returns>The <see cref="SourceText"/> decoded from the stream.</returns> 146private static SourceText Decode( 165return SourceText.From(bytes.Array, 175return SourceText.From(data, encoding, checksumAlgorithm, throwIfBinaryDetected, canBeEmbedded); 249internal static SourceText Create(Stream stream, Lazy<Encoding> getEncoding, Encoding defaultEncoding, SourceHashAlgorithm checksumAlgorithm, bool canBeEmbedded) 252internal static SourceText Decode(Stream data, Encoding encoding, SourceHashAlgorithm checksumAlgorithm, bool throwIfBinaryDetected, bool canBeEmbedded)
src\roslyn\src\Compilers\Core\Portable\Syntax\SyntaxTreeExtensions.cs (1)
27internal static void VerifySource(SourceText text, SyntaxNode root, IEnumerable<TextChangeRange>? changes = null)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EditorConfig\Parsing\EditorConfigParser.cs (2)
40return Parse<TEditorConfigFile, TResult, TAccumulator>(SourceText.From(text), pathToFile, accumulator); 43public static TEditorConfigFile Parse<TEditorConfigFile, TEditorConfigOption, TAccumulator>(SourceText text, string? pathToFile, TAccumulator accumulator)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EditorConfig\Parsing\NamingStyles\EditorConfigNamingStylesParser.cs (5)
18=> Parse(SourceText.From(editorConfigText), pathToEditorConfigFile); 21/// Parses a <see cref="SourceText"/> and returns all discovered naming style options and their locations 23/// <param name="editorConfigText">The <see cref="SourceText"/> contents of the editorconfig file.</param> 25/// <returns>A type that represents all discovered naming style options in the given <see cref="SourceText"/>.</returns> 26public static EditorConfigNamingStyles Parse(SourceText editorConfigText, string? pathToEditorConfigFile = null)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EmbeddedLanguages\VirtualChars\AbstractVirtualCharService.cs (1)
193protected static int ConvertTextAtIndexToVirtualChar(SourceText tokenText, int index, ImmutableSegmentedList<VirtualCharGreen>.Builder result)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EmbeddedLanguages\VirtualChars\AbstractVirtualCharService.ITextInfo.cs (4)
12/// Abstraction to allow generic algorithms to run over a string or <see cref="SourceText"/> without any 21private struct SourceTextTextInfo : ITextInfo<SourceText> 23public readonly char Get(SourceText text, int index) => text[index]; 24public readonly int Length(SourceText text) => text.Length;
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EmbeddedLanguages\VirtualChars\IVirtualCharService.cs (1)
33/// in the original <see cref="SourceText"/> that the language created that char from.
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EmbeddedLanguages\VirtualChars\VirtualChar.cs (2)
39/// The width of characters in the original <see cref="SourceText"/> that represent this <see cref="VirtualCharGreen"/>. 68/// value of <c>9</c> as well as what <see cref="TextSpan"/> in the original <see cref="SourceText"/> they occupied.
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EmbeddedLanguages\VirtualChars\VirtualCharSequenceSourceText.cs (1)
12/// Trivial implementation of a <see cref="SourceText"/> that directly maps over a <see
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EmbeddedLanguages\VirtualChars\VirtualCharUtilities.cs (2)
22/// cref="SourceText"/> (which only cares about their <see cref="char"/> value), as well as the way to then map 23/// positions/spans within that <see cref="SourceText"/> to actual full virtual char spans in the original
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\SourceTextExtensions_SharedWithCodeStyle.cs (5)
16public static string GetLeadingWhitespaceOfLineAtPosition(this SourceText text, int position) 32this SourceText text, TextSpan span, Func<int, CancellationToken, bool> isPositionHidden, CancellationToken cancellationToken) 44this SourceText text, TextSpan span, Func<int, CancellationToken, bool> isPositionHidden, 82public static bool AreOnSameLine(this SourceText text, SyntaxToken token1, SyntaxToken token2) 87public static bool AreOnSameLine(this SourceText text, int pos1, int pos2)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\SyntaxTreeExtensions.cs (2)
27var text = tree.GetText(cancellationToken); 105var text = tree.GetText(cancellationToken);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\TextLineExtensions.cs (3)
14var text = line.Text!; 46var text = line.Text; 67var text = line.Text;
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Engine\TreeData.cs (1)
20if (root.SyntaxTree == null || !root.SyntaxTree.TryGetText(out var text))
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Engine\TreeData.Debug.cs (1)
11private sealed class Debug(SyntaxNode root, SourceText text) : NodeAndText(root, text)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Engine\TreeData.NodeAndText.cs (2)
14private readonly SourceText _text; 16public NodeAndText(SyntaxNode root, SourceText text)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Engine\TreeData.StructuredTrivia.cs (2)
26var text = GetText(); 47private SourceText? GetText()
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Indentation\AbstractIndentation.cs (1)
29TSyntaxRoot root, SourceText text, TextLine lineToBeIndented, IndentationOptions options, AbstractFormattingRule baseFormattingRule);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Indentation\AbstractIndentation.Indenter.cs (3)
35public readonly SourceText Text; 43SourceText text, 172var updatedSourceText = Text.WithChanges(changes);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Services\RefactoringHelpers\AbstractRefactoringHelpers.cs (6)
25public abstract bool IsBetweenTypeMembers(SourceText sourceText, SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? typeDeclaration); 42private static TextSpan GetTrimmedTextSpan(SourceText sourceText, TextSpan span) 60SourceText sourceText, SyntaxNode root, TextSpan selectionRaw, bool allowEmptyNodes, int maxCount, ref TemporaryArray<TSyntaxNode> result, CancellationToken cancellationToken) where TSyntaxNode : SyntaxNode 179SourceText sourceText, SyntaxNode root, int location) 251SourceText sourceText, SyntaxToken tokenOnLocation, int location) 533SourceText sourceText,
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Services\RefactoringHelpers\IRefactoringHelpers.cs (2)
23bool IsBetweenTypeMembers(SourceText sourceText, SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? typeDeclaration); 55SourceText sourceText, SyntaxNode root, TextSpan selection, bool allowEmptyNodes, int maxCount, ref TemporaryArray<TSyntaxNode> result, CancellationToken cancellationToken) where TSyntaxNode : SyntaxNode;
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Services\SelectedMembers\AbstractSelectedMembers.cs (3)
45var text = await tree.GetTextAsync(cancellationToken).ConfigureAwait(false); 77SyntaxNode root, SourceText text, TextSpan textSpan, 164SourceText text, SyntaxNode root, SyntaxNode member, int position)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\CommonFormattingHelpers.cs (1)
156public static string GetText(this SourceText text, SyntaxToken token1, SyntaxToken token2)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\InterceptsLocationUtilities.cs (1)
16/// (See <see cref="SourceText.GetContentHash()"/>)</param>
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeRefactorings\AbstractRefactoringHelpersService.cs (2)
21public bool IsBetweenTypeMembers(SourceText sourceText, SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? typeDeclaration) 24public void AddRelevantNodes<TSyntaxNode>(SourceText sourceText, SyntaxNode root, TextSpan selection, bool allowEmptyNodes, int maxCount, ref TemporaryArray<TSyntaxNode> result, CancellationToken cancellationToken) where TSyntaxNode : SyntaxNode
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Editing\AddParameterEditor.cs (2)
25var sourceText = declaration.SyntaxTree.GetText(cancellationToken); 159var text = parameters[0].SyntaxTree.GetText(cancellationToken);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Extensions\TextDocumentExtensions.cs (3)
27public static TextDocument WithText(this TextDocument textDocument, SourceText text) 48public static TextDocument WithAdditionalDocumentText(this TextDocument textDocument, SourceText text) 57public static TextDocument WithAnalyzerConfigDocumentText(this TextDocument textDocument, SourceText text)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Indentation\IIndentationService.cs (3)
66public static string GetIndentationString(this IndentationResult indentationResult, SourceText sourceText, bool useTabs, int tabSize) 77public static string GetIndentationString(this IndentationResult indentationResult, SourceText sourceText, SyntaxFormattingOptions options) 80public static string GetIndentationString(this IndentationResult indentationResult, SourceText sourceText, IndentationOptions options)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Utilities\ParsedDocument.cs (6)
18/// Used to front-load <see cref="SyntaxTree"/> parsing and <see cref="SourceText"/> retrieval to a caller that has knowledge of whether or not these operations 24internal readonly record struct ParsedDocument(DocumentId Id, SourceText Text, SyntaxNode Root, HostLanguageServices HostLanguageServices) 33var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false); 41var text = document.GetTextSynchronously(cancellationToken); 47public ParsedDocument WithChangedText(SourceText text, CancellationToken cancellationToken) 55var text = root.SyntaxTree.GetText(cancellationToken);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Utilities\SemanticDocument.cs (2)
13internal sealed class SemanticDocument(Document document, SourceText text, SyntaxNode root, SemanticModel semanticModel) 20var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Utilities\SyntacticDocument.cs (3)
15public readonly SourceText Text; 18protected SyntacticDocument(Document document, SourceText text, SyntaxNode root) 30var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false);
TemporaryStorage\TemporaryStorageService.cs (6)
97ITemporaryStorageTextHandle ITemporaryStorageServiceInternal.WriteToTemporaryStorage(SourceText text, CancellationToken cancellationToken) 100async Task<ITemporaryStorageTextHandle> ITemporaryStorageServiceInternal.WriteToTemporaryStorageAsync(SourceText text, CancellationToken cancellationToken) 103public TemporaryStorageTextHandle WriteToTemporaryStorage(SourceText text, CancellationToken cancellationToken) 129public async Task<TemporaryStorageTextHandle> WriteToTemporaryStorageAsync(SourceText text, CancellationToken cancellationToken) 259public async Task<SourceText> ReadFromTemporaryStorageAsync(CancellationToken cancellationToken) 280public SourceText ReadFromTemporaryStorage(CancellationToken cancellationToken)
TemporaryStorage\TrivialTemporaryStorageService.cs (6)
30public ITemporaryStorageTextHandle WriteToTemporaryStorage(SourceText text, CancellationToken cancellationToken) 35public async Task<ITemporaryStorageTextHandle> WriteToTemporaryStorageAsync(SourceText text, CancellationToken cancellationToken) 62private readonly SourceText _sourceText; 66public TextStorage(SourceText sourceText) 72public SourceText ReadFromTemporaryStorage(CancellationToken cancellationToken) 77public async Task<SourceText> ReadFromTemporaryStorageAsync(CancellationToken cancellationToken)
Workspace\AdhocWorkspace.cs (7)
108public Document AddDocument(ProjectId projectId, string name, SourceText text) 154var text = doc.GetTextSynchronously(CancellationToken.None); 167var text = doc.GetTextSynchronously(CancellationToken.None); 182var text = doc.GetTextSynchronously(CancellationToken.None); 195var text = doc.GetTextSynchronously(CancellationToken.None); 210var text = doc.GetTextSynchronously(CancellationToken.None); 223var text = doc.GetTextSynchronously(CancellationToken.None);
Workspace\Host\DocumentService\IDocumentExcerptService.cs (2)
38internal readonly struct ExcerptResult(SourceText content, TextSpan mappedSpan, ImmutableArray<ClassifiedSpan> classifiedSpans, Document document, TextSpan span) 43public readonly SourceText Content = content;
Workspace\Host\HostWorkspaceServices.cs (1)
117/// A factory that constructs <see cref="SourceText"/>.
Workspace\Host\SyntaxTreeFactory\AbstractSyntaxTreeFactoryService.cs (2)
20public abstract SyntaxTree CreateSyntaxTree(string filePath, ParseOptions options, SourceText text, Encoding encoding, SourceHashAlgorithm checksumAlgorithm, SyntaxNode root); 21public abstract SyntaxTree ParseSyntaxTree(string filePath, ParseOptions options, SourceText text, CancellationToken cancellationToken);
Workspace\Host\SyntaxTreeFactory\ISyntaxTreeFactoryService.cs (2)
30SyntaxTree CreateSyntaxTree(string? filePath, ParseOptions options, SourceText? text, Encoding? encoding, SourceHashAlgorithm checksumAlgorithm, SyntaxNode root); 33SyntaxTree ParseSyntaxTree(string? filePath, ParseOptions options, SourceText text, CancellationToken cancellationToken);
Workspace\Host\TemporaryStorage\ITemporaryStorage.cs (4)
16SourceText ReadText(CancellationToken cancellationToken = default); 17Task<SourceText> ReadTextAsync(CancellationToken cancellationToken = default); 18void WriteText(SourceText text, CancellationToken cancellationToken = default); 19Task WriteTextAsync(SourceText text, CancellationToken cancellationToken = default);
Workspace\Host\TemporaryStorage\ITemporaryStorageService.cs (3)
54ITemporaryStorageTextHandle WriteToTemporaryStorage(SourceText text, CancellationToken cancellationToken); 56/// <inheritdoc cref="WriteToTemporaryStorage(SourceText, CancellationToken)"/>"/> 57Task<ITemporaryStorageTextHandle> WriteToTemporaryStorageAsync(SourceText text, CancellationToken cancellationToken);
Workspace\Host\TemporaryStorage\ITemporaryStorageTextHandle.cs (2)
15SourceText ReadFromTemporaryStorage(CancellationToken cancellationToken); 16Task<SourceText> ReadFromTemporaryStorageAsync(CancellationToken cancellationToken);
Workspace\Host\TemporaryStorage\LegacyTemporaryStorageService.cs (6)
87private SourceText? _sourceText; 92public SourceText ReadText(CancellationToken cancellationToken = default) 95public async Task<SourceText> ReadTextAsync(CancellationToken cancellationToken = default) 98public void WriteText(SourceText text, CancellationToken cancellationToken = default) 103var existingValue = Interlocked.CompareExchange(ref _sourceText, text, null); 110public async Task WriteTextAsync(SourceText text, CancellationToken cancellationToken = default)
Workspace\Host\TextFactory\ITextFactoryService.cs (6)
13/// A factory for creating <see cref="SourceText"/> instances. 18/// Creates <see cref="SourceText"/> from a stream. 33SourceText CreateText(Stream stream, Encoding? defaultEncoding, SourceHashAlgorithm checksumAlgorithm, CancellationToken cancellationToken); 36/// Creates <see cref="SourceText"/> from a reader with given <paramref name="encoding"/>. 39/// <param name="encoding">Specifies an encoding for the <see cref="SourceText"/>SourceText. 43SourceText CreateText(TextReader reader, Encoding? encoding, SourceHashAlgorithm checksumAlgorithm, CancellationToken cancellationToken);
Workspace\Host\TextFactory\TextFactoryService.cs (4)
25public SourceText CreateText(Stream stream, Encoding? defaultEncoding, SourceHashAlgorithm checksumAlgorithm, CancellationToken cancellationToken) 31public SourceText CreateText(TextReader reader, Encoding? encoding, SourceHashAlgorithm checksumAlgorithm, CancellationToken cancellationToken) 36? SourceText.From(textReaderWithLength, textReaderWithLength.Length, encoding, checksumAlgorithm) 37: SourceText.From(reader.ReadToEnd(), encoding, checksumAlgorithm);
Workspace\Solution\AdditionalDocumentState.cs (1)
53public new AdditionalDocumentState UpdateText(SourceText text, PreservationMode mode)
Workspace\Solution\AdditionalTextWithState.cs (4)
15/// Create a <see cref="SourceText"/> from a <see cref="AdditionalDocumentState"/>. 27/// Retrieves a <see cref="SourceText"/> with the contents of this file. 29public override SourceText GetText(CancellationToken cancellationToken = default) 31var text = _documentState.GetTextSynchronously(cancellationToken);
Workspace\Solution\AnalyzerConfigDocumentState.cs (1)
63public new AnalyzerConfigDocumentState UpdateText(SourceText text, PreservationMode mode)
Workspace\Solution\Document.cs (3)
390public Document WithText(SourceText text) 475if (this.TryGetText(out var text) && oldDocument.TryGetText(out var oldText))
Workspace\Solution\DocumentState.cs (12)
106var text = await this.GetTextAsync(cancellationToken).ConfigureAwait(false); 166var text = textAndVersion.Text; 239var newText = newTextAndVersion.Text; 242var oldText = oldTree.GetText(cancellationToken); 250private static TreeAndVersion MakeNewTreeAndVersion(SyntaxTree oldTree, SourceText oldText, VersionStamp oldVersion, SyntaxTree newTree, SourceText newText, VersionStamp newVersion) 259private static bool TopLevelChanged(SyntaxTree oldTree, SourceText oldText, SyntaxTree newTree, SourceText newText) 444public new DocumentState UpdateText(SourceText newText, PreservationMode mode) 507else if (TryGetText(out var priorText)) 672SourceText newText, 674SourceText? oldText = null)
Workspace\Solution\DocumentState_LinkedFileReuse.cs (1)
153siblingTree.TryGetText(out var lazyText);
Workspace\Solution\DocumentState_TreeTextSource.cs (4)
16internal sealed class TreeTextSource(AsyncLazy<SourceText> textSource, VersionStamp version) : ITextAndVersionSource 31var text = await textSource.GetValueAsync(cancellationToken).ConfigureAwait(false); 37var text = textSource.GetValue(cancellationToken); 43if (textSource.TryGetValue(out var text))
Workspace\Solution\FileTextLoader.cs (7)
68GetType(), _ => new StrongBox<bool>(new Func<Stream, Workspace, SourceText>(CreateText).Method.DeclaringType != typeof(FileTextLoader))).Value; 72/// Creates <see cref="SourceText"/> from <see cref="Stream"/>. 76protected virtual SourceText CreateText(Stream stream, Workspace? workspace) 80/// Creates <see cref="SourceText"/> from <see cref="Stream"/>. 83private protected virtual SourceText CreateText(Stream stream, LoadTextOptions options, CancellationToken cancellationToken) 183var text = t.self.CreateText(readStream, t.options, t.cancellationToken); 207var text = t.self.CreateText(stream, t.options, t.cancellationToken);
Workspace\Solution\LoadTextOptions.cs (1)
11/// Options used to load <see cref="SourceText"/>.
Workspace\Solution\Project.cs (3)
715public Document AddDocument(string name, SourceText text, IEnumerable<string>? folders = null, string? filePath = null) 733public TextDocument AddAdditionalDocument(string name, SourceText text, IEnumerable<string>? folders = null, string? filePath = null) 751public TextDocument AddAnalyzerConfigDocument(string name, SourceText text, IEnumerable<string>? folders = null, string? filePath = null)
Workspace\Solution\ProjectState.cs (1)
131var text = await documentState.GetTextAsync(cancellationToken).ConfigureAwait(false);
Workspace\Solution\Solution.cs (18)
986var sourceText = SourceText.From(text, encoding: null, checksumAlgorithm: project.ChecksumAlgorithm); 995public Solution AddDocument(DocumentId documentId, string name, SourceText text, IEnumerable<string>? folders = null, string? filePath = null, bool isGenerated = false) 1028var sourceText = SourceText.From(string.Empty, encoding: null, project.ChecksumAlgorithm); 1034private Solution AddDocumentImpl(ProjectState project, DocumentId documentId, string name, SourceText text, IReadOnlyList<string>? folders, string? filePath, bool isGenerated) 1089=> this.AddAdditionalDocument(documentId, name, SourceText.From(text), folders, filePath); 1095public Solution AddAdditionalDocument(DocumentId documentId, string name, SourceText text, IEnumerable<string>? folders = null, string? filePath = null) 1126public Solution AddAnalyzerConfigDocument(DocumentId documentId, string name, SourceText text, IEnumerable<string>? folders = null, string? filePath = null) 1150private DocumentInfo CreateDocumentInfo(DocumentId documentId, string name, SourceText text, IEnumerable<string>? folders, string? filePath) 1288public Solution WithDocumentText(DocumentId documentId, SourceText text, PreservationMode mode = PreservationMode.PreserveValue) 1291internal Solution WithDocumentTexts(ImmutableArray<(DocumentId documentId, SourceText text)> texts, PreservationMode mode = PreservationMode.PreserveValue) 1311public Solution WithAdditionalDocumentText(DocumentId documentId, SourceText text, PreservationMode mode = PreservationMode.PreserveValue) 1332public Solution WithAnalyzerConfigDocumentText(DocumentId documentId, SourceText text, PreservationMode mode = PreservationMode.PreserveValue) 1645public Solution WithDocumentText(IEnumerable<DocumentId?> documentIds, SourceText text, PreservationMode mode = PreservationMode.PreserveValue) 1671SourceGeneratedDocumentIdentity documentIdentity, DateTime generationDateTime, SourceText text) 1684internal Solution WithFrozenSourceGeneratedDocuments(ImmutableArray<(SourceGeneratedDocumentIdentity documentIdentity, DateTime generationDateTime, SourceText text)> documents) 1685=> WithCompilationState(CompilationState.WithFrozenSourceGeneratedDocuments(documents.SelectAsArray(d => (d.documentIdentity, d.generationDateTime, (SourceText?)d.text, (SyntaxNode?)null))));
Workspace\Solution\SolutionChanges.cs (1)
88/// Gets changed source generated document ids that were modified with <see cref="Solution.WithFrozenSourceGeneratedDocuments(System.Collections.Immutable.ImmutableArray{ValueTuple{SourceGeneratedDocumentIdentity, DateTime, Text.SourceText}})"/>
Workspace\Solution\SolutionCompilationState.cs (18)
806internal SolutionCompilationState WithDocumentTexts(ImmutableArray<(DocumentId documentId, SourceText text)> texts, PreservationMode mode) 810return UpdateDocumentsInMultipleProjects<DocumentState, SourceText, PreservationMode>( 817(ImmutableArray<(DocumentId, SourceText)>, 818ImmutableArray<(SourceGeneratedDocumentIdentity, DateTime, SourceText?, SyntaxNode?)>) GetOrdinaryAndSourceGeneratedDocuments() 823using var _1 = ArrayBuilder<(DocumentId, SourceText)>.GetInstance(capacity: texts.Length, out var ordinaryDocuments); 824using var _2 = ArrayBuilder<(SourceGeneratedDocumentIdentity, DateTime, SourceText?, SyntaxNode?)>.GetInstance(out var sourceGeneratedDocuments); 841private static bool SourceTextIsUnchanged(DocumentState oldDocument, SourceText text) 842=> oldDocument.TryGetText(out var oldText) && text == oldText; 850ImmutableArray<(SourceGeneratedDocumentIdentity documentIdentity, DateTime generationDateTime, SourceText? sourceText, SyntaxNode? syntaxNode)> sourceGeneratedDocuments, 962/// <inheritdoc cref="SolutionState.WithAdditionalDocumentText(DocumentId, SourceText, PreservationMode)"/> 964DocumentId documentId, SourceText text, PreservationMode mode) 970/// <inheritdoc cref="SolutionState.WithAnalyzerConfigDocumentText(DocumentId, SourceText, PreservationMode)"/> 972DocumentId documentId, SourceText text, PreservationMode mode) 1023ImmutableArray<(SourceGeneratedDocumentIdentity, DateTime, SourceText?, SyntaxNode?)>) GetOrdinaryAndSourceGeneratedDocuments() 1029using var _2 = ArrayBuilder<(SourceGeneratedDocumentIdentity, DateTime, SourceText?, SyntaxNode?)>.GetInstance(out var sourceGeneratedDocuments); 1405ImmutableArray<(SourceGeneratedDocumentIdentity documentIdentity, DateTime generationDateTime, SourceText? sourceText, SyntaxNode? syntaxNode)> documents) 1873public SolutionCompilationState WithDocumentText(IEnumerable<DocumentId?> documentIds, SourceText text, PreservationMode mode) 1875using var _ = ArrayBuilder<(DocumentId, SourceText)>.GetInstance(out var changedDocuments);
Workspace\Solution\SolutionCompilationState.RegularCompilationTracker_Generators.cs (2)
233var sourceText = SourceText.From(
Workspace\Solution\SolutionState.cs (6)
991public StateChange WithDocumentText(DocumentId documentId, SourceText text, PreservationMode mode = PreservationMode.PreserveValue) 994if (oldDocument.TryGetText(out var oldText) && text == oldText) 1019public StateChange WithAdditionalDocumentText(DocumentId documentId, SourceText text, PreservationMode mode = PreservationMode.PreserveValue) 1022if (oldDocument.TryGetText(out var oldText) && text == oldText) 1035public StateChange WithAnalyzerConfigDocumentText(DocumentId documentId, SourceText text, PreservationMode mode = PreservationMode.PreserveValue) 1038if (oldDocument.TryGetText(out var oldText) && text == oldText)
Workspace\Solution\SourceGeneratedDocument.cs (1)
30internal new SourceGeneratedDocument WithText(SourceText text)
Workspace\Solution\SourceGeneratedDocumentState.cs (9)
27public SourceText SourceText { get; } 31/// different from the checksum acquired from <see cref="SourceText.GetChecksum"/>. Specifically, the original 44SourceText generatedSourceText, 55SourceText? generatedSourceText, 83SourceText generatedSourceText, 139SourceText text, 153private static Checksum ComputeContentHash(SourceText text) 171public SourceGeneratedDocumentState WithText(SourceText sourceText) 237var sourceText = newRoot.GetText();
Workspace\Solution\TextAndVersion.cs (4)
18public SourceText Text { get; } 36private TextAndVersion(SourceText text, VersionStamp version, string? filePath, string? exceptionMessage) 53public static TextAndVersion Create(SourceText text, VersionStamp version, string? filePath = null) 61internal static TextAndVersion Create(SourceText text, VersionStamp version, string? filePath, string? exceptionMessage)
Workspace\Solution\TextDocument.cs (4)
63public bool TryGetText([NotNullWhen(returnValue: true)] out SourceText? text) 75public Task<SourceText> GetTextAsync(CancellationToken cancellationToken = default) 78internal ValueTask<SourceText> GetValueTextAsync(CancellationToken cancellationToken) 86internal SourceText GetTextSynchronously(CancellationToken cancellationToken)
Workspace\Solution\TextDocumentState.cs (6)
80public bool TryGetText([NotNullWhen(returnValue: true)] out SourceText? text) 100public async ValueTask<SourceText> GetTextAsync(CancellationToken cancellationToken) 102if (TryGetText(out var text)) 109public SourceText GetTextSynchronously(CancellationToken cancellationToken) 140public TextDocumentState UpdateText(SourceText newText, PreservationMode mode) 159: CreateStrongText(TextAndVersion.Create(SourceText.From(string.Empty, encoding: null, loadTextOptions.ChecksumAlgorithm), VersionStamp.Default, filePath));
Workspace\Solution\TextLoader.cs (5)
42/// True if <see cref="LoadTextAndVersionAsync(LoadTextOptions, CancellationToken)"/> reloads <see cref="SourceText"/> from its original binary representation (e.g. file on disk). 51/// Implementations of this method should use <see cref="LoadTextOptions.ChecksumAlgorithm"/> when creating <see cref="SourceText"/> from an original binary representation and 53/// Callers of this method should pass <see cref="LoadTextOptions"/> specifying the desired properties of <see cref="SourceText"/>. The implementation may return a <see cref="SourceText"/> 161SourceText.From(string.Empty, Encoding.UTF8),
Workspace\Solution\VersionSource\ITextAndVersionSource.cs (1)
15/// True if <see cref="SourceText"/> can be reloaded.
Workspace\Solution\VersionSource\RecoverableTextAndVersion.cs (5)
59if (recoverableText.LoadTextOptions == options && recoverableText.TryGetValue(out var text)) 166public TextAndVersion ToTextAndVersion(SourceText text) 171private async Task<SourceText> RecoverAsync(CancellationToken cancellationToken) 181private SourceText Recover(CancellationToken cancellationToken) 191private async Task SaveAsync(SourceText text, CancellationToken cancellationToken)
Workspace\Solution\VersionSource\RecoverableTextAndVersion.RecoverableText.cs (14)
20/// This class holds onto a <see cref="SourceText"/> value weakly, but can save its value and recover it on demand 28private static readonly AsyncBatchingWorkQueue<(RecoverableText recoverableText, SourceText sourceText)> s_saveQueue = 43private SourceText? _initialValue; 49private WeakReference<SourceText>? _weakReference; 57private bool TryGetWeakValue([NotNullWhen(true)] out SourceText? value) 67private bool TryGetStrongOrWeakValue([NotNullWhen(true)] out SourceText? value) 78public bool TryGetValue([MaybeNullWhen(false)] out SourceText value) 81public SourceText GetValue(CancellationToken cancellationToken) 87if (TryGetWeakValue(out var instance)) 103public async Task<SourceText> GetValueAsync(CancellationToken cancellationToken) 109if (TryGetWeakValue(out var instance)) 128private void UpdateWeakReferenceAndEnqueueSaveTask_NoLock(SourceText instance) 132_weakReference ??= new WeakReference<SourceText>(instance); 145ImmutableSegmentedList<(RecoverableText recoverableText, SourceText sourceText)> list, CancellationToken cancellationToken)
Workspace\TextExtensions.cs (5)
18public static ImmutableArray<Document> GetRelatedDocumentsWithChanges(this SourceText text) 48public static Document? GetOpenDocumentInCurrentContextWithChanges(this SourceText text) 55public static TextDocument? GetOpenTextDocumentInCurrentContextWithChanges(this SourceText text) 58private static TextDocument? GetOpenTextDocumentInCurrentContextWithChanges(this SourceText text, bool sourceDocumentOnly) 143internal static Document? GetDocumentWithFrozenPartialSemantics(this SourceText text, CancellationToken cancellationToken)
Workspace\Workspace.cs (18)
1138protected internal void OnDocumentTextChanged(DocumentId documentId, SourceText newText, PreservationMode mode) 1141private protected void OnDocumentTextChanged(DocumentId documentId, SourceText newText, PreservationMode mode, bool requireDocumentPresent) 1156protected internal void OnAdditionalDocumentTextChanged(DocumentId documentId, SourceText newText, PreservationMode mode) 1171protected internal void OnAnalyzerConfigDocumentTextChanged(DocumentId documentId, SourceText newText, PreservationMode mode) 1936var text = document.GetTextSynchronously(CancellationToken.None); 1945var text = document.GetTextSynchronously(CancellationToken.None); 1954var text = document.GetTextSynchronously(CancellationToken.None); 1971var currentText = newDoc.GetTextSynchronously(CancellationToken.None); // needs wait 1981var currentText = newDoc.GetTextSynchronously(CancellationToken.None); // needs wait 1998if (!oldDoc.TryGetText(out var oldText)) 2003var currentText = newDoc.GetTextSynchronously(CancellationToken.None); // needs wait 2006else if (!newDoc.TryGetText(out var newText)) 2202protected virtual void ApplyDocumentAdded(DocumentInfo info, SourceText text) 2224protected virtual void ApplyDocumentTextChanged(DocumentId id, SourceText text) 2246protected virtual void ApplyAdditionalDocumentAdded(DocumentInfo info, SourceText text) 2268protected virtual void ApplyAdditionalDocumentTextChanged(DocumentId id, SourceText text) 2279protected virtual void ApplyAnalyzerConfigDocumentAdded(DocumentInfo info, SourceText text) 2301protected virtual void ApplyAnalyzerConfigDocumentTextChanged(DocumentId id, SourceText text)
Workspace\Workspace.TextTracker.cs (2)
24private readonly Action<Workspace, DocumentId, SourceText, PreservationMode> _onChangedHandler; 30Action<Workspace, DocumentId, SourceText, PreservationMode> onChangedHandler)
Workspace\Workspace_Editor.cs (11)
396var newText = textContainer.CurrentText; 397if (oldDocument.TryGetText(out var oldText) && 486private static TextAndVersion GetProperTextAndVersion(SourceText oldText, SourceText newText, VersionStamp version, string? filePath) 495private void SignupForTextChanges(DocumentId documentId, SourceTextContainer textContainer, bool isCurrentContext, Action<Workspace, DocumentId, SourceText, PreservationMode> onChangedHandler) 556Func<Solution, DocumentId, SourceText, PreservationMode, Solution> withDocumentText, 558Action<Workspace, DocumentId, SourceText, PreservationMode> onDocumentTextChanged) 588var oldText = oldDocument.GetTextSynchronously(CancellationToken.None); 591var newText = data.textContainer.CurrentText; 850private SourceText GetOpenDocumentText(Solution solution, DocumentId documentId) 855Contract.ThrowIfFalse(doc.TryGetText(out var text));
Workspace\WorkspaceFileTextLoader.cs (1)
30private protected override SourceText CreateText(Stream stream, LoadTextOptions options, CancellationToken cancellationToken)
Microsoft.CodeAnalysis.Workspaces.MSBuild (9)
MSBuild\MSBuildWorkspace.cs (9)
394protected override void ApplyDocumentTextChanged(DocumentId documentId, SourceText text) 412protected override void ApplyAdditionalDocumentTextChanged(DocumentId documentId, SourceText text) 430private static Encoding? DetermineEncoding(SourceText text, TextDocument document) 445var onDiskText = EncodedStringText.Create(stream); 458protected override void ApplyDocumentAdded(DocumentInfo info, SourceText text) 496private void SaveDocumentText(DocumentId id, string fullPath, SourceText newText, Encoding encoding) 726internal void OnDocumentTextChangedInternal(DocumentId documentId, SourceText newText) 731internal void OnAdditionalDocumentTextChangedInternal(DocumentId documentId, SourceText newText) 736internal void OnAnalyzerConfigDocumentTextChangedInternal(DocumentId documentId, SourceText newText)
Microsoft.DotNet.CodeAnalysis (2)
Analyzers\MembersMustExistAnalyzer.cs (1)
71SourceText fileContents = additionalFile.GetText();
Analyzers\PinvokeAnalyzer.cs (1)
76SourceText fileContents = additionalFile.GetText();
Microsoft.DotNet.HotReload.Utils.Generator (1)
DeltaProject.cs (1)
77updatedSolution = Solution.WithDocumentText (baseDocumentId, SourceText.From (contents, Encoding.UTF8));
Microsoft.DotNet.HotReload.Watch (1)
HotReload\CompilationHandler.cs (1)
1064var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
Microsoft.DotNet.ProjectTools (5)
src\sdk\src\Cli\Microsoft.DotNet.FileBasedPrograms\FileLevelDirectiveHelpers.cs (4)
26public static SyntaxTokenParser CreateTokenizer(SourceText text) 225internal readonly record struct SourceFile(string Path, SourceText Text) 231return new SourceFile(filePath, SourceText.From(stream, encoding: null)); 961internal delegate void ErrorReporter(SourceText text, string path, TextSpan textSpan, string message, Exception? innerException = null);
VirtualProjectBuilder.cs (1)
60SourceText? sourceText = null)
Microsoft.Extensions.Logging.Generators (1)
LoggerMessageGenerator.Roslyn4.0.cs (1)
213context.AddSource("LoggerMessage.g.cs", SourceText.From(result, Encoding.UTF8));
Microsoft.Extensions.Options.SourceGeneration (1)
Generator.cs (1)
56context.AddSource("Validators.g.cs", SourceText.From(result, Encoding.UTF8));
Microsoft.Gen.BuildMetadata (1)
BuildMetadataGenerator.cs (1)
55context.AddSource("BuildMetadataExtensions.g.cs", SourceText.From(result, Encoding.UTF8));
Microsoft.Gen.BuildMetadata.Unit.Tests (5)
test\Generators\Shared\RoslynTestUtils.cs (5)
512var s = await proj.FindDocument(l[i]).GetTextAsync().ConfigureAwait(false); 520var s = await proj.FindDocument($"src-{i}.cs").GetTextAsync().ConfigureAwait(false); 527var s = await proj.FindDocument(extraFile).GetTextAsync().ConfigureAwait(false); 548var newText = await document.GetTextAsync().ConfigureAwait(false); 549return document.WithText(SourceText.From(newText.ToString(), newText.Encoding, newText.ChecksumAlgorithm));
Microsoft.Gen.ComplianceReports.Unit.Tests (5)
test\Generators\Shared\RoslynTestUtils.cs (5)
512var s = await proj.FindDocument(l[i]).GetTextAsync().ConfigureAwait(false); 520var s = await proj.FindDocument($"src-{i}.cs").GetTextAsync().ConfigureAwait(false); 527var s = await proj.FindDocument(extraFile).GetTextAsync().ConfigureAwait(false); 548var newText = await document.GetTextAsync().ConfigureAwait(false); 549return document.WithText(SourceText.From(newText.ToString(), newText.Encoding, newText.ChecksumAlgorithm));
Microsoft.Gen.ContextualOptions.Unit.Tests (5)
test\Generators\Shared\RoslynTestUtils.cs (5)
512var s = await proj.FindDocument(l[i]).GetTextAsync().ConfigureAwait(false); 520var s = await proj.FindDocument($"src-{i}.cs").GetTextAsync().ConfigureAwait(false); 527var s = await proj.FindDocument(extraFile).GetTextAsync().ConfigureAwait(false); 548var newText = await document.GetTextAsync().ConfigureAwait(false); 549return document.WithText(SourceText.From(newText.ToString(), newText.Encoding, newText.ChecksumAlgorithm));
Microsoft.Gen.Logging (1)
LoggingGenerator.cs (1)
49context.AddSource("Logging.g.cs", SourceText.From(result, Encoding.UTF8));
Microsoft.Gen.Logging.Unit.Tests (5)
test\Generators\Shared\RoslynTestUtils.cs (5)
512var s = await proj.FindDocument(l[i]).GetTextAsync().ConfigureAwait(false); 520var s = await proj.FindDocument($"src-{i}.cs").GetTextAsync().ConfigureAwait(false); 527var s = await proj.FindDocument(extraFile).GetTextAsync().ConfigureAwait(false); 548var newText = await document.GetTextAsync().ConfigureAwait(false); 549return document.WithText(SourceText.From(newText.ToString(), newText.Encoding, newText.ChecksumAlgorithm));
Microsoft.Gen.MetadataExtractor.Unit.Tests (5)
test\Generators\Shared\RoslynTestUtils.cs (5)
512var s = await proj.FindDocument(l[i]).GetTextAsync().ConfigureAwait(false); 520var s = await proj.FindDocument($"src-{i}.cs").GetTextAsync().ConfigureAwait(false); 527var s = await proj.FindDocument(extraFile).GetTextAsync().ConfigureAwait(false); 548var newText = await document.GetTextAsync().ConfigureAwait(false); 549return document.WithText(SourceText.From(newText.ToString(), newText.Encoding, newText.ChecksumAlgorithm));
Microsoft.Gen.Metrics (2)
MetricsGenerator.cs (2)
41context.AddSource("Factory.g.cs", SourceText.From(factory, Encoding.UTF8)); 45context.AddSource("Metrics.g.cs", SourceText.From(metrics, Encoding.UTF8));
Microsoft.Gen.Metrics.Unit.Tests (5)
test\Generators\Shared\RoslynTestUtils.cs (5)
512var s = await proj.FindDocument(l[i]).GetTextAsync().ConfigureAwait(false); 520var s = await proj.FindDocument($"src-{i}.cs").GetTextAsync().ConfigureAwait(false); 527var s = await proj.FindDocument(extraFile).GetTextAsync().ConfigureAwait(false); 548var newText = await document.GetTextAsync().ConfigureAwait(false); 549return document.WithText(SourceText.From(newText.ToString(), newText.Encoding, newText.ChecksumAlgorithm));
Microsoft.Gen.MetricsReports.Unit.Tests (5)
test\Generators\Shared\RoslynTestUtils.cs (5)
512var s = await proj.FindDocument(l[i]).GetTextAsync().ConfigureAwait(false); 520var s = await proj.FindDocument($"src-{i}.cs").GetTextAsync().ConfigureAwait(false); 527var s = await proj.FindDocument(extraFile).GetTextAsync().ConfigureAwait(false); 548var newText = await document.GetTextAsync().ConfigureAwait(false); 549return document.WithText(SourceText.From(newText.ToString(), newText.Encoding, newText.ChecksumAlgorithm));
Microsoft.Maui.Controls.SourceGen (4)
CodeBehindGenerator.cs (4)
127 var text = projectItem.AdditionalText.GetText(cancellationToken); 295 context.AddSource(hintName, SourceText.From(sb.ToString(), Encoding.UTF8)); 377 context.AddSource(hintName, SourceText.From(sb.ToString(), Encoding.UTF8)); 640 sourceProductionContext.AddSource(hintName, SourceText.From(sb.ToString(), Encoding.UTF8));
Microsoft.ML.AutoML.SourceGenerator (3)
EstimatorTypeGenerator.cs (1)
53context.AddSource(className + ".cs", SourceText.From(code.TransformText(), Encoding.UTF8));
SweepableEstimatorFactoryGenerator.cs (1)
48context.AddSource(className + ".cs", SourceText.From(code.TransformText(), Encoding.UTF8));
SweepableEstimatorGenerator.cs (1)
73context.AddSource(c.Item1 + ".cs", SourceText.From(c.Item2, Encoding.UTF8));
PlatformDocAnalyzer (1)
PlatformDocAnalyzer.cs (1)
119SourceText? text = file.GetText(context.CancellationToken);
Roslyn.Diagnostics.Analyzers (92)
src\roslyn\src\Compilers\Core\Portable\EncodedStringText.cs (11)
72/// Initializes an instance of <see cref="SourceText"/> from the provided stream. This version differs 73/// from <see cref="SourceText.From(Stream, Encoding, SourceHashAlgorithm, bool)"/> in two ways: 91internal static SourceText Create(Stream stream, 103internal static SourceText Create(Stream stream, 136/// Try to create a <see cref="SourceText"/> from the given stream using the given encoding. 143/// <returns>The <see cref="SourceText"/> decoded from the stream.</returns> 146private static SourceText Decode( 165return SourceText.From(bytes.Array, 175return SourceText.From(data, encoding, checksumAlgorithm, throwIfBinaryDetected, canBeEmbedded); 249internal static SourceText Create(Stream stream, Lazy<Encoding> getEncoding, Encoding defaultEncoding, SourceHashAlgorithm checksumAlgorithm, bool canBeEmbedded) 252internal static SourceText Decode(Stream data, Encoding encoding, SourceHashAlgorithm checksumAlgorithm, bool throwIfBinaryDetected, bool canBeEmbedded)
src\roslyn\src\Compilers\Core\Portable\Syntax\SyntaxTreeExtensions.cs (1)
27internal static void VerifySource(SourceText text, SyntaxNode root, IEnumerable<TextChangeRange>? changes = null)
src\roslyn\src\RoslynAnalyzers\Utilities\Compiler\Extensions\AdditionalTextExtensions.cs (3)
15private static readonly SourceText s_emptySourceText = SourceText.From("", s_utf8bom, SourceHashAlgorithm.Sha256); 17public static SourceText GetTextOrEmpty(this AdditionalText text, CancellationToken cancellationToken)
src\roslyn\src\RoslynAnalyzers\Utilities\Compiler\Extensions\SourceTextExtensions.cs (2)
13/// Class that contains extensions to <see cref="SourceText"/>. 25public static T Parse<T>(this SourceText text, Func<StreamReader, T> parser)
src\roslyn\src\RoslynAnalyzers\Utilities\Refactoring\CodeRefactoringContextExtensions.cs (2)
44var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); 52SourceText text,
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EditorConfig\Parsing\EditorConfigParser.cs (2)
40return Parse<TEditorConfigFile, TResult, TAccumulator>(SourceText.From(text), pathToFile, accumulator); 43public static TEditorConfigFile Parse<TEditorConfigFile, TEditorConfigOption, TAccumulator>(SourceText text, string? pathToFile, TAccumulator accumulator)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EditorConfig\Parsing\NamingStyles\EditorConfigNamingStylesParser.cs (5)
18=> Parse(SourceText.From(editorConfigText), pathToEditorConfigFile); 21/// Parses a <see cref="SourceText"/> and returns all discovered naming style options and their locations 23/// <param name="editorConfigText">The <see cref="SourceText"/> contents of the editorconfig file.</param> 25/// <returns>A type that represents all discovered naming style options in the given <see cref="SourceText"/>.</returns> 26public static EditorConfigNamingStyles Parse(SourceText editorConfigText, string? pathToEditorConfigFile = null)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EmbeddedLanguages\VirtualChars\AbstractVirtualCharService.cs (1)
193protected static int ConvertTextAtIndexToVirtualChar(SourceText tokenText, int index, ImmutableSegmentedList<VirtualCharGreen>.Builder result)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EmbeddedLanguages\VirtualChars\AbstractVirtualCharService.ITextInfo.cs (4)
12/// Abstraction to allow generic algorithms to run over a string or <see cref="SourceText"/> without any 21private struct SourceTextTextInfo : ITextInfo<SourceText> 23public readonly char Get(SourceText text, int index) => text[index]; 24public readonly int Length(SourceText text) => text.Length;
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EmbeddedLanguages\VirtualChars\IVirtualCharService.cs (1)
33/// in the original <see cref="SourceText"/> that the language created that char from.
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EmbeddedLanguages\VirtualChars\VirtualChar.cs (2)
39/// The width of characters in the original <see cref="SourceText"/> that represent this <see cref="VirtualCharGreen"/>. 68/// value of <c>9</c> as well as what <see cref="TextSpan"/> in the original <see cref="SourceText"/> they occupied.
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EmbeddedLanguages\VirtualChars\VirtualCharSequenceSourceText.cs (1)
12/// Trivial implementation of a <see cref="SourceText"/> that directly maps over a <see
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EmbeddedLanguages\VirtualChars\VirtualCharUtilities.cs (2)
22/// cref="SourceText"/> (which only cares about their <see cref="char"/> value), as well as the way to then map 23/// positions/spans within that <see cref="SourceText"/> to actual full virtual char spans in the original
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\SourceTextExtensions_SharedWithCodeStyle.cs (5)
16public static string GetLeadingWhitespaceOfLineAtPosition(this SourceText text, int position) 32this SourceText text, TextSpan span, Func<int, CancellationToken, bool> isPositionHidden, CancellationToken cancellationToken) 44this SourceText text, TextSpan span, Func<int, CancellationToken, bool> isPositionHidden, 82public static bool AreOnSameLine(this SourceText text, SyntaxToken token1, SyntaxToken token2) 87public static bool AreOnSameLine(this SourceText text, int pos1, int pos2)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\SyntaxTreeExtensions.cs (2)
27var text = tree.GetText(cancellationToken); 105var text = tree.GetText(cancellationToken);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\TextLineExtensions.cs (3)
14var text = line.Text!; 46var text = line.Text; 67var text = line.Text;
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Engine\TreeData.cs (1)
20if (root.SyntaxTree == null || !root.SyntaxTree.TryGetText(out var text))
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Engine\TreeData.Debug.cs (1)
11private sealed class Debug(SyntaxNode root, SourceText text) : NodeAndText(root, text)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Engine\TreeData.NodeAndText.cs (2)
14private readonly SourceText _text; 16public NodeAndText(SyntaxNode root, SourceText text)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Engine\TreeData.StructuredTrivia.cs (2)
26var text = GetText(); 47private SourceText? GetText()
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Indentation\AbstractIndentation.cs (1)
29TSyntaxRoot root, SourceText text, TextLine lineToBeIndented, IndentationOptions options, AbstractFormattingRule baseFormattingRule);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Indentation\AbstractIndentation.Indenter.cs (3)
35public readonly SourceText Text; 43SourceText text, 172var updatedSourceText = Text.WithChanges(changes);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Services\RefactoringHelpers\AbstractRefactoringHelpers.cs (6)
25public abstract bool IsBetweenTypeMembers(SourceText sourceText, SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? typeDeclaration); 42private static TextSpan GetTrimmedTextSpan(SourceText sourceText, TextSpan span) 60SourceText sourceText, SyntaxNode root, TextSpan selectionRaw, bool allowEmptyNodes, int maxCount, ref TemporaryArray<TSyntaxNode> result, CancellationToken cancellationToken) where TSyntaxNode : SyntaxNode 179SourceText sourceText, SyntaxNode root, int location) 251SourceText sourceText, SyntaxToken tokenOnLocation, int location) 533SourceText sourceText,
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Services\RefactoringHelpers\IRefactoringHelpers.cs (2)
23bool IsBetweenTypeMembers(SourceText sourceText, SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? typeDeclaration); 55SourceText sourceText, SyntaxNode root, TextSpan selection, bool allowEmptyNodes, int maxCount, ref TemporaryArray<TSyntaxNode> result, CancellationToken cancellationToken) where TSyntaxNode : SyntaxNode;
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Services\SelectedMembers\AbstractSelectedMembers.cs (3)
45var text = await tree.GetTextAsync(cancellationToken).ConfigureAwait(false); 77SyntaxNode root, SourceText text, TextSpan textSpan, 164SourceText text, SyntaxNode root, SyntaxNode member, int position)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\CommonFormattingHelpers.cs (1)
156public static string GetText(this SourceText text, SyntaxToken token1, SyntaxToken token2)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\InterceptsLocationUtilities.cs (1)
16/// (See <see cref="SourceText.GetContentHash()"/>)</param>
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeRefactorings\AbstractRefactoringHelpersService.cs (2)
21public bool IsBetweenTypeMembers(SourceText sourceText, SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? typeDeclaration) 24public void AddRelevantNodes<TSyntaxNode>(SourceText sourceText, SyntaxNode root, TextSpan selection, bool allowEmptyNodes, int maxCount, ref TemporaryArray<TSyntaxNode> result, CancellationToken cancellationToken) where TSyntaxNode : SyntaxNode
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Editing\AddParameterEditor.cs (2)
25var sourceText = declaration.SyntaxTree.GetText(cancellationToken); 159var text = parameters[0].SyntaxTree.GetText(cancellationToken);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Extensions\TextDocumentExtensions.cs (5)
15public static async ValueTask<SourceText> GetValueTextAsync(this TextDocument document, CancellationToken cancellationToken) 17if (document.TryGetText(out var text)) 27public static TextDocument WithText(this TextDocument textDocument, SourceText text) 48public static TextDocument WithAdditionalDocumentText(this TextDocument textDocument, SourceText text) 57public static TextDocument WithAnalyzerConfigDocumentText(this TextDocument textDocument, SourceText text)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Indentation\IIndentationService.cs (3)
66public static string GetIndentationString(this IndentationResult indentationResult, SourceText sourceText, bool useTabs, int tabSize) 77public static string GetIndentationString(this IndentationResult indentationResult, SourceText sourceText, SyntaxFormattingOptions options) 80public static string GetIndentationString(this IndentationResult indentationResult, SourceText sourceText, IndentationOptions options)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Utilities\ParsedDocument.cs (5)
18/// Used to front-load <see cref="SyntaxTree"/> parsing and <see cref="SourceText"/> retrieval to a caller that has knowledge of whether or not these operations 24internal readonly record struct ParsedDocument(DocumentId Id, SourceText Text, SyntaxNode Root, HostLanguageServices HostLanguageServices) 33var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false); 47public ParsedDocument WithChangedText(SourceText text, CancellationToken cancellationToken) 55var text = root.SyntaxTree.GetText(cancellationToken);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Utilities\SemanticDocument.cs (2)
13internal sealed class SemanticDocument(Document document, SourceText text, SyntaxNode root, SemanticModel semanticModel) 20var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Utilities\SyntacticDocument.cs (3)
15public readonly SourceText Text; 18protected SyntacticDocument(Document document, SourceText text, SyntaxNode root) 30var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false);
Roslyn.Diagnostics.CSharp.Analyzers (17)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\EmbeddedLanguages\VirtualChars\CSharpVirtualCharService.cs (3)
186var parentSourceText = parentExpression.SyntaxTree.GetText(); 191var tokenSourceText = SourceText.From(token.Text);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxNodeExtensions.cs (2)
61this SyntaxNode node, SourceText? sourceText = null, 71this SyntaxToken token, SourceText? sourceText = null,
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxTokenExtensions.cs (1)
168public static bool IsFirstTokenOnLine(this SyntaxToken token, SourceText text)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxTreeExtensions.cs (1)
351var sourceText = token.SyntaxTree!.GetText(cancellationToken);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Indentation\CSharpSmartTokenFormatter.cs (2)
27private readonly SourceText _text; 33SourceText text)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\RefactoringHelpers\CSharpRefactoringHelpers.cs (1)
30public override bool IsBetweenTypeMembers(SourceText sourceText, SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? typeDeclaration)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\FormattingRangeHelper.cs (1)
279if (tree != null && tree.TryGetText(out var text))
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Indentation\CSharpIndentationService.cs (1)
144var text = node.SyntaxTree.GetText();
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Indentation\CSharpIndentationService.Indenter.cs (5)
26CompilationUnitSyntax root, SourceText text, TextLine lineToBeIndented, 76var sourceText = indenter.LineToBeIndented.Text; 346var sourceText = indenter.LineToBeIndented.Text; 384var sourceText = indenter.LineToBeIndented.Text; 470var sourceText = indenter.LineToBeIndented.Text;
Roslyn.Diagnostics.VisualBasic.Analyzers (2)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Services\RefactoringHelpers\VisualBasicRefactoringHelpers.vb (1)
23Public Overrides Function IsBetweenTypeMembers(sourceText As SourceText, root As SyntaxNode, position As Integer, ByRef typeDeclaration As SyntaxNode) As Boolean
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\Indentation\VisualBasicIndentationService.Indenter.vb (1)
42text As SourceText,
SuperFileCheck (2)
Program.cs (2)
265var syntaxTree = CSharpSyntaxTree.ParseText(SourceText.From(File.ReadAllText(filePath))); 341var text = line.Text;
System.Private.CoreLib.Generators (1)
NativeRuntimeEventSourceGenerator.cs (1)
56spc.AddSource($"{className}.g.cs", SourceText.From(source, System.Text.Encoding.UTF8));
System.Text.Json.SourceGeneration (18)
JsonSourceGenerator.Emitter.cs (15)
90private partial void AddSource(string hintName, SourceText sourceText); 105SourceText? sourceText = GenerateTypeInfo(contextGenerationSpec, typeGenerationSpec); 176private static SourceText CompleteSourceFileAndReturnText(SourceWriter writer) 187private SourceText? GenerateTypeInfo(ContextGenerationSpec contextSpec, TypeGenerationSpec typeGenerationSpec) 225private static SourceText GenerateForTypeWithBuiltInConverter(ContextGenerationSpec contextSpec, TypeGenerationSpec typeMetadata) 242private static SourceText GenerateForTypeWithCustomConverter(ContextGenerationSpec contextSpec, TypeGenerationSpec typeMetadata) 263private static SourceText GenerateForNullable(ContextGenerationSpec contextSpec, TypeGenerationSpec typeMetadata) 284private static SourceText GenerateForUnsupportedType(ContextGenerationSpec contextSpec, TypeGenerationSpec typeMetadata) 300private static SourceText GenerateForEnum(ContextGenerationSpec contextSpec, TypeGenerationSpec typeMetadata) 316private SourceText GenerateForCollection(ContextGenerationSpec contextSpec, TypeGenerationSpec typeGenerationSpec) 496private SourceText GenerateForObject(ContextGenerationSpec contextSpec, TypeGenerationSpec typeMetadata) 613private static SourceText GenerateForUnion(ContextGenerationSpec contextSpec, TypeGenerationSpec typeMetadata) 1824private static SourceText GetRootJsonContextImplementation(ContextGenerationSpec contextSpec, bool emitGetConverterForNullablePropertyMethod, bool emitValueTypeSetterDelegate) 2113private static SourceText GetGetTypeInfoImplementation(ContextGenerationSpec contextSpec) 2155private SourceText GetPropertyNameInitialization(ContextGenerationSpec contextSpec)
JsonSourceGenerator.Roslyn4.0.cs (1)
140private partial void AddSource(string hintName, SourceText sourceText)
src\runtime\src\libraries\Common\src\SourceGenerators\SourceWriter.cs (2)
64public SourceText ToSourceText() 67return SourceText.From(_sb.ToString(), Encoding.UTF8);
System.Windows.Forms.Analyzers (1)
System\Windows\Forms\Analyzers\AppManifestAnalyzer.cs (1)
38SourceText? appManifestXml = appManifest.GetText(context.CancellationToken);