8 types derived from SourceText
Microsoft.CodeAnalysis (6)
Text\ChangedText.cs (1)
15internal sealed class ChangedText : SourceText
Text\CompositeText.cs (1)
20internal sealed class CompositeText : SourceText
Text\LargeText.cs (1)
20internal sealed class LargeText : SourceText
Text\StringBuilderText.cs (1)
15internal sealed partial class StringBuilderText : SourceText
Text\StringText.cs (1)
18internal sealed class StringText : SourceText
Text\SubText.cs (1)
13internal sealed class SubText : SourceText
Microsoft.CodeAnalysis.EditorFeatures.Text (1)
Extensions.SnapshotSourceText.cs (1)
25private class SnapshotSourceText : SourceText
Microsoft.CodeAnalysis.Test.Utilities (1)
Syntax\SourceUtilities.cs (1)
12internal sealed class RandomizedSourceText : SourceText
3674 references to SourceText
BuildValidator (4)
LocalSourceResolver.cs (3)
30public SourceText ResolveSource(SourceTextInfo sourceTextInfo) 51var sourceText = SourceText.From(fileStream, encoding: sourceTextInfo.SourceTextEncoding, checksumAlgorithm: sourceTextInfo.HashAlgorithm, canBeEmbedded: false);
RebuildArtifactResolver.cs (1)
27public SourceText ResolveSourceText(SourceTextInfo sourceTextInfo)
IdeCoreBenchmarks (11)
IncrementalSourceGeneratorBenchmarks.cs (2)
170var sourceText = syntaxTree.GetText(); 178var changedText = sourceText.WithChanges(new TextChange(sourceText.Lines[0].Span, $"// added text{i}"));
ProjectOperationBenchmarks.cs (4)
17private static readonly SourceText s_newText = SourceText.From("text"); 68var emptySourceText = SourceText.From("", Encoding.UTF8);
SerializationBenchmarks.cs (1)
43var tree = SyntaxFactory.ParseSyntaxTree(SourceText.From(text, encoding: null, SourceHashAlgorithms.Default));
SyntacticChangeRangeBenchmark.cs (4)
22private SourceText _text; 43_text = SourceText.From(text); 54var newText = _text.WithChanges(new TextChange(new TextSpan(_index + 8, 1), "m")); 63var newText = _text.WithChanges(new TextChange(new TextSpan(_index, 0), "var v = x "));
Microsoft.CodeAnalysis (232)
AdditionalTextFile.cs (6)
20private readonly Lazy<SourceText?> _text; 33_text = new Lazy<SourceText?>(ReadText); 36private SourceText? ReadText() 39var text = _compiler.TryReadFileContent(_sourceFile, diagnostics); 50/// Returns a <see cref="SourceText"/> with the contents of this file, or <c>null</c> if 53public override SourceText? GetText(CancellationToken cancellationToken = default) => _text.Value;
CommandLine\AnalyzerConfig.cs (2)
160return Parse(SourceText.From(text), pathToFile); 167public static AnalyzerConfig Parse(SourceText text, string? pathToFile)
CommandLine\CommonCompiler.cs (3)
253internal SourceText? TryReadFileContent(CommandLineSourceFile file, IList<DiagnosticInfo> diagnostics) 265internal SourceText? TryReadFileContent(CommandLineSourceFile file, IList<DiagnosticInfo> diagnostics, out string? normalizedFilePath) 1042var sourceText = tree.GetText(cancellationToken);
Compilation\DeterministicKey.cs (2)
23public abstract SourceText GetText(CancellationToken cancellationToken = default); 43public override SourceText GetText(CancellationToken cancellationToken = default)
Compilation\DeterministicKeyBuilder.cs (1)
269private void WriteSourceText(JsonWriter writer, SourceText? sourceText)
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\AnalysisContextInfo.cs (1)
111var text = _file.Value.SourceTree.GetText();
DiagnosticAnalyzer\DiagnosticAnalysisContext.cs (6)
230/// <param name="text"><see cref="SourceText"/> for which the value is queried.</param> 234public bool TryGetValue<TValue>(SourceText text, SourceTextValueProvider<TValue> valueProvider, [MaybeNullWhen(false)] out TValue value) 479/// <param name="text"><see cref="SourceText"/> for which the value is queried.</param> 483public bool TryGetValue<TValue>(SourceText text, SourceTextValueProvider<TValue> valueProvider, [MaybeNullWhen(false)] out TValue value) 586/// <param name="text"><see cref="SourceText"/> for which the value is queried.</param> 590public 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)
53/// Initializes an instance of <see cref="SourceText"/> from the provided stream. This version differs 54/// from <see cref="SourceText.From(Stream, Encoding, SourceHashAlgorithm, bool)"/> in two ways: 72internal static SourceText Create(Stream stream, 84internal static SourceText Create(Stream stream, 117/// Try to create a <see cref="SourceText"/> from the given stream using the given encoding. 124/// <returns>The <see cref="SourceText"/> decoded from the stream.</returns> 127private static SourceText Decode( 146return SourceText.From(bytes.Array, 156return SourceText.From(data, encoding, checksumAlgorithm, throwIfBinaryDetected, canBeEmbedded); 230internal static SourceText Create(Stream stream, Lazy<Encoding> getEncoding, Encoding defaultEncoding, SourceHashAlgorithm checksumAlgorithm, bool canBeEmbedded) 233internal static SourceText Decode(Stream data, Encoding encoding, SourceHashAlgorithm checksumAlgorithm, bool throwIfBinaryDetected, bool canBeEmbedded)
InternalUtilities\AdditionalTextComparer.cs (3)
35var xText = GetTextOrNullIfBinary(x); 36var yText = GetTextOrNullIfBinary(y); 59private static SourceText? GetTextOrNullIfBinary(AdditionalText text)
SourceGeneration\AdditionalSourcesCollection.cs (1)
37public void Add(string hintName, SourceText source)
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)
82public void AddSource(string hintName, string source) => AddSource(hintName, SourceText.From(source, Encoding.UTF8)); 85/// Adds a <see cref="SourceText"/> to the compilation 88/// <param name="sourceText">The <see cref="SourceText"/> to add to the compilation</param> 92public void AddSource(string hintName, SourceText sourceText) => _additionalSources.Add(hintName, sourceText); 266public void AddSource(string hintName, string source) => AddSource(hintName, SourceText.From(source, Encoding.UTF8)); 269/// Adds a <see cref="SourceText"/> to the compilation that will be available during subsequent phases 272/// <param name="sourceText">The <see cref="SourceText"/> to add to the compilation</param> 276public void AddSource(string hintName, SourceText sourceText) => _additionalSources.Add(hintName, sourceText);
SourceGeneration\IncrementalContexts.cs (8)
109public void AddSource(string hintName, string source) => AddSource(hintName, SourceText.From(source, Encoding.UTF8)); 112/// Adds a <see cref="SourceText"/> to the compilation that will be available during subsequent phases 115/// <param name="sourceText">The <see cref="SourceText"/> to add to the compilation</param> 119public void AddSource(string hintName, SourceText sourceText) => AdditionalSources.Add(hintName, sourceText); 144public void AddSource(string hintName, string source) => AddSource(hintName, SourceText.From(source, Encoding.UTF8)); 147/// Adds a <see cref="SourceText"/> to the compilation 150/// <param name="sourceText">The <see cref="SourceText"/> to add to the compilation</param> 154public void AddSource(string hintName, SourceText sourceText) => Sources.Add(hintName, sourceText);
SourceGeneration\ISourceGenerator.cs (1)
33/// to add source files via the <see cref="GeneratorExecutionContext.AddSource(string, SourceText)"/>
SourceGeneration\RunResults.cs (4)
57/// The <see cref="SyntaxTree"/>s produced during this generation pass by parsing each <see cref="SourceText"/> added by each generator. 149/// Represents the results of an <see cref="ISourceGenerator"/> calling <see cref="GeneratorExecutionContext.AddSource(string, SourceText)"/>. 156internal GeneratedSourceResult(SyntaxTree tree, SourceText text, string hintName) 171public 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)
313/// Gets the full text of this node as a new <see cref="SourceText"/> instance. 318/// If the encoding is not specified the <see cref="SourceText"/> isn't debuggable. 319/// If an encoding-less <see cref="SourceText"/> is written to a file a <see cref="Encoding.UTF8"/> shall be used as a default. 325public SourceText GetText(Encoding? encoding = null, SourceHashAlgorithm checksumAlgorithm = SourceHashAlgorithm.Sha1)
Syntax\SyntaxTree.cs (6)
93public abstract bool TryGetText([NotNullWhen(true)] out SourceText? text); 98public abstract SourceText GetText(CancellationToken cancellationToken = default); 119public virtual Task<SourceText> GetTextAsync(CancellationToken cancellationToken = default) 121return Task.FromResult(this.TryGetText(out SourceText? text) ? text : this.GetText(cancellationToken)); 171public abstract SyntaxTree WithChangedText(SourceText newText); 360var text = this.GetText();
Syntax\SyntaxTreeExtensions.cs (1)
23var text = tree.GetText();
Text\ChangedText.cs (21)
17private readonly SourceText _newText; 20public ChangedText(SourceText oldText, SourceText newText, ImmutableArray<TextChangeRange> changeRanges) 31_info = new ChangeInfo(changeRanges, new WeakReference<SourceText>(oldText), (oldText as ChangedText)?._info); 35SourceText oldText, SourceText newText, ImmutableArray<TextChangeRange> changeRanges) 66public WeakReference<SourceText> WeakOldText { get; } 70public ChangeInfo(ImmutableArray<TextChangeRange> changeRanges, WeakReference<SourceText> weakOldText, ChangeInfo? previous) 85SourceText? tmp; 123internal override ImmutableArray<SourceText> Segments 128internal override SourceText StorageKey 143public override SourceText GetSubText(TextSpan span) 153public override SourceText WithChanges(IEnumerable<TextChange> changes) 170public override IReadOnlyList<TextChangeRange> GetChangeRanges(SourceText oldText) 183SourceText? actualOldText; 210private bool IsChangedFrom(SourceText oldText) 214SourceText? text; 224private static IReadOnlyList<ImmutableArray<TextChangeRange>> GetChangesBetween(SourceText oldText, ChangedText newText) 233SourceText? actualOldText; 271SourceText? oldText; 325var text = GetSubText(new TextSpan(changeStart, change.NewLength));
Text\CompositeText.cs (27)
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) 62internal override ImmutableArray<SourceText> Segments 78public override SourceText GetSubText(TextSpan span) 89var newSegments = ArrayBuilder<SourceText>.GetInstance(); 94var segment = _segments[segIndex]; 152var segment = _segments[segIndex]; 164internal static void AddSegments(ArrayBuilder<SourceText> segments, SourceText text) 177internal static SourceText ToSourceText(ArrayBuilder<SourceText> segments, SourceText original, bool adjustSegments) 187return SourceText.From(string.Empty, original.Encoding, original.ChecksumAlgorithm); 207private static void ReduceSegmentCountIfNecessary(ArrayBuilder<SourceText> segments) 228private static int GetMinimalSegmentSizeToUseForCombining(ArrayBuilder<SourceText> segments) 248private static int GetSegmentCountIfCombined(ArrayBuilder<SourceText> segments, int segmentSize) 281private static void CombineSegments(ArrayBuilder<SourceText> segments, int segmentSize) 315var newText = writer.ToSourceText(); 323private static readonly ObjectPool<HashSet<SourceText>> s_uniqueSourcesPool 324= new ObjectPool<HashSet<SourceText>>(() => new HashSet<SourceText>(), 5); 329private static void ComputeLengthAndStorageSize(IReadOnlyList<SourceText> segments, out int length, out int size) 336var segment = segments[i]; 342foreach (var segment in uniqueSources) 354private static void TrimInaccessibleText(ArrayBuilder<SourceText> segments) 366foreach (var segment in segments)
Text\LargeText.cs (7)
17/// A <see cref="SourceText"/> optimized for very large sources. The text is stored as 25internal const int ChunkSize = SourceText.LargeObjectHeapLimitInChars; // 40K Unicode chars is 80KB which is less than the large object heap limit. 54internal static SourceText Decode(Stream stream, Encoding encoding, SourceHashAlgorithm checksumAlgorithm, bool throwIfBinaryDetected, bool canBeEmbedded) 61return SourceText.From(string.Empty, encoding, checksumAlgorithm); 80internal static SourceText Decode(TextReader reader, int length, Encoding? encodingOpt, SourceHashAlgorithm checksumAlgorithm) 84return SourceText.From(string.Empty, encodingOpt, checksumAlgorithm); 226/// Called from <see cref="SourceText.Lines"/> to initialize the <see cref="TextLineCollection"/>. Thereafter,
Text\LargeTextWriter.cs (1)
30public override SourceText ToSourceText()
Text\SourceText.cs (47)
80/// Constructs a <see cref="SourceText"/> from text in a string. 86/// If the encoding is not specified the resulting <see cref="SourceText"/> isn't debuggable. 87/// If an encoding-less <see cref="SourceText"/> is written to a file a <see cref="Encoding.UTF8"/> shall be used as a default. 94public static SourceText From(string text, Encoding? encoding = null, SourceHashAlgorithm checksumAlgorithm = SourceHashAlgorithm.Sha1) 105/// Constructs a <see cref="SourceText"/> from text in a string. 112/// If the encoding is not specified the resulting <see cref="SourceText"/> isn't debuggable. 113/// If an encoding-less <see cref="SourceText"/> is written to a file a <see cref="Encoding.UTF8"/> shall be used as a default. 120public static SourceText From( 143public static SourceText From(Stream stream, Encoding? encoding, SourceHashAlgorithm checksumAlgorithm, bool throwIfBinaryDetected) 147/// Constructs a <see cref="SourceText"/> from stream content. 169public static SourceText From( 214public static SourceText From(byte[] buffer, int length, Encoding? encoding, SourceHashAlgorithm checksumAlgorithm, bool throwIfBinaryDetected) 218/// Constructs a <see cref="SourceText"/> from a byte array. 238public static SourceText From( 381/// If an encoding-less <see cref="SourceText"/> is written to a file a <see cref="Encoding.UTF8"/> shall be used as a default. 399internal virtual ImmutableArray<SourceText> Segments 401get { return ImmutableArray<SourceText>.Empty; } 404internal virtual SourceText StorageKey 460/// The container of this <see cref="SourceText"/>. 486/// Gets a <see cref="SourceText"/> that contains the characters in the specified span of this text. 488public virtual SourceText GetSubText(TextSpan span) 495return SourceText.From(string.Empty, this.Encoding, this.ChecksumAlgorithm); 508/// Returns a <see cref="SourceText"/> that has the contents of this text including and after the start position. 510public SourceText GetSubText(int start) 528/// Write this <see cref="SourceText"/> to a text writer. 638public virtual SourceText WithChanges(IEnumerable<TextChange> changes) 650var segments = ArrayBuilder<SourceText>.GetInstance(); 688var subText = this.GetSubText(new TextSpan(position, change.Span.Start - position)); 694var segment = SourceText.From(change.NewText!, this.Encoding, this.ChecksumAlgorithm); 711var subText = this.GetSubText(new TextSpan(position, this.Length - position)); 715var newText = CompositeText.ToSourceText(segments, this, adjustSegments: true); 739/// <exception cref="ArgumentException">If any changes are not in bounds of this <see cref="SourceText"/>.</exception> 741public SourceText WithChanges(params TextChange[] changes) 749public SourceText Replace(TextSpan span, string newText) 757public SourceText Replace(int start, int length, string newText) 767public virtual IReadOnlyList<TextChangeRange> GetChangeRanges(SourceText oldText) 789public virtual IReadOnlyList<TextChange> GetTextChanges(SourceText oldText) 854private readonly SourceText _text; 858public LineInfo(SourceText text, int[] lineStarts) 1025/// Compares the content with content of another <see cref="SourceText"/>. 1027public bool ContentEquals(SourceText other) 1046/// Implements equality comparison of the content of two different instances of <see cref="SourceText"/>. 1048protected virtual bool ContentEqualsImpl(SourceText other) 1147private readonly SourceText _text; 1149public StaticContainer(SourceText text) 1154public override SourceText CurrentText => _text;
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)
13/// A read-only, non-seekable <see cref="Stream"/> over a <see cref="SourceText"/>. 17private readonly SourceText _source; 31public SourceTextStream(SourceText source, int bufferSize = 2048, 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)
11/// A <see cref="SourceText"/> that represents a subrange of another <see cref="SourceText"/>. 15public SubText(SourceText text, TextSpan span) 37public SourceText UnderlyingText { get; } 48internal override SourceText StorageKey 73public 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 (4)
15private readonly SourceText? _text; 19private TextLine(SourceText text, int start, int endIncludingBreaks) 33public static TextLine FromSpan(SourceText text, TextSpan span) 87public 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.CodeStyle (52)
AbstractIndentation.cs (1)
29TSyntaxRoot root, SourceText text, TextLine lineToBeIndented, IndentationOptions options, AbstractFormattingRule baseFormattingRule);
AbstractIndentation.Indenter.cs (2)
36public readonly SourceText Text; 172var updatedSourceText = Text.WithChanges(changes);
AbstractSelectedMembers.cs (3)
46var text = await tree.GetTextAsync(cancellationToken).ConfigureAwait(false); 78SyntaxNode root, SourceText text, TextSpan textSpan, 165SourceText text, SyntaxNode root, SyntaxNode member, int position)
AbstractVirtualCharService.cs (1)
195protected static int ConvertTextAtIndexToRune(SourceText tokenText, int index, ImmutableSegmentedList<VirtualChar>.Builder result, int offset)
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;
CommonFormattingHelpers.cs (1)
153public static string GetText(this SourceText text, SyntaxToken token1, SyntaxToken token2)
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)
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)
EncodedStringText.cs (11)
53/// Initializes an instance of <see cref="SourceText"/> from the provided stream. This version differs 54/// from <see cref="SourceText.From(Stream, Encoding, SourceHashAlgorithm, bool)"/> in two ways: 72internal static SourceText Create(Stream stream, 84internal static SourceText Create(Stream stream, 117/// Try to create a <see cref="SourceText"/> from the given stream using the given encoding. 124/// <returns>The <see cref="SourceText"/> decoded from the stream.</returns> 127private static SourceText Decode( 146return SourceText.From(bytes.Array, 156return SourceText.From(data, encoding, checksumAlgorithm, throwIfBinaryDetected, canBeEmbedded); 230internal static SourceText Create(Stream stream, Lazy<Encoding> getEncoding, Encoding defaultEncoding, SourceHashAlgorithm checksumAlgorithm, bool canBeEmbedded) 233internal static SourceText Decode(Stream data, Encoding encoding, SourceHashAlgorithm checksumAlgorithm, bool throwIfBinaryDetected, bool canBeEmbedded)
FormattingAnalyzerHelper.cs (3)
23var oldText = tree.GetText(cancellationToken); 41if (oldText.GetSubText(new TextSpan(change.Span.Start + offset, change.NewText.Length)).ContentEquals(SourceText.From(change.NewText))) 50if (oldText.GetSubText(new TextSpan(change.Span.Start, change.NewText.Length)).ContentEquals(SourceText.From(change.NewText)))
IVirtualCharService.cs (1)
33/// in the original <see cref="SourceText"/> that the language created that char from.
J\s\src\Compilers\Core\Portable\Syntax\SyntaxTreeExtensions.cs\SyntaxTreeExtensions.cs (1)
23var text = tree.GetText();
J\s\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\SyntaxTreeExtensions.cs\SyntaxTreeExtensions.cs (2)
25var text = tree.GetText(cancellationToken); 102var text = tree.GetText(cancellationToken);
SourceTextExtensions_SharedWithCodeStyle.cs (5)
17public static string GetLeadingWhitespaceOfLineAtPosition(this SourceText text, int position) 33this SourceText text, TextSpan span, Func<int, CancellationToken, bool> isPositionHidden, CancellationToken cancellationToken) 45this SourceText text, TextSpan span, Func<int, CancellationToken, bool> isPositionHidden, 83public static bool AreOnSameLine(this SourceText text, SyntaxToken token1, SyntaxToken token2) 88public static bool AreOnSameLine(this SourceText text, int pos1, int pos2)
TextLineExtensions.cs (2)
48var text = line.Text; 69var text = line.Text;
TreeData.cs (1)
21if (root.SyntaxTree == null || !root.SyntaxTree.TryGetText(out var text))
TreeData.Debug.cs (1)
16public Debug(SyntaxNode root, SourceText text)
TreeData.NodeAndText.cs (2)
15private readonly SourceText _text; 17public NodeAndText(SyntaxNode root, SourceText text)
TreeData.StructuredTrivia.cs (2)
27var text = GetText(); 48private SourceText? GetText()
VirtualChar.cs (2)
18/// value of <c>9</c> as well as what <see cref="TextSpan"/> in the original <see cref="SourceText"/> they occupied. 45/// The span of characters in the original <see cref="SourceText"/> that represent this <see
Microsoft.CodeAnalysis.CodeStyle.Fixes (35)
AbstractConflictMarkerCodeFixProvider.cs (15)
73var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); 83SyntaxNode root, SourceText text, int position, 144SourceText text, int position, 208var text = startLine.Text!; 226var text = startLine.Text!; 244var text = currentLine.Text!; 302Action<SourceText, ArrayBuilder<TextChange>, int, int, int, int> addEdits, 305var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); 310var finalText = text.WithChanges(edits); 315SourceText text, ArrayBuilder<TextChange> edits, 328SourceText text, ArrayBuilder<TextChange> edits, 341SourceText text, ArrayBuilder<TextChange> edits, 375private static int GetEndIncludingLineBreak(SourceText text, int position) 391var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); 430var finalText = text.WithChanges(edits);
AbstractUseConditionalExpressionCodeFixProvider.cs (1)
143var sourceText = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
AddParameterEditor.cs (2)
25var sourceText = declaration.SyntaxTree.GetText(cancellationToken); 159var text = parameters[0].SyntaxTree.GetText(cancellationToken);
FormattingCodeFixHelper.cs (1)
20var text = await syntaxTree.GetTextAsync(cancellationToken).ConfigureAwait(false);
IIndentationService.cs (3)
67public static string GetIndentationString(this IndentationResult indentationResult, SourceText sourceText, bool useTabs, int tabSize) 78public static string GetIndentationString(this IndentationResult indentationResult, SourceText sourceText, SyntaxFormattingOptions options) 81public static string GetIndentationString(this IndentationResult indentationResult, SourceText sourceText, IndentationOptions options)
ParsedDocument.cs (5)
21/// 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 27internal readonly record struct ParsedDocument(DocumentId Id, SourceText Text, SyntaxNode Root, HostLanguageServices HostLanguageServices) 36var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); 50public ParsedDocument WithChangedText(SourceText text, CancellationToken cancellationToken) 58var text = root.SyntaxTree.GetText(cancellationToken);
SemanticDocument.cs (2)
17private SemanticDocument(Document document, SourceText text, SyntaxNode root, SemanticModel semanticModel) 25var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
SyntacticDocument.cs (3)
15public readonly SourceText Text; 18protected SyntacticDocument(Document document, SourceText text, SyntaxNode root) 30var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
TextDocumentExtensions.cs (3)
15public static TextDocument WithText(this TextDocument textDocument, SourceText text) 36public static TextDocument WithAdditionalDocumentText(this TextDocument textDocument, SourceText text) 45public static TextDocument WithAnalyzerConfigDocumentText(this TextDocument textDocument, SourceText text)
Microsoft.CodeAnalysis.CodeStyle.LegacyTestFramework.UnitTestUtilities (5)
AbstractCodeActionOrUserDiagnosticTest.cs (5)
245SourceText.From(analyzerConfigText), 697var root = await additionalDoc.GetTextAsync(); 699var expectedRoot = await expectedDocument.GetTextAsync(); 705var root = await analyzerConfigDoc.GetTextAsync(); 715var expectedRoot = await expectedDocument.GetTextAsync();
Microsoft.CodeAnalysis.CodeStyle.UnitTestUtilities (5)
CodeFixVerifierHelper.cs (4)
99var text = ConvertOptionsToAnalyzerConfig(options.DefaultExtension, explicitEditorConfig: string.Empty, options); 103public static SourceText? ConvertOptionsToAnalyzerConfig(string defaultFileExtension, string? explicitEditorConfig, OptionsCollection options) 107return explicitEditorConfig is object ? SourceText.From(explicitEditorConfig, Encoding.UTF8) : null; 136return SourceText.From(analyzerConfig.ToString(), Encoding.UTF8);
SharedVerifierState.cs (1)
59var analyzerConfigSource = CodeFixVerifierHelper.ConvertOptionsToAnalyzerConfig(_defaultFileExt, EditorConfig, Options);
Microsoft.CodeAnalysis.CSharp (48)
Binder\Binder_InterpolatedString.cs (1)
78var text = node.SyntaxTree.GetText();
CommandLine\CSharpCompiler.cs (2)
182var content = TryReadFileContent(file, fileDiagnostics, out normalizedFilePath); 204SourceText content,
Compilation\SyntaxAndDeclarationManager.cs (1)
219var code = resolver.ReadText(resolvedFilePath);
Parser\AbstractLexer.cs (1)
19protected AbstractLexer(SourceText text)
Parser\LanguageParser_InterpolatedString.cs (3)
73using var tempLexer = new Lexer(SourceText.From(originalText), this.Options, allowPreprocessorDirectives: false); 373using var tempLexer = new Lexer(SourceText.From(expressionText), options, allowPreprocessorDirectives: false, interpolationFollowedByColon: interpolation.HasColon); 463using var tempLexer = new Lexer(SourceText.From(fakeString), this.Options, allowPreprocessorDirectives: false);
Parser\Lexer.cs (2)
109public Lexer(SourceText text, CSharpParseOptions options, bool allowPreprocessorDirectives = true, bool interpolationFollowedByColon = false) 2419var text = TextWindow.Text;
Parser\SlidingTextWindow.cs (3)
43private readonly SourceText _text; // Source of text to parse. 63public SlidingTextWindow(SourceText text) 84public SourceText Text => _text;
Syntax\CSharpLineDirectiveMap.cs (3)
28protected override LineMappingEntry GetEntry(DirectiveTriviaSyntax directiveNode, SourceText sourceText, LineMappingEntry previous) 174public override LineVisibility GetLineVisibility(SourceText sourceText, int position) 222internal override FileLinePositionSpan TranslateSpanAndVisibility(SourceText sourceText, string treeFilePath, TextSpan span, out bool isHiddenPosition)
Syntax\CSharpSyntaxTree.cs (10)
380internal static SyntaxTree CreateForDebugger(CSharpSyntaxNode root, SourceText text, CSharpParseOptions options) 416SourceText text, 460return ParseText(SourceText.From(text, encoding, SourceHashAlgorithm.Sha1), options, path, diagnosticOptions, isGeneratedCode, cancellationToken); 471SourceText text, 491SourceText text, 534public override SyntaxTree WithChangedText(SourceText newText) 537if (this.TryGetText(out SourceText? oldText)) 553private SyntaxTree WithChanges(SourceText newText, IReadOnlyList<TextChangeRange> changes) 920SourceText text, 937=> 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 (9)
1561return CSharpSyntaxTree.ParseText(SourceText.From(text, encoding, SourceHashAlgorithm.Sha1), (CSharpParseOptions?)options, path, diagnosticOptions: null, isGeneratedCode: null, cancellationToken); 1565/// <inheritdoc cref="CSharpSyntaxTree.ParseText(SourceText, CSharpParseOptions?, string, CancellationToken)"/> 1567SourceText text, 1899private static SourceText MakeSourceText(string text, int offset) 1901return SourceText.From(text, Encoding.UTF8).GetSubText(offset); 2778return ParseSyntaxTree(SourceText.From(text, encoding), options, path, diagnosticOptions, isGeneratedCode: null, cancellationToken); 2785SourceText text, 2806return ParseSyntaxTree(SourceText.From(text, encoding), options, path, diagnosticOptions, isGeneratedCode, cancellationToken); 2813SourceText text,
Microsoft.CodeAnalysis.CSharp.CodeStyle (15)
ConsecutiveBracePlacementDiagnosticAnalyzer.cs (4)
50var text = tree.GetText(cancellationToken); 74private void ProcessToken(SyntaxTreeAnalysisContext context, ReportDiagnostic severity, SourceText text, SyntaxToken token) 88SourceText text, SyntaxToken token, 129var text = textLine.Text!;
ConstructorInitializerPlacementDiagnosticAnalyzer.cs (1)
65var sourceText = context.Tree.GetText(context.CancellationToken);
CSharpSmartTokenFormatter.cs (2)
28private readonly SourceText _text; 34SourceText text)
CSharpVirtualCharService.cs (3)
186var parentSourceText = parentExpression.SyntaxTree.GetText(); 191var tokenSourceText = SourceText.From(token.Text);
FormattingRangeHelper.cs (1)
300if (tree != null && tree.TryGetText(out var text))
J\s\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxTreeExtensions.cs\SyntaxTreeExtensions.cs (1)
377var sourceText = token.SyntaxTree!.GetText(cancellationToken);
SyntaxNodeExtensions.cs (2)
60this SyntaxNode node, SourceText? sourceText = null, 70this SyntaxToken token, SourceText? sourceText = null,
SyntaxTokenExtensions.cs (1)
112public static bool IsFirstTokenOnLine(this SyntaxToken token, SourceText text)
Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes (27)
AddInheritdocCodeFixProvider.cs (1)
92SourceText? sourceText = null;
ArrowExpressionClausePlacementCodeFixProvider.cs (3)
52var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); 66var changedText = text.WithChanges(edits); 71SourceText text,
ConditionalExpressionPlacementCodeFixProvider.cs (3)
52var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); 67var changedText = text.WithChanges(edits); 72SourceText text,
ConsecutiveBracePlacementCodeFixProvider.cs (2)
53var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); 66SyntaxNode root, SourceText text,
ConstructorInitializerPlacementCodeFixProvider.cs (1)
50var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
ConvertNamespaceTransform.cs (5)
73public static (SourceText text, TextSpan semicolonSpan) ConvertNamespaceDeclaration(ParsedDocument document, NamespaceDeclarationSyntax namespaceDeclaration, SyntaxFormattingOptions options, CancellationToken cancellationToken) 119private static (SourceText text, TextSpan semicolonSpan) DedentNamespace( 123var text = document.Text; 133var dedentedText = text.WithChanges(changes); 138SyntaxTree tree, SourceText text, string indentation, TextLine textLine, CancellationToken cancellationToken)
CSharpAddParenthesesAroundConditionalExpressionInInterpolatedStringCodeFixProvider.cs (4)
65var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); 67var textWithOpenParenthesis = text.Replace(openParenthesisPosition, 0, "("); 88var sourceText = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); 117var textWithCloseParenthesis = sourceText.Replace(closeParenPosition, 0, ")");
CSharpIndentationService.cs (1)
147var text = node.SyntaxTree.GetText();
CSharpIndentationService.Indenter.cs (5)
29CompilationUnitSyntax root, SourceText text, TextLine lineToBeIndented, 79var sourceText = indenter.LineToBeIndented.Text; 345var sourceText = indenter.LineToBeIndented.Text; 383var sourceText = indenter.LineToBeIndented.Text; 469var sourceText = indenter.LineToBeIndented.Text;
CSharpInlineDeclarationCodeFixProvider.cs (2)
119var sourceText = currentRoot.GetText(); 280SourceText sourceText, IdentifierNameSyntax identifier,
Microsoft.CodeAnalysis.CSharp.CommandLine.UnitTests (2)
CommandLineTests.cs (2)
2430SourceText embeddedSource = mdReader.GetEmbeddedSource(handle); 13353context.AddSource("hint2", SourceText.From("class G2 { void F() {} }", Encoding.UTF8, checksumAlgorithm: SourceHashAlgorithm.Sha1));
Microsoft.CodeAnalysis.CSharp.EditorFeatures (44)
AutomaticCompletion\AutomaticLineEnderCommandHandler.cs (3)
146var text = document.Text; 202private static bool CheckLocation(SourceText text, int position, SyntaxNode owningNode, SyntaxToken lastToken) 259private static bool TryGetLastToken(SourceText text, int position, SyntaxNode owningNode, out SyntaxToken lastToken)
ConvertNamespace\ConvertNamespaceCommandHandler.cs (1)
107private (SourceText? convertedText, TextSpan semicolonSpan) ConvertNamespace(
DecompiledSource\CSharpDecompiledSourceService.cs (1)
120return document.WithText(SourceText.From(text, encoding: null, checksumAlgorithm: SourceHashAlgorithms.Default));
EventHookup\EventHookupCommandHandler_TabKeyCommand.cs (1)
209var newText = document.GetTextSynchronously(cancellationToken).WithChanges(textChange);
Interactive\CSharpInteractiveEvaluatorLanguageInfoProvider.cs (1)
48=> SyntaxFactory.IsCompleteSubmission(SyntaxFactory.ParseSyntaxTree(SourceText.From(text, encoding: null, SourceHashAlgorithms.Default), options: s_parseOptions));
Interactive\CSharpSendToInteractiveSubmissionProvider.cs (1)
31var tree = SyntaxFactory.ParseSyntaxTree(SourceText.From(code, encoding: null, SourceHashAlgorithms.Default), options);
StringCopyPaste\AbstractPasteProcessor.cs (4)
42protected readonly SourceText TextBeforePaste; 47protected readonly SourceText TextAfterPaste; 143SourceText textAfterChange, ImmutableArray<TextSpan> textContentSpansAfterChange) 158SourceText textAfterChange, ImmutableArray<TextSpan> textContentSpansAfterChange)
StringCopyPaste\KnownSourcePasteProcessor.cs (5)
161PerformInitialBasicPasteInRawString(out var textAfterBasicPaste, out var contentSpansAfterBasicPaste); 170out SourceText textAfterBasicPaste, out ImmutableArray<TextSpan> contentSpansAfterBasicPaste) 297SourceText? lastContentSourceText = null; 301var sourceText = SourceText.From(content.TextValue);
StringCopyPaste\StringCopyPasteCommandHandler.cs (5)
156var newTextAfterChanges = snapshotBeforePaste.AsText().WithChanges(textChanges); 249SourceText textBeforePaste, 307SourceText newTextAfterChanges) 316var originalStringContentsAfterPaste = snapshotAfterPaste.AsText().GetSubText(spanAfterPaste); 317var newStringContentsAfterEdit = newTextAfterChanges.GetSubText(spanAfterPaste);
StringCopyPaste\StringCopyPasteHelpers.cs (11)
32public static char SafeCharAt(SourceText text, int index) 107public static int GetFirstNonWhitespaceIndex(SourceText text, TextLine line) 172public static int SkipU8Suffix(SourceText text, int end) 186public static int GetLongestQuoteSequence(SourceText text, TextSpan span) 189public static int GetLongestOpenBraceSequence(SourceText text, TextSpan span) 192public static int GetLongestCloseBraceSequence(SourceText text, TextSpan span) 200private static int GetLongestCharacterSequence(SourceText text, TextSpan span, char character) 506var text = SourceText.From(change.NewText); 524private static string? GetCommonIndentationPrefix(string? commonIndentPrefix, SourceText text, TextSpan lineWhitespaceSpan) 545public static bool RawContentMustBeMultiLine(SourceText text, ImmutableArray<TextSpan> spans)
StringCopyPaste\StringInfo.cs (5)
73public static StringInfo GetStringInfo(SourceText text, ExpressionSyntax stringExpression) 81private static StringInfo GetStringLiteralInfo(SourceText text, LiteralExpressionSyntax literal) 95private static StringInfo GetRawStringLiteralInfo(SourceText text, LiteralExpressionSyntax literal) 167private static StringInfo GetNormalStringLiteralStringInfo(SourceText text, LiteralExpressionSyntax literal) 193SourceText text, InterpolatedStringExpressionSyntax interpolatedString)
StringCopyPaste\UnknownSourcePasteProcessor.cs (6)
153/// <inheritdoc cref="AbstractPasteProcessor.GetQuotesToAddToRawString(SourceText, ImmutableArray{TextSpan})" /> 157/// <inheritdoc cref="AbstractPasteProcessor.GetDollarSignsToAddToRawString(SourceText, ImmutableArray{TextSpan})" /> 179SourceText? textOfCurrentChange = null; 186textOfCurrentChange = SourceText.From(change.NewText); 253var textOfCurrentChange = SourceText.From(change.NewText);
Microsoft.CodeAnalysis.CSharp.EditorFeatures.UnitTests (125)
CodeActions\ApplyChangesOperationTests.cs (7)
80return solution.WithDocumentText(document1.Id, SourceText.From("NewProgram1Content")); 85return solution.WithDocumentText(document2.Id, SourceText.From("NewProgram2Content")); 112return solution.WithDocumentText(document1.Id, SourceText.From("NewProgram1Content")); 144return solution.WithDocumentText(document1.Id, SourceText.From("NewProgram1Content1")); 149return solution.WithDocumentText(document1.Id, SourceText.From("NewProgram1Content2")); 175return solution.WithDocumentText(document1.Id, SourceText.From("NewProgram1Content1")); 212return solution.WithDocumentText(document2.Id, SourceText.From("NewProgram1Content2"));
CodeActions\MoveType\MoveTypeTests.MoveScope.cs (1)
939var formattedText = await formattedDocument.GetTextAsync().ConfigureAwait(false);
Completion\CompletionProviders\LoadDirectiveCompletionProviderTests.cs (1)
83Assert.Equal(expectedResult, provider.ShouldTriggerCompletion(languageServices.LanguageServices, SourceText.From(text), position, trigger: default, CompletionOptions.Default, OptionSet.Empty));
Completion\CompletionProviders\OverrideCompletionProviderTests.cs (2)
3281var text = await document.GetTextAsync(); 3282var newText = text.WithChanges(commit.TextChange);
Completion\CompletionProviders\ReferenceDirectiveCompletionProviderTests.cs (1)
120Assert.Equal(expectedResult, provider.ShouldTriggerCompletion(languageServices.LanguageServices, SourceText.From(text), position, trigger: default, CompletionOptions.Default, OptionSet.Empty));
Completion\CompletionServiceTests.cs (7)
50var text = SourceText.From("class C { }"); 81public override bool ShouldTriggerCompletion(SourceText text, int caretPosition, CompletionTrigger trigger, OptionSet options) 108var text = SourceText.From("class C { }"); 140var text = await document.GetTextAsync(); 185document = document.WithText(SourceText.From(sourceMarkup.Replace("C1", "C2")));
DecompiledSource\DecompiledSourceFormattingTests.cs (1)
232var test = await formatted.GetTextAsync();
Diagnostics\DiagnosticAnalyzerDriver\DiagnosticAnalyzerDriverTests.cs (1)
164var additionalText = new TestAdditionalText("add.config", SourceText.From("random text"));
EditAndContinue\CSharpEditAndContinueAnalyzerTests.cs (13)
47AddDocument("test.cs", SourceText.From(source, Encoding.UTF8), filePath: Path.Combine(TempRoot.Root, "test.cs")).Project.Solution; 305var oldText = await oldDocument.GetTextAsync(); 308var newSolution = oldSolution.WithDocumentText(documentId, SourceText.From(source2)); 310var newText = await newDocument.GetTextAsync(); 373var newSolution = oldSolution.WithDocumentText(documentId, SourceText.From(source2)); 435var newSolution = oldSolution.WithDocumentText(documentId, SourceText.From(source2)); 517var newSolution = workspace.CurrentSolution.WithDocumentText(documentId, SourceText.From(source2)); 586var newSolution = oldSolution.WithDocumentText(documentId, SourceText.From(source2)); 625var newSolution = oldSolution.WithDocumentText(documentId, SourceText.From(source2)); 666var newSolution = oldSolution.AddDocument(newDocId, "goo.cs", SourceText.From(source2), filePath: Path.Combine(TempRoot.Root, "goo.cs")); 712var newSolution = oldSolution.AddDocument(newDocId, "goo.cs", SourceText.From(source2), filePath: Path.Combine(TempRoot.Root, "goo.cs")); 745var newSolution = oldSolution.AddDocument(documentId, "goo.cs", SourceText.From(source2), filePath: filePath); 800var newSolution = oldSolution.WithDocumentText(documentId, SourceText.From(source2));
EditorConfigSettings\Updater\SettingsUpdaterTests.cs (13)
43.AddAnalyzerConfigDocument(DocumentId.CreateNewId(projectId), "editorcfg", SourceText.From(""), filePath: EditorconfigPath))); 55var text = SourceText.From(contents); 58Assert.True(analyzerConfigDocument!.TryGetText(out var actualText)); 67var sourcetext = await analyzerConfigDocument.GetTextAsync(default); 68var result = SettingsUpdateHelper.TryUpdateAnalyzerConfigDocument(sourcetext, analyzerConfigDocument.FilePath!, options); 76var sourcetext = await analyzerConfigDocument.GetTextAsync(default); 77var result = SettingsUpdateHelper.TryUpdateAnalyzerConfigDocument(sourcetext, analyzerConfigDocument.FilePath!, options); 365var text = await editorconfig.GetTextAsync(); 413var newText = await settingsProvider.GetChangedEditorConfigAsync(SourceText.From(string.Empty)); 594Task<SourceText> ISettingsEditorViewModel.UpdateEditorConfigAsync(SourceText sourceText)
ExtractMethod\ExtractMethodTests.cs (1)
11254.AddDocument("Document", SourceText.From(""));
Formatting\CodeCleanupTests.cs (3)
744project = project.AddAnalyzerConfigDocument(".editorconfig", SourceText.From(editorconfigText), filePath: @"z:\\.editorconfig").Project; 761var actual = await newDoc.GetTextAsync(); 845var actual = await newDoc.GetTextAsync();
Formatting\CodeCleanupTests.TestFixers.cs (2)
116return solution.AddDocument(DocumentId.CreateNewId(project.Id), "new.cs", SourceText.From("")); 172return solution.AddDocument(DocumentId.CreateNewId(project.Id), "new.cs", SourceText.From(""));
Formatting\Indentation\SmartTokenFormatterFormatTokenTests.cs (2)
567SourceText.From(code).Lines.IndexOf(position), 634SourceText.From(code).Lines.IndexOf(position),
Formatting\RazorLineFormattingOptionsTests.cs (3)
56var sourceText = SourceText.From(source, encoding: null, SourceHashAlgorithms.Default); 73var formattedText = await formattedDocument.GetTextAsync();
Intents\IntentTestsBase.cs (1)
116testDocument.Update(SourceText.From(currentDocumentText));
PdbSourceDocument\AbstractPdbSourceDocumentTests.cs (8)
123protected static async Task<(SourceText?, TextSpan)> GetGeneratedSourceTextAsync( 168var actual = await document.GetTextAsync(); 191var sourceText = SourceText.From(source, encoding: encoding ?? Encoding.UTF8); 199SourceText source, 241protected static void CompileTestSource(string path, SourceText source, Project project, Location pdbLocation, Location sourceLocation, bool buildReferenceAssembly, bool windowsPdb, Encoding? fallbackEncoding = null) 251protected static void CompileTestSource(string dllFilePath, string sourceCodePath, string? pdbFilePath, string assemblyName, SourceText source, Project project, Location pdbLocation, Location sourceLocation, bool buildReferenceAssembly, bool windowsPdb, Encoding? fallbackEncoding = null) 256protected static void CompileTestSource(string dllFilePath, string[] sourceCodePaths, string? pdbFilePath, string assemblyName, SourceText[] sources, Project project, Location pdbLocation, Location sourceLocation, bool buildReferenceAssembly, bool windowsPdb, Encoding? fallbackEncoding = null)
PdbSourceDocument\ImplementationAssemblyLookupServiceTests.cs (28)
43var sourceText = SourceText.From(metadataSource, encoding: Encoding.UTF8); 80var sourceText = SourceText.From(metadataSource, encoding: Encoding.UTF8); 121var sourceText = SourceText.From(metadataSource, encoding: Encoding.UTF8); 158var sourceText = SourceText.From(metadataSource, Encoding.UTF8); 182sourceText = SourceText.From(typeForwardSource, Encoding.UTF8); 218var sourceText = SourceText.From(metadataSource, encoding: Encoding.UTF8); 241sourceText = SourceText.From(typeForwardSource, Encoding.UTF8); 278var sourceText = SourceText.From(metadataSource, encoding: Encoding.UTF8); 301sourceText = SourceText.From(typeForwardSource, Encoding.UTF8); 332var sourceText = SourceText.From(metadataSource, encoding: Encoding.UTF8); 355sourceText = SourceText.From(typeForwardSource, Encoding.UTF8); 382var sourceText = SourceText.From(metadataSource, encoding: Encoding.UTF8); 405sourceText = SourceText.From(typeForwardSource, Encoding.UTF8); 446var sourceText = SourceText.From(metadataSource, encoding: Encoding.UTF8); 469sourceText = SourceText.From(typeForwardSource, Encoding.UTF8); 503var sourceText = SourceText.From(metadataSource, encoding: Encoding.UTF8); 526var typeForwardSourceText = SourceText.From(typeForwardSource, Encoding.UTF8);
PdbSourceDocument\PdbSourceDocumentTests.cs (19)
407var sourceText = SourceText.From(metadataSource, encoding: Encoding.UTF8); 436var sourceText = SourceText.From(metadataSource, encoding: Encoding.UTF8); 472var sourceText = SourceText.From(metadataSource, Encoding.UTF8); 519var sourceText = SourceText.From(metadataSource, Encoding.UTF8); 545sourceText = SourceText.From(typeForwardSource, Encoding.UTF8); 714CompileTestSource(path, SourceText.From(source2, Encoding.UTF8), project, Location.OnDisk, Location.OnDisk, buildReferenceAssembly: false, windowsPdb: false); 780var encodedSourceText = EncodedStringText.Create(ms, encoding, canBeEmbedded: true); 809var encodedSourceText = EncodedStringText.Create(ms, encoding, canBeEmbedded: true); 838var encodedSourceText = EncodedStringText.Create(ms, encoding, canBeEmbedded: true); 862var sourceText = SourceText.From(source, Encoding.UTF8); 914var sourceText1 = SourceText.From(source1, Encoding.UTF8); 915var sourceText2 = SourceText.From(source2, Encoding.UTF8);
StringIndentation\StringIndentationTests.cs (3)
43var text = SourceText.From(val); 62var changedText = text.WithChanges(changes);
Workspaces\WorkspaceTests_EditorFeatures.cs (8)
498var docZText = await docZ.GetTextAsync(); 674var newSolution = oldSolution.WithDocumentText(document.Id, SourceText.From(newText)); 702var newSolution = oldSolution.AddDocument(DocumentId.CreateNewId(project1.Id), "Doc2", SourceText.From(doc2Text)); 1051var newSolution = oldSolution.WithAdditionalDocumentText(additionalDoc.Id, SourceText.From(newText)); 1084var newSolution = oldSolution.WithAnalyzerConfigDocumentText(analyzerConfigDoc.Id, SourceText.From(newText)); 1206var newSolution = oldSolution.AddAnalyzerConfigDocument(newDocId, "app.config", SourceText.From("text")); 1268var doc = project.AddAnalyzerConfigDocument("app.config", SourceText.From("text")); 1350workspace.GetTestDocument(originalDocumentId).Update(SourceText.From("class Program2 { }"));
Microsoft.CodeAnalysis.CSharp.EditorFeatures2.UnitTests (5)
EmbeddedLanguages\RegularExpressions\CSharpRegexParserTests.cs (5)
125private (RegexTree, SourceText) TryParseTree( 141var sourceText = token.SyntaxTree.GetText(); 199private static string TreeToText(SourceText text, RegexTree tree) 218private static XElement CreateDiagnosticsElement(SourceText text, RegexTree tree) 226private static XAttribute GetTextAttribute(SourceText text, TextSpan span)
Microsoft.CodeAnalysis.CSharp.Emit.UnitTests (9)
CodeGen\CodeGenTupleTest.cs (3)
22644var text = SourceText.From(source1); 22649var newText = text.WithChanges(new TextChange(new TextSpan(pos, 0), " ")); // add space before closing-paren
PDB\CSharpPDBTestBase.cs (2)
39var text = SourceText.From(source);
PDB\PDBTests.cs (4)
40var tree3 = SyntaxFactory.ParseSyntaxTree(SourceText.From("class C { }", encoding: null), path: "Bar.cs"); 61var tree4 = SyntaxFactory.ParseSyntaxTree(SourceText.From("class D { public void F() { } }", new UTF8Encoding(false, false)), path: "Baz.cs"); 97context.AddSource("hint2", SourceText.From("class G2 { void F() {} }", Encoding.UTF8, checksumAlgorithm: SourceHashAlgorithm.Sha256)); 99Assert.Throws<ArgumentException>(() => context.AddSource("hint3", SourceText.From("class G3 { void F() {} }", encoding: null, checksumAlgorithm: SourceHashAlgorithm.Sha256)));
Microsoft.CodeAnalysis.CSharp.ExpressionEvaluator.ExpressionCompiler (11)
SyntaxHelpers.cs (11)
61var text = SourceText.From(expr, encoding: null, SourceHashAlgorithms.Default); 75var targetSyntax = ParseDebuggerExpressionInternal(SourceText.From(target, encoding: null, SourceHashAlgorithms.Default), consumeFullText: true); 83return assignment.MakeDebuggerExpression(SourceText.From(assignment.ToString(), encoding: null, SourceHashAlgorithms.Default)); 199var source = SourceText.From(text, encoding: null, SourceHashAlgorithms.Default); 204private static InternalSyntax.ExpressionSyntax ParseDebuggerExpressionInternal(SourceText source, bool consumeFullText) 217var source = SourceText.From(text, encoding: null, SourceHashAlgorithms.Default); 226private static SyntaxTree CreateSyntaxTree(this InternalSyntax.CSharpSyntaxNode root, SourceText text) 231private static ExpressionSyntax MakeDebuggerExpression(this InternalSyntax.ExpressionSyntax expression, SourceText text)
Microsoft.CodeAnalysis.CSharp.Features (114)
AddImport\CSharpAddMissingImportsFeatureService.cs (1)
30protected override ImmutableArray<AbstractFormattingRule> GetFormatRules(SourceText text)
AddInheritdocCodeFixProvider.cs (1)
92SourceText? sourceText = null;
ArrowExpressionClausePlacementCodeFixProvider.cs (3)
52var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); 66var changedText = text.WithChanges(edits); 71SourceText text,
BraceCompletion\AbstractCurlyBraceOrBracketCompletionService.cs (6)
62var formattedText = context.Document.Text.WithChanges(formattingChanges); 68private static bool ContainsOnlyWhitespace(SourceText text, int openingPosition, int closingBraceEndPoint) 94var originalDocumentText = document.Text; 151static TextLine GetLineBetweenCurlys(int closingPosition, SourceText text) 157static LinePosition GetIndentedLinePosition(ParsedDocument document, SourceText sourceText, int lineNumber, IndentationOptions options, CancellationToken cancellationToken) 169static ImmutableArray<TextChange> GetMergedChanges(TextChange? newLineEdit, ImmutableArray<TextChange> formattingChanges, SourceText formattedText)
BraceCompletion\InterpolatedStringBraceCompletionService.cs (2)
50protected override bool IsValidOpenBraceTokenAtPosition(SourceText text, SyntaxToken token, int position) 58var text = document.Text;
BraceCompletion\InterpolationBraceCompletionService.cs (1)
43protected override bool IsValidOpenBraceTokenAtPosition(SourceText text, SyntaxToken token, int position)
BraceCompletion\ParenthesisBraceCompletionService.cs (1)
37protected override bool IsValidOpenBraceTokenAtPosition(SourceText text, SyntaxToken token, int position)
BraceCompletion\StringLiteralBraceCompletionService.cs (1)
49protected override bool IsValidOpenBraceTokenAtPosition(SourceText text, SyntaxToken token, int position)
BraceMatching\BlockCommentBraceMatcher.cs (1)
28var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
CodeRefactorings\CSharpRefactoringHelpersService.cs (1)
33public override bool IsBetweenTypeMembers(SourceText sourceText, SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? typeDeclaration)
CodeRefactorings\InlineTemporary\InlineTemporaryCodeRefactoringProvider.cs (1)
372var text = await document.GetTextAsync(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 (3)
57public override bool IsInsertionTrigger(SourceText text, int characterPosition, CompletionOptions options) 80var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); 231private static TextSpan GetCompletionItemSpan(SourceText text, int position)
Completion\CompletionProviders\DeclarationName\DeclarationNameCompletionProvider.cs (1)
43public override bool IsInsertionTrigger(SourceText text, int insertedCharacterPosition, CompletionOptions options)
Completion\CompletionProviders\EnumAndCompletionListTagCompletionProvider.cs (1)
46public override bool IsInsertionTrigger(SourceText text, int characterPosition, CompletionOptions options)
Completion\CompletionProviders\ExplicitInterfaceMemberCompletionProvider.cs (1)
36public override bool IsInsertionTrigger(SourceText text, int characterPosition, CompletionOptions options)
Completion\CompletionProviders\ExplicitInterfaceTypeCompletionProvider.cs (1)
39public override bool IsInsertionTrigger(SourceText text, int insertedCharacterPosition, CompletionOptions options)
Completion\CompletionProviders\ExternAliasCompletionProvider.cs (2)
35public override bool IsInsertionTrigger(SourceText text, int characterPosition, CompletionOptions options) 81var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
Completion\CompletionProviders\FunctionPointerUnmanagedCallingConventionCompletionProvider.cs (1)
38public override bool IsInsertionTrigger(SourceText text, int characterPosition, CompletionOptions options)
Completion\CompletionProviders\ImportCompletion\ExtensionMethodImportCompletionProvider.cs (1)
34public override bool IsInsertionTrigger(SourceText text, int characterPosition, CompletionOptions options)
Completion\CompletionProviders\ImportCompletion\TypeImportCompletionProvider.cs (1)
36public 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)
176public override bool IsInsertionTrigger(SourceText text, int characterPosition, CompletionOptions options)
Completion\CompletionProviders\NamedParameterCompletionProvider.cs (2)
49public override bool IsInsertionTrigger(SourceText text, int characterPosition, CompletionOptions options) 109var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
Completion\CompletionProviders\ObjectAndWithInitializerCompletionProvider.cs (1)
103public override bool IsInsertionTrigger(SourceText text, int characterPosition, CompletionOptions options)
Completion\CompletionProviders\ObjectCreationCompletionProvider.cs (1)
37public override bool IsInsertionTrigger(SourceText text, int characterPosition, CompletionOptions options)
Completion\CompletionProviders\OperatorsAndIndexer\UnnamedSymbolCompletionProvider.cs (1)
66public override bool IsInsertionTrigger(SourceText text, int insertedCharacterPosition, CompletionOptions options)
Completion\CompletionProviders\OperatorsAndIndexer\UnnamedSymbolCompletionProvider_Conversions.cs (2)
76var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); 118var newText = text.WithChanges(builder);
Completion\CompletionProviders\OperatorsAndIndexer\UnnamedSymbolCompletionProvider_Operators.cs (1)
141var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
Completion\CompletionProviders\OverrideCompletionProvider.cs (2)
44public override bool IsInsertionTrigger(SourceText text, int characterPosition, CompletionOptions options) 79SourceText text,
Completion\CompletionProviders\PartialMethodCompletionProvider.cs (3)
77public override bool IsInsertionTrigger(SourceText text, int characterPosition, CompletionOptions options) 93var text = tree.GetText(cancellationToken); 134private static bool IsOnSameLine(SyntaxToken syntaxToken, SyntaxToken touchingToken, SourceText text)
Completion\CompletionProviders\PartialTypeCompletionProvider.cs (1)
51public override bool IsInsertionTrigger(SourceText text, int characterPosition, CompletionOptions options)
Completion\CompletionProviders\PreprocessorCompletionProvider.cs (1)
29public override bool IsInsertionTrigger(SourceText text, int characterPosition, CompletionOptions options)
Completion\CompletionProviders\PropertySubPatternCompletionProvider.cs (1)
166public override bool IsInsertionTrigger(SourceText text, int characterPosition, CompletionOptions options)
Completion\CompletionProviders\SnippetCompletionProvider.cs (1)
49public override bool IsInsertionTrigger(SourceText text, int characterPosition, CompletionOptions options)
Completion\CompletionProviders\SpeculativeTCompletionProvider.cs (1)
37public override bool IsInsertionTrigger(SourceText text, int characterPosition, CompletionOptions options)
Completion\CompletionProviders\SymbolCompletionProvider.cs (2)
108public override bool IsInsertionTrigger(SourceText text, int characterPosition, CompletionOptions options) 147var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
Completion\CompletionProviders\XmlDocCommentCompletionProvider.cs (1)
42public override bool IsInsertionTrigger(SourceText text, int characterPosition, CompletionOptions options)
Completion\CSharpCompletionService.cs (1)
45public override TextSpan GetDefaultCompletionListSpan(SourceText text, int caretPosition)
ConditionalExpressionPlacementCodeFixProvider.cs (3)
52var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); 67var changedText = text.WithChanges(edits); 72SourceText text,
ConsecutiveBracePlacementCodeFixProvider.cs (2)
53var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); 66SyntaxNode root, SourceText text,
ConsecutiveBracePlacementDiagnosticAnalyzer.cs (4)
50var text = tree.GetText(cancellationToken); 74private void ProcessToken(SyntaxTreeAnalysisContext context, ReportDiagnostic severity, SourceText text, SyntaxToken token) 88SourceText text, SyntaxToken token, 129var text = textLine.Text!;
ConstructorInitializerPlacementCodeFixProvider.cs (1)
50var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
ConstructorInitializerPlacementDiagnosticAnalyzer.cs (1)
65var sourceText = context.Tree.GetText(context.CancellationToken);
ConvertNamespaceTransform.cs (5)
73public static (SourceText text, TextSpan semicolonSpan) ConvertNamespaceDeclaration(ParsedDocument document, NamespaceDeclarationSyntax namespaceDeclaration, SyntaxFormattingOptions options, CancellationToken cancellationToken) 119private static (SourceText text, TextSpan semicolonSpan) DedentNamespace( 123var text = document.Text; 133var dedentedText = text.WithChanges(changes); 138SyntaxTree tree, SourceText text, string indentation, TextLine textLine, CancellationToken cancellationToken)
CSharpAddParenthesesAroundConditionalExpressionInInterpolatedStringCodeFixProvider.cs (4)
65var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); 67var textWithOpenParenthesis = text.Replace(openParenthesisPosition, 0, "("); 88var sourceText = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); 117var textWithCloseParenthesis = sourceText.Replace(closeParenPosition, 0, ")");
CSharpInlineDeclarationCodeFixProvider.cs (2)
119var sourceText = currentRoot.GetText(); 280SourceText sourceText, IdentifierNameSyntax identifier,
Debugging\LocationInfoGetter.cs (1)
60var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
EditAndContinue\BreakpointSpans.cs (1)
19var source = tree.GetText(cancellationToken);
ExtractMethod\CSharpSelectionValidator.cs (5)
44var text = SemanticDocument.Text; 95private SelectionInfo ApplySpecialCases(SelectionInfo selectionInfo, SourceText text, ParseOptions options, bool localFunction) 203private SelectionInfo GetInitialSelectionInfo(SyntaxNode root, SourceText text) 400private static SelectionInfo AssignFinalSpan(SelectionInfo selectionInfo, SourceText text) 493private static TextSpan GetAdjustedSpan(SourceText text, TextSpan textSpan)
IntroduceVariable\CSharpIntroduceVariableService_IntroduceLocal.cs (1)
55var text = await document.Document.GetTextAsync(cancellationToken).ConfigureAwait(false);
InvertIf\CSharpInvertIfCodeRefactoringProvider.cs (1)
134SourceText sourceText,
Snippets\AbstractCSharpAutoPropertySnippetProvider.cs (1)
72protected override int GetTargetCaretPosition(ISyntaxFactsService syntaxFacts, SyntaxNode caretTarget, SourceText sourceText)
Snippets\AbstractCSharpTypeSnippetProvider.cs (1)
59protected override int GetTargetCaretPosition(ISyntaxFactsService syntaxFacts, SyntaxNode caretTarget, SourceText sourceText)
Snippets\CSharpConstructorSnippetProvider.cs (1)
51protected override int GetTargetCaretPosition(ISyntaxFactsService syntaxFacts, SyntaxNode caretTarget, SourceText sourceText)
Snippets\CSharpElseSnippetProvider.cs (1)
73protected override int GetTargetCaretPosition(ISyntaxFactsService syntaxFacts, SyntaxNode caretTarget, SourceText sourceText)
Snippets\CSharpForEachLoopSnippetProvider.cs (1)
110protected override int GetTargetCaretPosition(ISyntaxFactsService syntaxFacts, SyntaxNode caretTarget, SourceText sourceText)
Snippets\CSharpIfSnippetProvider.cs (1)
31protected override int GetTargetCaretPosition(ISyntaxFactsService syntaxFacts, SyntaxNode caretTarget, SourceText sourceText)
Snippets\CSharpSnippetFunctionService.cs (1)
62var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
Snippets\CSharpWhileLoopSnippetProvider.cs (1)
31protected override int GetTargetCaretPosition(ISyntaxFactsService syntaxFacts, SyntaxNode caretTarget, SourceText sourceText)
SplitStringLiteral\StringSplitter.cs (1)
143var newSourceText = newDocument.Text;
StringIndentation\CSharpStringIndentationService.cs (6)
33var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); 44SourceText text, 87SourceText text, SyntaxToken token, ArrayBuilder<StringIndentationRegion> result, CancellationToken cancellationToken) 101private static void ProcessInterpolatedStringExpression(SourceText text, InterpolatedStringExpressionSyntax interpolatedString, ArrayBuilder<StringIndentationRegion> result, CancellationToken cancellationToken) 144private static bool IgnoreInterpolation(SourceText text, int offset, InterpolationSyntax interpolation) 165private static bool TryGetIndentSpan(SourceText text, ExpressionSyntax expression, out int offset, out TextSpan indentSpan)
Structure\Providers\DisabledTextTriviaStructureProvider.cs (1)
71var text = syntaxTree.GetText(cancellationToken);
Structure\Providers\IfDirectiveTriviaStructureProvider.cs (1)
27SourceText? text = null;
UseExpressionBody\UseExpressionBodyCodeRefactoringProvider.cs (2)
82var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); 98UseExpressionBodyHelper 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.Semantic.UnitTests (56)
Semantics\BindingAwaitTests.cs (2)
26SourceText text = tree.GetText(); 29SourceText newText = text.WithChanges(change);
Semantics\TopLevelStatementsTests.cs (2)
8776var newText = SourceText.From(text2, Encoding.UTF8, SourceHashAlgorithms.Default);
SourceGeneration\AdditionalSourcesCollectionTests.cs (23)
54asc.Add(hintName, SourceText.From("public class D{}", Encoding.UTF8)); 70asc.Add(hintName, SourceText.From("public class D{}", Encoding.UTF8)); 110var exception = Assert.Throws<ArgumentException>(nameof(hintName), () => asc.Add(hintName, SourceText.From("public class D{}", Encoding.UTF8))); 120asc.Add("file3.cs", SourceText.From("", Encoding.UTF8)); 121asc.Add("file1.cs", SourceText.From("", Encoding.UTF8)); 122asc.Add("file2.cs", SourceText.From("", Encoding.UTF8)); 123asc.Add("file5.cs", SourceText.From("", Encoding.UTF8)); 124asc.Add("file4.cs", SourceText.From("", Encoding.UTF8)); 144asc.Add(names[i], SourceText.From("", Encoding.UTF8)); 166asc.Add(hintName1, SourceText.From("", Encoding.UTF8)); 167var exception = Assert.Throws<ArgumentException>("hintName", () => asc.Add(hintName2, SourceText.From("", Encoding.UTF8))); 176asc.Add("hintName1", SourceText.From("", Encoding.UTF8)); 177asc.Add("hintName2", SourceText.From("", Encoding.UTF8)); 180asc2.Add("hintName3", SourceText.From("", Encoding.UTF8)); 181asc2.Add("hintName1", SourceText.From("", Encoding.UTF8)); 200asc.Add(addHintName, SourceText.From("", Encoding.UTF8)); 212asc.Add(addHintName, SourceText.From("", Encoding.UTF8)); 224asc.Add("file1.cs", SourceText.From("", Encoding.UTF8)); 225asc.Add("file2.cs", SourceText.From("", Encoding.UTF32)); 226asc.Add("file3.cs", SourceText.From("", Encoding.Unicode)); 229Assert.Throws<ArgumentException>(() => asc.Add("file4.cs", SourceText.From(""))); 232Assert.Throws<ArgumentException>(() => asc.Add("file5.cs", SourceText.From("", encoding: null))); 234var exception = Assert.Throws<ArgumentException>(() => asc.Add("file5.cs", SourceText.From("", encoding: null)));
SourceGeneration\GeneratorDriverTests.cs (12)
472sgc.AddSource("test", SourceText.From("public class D{}", Encoding.UTF8)); 475Assert.Throws<ArgumentException>("hintName", () => sgc.AddSource("test", SourceText.From("public class D{}", Encoding.UTF8))); 478Assert.Throws<ArgumentException>("hintName", () => sgc.AddSource("test.cs", SourceText.From("public class D{}", Encoding.UTF8))); 503spc.AddSource("test", SourceText.From("public class D{}", Encoding.UTF8)); 506Assert.Throws<ArgumentException>("hintName", () => spc.AddSource("test", SourceText.From("public class D{}", Encoding.UTF8))); 509Assert.Throws<ArgumentException>("hintName", () => spc.AddSource("test.cs", SourceText.From("public class D{}", Encoding.UTF8))); 516spc.AddSource("test", SourceText.From("public class D{}", Encoding.UTF8)); 578var generator = new CallbackGenerator((ic) => { }, (sgc) => { sgc.AddSource("test", SourceText.From("public class D {}", Encoding.UTF8)); }); 608var generator = new CallbackGenerator((ic) => { }, (sgc) => { sgc.AddSource("test", SourceText.From("public class D {}", Encoding.UTF8)); sgc.AddSource("test2", SourceText.From("public class E {}", Encoding.UTF8)); }); 748e.AddSource("a", SourceText.From("public class E {}", Encoding.UTF8)); 772var generator = new CallbackGenerator((ic) => { }, (sgc) => { sgc.AddSource("a", SourceText.From("")); });
SourceGeneration\GeneratorDriverTests_Attributes_FullyQualifiedName.cs (6)
1365driver = driver.RunGenerators(compilation.AddSyntaxTrees(compilation.SyntaxTrees.First().WithChangedText(SourceText.From("")))); 1407driver = driver.RunGenerators(compilation.AddSyntaxTrees(compilation.SyntaxTrees.First().WithChangedText(SourceText.From(@" 1454driver = driver.RunGenerators(compilation.AddSyntaxTrees(compilation.SyntaxTrees.First().WithChangedText(SourceText.From(@" 1506driver = driver.RunGenerators(compilation.AddSyntaxTrees(compilation.SyntaxTrees.First().WithChangedText(SourceText.From(@" 1566compilation.SyntaxTrees.First().WithChangedText(SourceText.From(@" 1618compilation.SyntaxTrees.First().WithChangedText(SourceText.From(@"
SourceGeneration\GeneratorDriverTests_Attributes_SimpleName.cs (8)
1158compilation.SyntaxTrees.Last().WithChangedText(SourceText.From(@" 1206compilation.SyntaxTrees.Last().WithChangedText(SourceText.From(@" 1260compilation.SyntaxTrees.First().WithChangedText(SourceText.From(@" 1400compilation.SyntaxTrees.First().WithChangedText(SourceText.From(@" 1444compilation.SyntaxTrees.First().WithChangedText(SourceText.From(@" 1493compilation.SyntaxTrees.First().WithChangedText(SourceText.From(@" 1541compilation.SyntaxTrees.First().WithChangedText(SourceText.From(@" 1600compilation.SyntaxTrees.Last().WithChangedText(SourceText.From(@"
SourceGeneration\SyntaxAwareGeneratorTests.cs (3)
421onExecute: (e) => { e.AddSource("test", SourceText.From("public class D{}", Encoding.UTF8)); } 513onExecute: (e) => { receiver = e.SyntaxReceiver; e.AddSource("test", SourceText.From("public class D{}", Encoding.UTF8)); } 2063onExecute: (e) => { e.AddSource("test", SourceText.From("public class D{}", Encoding.UTF8)); }
Microsoft.CodeAnalysis.CSharp.Symbol.UnitTests (5)
DeclarationTests.cs (3)
450public override SourceText GetText(CancellationToken cancellationToken) 455public override bool TryGetText(out SourceText text) 478public override SyntaxTree WithChangedText(SourceText newText)
Symbols\Metadata\MetadataTypeTests.cs (2)
362var oldIText = oldTree.GetText(); 366var newIText = oldIText.WithChanges(change);
Microsoft.CodeAnalysis.CSharp.Syntax.UnitTests (296)
Diagnostics\LineSpanDirectiveTests.cs (18)
27var textA = SourceText.From(sourceA); 73var textA = SourceText.From(sourceA); 169var textA = SourceText.From(sourceA); 220var textA = SourceText.From(sourceA); 248var textB = SourceText.From(sourceB); 289var textA = SourceText.From(sourceA); 338var textA = SourceText.From(sourceA); 392var textA = SourceText.From(sourceA); 474private static (string, string) GetTextMapping(SourceText mappedText, SyntaxTree unmappedText, SyntaxNode syntax) 487static string getMapping(SourceText mappedText, SyntaxTree unmappedText, SyntaxNode syntax)
Diagnostics\LocationsTests.cs (1)
76var text = tree.GetText();
IncrementalParsing\IncrementalParsingTests.cs (221)
27var itext = SourceText.From(text); 34var itext = SourceText.From(text); 586var text = SourceText.From(@"partial class C{}"); 590var newText = text.WithChanges(new TextChange(new TextSpan(0, 8), "")); 600var text = SourceText.From(@"partial class C{}"); 604var newText = text.WithChanges(new TextChange(new TextSpan(0, 8), "")); 614SourceText oldText = SourceText.From(@" 630SourceText oldText = SourceText.From(@" 646SourceText oldText = SourceText.From(@" 663SourceText oldText = SourceText.From(@" 679SourceText oldText = SourceText.From(@" 692SourceText oldText = SourceText.From(@" 708SourceText oldText = SourceText.From(@" 720SourceText oldText = SourceText.From(@" 732SourceText oldText = SourceText.From(@" class A 748SourceText oldText = SourceText.From(@"public class TestClass 761SourceText oldText = SourceText.From(@"using System; 776SourceText oldText = SourceText.From(@"public class MyClass { 788SourceText oldText = SourceText.From(@" 802SourceText startingText = SourceText.From(@" 823SourceText startingText = SourceText.From(@" 842SourceText startingText = SourceText.From(@" 862SourceText oldText = SourceText.From(@"class MyClass 882SourceText oldText = SourceText.From(@" 906SourceText oldText = SourceText.From(@" 930SourceText oldText = SourceText.From(@"interface IGoo 954SourceText oldText = SourceText.From(@"interface IGoo 978SourceText oldText = SourceText.From(@"using System.Runtime.CompilerServices; 1000SourceText oldText = SourceText.From(@"class A 1024SourceText oldText = SourceText.From(@"public class MyClass { 1046SourceText oldText = SourceText.From(@"public class MyClass { 1137SourceText oldText = SourceText.From(@"class filesystem{ 1156SourceText oldText = SourceText.From(@"class CSTR020mod{ public static void CSTR020() { ON ERROR GOTO ErrorTrap; } }"); 1172SourceText oldText = SourceText.From(@"class A 1192SourceText oldText = SourceText.From(@"public class DynClassDrived 1214SourceText oldText = SourceText.From(@"public class MemberClass 1234SourceText oldText = SourceText.From(@"public class MemberClass 1253SourceText oldText = SourceText.From(@"class Test 1275SourceText oldText = SourceText.From( 1302SourceText oldText = SourceText.From( 1328SourceText oldText = SourceText.From( 1353SourceText oldText = SourceText.From( 1375SourceText oldText = SourceText.From( 1430SourceText oldText = SourceText.From( 1452SourceText oldText = SourceText.From( 1473SourceText oldText = SourceText.From( 1494SourceText oldText = SourceText.From( 1517SourceText oldText = SourceText.From( 1538SourceText oldText = SourceText.From( 1558SourceText oldText = SourceText.From( 1576SourceText oldText = SourceText.From( 1597SourceText oldText = SourceText.From( 1620SourceText oldText = SourceText.From( 1637SourceText oldText = SourceText.From( 1655SourceText oldText = SourceText.From( 1673SourceText oldText = SourceText.From( 1694SourceText oldText = SourceText.From( 1729SourceText oldText = SourceText.From( 1753SourceText oldText = SourceText.From( 1771SourceText oldText = SourceText.From( 1789SourceText oldText = SourceText.From( 1808SourceText oldText = SourceText.From( 1839SourceText oldText = SourceText.From( 1864SourceText oldText = SourceText.From( 1883SourceText oldText = SourceText.From( 1901SourceText oldText = SourceText.From( 1920SourceText oldText = SourceText.From( 1939SourceText oldText = SourceText.From( 1960SourceText oldText = SourceText.From( 1979SourceText oldText = SourceText.From( 2006SourceText oldText = SourceText.From( 2034SourceText oldText = SourceText.From( 2056SourceText oldText = SourceText.From( 2075SourceText oldText = SourceText.From( 2107SourceText oldText = SourceText.From( 2140SourceText oldText = SourceText.From( 2166SourceText oldText = SourceText.From( 2191SourceText oldText = SourceText.From( 2221SourceText oldText = SourceText.From( 2250SourceText oldText = SourceText.From( 2271SourceText oldText = SourceText.From( 2303SourceText oldText = SourceText.From( 2331SourceText oldText = SourceText.From( 2369var text = SourceText.From(str); 2372var text2 = text.WithChanges( 2387SourceText oldText = SourceText.From(@" 2395var newText = oldText.WithChanges(new TextChange(new TextSpan(0, 0), "{")); 2405SourceText oldText = SourceText.From(@"System.Console.WriteLine(true) 2411var newText = oldText.WithChanges(new TextChange(new TextSpan(0, 0), @"System.Console.WriteLine(false) 2434SourceText oldText = SourceText.From(@"System.Console.WriteLine(true) 2440var newText = oldText.WithInsertAt( 2464SourceText oldText = SourceText.From(@"System.Console.WriteLine(true) 2470var newText = oldText.WithChanges(new TextChange(new TextSpan(0, 0), @"if (false) 2524var oldIText = oldTree.GetText(); 2528var newIText = oldIText.WithChanges(change); 2602var currIText = currTree.GetText(); 2642var currIText = currTree.GetText(); 2722var oldText = SourceText.From(items[0]); 2726var newText = oldText.WithChanges(change); // f is a method decl parameter 2753var oldText = SourceText.From(@" 2779var newText = SourceText.From(@" 2822var text = tree.GetText(); 2843var text = tree.GetText(); 2864var text = tree.GetText(); 2885var text = tree.GetText(); 2906var text = tree.GetText(); 2927var text = tree.GetText(); 2951var text = tree.GetText(); 2975var text = tree.GetText(); 2999var text = tree.GetText(); 3023var text = tree.GetText(); 3047var text = tree.GetText(); 3073var text = tree.GetText(); 3099var text = tree.GetText(); 3124var text = tree.GetText(); 3150var text = tree.GetText(); 3168var text = tree.GetText(); 3186var text = tree.GetText(); 3204var text = tree.GetText(); 3219var text = tree.GetText(); 3233var text = tree.GetText(); 3247var text = tree.GetText(); 3285var text = tree.GetText(); 3312private static void CommentOutText(SourceText oldText, int locationOfChange, int widthOfChange, out SyntaxTree incrementalTree, out SyntaxTree parsedTree) 3314var newText = oldText.WithChanges( 3324private static void RemoveText(SourceText oldText, int locationOfChange, int widthOfChange, out SyntaxTree incrementalTree, out SyntaxTree parsedTree) 3326var newText = oldText.WithChanges(new TextChange(new TextSpan(locationOfChange, widthOfChange), "")); 3346private static void CharByCharIncrementalParse(SourceText oldText, char newChar, out SyntaxTree incrementalTree, out SyntaxTree parsedTree) 3352var newText = oldText.WithChanges(new TextChange(new TextSpan(oldText.Length, 0), newChar.ToString())); 3357private static void TokenByTokenBottomUp(SourceText oldText, string token, out SyntaxTree incrementalTree, out SyntaxTree parsedTree) 3360SourceText newText = SourceText.From(token + oldText.ToString());
LexicalAndXml\CrefLexerTests.cs (1)
444using (var lexer = new InternalSyntax.Lexer(SourceText.From(text + "'"), TestOptions.RegularWithDocumentationComments))
LexicalAndXml\LexicalTests.cs (2)
72using (var lexer = new InternalSyntax.Lexer(SourceText.From(text), _options)) 85using (var lexer = new InternalSyntax.Lexer(SourceText.From(text), _options))
LexicalAndXml\NameAttributeValueLexerTests.cs (1)
408using (var lexer = new InternalSyntax.Lexer(SourceText.From(text + "'"), TestOptions.RegularWithDocumentationComments))
LexicalAndXml\PreprocessorTests.cs (4)
93var itext = SourceText.From(text); 100var itext = SourceText.From(text);
LexicalAndXml\XmlDocCommentTests.cs (2)
34var itext = SourceText.From(text);
Parsing\ParsingTests.cs (1)
367var lexer = new Syntax.InternalSyntax.Lexer(Text.SourceText.From(text), CSharpParseOptions.Default);
Parsing\RoundTrippingTests.cs (4)
28var tree = SyntaxFactory.ParseSyntaxTree(SourceText.From(text), options); 103var tree = SyntaxFactory.ParseSyntaxTree(SourceText.From(text), path: ""); 1581var itext = SourceText.From(text);
Syntax\Mocks\MockCSharpSyntaxTree.cs (5)
16private readonly SourceText _sourceText; 24SourceText? source = null, 29_sourceText = source ?? SourceText.From("", Encoding.UTF8, SourceHashAlgorithm.Sha256); 34public override SourceText GetText(CancellationToken cancellationToken) 37public override bool TryGetText(out SourceText text)
Syntax\SyntaxFactoryTests.cs (2)
33var text = SyntaxFactory.SyntaxTree(SyntaxFactory.CompilationUnit(), encoding: null).GetText(); 41var text = SyntaxFactory.CompilationUnit().SyntaxTree.GetText();
Syntax\SyntaxNodeTests.cs (1)
3554SourceText st = null;
Syntax\SyntaxTreeTests.cs (15)
86SyntaxTreeFactoryKind.ParseText => CSharpSyntaxTree.ParseText(SourceText.From(source, Encoding.UTF8, SourceHashAlgorithm.Sha256), parseOptions), 87SyntaxTreeFactoryKind.Subclass => new MockCSharpSyntaxTree(root, SourceText.From(source, Encoding.UTF8, SourceHashAlgorithm.Sha256), parseOptions), 142SourceText.From(""), 149var newTree = tree.WithChangedText(SourceText.From("class C { }")); 157SourceText.From(""), 173SourceText.From(""), 189SourceText.From(""), 247var newText = newTree.GetText(); 259var oldText = SourceText.From("class B {}", Encoding.Unicode, SourceHashAlgorithms.Default); 265var newText = newTree.GetText(); 289var newText = newTree.GetText(); 301var oldText = SourceText.From("class B {}", Encoding.Unicode, SourceHashAlgorithms.Default); 305var newText = newTree.GetText();
TextExtensions.cs (18)
22public static SourceText WithReplace(this SourceText text, int offset, int length, string newText) 27return SourceText.From(newFullText); 30public static SourceText WithReplaceFirst(this SourceText text, string oldText, string newText) 37return SourceText.From(newFullText); 40public static SourceText WithReplace(this SourceText text, int startIndex, string oldText, string newText) 47return SourceText.From(newFullText); 50public static SourceText WithInsertAt(this SourceText text, int offset, string newText) 55public static SourceText WithInsertBefore(this SourceText text, string existingText, string newText) 61return SourceText.From(newFullText); 64public static SourceText WithRemoveAt(this SourceText text, int offset, int length) 69public static SourceText WithRemoveFirst(this SourceText text, string oldText)
Microsoft.CodeAnalysis.CSharp.Test.Utilities (6)
BasicCompilationUtils.cs (1)
36var tree = VisualBasicSyntaxTree.ParseText(SourceText.From(source, encoding: null, SourceHashAlgorithms.Default));
CSharpTestSource.cs (2)
40var stringText = SourceText.From(text, encoding ?? Encoding.UTF8, checksumAlgorithm);
DiagnosticTestUtilities.cs (1)
67select SyntaxFactory.ParseSyntaxTree(SourceText.From(text, encoding: null, SourceHashAlgorithms.Default))).ToArray();
SyntaxTreeExtensions.cs (2)
19var oldFullText = syntaxTree.GetText(); 20var newFullText = oldFullText.WithChanges(new TextChange(new TextSpan(offset, length), newText));
Microsoft.CodeAnalysis.CSharp.Workspaces (28)
Classification\ClassificationHelpers.cs (2)
500internal static void AddLexicalClassifications(SourceText text, TextSpan textSpan, ArrayBuilder<ClassifiedSpan> result, CancellationToken cancellationToken) 508internal static ClassifiedSpan AdjustStaleClassification(SourceText rawText, ClassifiedSpan classifiedSpan)
Classification\CSharpClassificationService.cs (2)
24public override void AddLexicalClassifications(SourceText text, TextSpan textSpan, ArrayBuilder<ClassifiedSpan> result, CancellationToken cancellationToken) 27public override ClassifiedSpan AdjustStaleClassification(SourceText text, ClassifiedSpan classifiedSpan)
Classification\SyntaxClassification\CSharpSyntaxClassificationService.cs (2)
37public override void AddLexicalClassifications(SourceText text, TextSpan textSpan, ArrayBuilder<ClassifiedSpan> result, CancellationToken cancellationToken) 43public override ClassifiedSpan FixClassification(SourceText rawText, ClassifiedSpan classifiedSpan)
CSharpIndentationService.cs (1)
147var text = node.SyntaxTree.GetText();
CSharpIndentationService.Indenter.cs (5)
29CompilationUnitSyntax root, SourceText text, TextLine lineToBeIndented, 79var sourceText = indenter.LineToBeIndented.Text; 345var sourceText = indenter.LineToBeIndented.Text; 383var sourceText = indenter.LineToBeIndented.Text; 469var sourceText = indenter.LineToBeIndented.Text;
CSharpSmartTokenFormatter.cs (2)
28private readonly SourceText _text; 34SourceText text)
CSharpVirtualCharService.cs (3)
186var parentSourceText = parentExpression.SyntaxTree.GetText(); 191var tokenSourceText = SourceText.From(token.Text);
FormattingRangeHelper.cs (1)
300if (tree != null && tree.TryGetText(out var text))
J\s\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxNodeExtensions.cs\SyntaxNodeExtensions.cs (2)
60this SyntaxNode node, SourceText? sourceText = null, 70this SyntaxToken token, SourceText? sourceText = null,
J\s\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxTokenExtensions.cs\SyntaxTokenExtensions.cs (1)
112public static bool IsFirstTokenOnLine(this SyntaxToken token, SourceText text)
J\s\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxTreeExtensions.cs\SyntaxTreeExtensions.cs (1)
377var sourceText = token.SyntaxTree!.GetText(cancellationToken);
Workspace\LanguageServices\CSharpSyntaxTreeFactoryService.cs (1)
69public 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; 28public ParsedSyntaxTree(SourceText? lazyText, CSharpSyntaxNode root, CSharpParseOptions options, string filePath, Encoding? encoding, SourceHashAlgorithm checksumAlgorithm) 39public override SourceText GetText(CancellationToken cancellationToken) 49public override bool TryGetText([NotNullWhen(true)] out SourceText? text)
Microsoft.CodeAnalysis.CSharp.Workspaces.UnitTests (3)
CodeGeneration\SymbolEditorTests.cs (1)
40loader: TextLoader.From(TextAndVersion.Create(SourceText.From(s, encoding: null, SourceHashAlgorithms.Default), VersionStamp.Default)))).ToList();
Formatting\FormattingMultipleSpanTests.cs (1)
165var document = project.AddDocument("Document", SourceText.From(""));
Formatting\FormattingTreeEditTests.cs (1)
25return project.AddDocument("code", SourceText.From(code));
Microsoft.CodeAnalysis.EditorFeatures (132)
AutomaticCompletion\AbstractAutomaticLineEnderCommandHandler.cs (1)
175var text = document.Text;
Classification\Syntactic\SyntacticClassificationTaggerProvider.TagComputer.cs (1)
466var currentText = currentSnapshot.AsText();
CodeActions\CodeActionEditHandlerService.cs (2)
145var text = await singleChangedDocument.GetTextAsync(cancellationToken).ConfigureAwait(true); 368var text = await openDocument.GetTextAsync(cancellationToken).ConfigureAwait(false);
CodeDefinitionWindow\DefinitionContextTracker.cs (1)
174var text = await item.Document.GetTextAsync(cancellationToken).ConfigureAwait(false);
CommentSelection\AbstractCommentSelectionBase.cs (1)
151var newText = subjectBuffer.CurrentSnapshot.AsText();
CommentSelection\CommentUncommentSelectionCommandHandler.cs (1)
244var text = span.Snapshot.AsText();
CommentSelection\ToggleBlockCommentCommandHandler.cs (1)
47var allText = snapshot.AsText();
Diagnostics\AbstractPushOrPullDiagnosticsTaggerProvider.PushDiagnosticsTaggerProvider.cs (3)
94var sourceText = document.State.GetTextSynchronously(cancellationToken: default); 189var sourceText = diagnosticSnapshot.AsText(); 233ITextSnapshot editorSnapshot, SourceText sourceText)
Diagnostics\AbstractPushOrPullDiagnosticsTaggerProvider.SingleDiagnosticKindPullTaggerProvider.cs (1)
110var sourceText = snapshot.AsText();
DocumentationComments\AbstractDocumentationCommentCommandHandler.cs (5)
60private static DocumentationCommentSnippet? InsertOnCharacterTyped(IDocumentationCommentSnippetService service, SyntaxTree syntaxTree, SourceText text, int position, DocumentationCommentOptions options, CancellationToken cancellationToken) 63private static DocumentationCommentSnippet? InsertOnEnterTyped(IDocumentationCommentSnippetService service, SyntaxTree syntaxTree, SourceText text, int position, DocumentationCommentOptions options, CancellationToken cancellationToken) 66private static DocumentationCommentSnippet? InsertOnCommandInvoke(IDocumentationCommentSnippetService service, SyntaxTree syntaxTree, SourceText text, int position, DocumentationCommentOptions options, CancellationToken cancellationToken) 79Func<IDocumentationCommentSnippetService, SyntaxTree, SourceText, int, DocumentationCommentOptions, CancellationToken, DocumentationCommentSnippet?> getSnippetAction, 215var text = syntaxTree.GetText(c.UserCancellationToken);
EditAndContinue\ActiveStatementTrackingService.cs (2)
295if (!document.TryGetText(out var source)) 319var sourceText = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
EditAndContinue\PdbMatchingSourceTextProvider.cs (1)
145var text = await state.GetTextAsync(cancellationToken).ConfigureAwait(false);
EditorConfigSettings\DataProvider\CombinedProvider.cs (2)
20public async Task<SourceText> GetChangedEditorConfigAsync(SourceText sourceText)
EditorConfigSettings\DataProvider\ISettingsProvider.cs (2)
16Task<SourceText> GetChangedEditorConfigAsync(SourceText sourceText);
EditorConfigSettings\DataProvider\SettingsProviderBase.cs (3)
76public async Task<SourceText> GetChangedEditorConfigAsync(SourceText sourceText) 83var text = await SettingsUpdater.GetChangedEditorConfigAsync(sourceText, default).ConfigureAwait(false);
EditorConfigSettings\ISettingsEditorViewModel.cs (2)
14Task<SourceText> UpdateEditorConfigAsync(SourceText sourceText);
EditorConfigSettings\Updater\AnalyzerSettingsUpdater.cs (2)
19protected override SourceText? GetNewText(SourceText sourceText,
EditorConfigSettings\Updater\ISettingUpdater.cs (2)
14Task<SourceText?> GetChangedEditorConfigAsync(SourceText sourceText, CancellationToken token);
EditorConfigSettings\Updater\NamingStyles\NamingStyleSettingsUpdater.cs (4)
31protected override SourceText? GetNewText( 32SourceText analyzerConfigDocument, 97static SourceText UpdateDocument(SourceText sourceText, string newLine, TextSpan? potentialSpan, TextSpan backupSpan)
EditorConfigSettings\Updater\NamingStyles\SourceTextExtensions.cs (6)
23public static SourceText WithNamingStyles(this SourceText sourceText, IGlobalOptionService globalOptions) 32private static SourceText WithNamingStyles(SourceText sourceText, IEnumerable<NamingRule> rules, Language language) 56static SourceText WithChanges(SourceText sourceText, TextSpan span, string newText)
EditorConfigSettings\Updater\OptionUpdater.cs (2)
20protected override SourceText? GetNewText(SourceText sourceText,
EditorConfigSettings\Updater\SettingsUpdateHelper.cs (13)
24public static SourceText? TryUpdateAnalyzerConfigDocument(SourceText originalText, 46public static SourceText? TryUpdateAnalyzerConfigDocument( 47SourceText originalText, 102public static SourceText? TryUpdateAnalyzerConfigDocument(SourceText originalText, 106var updatedText = originalText; 111SourceText? newText; 154private static (SourceText? newText, TextLine? lastValidHeaderSpanEnd, TextLine? lastValidSpecificHeaderSpanEnd) UpdateIfExistsInFile(SourceText editorConfigText, 291private static (SourceText? newText, TextLine? lastValidHeaderSpanEnd, TextLine? lastValidSpecificHeaderSpanEnd) AddMissingRule(SourceText editorConfigText, 349var result = editorConfigText.WithChanges(new TextChange(new TextSpan(editorConfigText.Length, 0), prefix + newEntry));
EditorConfigSettings\Updater\SettingsUpdaterBase.cs (10)
24protected abstract SourceText? GetNewText(SourceText analyzerConfigDocument, IReadOnlyList<(TOption option, TValue value)> settingsToUpdate, CancellationToken token); 50public async Task<SourceText?> GetChangedEditorConfigAsync(AnalyzerConfigDocument? analyzerConfigDocument, CancellationToken token) 55var originalText = await analyzerConfigDocument.GetTextAsync(token).ConfigureAwait(false); 58var newText = GetNewText(originalText, _queue, token); 78var newText = await GetChangedEditorConfigAsync(analyzerConfigDocument, token).ConfigureAwait(false); 84var originalText = await analyzerConfigDocument!.GetTextAsync(token).ConfigureAwait(false); 88public async Task<SourceText?> GetChangedEditorConfigAsync(SourceText originalText, CancellationToken token) 92var newText = GetNewText(originalText, _queue, token);
ExternalAccess\IntelliCode\IntentProcessor.cs (1)
71var currentText = await currentDocument.GetTextAsync(cancellationToken).ConfigureAwait(false);
InlineRename\InlineRenameService.cs (2)
101var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); 146var sourceText = await documentSpan.Document.GetTextAsync(cancellationToken).ConfigureAwait(false);
InlineRename\InlineRenameSession.cs (4)
201private readonly SourceText _text; 204public NullTextBufferException(Document document, SourceText text) 225Contract.ThrowIfFalse(document.TryGetText(out var text)); 939var newText = newDocument.GetTextSynchronously(cancellationToken);
InlineRename\InlineRenameSession.OpenTextBufferManager.cs (6)
215var sourceText = document.GetTextSynchronously(CancellationToken.None); 410var firstDocumentNewText = conflictResolution.NewSolution.GetDocument(firstDocumentReplacements.document.Id).GetTextAsync(cancellationToken).WaitAndGetResult(cancellationToken); 419var documentNewText = conflictResolution.NewSolution.GetDocument(document.Id).GetTextAsync(cancellationToken).WaitAndGetResult(cancellationToken); 557var oldText = await oldDocument.GetTextAsync(cancellationToken).ConfigureAwait(false); 558var newText = await newDocument.GetTextAsync(cancellationToken).ConfigureAwait(false); 599var preMergeDocumentText = preMergeDocument.GetTextAsync(cancellationToken).WaitAndGetResult(cancellationToken);
IntelliSense\AsyncCompletion\CompletionSource.cs (4)
138var sourceText = document.GetTextSynchronously(cancellationToken); 157SourceText sourceText, 191ITextBuffer buffer, int caretPoint, SourceText text, LanguageServices services, CompletionRules rules) 645SourceText text, int questionPosition, ISyntaxFactsService syntaxFacts)
IntelliSense\QuickInfo\IntellisenseQuickInfoBuilder.cs (1)
117var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
Interactive\InteractiveSession.cs (1)
209var newSubmissionText = submissionBuffer.CurrentSnapshot.AsText();
Interactive\InteractiveWorkspace.cs (2)
50protected override void ApplyDocumentTextChanged(DocumentId document, SourceText newText) 62var oldText = _openTextContainer.CurrentText;
LanguageServer\EditorHoverCreationService.cs (1)
40var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
LanguageServer\EditorLspCompletionResultCreationService.cs (1)
30SourceText documentText,
Preview\AbstractPreviewFactoryService.cs (4)
620var text = await document.State.GetTextAsync(cancellationToken); 633var text = await document.State.GetTextAsync(cancellationToken); 755var oldText = oldDocument.GetTextAsync(cancellationToken).WaitAndGetResult(cancellationToken); 756var newText = newDocument.GetTextAsync(cancellationToken).WaitAndGetResult(cancellationToken);
Remote\SolutionChecksumUpdater.cs (2)
193if ((oldDocument.TryGetText(out var oldText) == false) || 194(newDocument.TryGetText(out var newText) == false))
RenameTracking\RenameTrackingTaggerProvider.cs (2)
84document.TryGetText(out var text)) 123if (document != null && document.TryGetText(out var text))
RenameTracking\RenameTrackingTaggerProvider.RenameTrackingCodeAction.cs (1)
83if (_document.TryGetText(out var text))
RenameTracking\RenameTrackingTaggerProvider.RenameTrackingCommitter.cs (2)
184var fullText = syntaxTree.GetText(cancellationToken); 187var newFullText = fullText.WithChanges(textChange);
RenameTracking\RenameTrackingTaggerProvider.StateMachine.cs (2)
173var beforeText = eventArgs.Before.AsText(); 290Document document, SourceText text, TextSpan userSpan,
Shared\Extensions\WorkspaceExtensions.cs (2)
42var oldText = oldDocument.GetTextSynchronously(cancellationToken); 43var newText = oldText.WithChanges(textChanges);
Shared\Preview\PreviewWorkspace.cs (3)
82var text = document.GetTextSynchronously(CancellationToken.None); 91var text = document.GetTextSynchronously(CancellationToken.None); 100var text = document.GetTextSynchronously(CancellationToken.None);
Shared\Utilities\VirtualTreePoint.cs (3)
15private readonly SourceText _text; 19public VirtualTreePoint(SyntaxTree tree, SourceText text, int position, int virtualSpaces = 0) 58public SourceText Text => _text;
TextDiffing\EditorTextDifferencingService.cs (2)
37var oldText = await oldDocument.GetTextAsync(cancellationToken).ConfigureAwait(false); 38var newText = await newDocument.GetTextAsync(cancellationToken).ConfigureAwait(false);
Undo\DefaultSourceTextUndoService.cs (1)
24public ISourceTextUndoTransaction RegisterUndoTransaction(SourceText sourceText, string description)
Undo\EditorSourceTextUndoService.cs (5)
21private readonly Dictionary<SourceText, SourceTextUndoTransaction> _transactions = new(); 30public ISourceTextUndoTransaction RegisterUndoTransaction(SourceText sourceText, string description) 44var sourceText = snapshot?.AsText(); 71public SourceText SourceText { get; } 76public SourceTextUndoTransaction(ISourceTextUndoService service, SourceText sourceText, string description)
Undo\ISourceTextUndoService.cs (6)
15/// <see cref="SourceText"/> with a supplied description. The description is the 21/// Registers undo transaction for the supplied <see cref="SourceText"/>. 23/// <param name="sourceText">The <see cref="SourceText"/> for which undo transaction is being registered.</param> 25ISourceTextUndoTransaction RegisterUndoTransaction(SourceText sourceText, string description); 30/// <param name="snapshot">The <see cref="ITextSnapshot"/> for the <see cref="SourceText"/> for undo transaction being started.</param> 32/// This method will handle the translation from <see cref="ITextSnapshot"/> to <see cref="SourceText"/>
Undo\ISourceTextUndoTransaction.cs (3)
13/// Represents undo transaction for a <see cref="Microsoft.CodeAnalysis.Text.SourceText"/> 19/// The <see cref="Microsoft.CodeAnalysis.Text.SourceText"/> for this undo transaction. 21SourceText SourceText { get; }
Workspaces\EditorTextFactoryService.cs (3)
40public SourceText CreateText(Stream stream, Encoding? defaultEncoding, SourceHashAlgorithm checksumAlgorithm, CancellationToken cancellationToken) 73public SourceText CreateText(TextReader reader, Encoding? encoding, SourceHashAlgorithm checksumAlgorithm, CancellationToken cancellationToken) 85private SourceText CreateTextInternal(Stream stream, Encoding encoding, SourceHashAlgorithm checksumAlgorithm, CancellationToken cancellationToken)
Microsoft.CodeAnalysis.EditorFeatures.Cocoa (3)
Snippets\AbstractSnippetCommandHandler.cs (1)
255var currentText = subjectBuffer.AsTextContainer().CurrentText;
Snippets\CSharpSnippets\SnippetFunctions\SnippetFunctionGenerateSwitchCases.cs (1)
85var textWithCaseAdded = document.GetTextSynchronously(cancellationToken).WithChanges(textChange);
Snippets\SnippetFunctions\AbstractSnippetFunctionSimpleTypeName.cs (1)
70var newText = document.GetTextSynchronously(CancellationToken.None).WithChanges(textChange);
Microsoft.CodeAnalysis.EditorFeatures.DiagnosticsTests.Utilities (10)
CodeActions\AbstractCodeActionOrUserDiagnosticTest.cs (5)
245SourceText.From(analyzerConfigText), 697var root = await additionalDoc.GetTextAsync(); 699var expectedRoot = await expectedDocument.GetTextAsync(); 705var root = await analyzerConfigDoc.GetTextAsync(); 715var expectedRoot = await expectedDocument.GetTextAsync();
CodeActions\CodeFixVerifierHelper.cs (4)
99var text = ConvertOptionsToAnalyzerConfig(options.DefaultExtension, explicitEditorConfig: string.Empty, options); 103public static SourceText? ConvertOptionsToAnalyzerConfig(string defaultFileExtension, string? explicitEditorConfig, OptionsCollection options) 107return explicitEditorConfig is object ? SourceText.From(explicitEditorConfig, Encoding.UTF8) : null; 136return SourceText.From(analyzerConfig.ToString(), Encoding.UTF8);
CodeActions\SharedVerifierState.cs (1)
59var analyzerConfigSource = CodeFixVerifierHelper.ConvertOptionsToAnalyzerConfig(_defaultFileExt, EditorConfig, Options);
Microsoft.CodeAnalysis.EditorFeatures.Test.Utilities (49)
BracePairs\AbstractBracePairsTests.cs (1)
34var text = await document.GetTextAsync();
Completion\AbstractCompletionProviderTests.cs (4)
507var text = await document.GetTextAsync(); 508var newText = text.WithChanges(commit.TextChange); 594var text = await document.GetTextAsync(); 1048var text = hostDocument.GetTextBuffer().CurrentSnapshot.AsText();
Diagnostics\TestDiagnosticAnalyzerDriver.cs (1)
61var text = await document.GetTextAsync().ConfigureAwait(false);
EditAndContinue\ActiveStatementsDescription.cs (1)
88var newText = newTree.GetText();
EditAndContinue\ActiveStatementTestHelpers.cs (3)
42static (source, path) => SyntaxFactory.ParseSyntaxTree(SourceText.From(source, encoding: Encoding.UTF8, SourceHashAlgorithms.Default), path: path), 101public static string InspectActiveStatementAndInstruction(ActiveStatement statement, SourceText text) 113public static string GetFirstLineText(LinePositionSpan span, SourceText text)
EditAndContinue\EditAndContinueTestHelpers.cs (4)
155var oldText = oldDocument.GetTextSynchronously(default); 156var newText = newDocument.GetTextSynchronously(default); 254public static void VerifyDiagnostics(IEnumerable<RudeEditDiagnosticDescription> expected, IEnumerable<RudeEditDiagnostic> actual, SourceText newSource) 432var text = tree.GetText();
EditAndContinue\Extensions.cs (1)
17public static IEnumerable<RudeEditDiagnosticDescription> ToDescription(this IEnumerable<RudeEditDiagnostic> diagnostics, SourceText newSource, bool includeFirstLines)
Formatting\AbstractNewDocumentFormattingServiceTests.cs (1)
42var actual = await formattedDocument.GetTextAsync();
LanguageServer\AbstractLanguageServerProtocolTests.cs (9)
160protected static string ApplyTextEdits(LSP.TextEdit[] edits, SourceText originalMarkup) 162var text = originalMarkup; 329var documentText = await solution.GetRequiredDocument(document.Id).GetTextAsync(CancellationToken.None); 330solution = solution.WithDocumentText(document.Id, SourceText.From(documentText.ToString(), System.Text.Encoding.UTF8, SourceHashAlgorithms.Default)); 403var loader = TextLoader.From(TextAndVersion.Create(SourceText.From(markup), version, TestSpanMapper.GeneratedFileName)); 422var text = await document.GetTextAsync(CancellationToken.None); 436static LSP.Location ConvertTextSpanWithTextToLocation(TextSpan span, SourceText text, Uri documentUri) 611var sourceText = await TestWorkspace.CurrentSolution.GetDocuments(documentUri).First().GetTextAsync(CancellationToken.None).ConfigureAwait(false); 688internal ImmutableArray<SourceText> GetTrackedTexts() => GetManager().GetTrackedLspText().Values.ToImmutableArray();
ReassignedVariable\AbstractReassignedVariableTests.cs (1)
29var text = await document.GetTextAsync();
Rename\RenamerTests.cs (6)
55var startSourceText = SourceText.From(startDocument.Text); 188var startSourceText = SourceText.From(startDocument.Text); 222var startSourceText = SourceText.From(startText, encoding: null, SourceHashAlgorithms.Default);
Squiggles\TestDiagnosticTagProducer.cs (1)
60var sourceText = document.GetTextBuffer().CurrentSnapshot.AsText();
TaskList\AbstractTaskListTests.cs (1)
47var sourceText = await document.GetTextAsync();
Workspaces\TestHostDocument.cs (3)
217=> Task.FromResult(TextAndVersion.Create(SourceText.From(_text, encoding: null, options.ChecksumAlgorithm), VersionStamp.Create(), _hostDocument.FilePath)); 323internal void Update(SourceText newText) 328var oldText = buffer.CurrentSnapshot.AsText();
Workspaces\TestWorkspace.cs (10)
329protected override void ApplyDocumentTextChanged(DocumentId document, SourceText newText) 335protected override void ApplyDocumentAdded(DocumentInfo info, SourceText text) 354protected override void ApplyAdditionalDocumentTextChanged(DocumentId document, SourceText newText) 360protected override void ApplyAdditionalDocumentAdded(DocumentInfo info, SourceText text) 376protected override void ApplyAnalyzerConfigDocumentTextChanged(DocumentId document, SourceText newText) 382protected override void ApplyAnalyzerConfigDocumentAdded(DocumentInfo info, SourceText text) 754public void ChangeDocument(DocumentId documentId, SourceText text) 759public Task ChangeDocumentAsync(DocumentId documentId, SourceText text) 780public void ChangeAdditionalDocument(DocumentId documentId, SourceText text) 787public void ChangeAnalyzerConfigDocument(DocumentId documentId, SourceText text)
Workspaces\TestWorkspace_XmlConsumption.cs (2)
987var sourceText = SourceText.From(referencedCode, encoding: null, SourceHashAlgorithms.Default);
Microsoft.CodeAnalysis.EditorFeatures.Text (20)
Extensions.cs (6)
25/// Returns the <see cref="ITextSnapshot"/> behind this <see cref="SourceText"/>, or null if it wasn't created from one. 27/// Note that multiple <see cref="ITextSnapshot"/>s may map to the same <see cref="SourceText"/> instance if it's 31public static ITextSnapshot? FindCorrespondingEditorTextSnapshot(this SourceText? text) 34internal static ITextImage? TryFindCorrespondingEditorTextImage(this SourceText? text) 40public static SourceText AsText(this ITextSnapshot textSnapshot) 46internal static SourceText AsRoslynText(this ITextSnapshot textSnapshot, ITextBufferCloneService textBufferCloneServiceOpt, Encoding? encoding, SourceHashAlgorithm checksumAlgorithm)
Extensions.SnapshotSourceText.cs (5)
72public static SourceText From(ITextBufferCloneService? textBufferCloneService, ITextSnapshot editorSnapshot) 96internal static SourceText From(ITextBufferCloneService? textBufferCloneService, ITextSnapshot editorSnapshot, TextBufferContainer container) 186public override SourceText WithChanges(IEnumerable<TextChange> changes) 289public override IReadOnlyList<TextChangeRange> GetChangeRanges(SourceText oldText) 319public override IReadOnlyList<TextChangeRange> GetChangeRanges(SourceText oldText)
Extensions.TextBufferContainer.cs (3)
26private SourceText _currentText; 55public override SourceText CurrentText 110var newText = SnapshotSourceText.From(_textBufferCloneService, args.After);
Implementation\TextBufferFactoryService\ITextBufferCloneService.cs (4)
29/// get new <see cref="ITextBuffer"/> from <see cref="SourceText"/> with <see cref="ContentTypeNames.RoslynContentType"/> 31ITextBuffer CloneWithRoslynContentType(SourceText sourceText); 34/// get new <see cref="ITextBuffer"/> from <see cref="SourceText"/> with <see cref="IContentType"/> 36ITextBuffer Clone(SourceText sourceText, IContentType contentType);
Implementation\TextBufferFactoryService\TextBufferCloneServiceFactory.cs (2)
39public ITextBuffer CloneWithRoslynContentType(SourceText sourceText) 42public ITextBuffer Clone(SourceText sourceText, IContentType contentType)
Microsoft.CodeAnalysis.EditorFeatures.UnitTests (116)
CodeFixes\CodeFixServiceTests.cs (4)
854var text = context.AdditionalFile.GetText(context.CancellationToken); 880var text = await document.GetTextAsync(ct).ConfigureAwait(false); 881var newText = SourceText.From(text.ToString() + Title);
CodeGeneration\AbstractCodeGenerationTests.cs (1)
36.AddDocument("Fake Document", SourceText.From(normalizedSyntax));
CodeRefactorings\CodeRefactoringServiceTest.cs (5)
215.AddAnalyzerConfigDocument(".editorconfig", SourceText.From(""), filePath: "c:\\.editorconfig").Project 216.AddAnalyzerConfigDocument(".globalconfig", SourceText.From("is_global = true"), filePath: "c:\\.globalconfig").Project; 254var text = await document.GetTextAsync(ct).ConfigureAwait(false); 255var newText = SourceText.From(text.ToString() + Title);
Completion\CompletionServiceTests.cs (2)
102public override bool ShouldTriggerCompletion(SourceText text, int caretPosition, CompletionTrigger trigger, OptionSet options) 138var text = root.GetText();
Diagnostics\DiagnosticAnalyzerServiceTests.cs (10)
194project = project.AddAnalyzerConfigDocument(".editorconfig", filePath: "z:\\.editorconfig", text: SourceText.From(editorconfigText)).Project; 197var document = project.AddDocument("test.cs", SourceText.From("class A {}"), filePath: "z:\\test.cs"); 299var document = workspace.AddDocument(project.Id, "Empty.cs", SourceText.From("")); 365loader: TextLoader.From(TextAndVersion.Create(SourceText.From(""), VersionStamp.Create(), filePath)), 488loader: TextLoader.From(TextAndVersion.Create(SourceText.From("class A {}"), VersionStamp.Create(), filePath: "test.cs")), 556text: SourceText.From(analyzerConfigText), 586loader: TextLoader.From(TextAndVersion.Create(SourceText.From("class A {}"), VersionStamp.Create(), filePath: "test.cs")), 706var text = await additionalDoc.GetTextAsync(); 899var text = await document.GetTextAsync(); 1199return workspace.AddDocument(project.Id, "Empty.cs", SourceText.From("class A { B B {get} }"));
Diagnostics\DiagnosticDataTests.cs (1)
131var text = await document.GetTextAsync();
Diagnostics\DiagnosticsSquiggleTaggerProviderTests.cs (1)
67var text = await document.GetTextAsync();
EditAndContinue\ActiveStatementsMapTests.cs (3)
92.AddDocument("doc", SourceText.From(source, Encoding.UTF8), filePath: "a.cs").Project.Solution; 147.AddDocument("doc", SourceText.From(source, Encoding.UTF8), filePath: "a.cs").Project.Solution; 198.AddDocument("doc", SourceText.From(source, Encoding.UTF8), filePath: "a.cs").Project.Solution;
EditAndContinue\CompileTimeSolutionProviderTests.cs (5)
51AddAdditionalDocument(additionalDocumentId, "additional", SourceText.From(""), filePath: additionalFilePath). 52AddAnalyzerConfigDocument(analyzerConfigId, "config", SourceText.From(""), filePath: "RazorSourceGenerator.razorencconfig"). 110context.AddSource("hint", SourceText.From(s)); 122AddAdditionalDocument(additionalDocumentId, "additional", SourceText.From(""), filePath: "additional.razor"). 123AddAnalyzerConfigDocument(analyzerConfigId, "config", SourceText.From(analyzerConfigText), filePath: "Z:\\RazorSourceGenerator.razorencconfig"),
EditAndContinue\EditAndContinueWorkspaceServiceTests.cs (32)
101private static SourceText GetAnalyzerConfigText((string key, string value)[] analyzerConfig) 314var sourceText = SourceText.From(new MemoryStream(encoding.GetBytesWithPreamble(source.content)), encoding, checksumAlgorithm); 363private static SourceText CreateText(string source) 364=> SourceText.From(source, Encoding.UTF8, SourceHashAlgorithms.Default); 366private static SourceText CreateTextFromFile(string path) 369return SourceText.From(stream, Encoding.UTF8, SourceHashAlgorithms.Default); 395var sourceText = CreateText("class DTO {}"); 513var sourceTreeA1 = SyntaxFactory.ParseSyntaxTree(SourceText.From(sourceBytesA1, sourceBytesA1.Length, encodingA, SourceHashAlgorithms.Default), TestOptions.Regular, sourceFileA.Path); 514var sourceTreeB1 = SyntaxFactory.ParseSyntaxTree(SourceText.From(sourceBytesB1, sourceBytesB1.Length, encodingB, SourceHashAlgorithms.Default), TestOptions.Regular, sourceFileB.Path); 515var sourceTreeC1 = SyntaxFactory.ParseSyntaxTree(SourceText.From(sourceBytesC1, sourceBytesC1.Length, encodingC, SourceHashAlgorithm.Sha1), TestOptions.Regular, sourceFileC.Path); 752var sourceText = CreateText("class D {}"); 817solution = solution.AddDocument(designTimeOnlyDocumentId, designTimeOnlyFileName, SourceText.From(sourceDesignTimeOnly, Encoding.UTF8), filePath: designTimeOnlyFilePath); 837solution = solution.AddDocument(designTimeOnlyDocumentId, designTimeOnlyFileName, SourceText.From(sourceDesignTimeOnly, Encoding.UTF8), filePath: designTimeOnlyFilePath); 1035AddDocument("a.cs", SourceText.From(source1, Encoding.UTF8, SourceHashAlgorithm.Sha1), filePath: sourceFile.Path); 1318public SourceText Text { get; set; } 1320public override SourceText CurrentText => Text; 1346AddDocument(documentId, "test.cs", SourceText.From(source1, encoding, SourceHashAlgorithm.Sha1), filePath: sourceFile.Path); 1368var text = await document.GetTextAsync(); 2365solution = solution.WithDocumentText(document1.Id, SourceText.From("class C1 { void M() { System.Console.WriteLine(2); } }", encoding: null, SourceHashAlgorithms.Default)); 2599var sourceText1 = CreateText(source1); 3552var sourceTextV1 = document1.GetTextSynchronously(CancellationToken.None); 3553var sourceTextV2 = CreateText(sourceV2); 3645var sourceTextV1 = await document1.GetTextAsync(CancellationToken.None); 3646var sourceTextV2 = CreateText(sourceV2); 3713var sourceText = CreateText("dummy1"); 3784var text1 = await doc1.GetTextAsync(); 3785var text2 = await doc2.GetTextAsync(); 3787DocumentId AddProjectAndLinkDocument(string projectName, Document doc, SourceText text) 4708var document1 = await solution.GetDocument(documentId).GetTextAsync(); 4716Text = SourceText.From(source3, Encoding.UTF8, SourceHashAlgorithm.Sha1) 4729var text = await document.GetTextAsync();
EditAndContinue\EditSessionActiveStatementsTests.cs (12)
81var text = SourceText.From(ActiveStatementsDescription.ClearTags(markedSources[i]), Encoding.UTF8); 325var baseText = SourceText.From(baseSource); 326var updatedText = SourceText.From(updatedSource); 477var sourceTextV1 = SourceText.From(markedSourceV1); 478var sourceTextV2 = SourceText.From(markedSourceV2); 479var sourceTextV3 = SourceText.From(markedSourceV3);
EditAndContinue\EmitSolutionUpdateResultsTests.cs (1)
34AddDocument(sourcePath, SourceText.From("class C {}", Encoding.UTF8), filePath: Path.Combine(TempRoot.Root, sourcePath));
EditAndContinue\RemoteEditAndContinueServiceTests.cs (1)
86.AddDocument(documentId, "test.cs", SourceText.From("class C { }", Encoding.UTF8), filePath: "test.cs")
EditorAdapter\TextSnapshotImplementationTest.cs (5)
20private static Tuple<ITextSnapshot, SourceText> Create(params string[] lines) 24var text = buffer.CurrentSnapshot.AsText(); 32var text = tuple.Item2; 42var text = tuple.Item2; 53var text = tuple.Item2;
Extensions\ITextExtensionsTests.cs (2)
131var text = SourceText.From(code);
Extensions\ITextLineExtensionsTests.cs (2)
131var text = SourceText.From(codeLine);
LinkedFiles\LinkedFileDiffMergingEditorTests.cs (2)
59var text = await workspace.CurrentSolution.GetDocument(documentId).GetTextAsync(); 62var linkedText = await workspace.CurrentSolution.GetDocument(linkedDocumentId).GetTextAsync();
MetadataAsSource\AbstractMetadataAsSourceTests.cs (1)
60var text = await document.GetTextAsync();
MetadataAsSource\AbstractMetadataAsSourceTests.TestContext.cs (1)
314var stringText = EncodedStringText.Create(reader);
Preview\PreviewWorkspaceTests.cs (3)
89var changedSolution = previewWorkspace.CurrentSolution.Projects.First().Documents.First().WithText(SourceText.From(text)).Project.Solution; 110var sourceTextContainer = SourceText.From("Text").Container; 171var oldText = oldDocument.GetTextAsync().Result;
SolutionCrawler\WorkCoordinatorTests.cs (11)
348project = project.AddAdditionalDocument("a1", SourceText.From("")).Project; 706var worker = await ExecuteOperation(workspace, w => w.ChangeDocument(document.Id, SourceText.From("//"))); 743worker = await ExecuteOperation(workspace, w => w.ChangeAdditionalDocument(ncfile.Id, SourceText.From("//"))); 785worker = await ExecuteOperation(workspace, w => w.ChangeAnalyzerConfigDocument(analyzerConfigFile.Id, SourceText.From("//"))); 833workspace.ChangeDocument(document.Id, SourceText.From("//")); 841workspace.ChangeDocument(document.Id, SourceText.From("// ")); 888workspace.ChangeDocument(document.Id, SourceText.From("//")); 895workspace.ChangeDocument(document.Id, SourceText.From("// ")); 903workspace.ChangeDocument(document.Id, SourceText.From("// ")); 933workspace.ChangeDocument(id, SourceText.From("//")); 943workspace.ChangeDocument(id, SourceText.From("// "));
SymbolFinder\DependentTypeFinderTests.cs (1)
40return solution.AddProject(pi).AddDocument(did, $"{projectName}.{suffix}", SourceText.From(code));
TextEditor\TryGetDocumentTests.cs (3)
43var newSourceText = newDocument.GetTextAsync().Result; 59var text = buffer.CurrentSnapshot.AsText(); 73var newText = buffer.CurrentSnapshot.AsText();
Workspaces\TextFactoryTests.cs (7)
83var text = SourceText.From("Hello, World!"); 91var text2 = await temporaryStorage.ReadTextAsync(); 105var text = SourceText.From("Hello, World!", Encoding.ASCII); 113var text2 = await temporaryStorage.ReadTextAsync(); 123var text = textFactoryService.CreateText(stream, defaultEncoding, SourceHashAlgorithms.Default, CancellationToken.None);
Microsoft.CodeAnalysis.EditorFeatures.Wpf (8)
Interactive\AbstractInteractiveWindowCommandCompletionProvider.cs (1)
28var sourceText = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
Interactive\InteractiveDocumentNavigationService.cs (1)
57var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
NavigateTo\NavigateToItemDisplay.cs (1)
66var sourceText = document.GetTextSynchronously(CancellationToken.None);
Peek\PeekableItemSource.cs (1)
139var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
QuickInfo\Extensions.cs (4)
21public static ITextBuffer CreateTextBufferWithRoslynContentType(this SourceText sourceText, Workspace workspace) 34public static ITextBuffer CloneTextBuffer(this Document document, SourceText sourceText) 47/// async version of <see cref="CloneTextBuffer(Document, SourceText)"/> 51var sourceText = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
Microsoft.CodeAnalysis.EditorFeatures2.UnitTests (25)
Classification\ClassificationTests.vb (3)
238Private Shared Function ToTestString(text As SourceText, span As ClassifiedSpan) As String 345Public Sub AddLexicalClassifications(text As SourceText, textSpan As TextSpan, result As ArrayBuilder(Of ClassifiedSpan), cancellationToken As CancellationToken) Implements IClassificationService.AddLexicalClassifications 359Public Function AdjustStaleClassification(text As SourceText, classifiedSpan As ClassifiedSpan) As ClassifiedSpan Implements IClassificationService.AdjustStaleClassification
Diagnostics\AdditionalFileDiagnosticsTests.vb (2)
47Dim newSln = workspace.CurrentSolution.AddAdditionalDocument(DocumentId.CreateNewId(project.Id), "App.Config", SourceText.From("false")) 122Dim newSln = appConfigDoc.Project.Solution.WithAdditionalDocumentText(appConfigDoc.Id, SourceText.From("true", text.Encoding))
Diagnostics\DiagnosticServiceTests.vb (1)
1451additionalDoc = additionalDoc.WithText(SourceText.From(newAdditionalDocText))
FindReferences\FindReferencesTests.vb (3)
438Dim text As SourceText = Nothing 557solution = solution.WithDocumentText(document2.Id, SourceText.From("")) 566solution = solution.WithDocumentText(document2.Id, SourceText.From(text1.ToString().Replace("int i", "int j")))
IntelliSense\CompletionServiceTests.vb (2)
77Public Overrides Function ShouldTriggerCompletion(text As SourceText, position As Int32, trigger As CompletionTrigger, options As OptionSet) As [Boolean] 128Friend Overrides Function ShouldTriggerCompletion(languageServices As CodeAnalysis.Host.LanguageServices, text As SourceText, caretPosition As Integer, trigger As CompletionTrigger, options As CompletionOptions, passThroughOptions As OptionSet) As Boolean
IntelliSense\CompletionServiceTests_Exclusivitiy.vb (1)
85Public Overrides Function ShouldTriggerCompletion(text As SourceText, position As Int32, trigger As CompletionTrigger, options As OptionSet) As [Boolean]
IntelliSense\CSharpCompletionCommandHandlerTests.vb (8)
4167Public Overrides Function IsInsertionTrigger(text As SourceText, characterPosition As Integer, options As CompletionOptions) As Boolean 8204Public Overrides Function ShouldTriggerCompletion(text As SourceText, caretPosition As Integer, trigger As CompletionTrigger, options As OptionSet) As Boolean 8249Public Overrides Function ShouldTriggerCompletion(text As SourceText, caretPosition As Integer, trigger As CompletionTrigger, options As OptionSet) As Boolean 9591Public Overrides Function ShouldTriggerCompletion(text As SourceText, caretPosition As Integer, trigger As CompletionTrigger, options As OptionSet) As Boolean 10252Public Overrides Function IsInsertionTrigger(text As SourceText, characterPosition As Integer, options As CompletionOptions) As Boolean 10325Public Overrides Function IsInsertionTrigger(text As SourceText, characterPosition As Integer, options As CompletionOptions) As Boolean 10618Public Overrides Function IsInsertionTrigger(text As SourceText, characterPosition As Integer, options As CompletionOptions) As Boolean 10754Public Overrides Function ShouldTriggerCompletion(text As SourceText, caretPosition As Integer, trigger As CompletionTrigger, options As OptionSet) As Boolean
IntelliSense\CSharpCompletionCommandHandlerTests_DefaultsSource.vb (1)
435Public Overrides Function ShouldTriggerCompletion(text As SourceText, caretPosition As Integer, trigger As CompletionTrigger, options As OptionSet) As Boolean
IntelliSense\MockCompletionProvider.vb (3)
18Private ReadOnly _isTriggerCharacter As Func(Of SourceText, Integer, Boolean) 22Optional isTriggerCharacter As Func(Of SourceText, Integer, Boolean) = Nothing) 45Public Overrides Function IsInsertionTrigger(text As SourceText, characterPosition As Integer, options As CompletionOptions) As Boolean
Simplification\ParameterSimplificationTests.vb (1)
24.AddDocument("Document", SourceText.From(input))
Microsoft.CodeAnalysis.ExternalAccess.FSharp (13)
Classification\IFSharpClassificationService.cs (2)
28void AddLexicalClassifications(SourceText text, TextSpan textSpan, List<ClassifiedSpan> result, CancellationToken cancellationToken); 55ClassifiedSpan AdjustStaleClassification(SourceText text, ClassifiedSpan classifiedSpan);
Completion\FSharpCommonCompletionUtilities.cs (1)
15public static bool IsStartingNewWord(SourceText text, int characterPosition, Func<char, bool> isWordStartCharacter, Func<char, bool> isWordCharacter)
Completion\FSharpCompletionProviderBase.cs (3)
14public sealed override bool ShouldTriggerCompletion(SourceText text, int caretPosition, CompletionTrigger trigger, OptionSet options) 17internal sealed override bool ShouldTriggerCompletion(Host.LanguageServices languageServices, SourceText text, int caretPosition, CompletionTrigger trigger, CompletionOptions options, OptionSet passthroughOptions) 20protected abstract bool ShouldTriggerCompletionImpl(SourceText text, int caretPosition, CompletionTrigger trigger);
Completion\IFSharpCommonCompletionProvider.cs (1)
19public abstract bool IsInsertionTrigger(SourceText text, int insertedCharacterPosition);
Editor\IFSharpIndentationService.cs (1)
64FSharpIndentationResult? GetDesiredIndentation(HostLanguageServices services, SourceText text, DocumentId documentId, string path, int lineNumber, FSharpIndentationOptions options);
Internal\Classification\FSharpClassificationService.cs (2)
33public void AddLexicalClassifications(SourceText text, TextSpan textSpan, ArrayBuilder<ClassifiedSpan> result, CancellationToken cancellationToken) 54public ClassifiedSpan AdjustStaleClassification(SourceText text, ClassifiedSpan classifiedSpan)
Internal\Completion\FSharpInternalCommonCompletionProvider.cs (1)
36public override bool IsInsertionTrigger(SourceText text, int insertedCharacterPosition, CompletionOptions options)
Internal\Editor\FSharpSmartIndentProvider.cs (1)
86var text = document.GetTextSynchronously(cancellationToken);
TaskList\FSharpTaskListService.cs (1)
42var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
Microsoft.CodeAnalysis.ExternalAccess.OmniSharp (3)
Completion\OmniSharpCompletionService.cs (1)
24var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
DocumentationComments\OmniSharpDocumentationCommentsSnippetService.cs (2)
18SourceText text, 30SourceText text,
Microsoft.CodeAnalysis.ExternalAccess.Razor (2)
RazorExcerptResult.cs (2)
13public readonly SourceText Content; 23public RazorExcerptResult(SourceText content, TextSpan mappedSpan, ImmutableArray<ClassifiedSpan> classifiedSpans, Document document, TextSpan span)
Microsoft.CodeAnalysis.Features (225)
AbstractConflictMarkerCodeFixProvider.cs (15)
73var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); 83SyntaxNode root, SourceText text, int position, 144SourceText text, int position, 208var text = startLine.Text!; 226var text = startLine.Text!; 244var text = currentLine.Text!; 302Action<SourceText, ArrayBuilder<TextChange>, int, int, int, int> addEdits, 305var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); 310var finalText = text.WithChanges(edits); 315SourceText text, ArrayBuilder<TextChange> edits, 328SourceText text, ArrayBuilder<TextChange> edits, 341SourceText text, ArrayBuilder<TextChange> edits, 375private static int GetEndIncludingLineBreak(SourceText text, int position) 391var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); 430var finalText = text.WithChanges(edits);
AbstractUseConditionalExpressionCodeFixProvider.cs (1)
143var sourceText = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
AddFileBanner\AbstractAddFileBannerCodeRefactoringProvider.cs (1)
179var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
AddImport\CodeActions\AddImportCodeAction.cs (2)
60var oldText = await OriginalDocument.GetTextAsync(cancellationToken).ConfigureAwait(false); 61var newText = oldText.WithChanges(_textChanges);
AddImport\CodeActions\InstallPackageAndAddImportCodeAction.cs (6)
90var oldText = await OriginalDocument.GetTextAsync(cancellationToken).ConfigureAwait(false); 91var newText = await updatedDocument.GetTextAsync(cancellationToken).ConfigureAwait(false); 102private readonly SourceText _oldText; 103private readonly SourceText _newText; 108SourceText oldText, 109SourceText newText,
BraceCompletion\AbstractBraceCompletionService.cs (2)
117protected virtual bool IsValidOpenBraceTokenAtPosition(SourceText text, SyntaxToken token, int position) 197protected static bool CouldEscapePreviousOpenBrace(char openingBrace, int position, SourceText text)
BraceMatching\AbstractBraceMatcher.cs (1)
67var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
BraceMatching\BraceMatchingService.cs (1)
33var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
ClassifiedSpansAndHighlightSpanFactory.cs (2)
49var sourceText = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); 59private static TextSpan GetLineSpanForReference(SourceText sourceText, TextSpan referenceSpan)
CodeFixes\Configuration\ConfigurationUpdater.cs (8)
275var originalText = await editorConfigDocument.GetTextAsync(_cancellationToken).ConfigureAwait(false); 278var newText = GetNewAnalyzerConfigDocumentText(originalText, editorConfigDocument); 413private SourceText? GetNewAnalyzerConfigDocumentText(SourceText originalText, AnalyzerConfigDocument editorConfigDocument) 433private (SourceText? newText, TextLine? lastValidHeaderSpanEnd, TextLine? lastValidSpecificHeaderSpanEnd) CheckIfRuleExistsAndReplaceInFile( 434SourceText result, 691private SourceText? AddMissingRule( 692SourceText result,
CodeFixes\Suppression\AbstractSuppressionBatchFixAllProvider.cs (5)
302private static async Task<IReadOnlyDictionary<DocumentId, SourceText>> GetDocumentIdToFinalTextAsync( 315var documentIdToFinalText = new ConcurrentDictionary<DocumentId, SourceText>(); 330ConcurrentDictionary<DocumentId, SourceText> documentIdToFinalText, 346var finalText = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); 368var newText = await merger.GetFinalMergedTextAsync(cancellationToken).ConfigureAwait(false);
CodeFixes\Suppression\AbstractSuppressionCodeFixProvider.PragmaBatchFixHelpers.cs (2)
106var currentText = await currentDocument.GetTextAsync(cancellationToken).ConfigureAwait(false); 108var newText = currentText.WithChanges(orderedChanges);
CodeLens\CodeLensReferencesService.cs (1)
125var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
CodeRefactoringHelpers.cs (1)
115var sourceText = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
CodeRefactorings\AbstractRefactoringHelpersService.cs (4)
26public abstract bool IsBetweenTypeMembers(SourceText sourceText, SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? typeDeclaration); 223var sourceText = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); 242SourceText sourceText, SyntaxToken tokenOnLocation, int location) 533var sourceText = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
CodeRefactorings\AddMissingImports\AbstractAddMissingImportsFeatureService.cs (7)
29protected abstract ImmutableArray<AbstractFormattingRule> GetFormatRules(SourceText text); 136var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); 137var newText = text.WithChanges(orderedTextInserts); 165var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); 191var newText = text.WithChanges(textChanges); 243private readonly SourceText _text; 245public CleanUpNewLinesFormatter(SourceText text)
CodeRefactorings\AddMissingImports\AbstractAddMissingImportsRefactoringProvider.cs (1)
33var sourceText = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
CodeRefactorings\IRefactoringHelpersService.cs (1)
25bool IsBetweenTypeMembers(SourceText sourceText, SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? typeDeclaration);
CodeRefactorings\SyncNamespace\AbstractSyncNamespaceCodeRefactoringProvider.MoveFileCodeAction.cs (1)
50var text = await document.GetTextAsync(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)
29public static TextSpan GetWordSpan(SourceText text, int position, 35public static TextSpan GetWordSpan(SourceText text, int position, 62public static bool IsStartingNewWord(SourceText text, int characterPosition, Func<char, bool> isWordStartCharacter, Func<char, bool> isWordCharacter) 209internal 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)
94SourceText text, 132SourceText text, 160public virtual TextSpan GetDefaultItemSpan(SourceText text, int caretPosition) 163public virtual TextSpan GetDefaultCompletionListSpan(SourceText text, int caretPosition) 373var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
Completion\CompletionService_GetCompletions.cs (3)
99var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); 154Document document, ConcatImmutableArray<CompletionProvider> providers, int caretPosition, CompletionOptions options, CompletionTrigger trigger, ImmutableHashSet<string>? roles, SourceText text) 196Document document, SourceText text, int caretPosition, in CompletionOptions options)
Completion\Providers\AbstractAggregateEmbeddedLanguageCompletionProvider.cs (1)
73internal sealed override bool ShouldTriggerCompletion(LanguageServices languageServices, SourceText text, int caretPosition, CompletionTrigger trigger, CompletionOptions options, OptionSet passThroughOptions)
Completion\Providers\AbstractAwaitCompletionProvider.cs (2)
213var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); 214var newText = text.WithChanges(builder);
Completion\Providers\AbstractDocCommentCompletionProvider.cs (1)
273var text = await document.GetTextAsync(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 = root.GetText();
Completion\Providers\AbstractMemberInsertingCompletionProvider.cs (4)
45var newText = await newDocument.GetTextAsync(cancellationToken).ConfigureAwait(false); 80var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); 106var finalText = insertionRoot.GetText(text.Encoding) 174var text = insertionRoot.GetText();
Completion\Providers\AbstractOverrideCompletionProvider.cs (2)
26public abstract bool TryDetermineModifiers(SyntaxToken startToken, SourceText text, int startLine, out Accessibility seenAccessibility, out DeclarationModifiers modifiers); 73protected static bool IsOnStartLine(int position, SourceText text, int startLine)
Completion\Providers\AbstractOverrideCompletionProvider.ItemGetter.cs (3)
31private readonly SourceText _text; 39SourceText text, 59var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
Completion\Providers\AbstractPartialMethodCompletionProvider.cs (1)
98var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
Completion\Providers\AbstractRecommendationServiceBasedCompletionProvider.cs (1)
253var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
Completion\Providers\EmbeddedLanguageCompletionProvider.cs (1)
23public abstract bool ShouldTriggerCompletion(SourceText text, int caretPosition, CompletionTrigger trigger);
Completion\Providers\ImportCompletionProvider\AbstractImportCompletionProvider.cs (2)
168var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); 169var newText = text.WithChanges(builder);
Completion\Providers\Scripting\AbstractDirectivePathCompletionProvider.cs (1)
68public sealed override bool ShouldTriggerCompletion(SourceText text, int caretPosition, CompletionTrigger trigger, OptionSet options)
Completion\Providers\Snippets\AbstractSnippetCompletionProvider.cs (3)
37var strippedText = await strippedDocument.GetTextAsync(cancellationToken).ConfigureAwait(false); 40var allChangesText = strippedText.WithChanges(snippet.TextChanges); 124var originalText = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
Completion\Utilities.cs (1)
18public static TextChange Collapse(SourceText newText, ImmutableArray<TextChange> changes)
DocumentationComments\AbstractDocumentationCommentSnippetService.cs (8)
43SourceText text, 80private List<string>? GetDocumentationCommentLines(SyntaxToken token, SourceText text, in DocumentationCommentOptions options, out string? indentText, out int caretOffset, out int spanToReplaceLength) 129public bool IsValidTargetMember(SyntaxTree syntaxTree, SourceText text, int position, CancellationToken cancellationToken) 132private TMemberNode? GetTargetMember(SyntaxTree syntaxTree, SourceText text, int position, CancellationToken cancellationToken) 189public DocumentationCommentSnippet? GetDocumentationCommentSnippetOnEnterTyped(SyntaxTree syntaxTree, SourceText text, int position, in DocumentationCommentOptions options, CancellationToken cancellationToken) 207private DocumentationCommentSnippet? GenerateDocumentationCommentAfterEnter(SyntaxTree syntaxTree, SourceText text, int position, in DocumentationCommentOptions options, CancellationToken cancellationToken) 249public DocumentationCommentSnippet? GetDocumentationCommentSnippetOnCommandInvoke(SyntaxTree syntaxTree, SourceText text, int position, in DocumentationCommentOptions options, CancellationToken cancellationToken) 286private DocumentationCommentSnippet? GenerateExteriorTriviaAfterEnter(SyntaxTree syntaxTree, SourceText text, int position, in DocumentationCommentOptions options, CancellationToken cancellationToken)
DocumentationComments\IDocumentationCommentSnippetService.cs (4)
20SourceText text, 27SourceText text, 34SourceText text, 44bool IsValidTargetMember(SyntaxTree syntaxTree, SourceText text, int caretPosition, CancellationToken cancellationToken);
EditAndContinue\AbstractEditAndContinueAnalyzer.cs (10)
498private static readonly SourceText s_emptySource = SourceText.From(""); 527SourceText oldText; 551var newText = await newDocument.GetTextAsync(cancellationToken).ConfigureAwait(false); 700static void LogRudeEdits(ArrayBuilder<RudeEditDiagnostic> diagnostics, SourceText text, string filePath) 794SourceText newText, 951SourceText newText, 1263private bool TryGetTrackedStatement(ImmutableArray<LinePositionSpan> activeStatementSpans, int index, SourceText text, SyntaxNode declaration, SyntaxNode body, [NotNullWhen(true)] out SyntaxNode? trackedStatement, out int trackedStatementPart) 2411SourceText newText, 2846var oldSyntaxText = await oldSyntaxDocument.GetTextAsync(cancellationToken).ConfigureAwait(false);
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 (13)
224var sourceText = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); 283var matchingSourceText = maybeMatchingSourceText.Value; 310private async ValueTask<(Optional<SourceText?> matchingSourceText, bool? hasDocument)> TryGetMatchingSourceTextAsync(Document document, SourceText sourceText, Document? currentDocument, CancellationToken cancellationToken) 322private static async ValueTask<Optional<SourceText?>> TryGetMatchingSourceTextAsync( 323SourceText sourceText, string filePath, Document? currentDocument, IPdbMatchingSourceTextProvider sourceTextProvider, ImmutableArray<byte> requiredChecksum, SourceHashAlgorithm checksumAlgorithm, CancellationToken cancellationToken) 332var currentDocumentSourceText = await currentDocument.GetTextAsync(cancellationToken).ConfigureAwait(false); 342return SourceText.From(text, sourceText.Encoding, checksumAlgorithm); 386var sourceText = await documentState.GetTextAsync(cancellationToken).ConfigureAwait(false); 437private static bool IsMatchingSourceText(SourceText sourceText, ImmutableArray<byte> requiredChecksum, SourceHashAlgorithm checksumAlgorithm) 440private static Optional<SourceText?> TryGetPdbMatchingSourceTextFromDisk(string sourceFilePath, Encoding? encoding, ImmutableArray<byte> requiredChecksum, SourceHashAlgorithm checksumAlgorithm) 450var sourceText = SourceText.From(fileStream, encoding, checksumAlgorithm);
EditAndContinue\EditSession.cs (6)
203var oldText = await oldDocument.GetTextAsync(cancellationToken).ConfigureAwait(false); 204var newText = await newDocument.GetTextAsync(cancellationToken).ConfigureAwait(false); 218private static TextSpan GetFirstLineDifferenceSpan(SourceText oldText, SourceText newText) 325var oldSource = await oldDocument.GetTextAsync(cancellationToken).ConfigureAwait(false); 326var newSource = await newDocument.GetTextAsync(cancellationToken).ConfigureAwait(false);
EditAndContinue\TraceLog.cs (1)
203var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
EmbeddedLanguages\DateAndTime\DateAndTimeEmbeddedCompletionProvider.cs (2)
38public override bool ShouldTriggerCompletion(SourceText text, int caretPosition, CompletionTrigger trigger) 97var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
EmbeddedLanguages\DateAndTime\EmbeddedCompletionContext.cs (1)
37SourceText text,
EmbeddedLanguages\RegularExpressions\LanguageServices\RegexEmbeddedCompletionProvider.cs (1)
49public 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)
29if (!oldDocument.TryGetText(out var oldText) || 30!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)
39public LinePositionSpan GetLinePositionSpan(SourceText sourceText, bool useMapped) 46public LinePositionSpan GetLinePositionSpan(SourceText sourceText)
ExternalAccess\VSTypeScript\VSTypeScriptTaskListService.cs (1)
41var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
FormattingAnalyzerHelper.cs (3)
23var oldText = tree.GetText(cancellationToken); 41if (oldText.GetSubText(new TextSpan(change.Span.Start + offset, change.NewText.Length)).ContentEquals(SourceText.From(change.NewText))) 50if (oldText.GetSubText(new TextSpan(change.Span.Start, change.NewText.Length)).ContentEquals(SourceText.From(change.NewText)))
FormattingCodeFixHelper.cs (1)
20var text = await syntaxTree.GetTextAsync(cancellationToken).ConfigureAwait(false);
FullyQualify\AbstractFullyQualifyCodeFixProvider.cs (2)
41var sourceText = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); 42var newText = sourceText.WithChanges(d.TextChanges);
GenerateComparisonOperators\GenerateComparisonOperatorsCodeRefactoringProvider.cs (1)
48var sourceText = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
GenerateConstructorFromMembers\AbstractGenerateConstructorFromMembersCodeRefactoringProvider.cs (1)
185var sourceText = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
GenerateEqualsAndGetHashCodeFromMembers\GenerateEqualsAndGetHashCodeFromMembersCodeRefactoringProvider.cs (1)
79var sourceText = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
GenerateOverrides\GenerateOverridesCodeRefactoringProvider.cs (1)
39var sourceText = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
InheritanceMargin\AbstractInheritanceMarginService_Helpers.cs (2)
87var sourceText = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); 206var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
InvertIf\AbstractInvertIfCodeRefactoringProvider.cs (3)
74SourceText sourceText, 296var sourceText = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); 426SourceText text,
MetadataAsSource\DecompilationMetadataAsSourceFileProvider.cs (1)
156var text = await temporaryDocument.GetTextAsync(cancellationToken).ConfigureAwait(false);
MetadataAsSource\MetadataAsSourceGeneratedFileInfo.cs (2)
75var assemblyInfoSourceText = SourceText.From(assemblyInfoString, Encoding, ChecksumAlgorithm);
MoveToNamespace\AbstractMoveToNamespaceService.cs (1)
288var formattedText = await formattedDocument.GetTextAsync(cancellationToken).ConfigureAwait(false);
NavigateTo\NavigateToUtilities.cs (1)
29public static TextSpan GetBoundedSpan(INavigableItem item, SourceText sourceText)
PdbSourceDocument\PdbSourceDocumentLoaderService.cs (2)
201var sourceText = SourceText.From(stream, encoding, sourceDocument.ChecksumAlgorithm, throwIfBinaryDetected: true);
QuickInfo\IndentationHelper.cs (2)
28SourceText text, 85SourceText text,
Rename\SymbolicRenameInfo.cs (1)
256var sourceText = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
ReplaceDocCommentTextWithTag\AbstractReplaceDocCommentTextWithTagCodeRefactoringProvider.cs (7)
40var sourceText = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); 113var sourceText = semanticModel.SyntaxTree.GetText(cancellationToken); 155var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); 156var newText = text.Replace(span, replacement); 161private static TextSpan ExpandSpan(SourceText sourceText, TextSpan span, bool fullyQualifiedName) 186SourceText sourceText, int endExclusive, bool fullyQualifiedName) 207SourceText sourceText, int startInclusive, bool fullyQualifiedName)
Snippets\RoslynLSPSnippetConverter.cs (1)
114var documentText = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
Snippets\SnippetFunctionService.cs (1)
44var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
Snippets\SnippetProviders\AbstractConsoleSnippetProvider.cs (1)
84protected override int GetTargetCaretPosition(ISyntaxFactsService syntaxFacts, SyntaxNode caretTarget, SourceText sourceText)
Snippets\SnippetProviders\AbstractSnippetProvider.cs (3)
48protected abstract int GetTargetCaretPosition(ISyntaxFactsService syntaxFacts, SyntaxNode caretTarget, SourceText sourceText); 129var sourceText = await annotatedReformattedDocument.GetTextAsync(cancellationToken).ConfigureAwait(false); 210var originalText = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
Snippets\SnippetUtilities.cs (1)
12public static bool TryGetWordOnLeft(int position, SourceText currentText, ISyntaxFactsService syntaxFactsService, [NotNullWhen(true)] out TextSpan? wordSpan)
SolutionCrawler\AbstractDocumentDifferenceService.cs (2)
30if (!oldDocument.TryGetText(out var oldText) || 31!newDocument.TryGetText(out var newText))
TaskList\AbstractTaskListService.cs (1)
128var text = document.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)
ValueTracking\SerializableValueTrackedItem.cs (1)
63var sourceText = await syntaxTree.GetTextAsync(cancellationToken).ConfigureAwait(false);
ValueTracking\ValueTrackedItem.cs (4)
24public SourceText SourceText { get; } 29SourceText sourceText, 45var subText = SourceText.GetSubText(Span); 55var sourceText = await syntaxTree.GetTextAsync(cancellationToken).ConfigureAwait(false);
Wrapping\AbstractCodeActionComputer.cs (3)
50protected readonly SourceText OriginalSourceText; 67SourceText originalSourceText, 91var newSourceText = OriginalSourceText.WithChanges(new TextChange(new TextSpan(nodeOrToken.Span.End, 0), newLine));
Wrapping\AbstractWrapper.cs (1)
47var sourceText = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
Wrapping\BinaryExpression\AbstractBinaryExpressionWrapper.cs (1)
90var sourceText = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
Wrapping\BinaryExpression\BinaryExpressionCodeActionComputer.cs (1)
48SourceText originalSourceText,
Wrapping\ChainedExpression\AbstractChainedExpressionWrapper.cs (1)
111var sourceText = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
Wrapping\ChainedExpression\ChainedExpressionCodeActionComputer.cs (1)
72SourceText originalSourceText,
Wrapping\SeparatedSyntaxList\AbstractSeparatedSyntaxListWrapper.cs (1)
84var sourceText = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
Wrapping\SeparatedSyntaxList\SeparatedSyntaxListCodeActionComputer.cs (1)
76SourceText sourceText,
Microsoft.CodeAnalysis.LanguageServer.Protocol (100)
Extensions\Extensions.cs (1)
134var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
Extensions\ProtocolConversions.cs (10)
140var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); 174public static LSP.TextDocumentPositionParams PositionToTextDocumentPositionParams(int position, SourceText text, Document document) 195public static TextSpan RangeToTextSpan(LSP.Range range, SourceText text) 210public static LSP.TextEdit TextChangeToTextEdit(TextChange textChange, SourceText oldText) 220public static TextChange ContentChangeEventToTextChange(LSP.TextDocumentContentChangeEvent changeEvent, SourceText text) 229public static LSP.Range TextSpanToRange(TextSpan textSpan, SourceText text) 266var oldText = await oldDocument.GetTextAsync(cancellationToken).ConfigureAwait(false); 279var newText = await newDocument.GetTextAsync(cancellationToken).ConfigureAwait(false); 366var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); 380static LSP.Location ConvertTextSpanWithTextToLocation(TextSpan span, SourceText text, Uri documentUri)
Features\CodeFixes\CodeFixService.cs (5)
109var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); 191var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); 211var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); 228SourceText text, ImmutableArray<DiagnosticData> diagnostics) 301var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
Features\Diagnostics\DocumentAnalysisExecutor.cs (1)
161var sourceText = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
Features\Diagnostics\DocumentAnalysisExecutor_Helpers.cs (1)
360var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
Features\Diagnostics\EngineV2\DiagnosticIncrementalAnalyzer.IncrementalMemberEditAnalyzer.cs (3)
259var text = tree.GetText(cancellationToken); 290SourceText text, 374static DiagnosticData UpdateLocations(DiagnosticData diagnostic, SyntaxTree tree, SourceText text, int delta)
Features\Diagnostics\EngineV2\DiagnosticIncrementalAnalyzer_GetDiagnosticsForSpan.cs (3)
67private readonly SourceText _text; 98var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); 152SourceText text,
Features\UnifiedSuggestions\UnifiedSuggestedActionsSource.cs (4)
59var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); 71SourceText text, 283SourceText text, 391SourceText text,
Handler\Breakpoints\ValidateBreakableRangeHandler.cs (1)
39var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
Handler\CodeActions\CodeActionHelpers.cs (4)
45var documentText = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); 81SourceText documentText, 118SourceText documentText, 240var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
Handler\CodeActions\CodeActionResolveHandler.cs (2)
184var oldText = await oldTextDoc.GetTextAsync(cancellationToken).ConfigureAwait(false); 197var newText = await newTextDoc.GetTextAsync(cancellationToken).ConfigureAwait(false);
Handler\CodeLens\CodeLensHandler.cs (1)
45var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
Handler\Completion\CompletionHandler.cs (3)
84var documentText = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); 302SourceText sourceText, 369SourceText sourceText)
Handler\Completion\CompletionResolveHandler.cs (1)
142var documentText = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
Handler\Completion\ILspCompletionResultCreationService.cs (3)
22SourceText documentText, 41SourceText documentText, 58SourceText documentText,
Handler\DocumentChanges\DidChangeHandler.cs (1)
34var text = context.GetTrackedDocumentSourceText(request.TextDocument.Uri);
Handler\DocumentChanges\DidOpenHandler.cs (2)
40var sourceText = SourceText.From(request.TextDocument.Text, System.Text.Encoding.UTF8, SourceHashAlgorithms.OpenDocumentChecksumAlgorithm);
Handler\FoldingRanges\FoldingRangesHandler.cs (2)
61var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); 65private static FoldingRange[] GetFoldingRanges(BlockStructure blockStructure, SourceText text)
Handler\Formatting\AbstractFormatDocumentHandlerBase.cs (1)
35var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
Handler\Highlights\DocumentHighlightHandler.cs (3)
49var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); 70private async Task<ImmutableArray<DocumentHighlight>> GetKeywordHighlightsAsync(Document document, SourceText text, int position, CancellationToken cancellationToken) 84private async Task<ImmutableArray<DocumentHighlight>> GetReferenceHighlightsAsync(Document document, SourceText text, int position, CancellationToken cancellationToken)
Handler\Hover\ILspHoverResultCreationService.cs (1)
45var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
Handler\IDocumentChangeTracker.cs (4)
17void StartTracking(Uri documentUri, SourceText initialText); 18void UpdateTrackedDocument(Uri documentUri, SourceText text); 24public void StartTracking(Uri documentUri, SourceText initialText) 34public void UpdateTrackedDocument(Uri documentUri, SourceText text)
Handler\InlineCompletions\InlineCompletionsHandler.cs (6)
78var sourceText = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); 132SourceText originalSourceText, 145var documentWithSnippetText = originalSourceText.WithChanges(textChange); 152var formattedText = documentWithSnippetText.WithChanges(formattingChanges); 186var formattedLspSnippetText = formattedText.GetSubText(spanContainingFormattedSnippet).WithChanges(lspTextChanges); 210SourceText originalSourceText,
Handler\OnAutoInsert\OnAutoInsertHandler.cs (9)
108var sourceText = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); 139var sourceText = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); 157var newSourceText = sourceText.WithChanges(textChanges); 165var indentedText = GetIndentedText(newSourceText, caretLine, desiredCaretLinePosition, options); 197static SourceText GetIndentedText( 198SourceText textToIndent, 208var indentedText = textToIndent.WithChanges(new TextChange(new TextSpan(lineToIndent.End, 0), indentText)); 214var documentText = await oldDocument.GetTextAsync(cancellationToken).ConfigureAwait(false); 219static string GetTextChangeTextWithCaretAtLocation(SourceText sourceText, TextChange textChange, LinePosition desiredCaretLinePosition)
Handler\References\FindUsagesLSPContext.cs (2)
265var docText = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); 286SourceText docText)
Handler\RequestContext.cs (5)
43private readonly ImmutableDictionary<Uri, SourceText> _trackedDocuments; 95ImmutableDictionary<Uri, SourceText> trackedDocuments, 205public void StartTracking(Uri uri, SourceText initialText) 212public void UpdateTrackedDocument(Uri uri, SourceText changedText) 215public SourceText GetTrackedDocumentSourceText(Uri documentUri)
Handler\SemanticTokens\SemanticTokensHelpers.cs (3)
82var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); 145public static ClassifiedSpan[] ConvertMultiLineToSingleLineSpans(SourceText text, ClassifiedSpan[] classifiedSpans) 172SourceText text,
Handler\SpellCheck\AbstractSpellCheckingHandler.cs (2)
157var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); 204private static LSP.VSInternalSpellCheckableRange ConvertSpan(SourceText text, SpellCheckSpan spellCheckSpan)
Handler\Symbols\DocumentSymbolsHandler.cs (4)
51var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); 81RoslynNavigationBarItem item, Document document, SourceText text, string? containerName = null) 103RoslynNavigationBarItem item, SourceText text, CancellationToken cancellationToken) 127ImmutableArray<RoslynNavigationBarItem> items, SourceText text, CancellationToken cancellationToken)
Workspaces\LspMiscellaneousFilesWorkspace.cs (4)
54public Document? AddMiscellaneousDocument(Uri uri, SourceText documentText, ILspLogger logger) 77/// Calls to this method and <see cref="AddMiscellaneousDocument(Uri, SourceText, ILspLogger)"/> are made 99private readonly SourceText _sourceText; 102public SourceTextLoader(SourceText sourceText, string fileUri)
Workspaces\LspWorkspaceManager.cs (8)
64private ImmutableDictionary<Uri, SourceText> _trackedDocuments = ImmutableDictionary<Uri, SourceText>.Empty; 96public void StartTracking(Uri uri, SourceText documentText) 133public void UpdateTrackedDocument(Uri uri, SourceText newSourceText) 145public ImmutableDictionary<Uri, SourceText> GetTrackedLspText() => _trackedDocuments; 211if (_trackedDocuments.TryGetValue(uri, out var trackedText)) 329private static async Task<bool> AreChecksumsEqualAsync(Document document, SourceText lspText, CancellationToken cancellationToken) 331var documentText = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
Microsoft.CodeAnalysis.LanguageServer.Protocol.UnitTests (45)
CodeActions\RunCodeActionsTests.cs (1)
57var textForB = await documentForB.GetTextAsync();
Completion\CompletionResolveTests.cs (1)
464internal override bool ShouldTriggerCompletion(Project project, LanguageServices languageServices, SourceText text, int caretPosition, CompletionTrigger trigger, CodeAnalysis.Completion.CompletionOptions options, OptionSet passthroughOptions, ImmutableHashSet<string> roles = null)
Diagnostics\AbstractPullDiagnosticTestsBase.cs (1)
207var sourceText = await document.GetTextAsync();
Diagnostics\PullDiagnosticTests.cs (4)
1209var text = await document.GetTextAsync(); 1304var csproj2DocumentText = await csproj2Document.GetTextAsync(); 1379var csproj3DocumentText = await csproj3Document.GetTextAsync().ConfigureAwait(false); 1446var csproj2DocumentText = await csproj2Document.GetTextAsync();
DocumentChanges\DocumentChangesTests.cs (6)
55var document = testLspServer.GetTrackedTexts().Single(); 86var document = testLspServer.GetTrackedTexts().FirstOrDefault(); 204var document = testLspServer.GetTrackedTexts().FirstOrDefault(); 278var document = testLspServer.GetTrackedTexts().FirstOrDefault(); 316var document = testLspServer.GetTrackedTexts().FirstOrDefault(); 327var documentText = await testLspServer.GetCurrentSolution().GetDocuments(locationTyped.Uri).Single().GetTextAsync();
Formatting\FormatDocumentOnTypeTests.cs (2)
47var documentText = await testLspServer.GetCurrentSolution().GetDocuments(locationTyped.Uri).Single().GetTextAsync(); 78var documentText = await testLspServer.GetCurrentSolution().GetDocuments(locationTyped.Uri).Single().GetTextAsync();
Formatting\FormatDocumentRangeTests.cs (2)
44var documentText = await testLspServer.GetCurrentSolution().GetDocuments(rangeToFormat.Uri).Single().GetTextAsync(); 72var documentText = await testLspServer.GetCurrentSolution().GetDocuments(rangeToFormat.Uri).Single().GetTextAsync();
Formatting\FormatDocumentTests.cs (3)
45var documentText = await testLspServer.GetCurrentSolution().GetDocuments(documentURI).Single().GetTextAsync(); 73var documentText = await testLspServer.GetCurrentSolution().GetDocuments(documentURI).Single().GetTextAsync(); 101var documentText = await testLspServer.GetCurrentSolution().GetDocuments(documentURI).Single().GetTextAsync();
OnAutoInsert\OnAutoInsertTests.cs (2)
407var documentText = await document.GetTextAsync(); 421var documentText = await testLspServer.GetCurrentSolution().GetDocuments(locationTyped.Uri).Single().GetTextAsync();
SemanticTokens\AbstractSemanticTokensTests.cs (2)
46await ((TestWorkspace)workspace).ChangeDocumentAsync(docId, SourceText.From(updatedText)); 54var text = await document.GetTextAsync().ConfigureAwait(false);
SpellCheck\SpellCheckTests.cs (14)
62var sourceText = await document.GetTextAsync(); 93var sourceText = await document.GetTextAsync(); 129var sourceText = await document.GetTextAsync(); 165var sourceText = await document.GetTextAsync(); 212var sourceText = await document.GetTextAsync(); 254var sourceText = await document.GetTextAsync(); 281var sourceText = await document.GetTextAsync(); 309var sourceText = await document.GetTextAsync(); 382var sourceText = await document.GetTextAsync(); 420var sourceText = await document.GetTextAsync(); 456var sourceText = await document.GetTextAsync(); 509var sourceText = await document.GetTextAsync(); 527private static VSInternalSpellCheckableRange[] GetRanges(SourceText sourceText, IDictionary<string, ImmutableArray<TextSpan>> annotatedSpans) 605var sourceText = await document.GetTextAsync();
Workspaces\LspWorkspaceManagerTests.cs (7)
74await testLspServer.TestWorkspace.ChangeDocumentAsync(firstDocument.Id, SourceText.From($"Some more text{markupOne}", System.Text.Encoding.UTF8, SourceHashAlgorithms.Default)); 108await testLspServer.TestWorkspace.ChangeDocumentAsync(secondDocument.Id, SourceText.From("Two is now three!", System.Text.Encoding.UTF8, SourceHashAlgorithms.Default)); 182var newSolution = testLspServer.TestWorkspace.CurrentSolution.AddDocument(newDocumentId, "NewDoc.cs", SourceText.From("New Doc", System.Text.Encoding.UTF8, SourceHashAlgorithms.Default), filePath: @"C:\NewDoc.cs"); 220var miscText = await miscDocument.GetTextAsync(CancellationToken.None); 232var documentText = await document.GetTextAsync(CancellationToken.None); 353var changedFirstDocumentText = await changedFirstDocument.GetTextAsync(CancellationToken.None); 354var firstDocumentText = await firstDocument.GetTextAsync(CancellationToken.None);
Microsoft.CodeAnalysis.LanguageServerIndexFormat.Generator (3)
Generator.cs (2)
266var sourceText = semanticModel.SyntaxTree.GetText(cancellationToken); 418var text = await document.GetTextAsync(cancellationToken);
Graph\Range.cs (1)
25public static Range FromTextSpan(TextSpan textSpan, SourceText sourceText, IdFactory idFactory)
Microsoft.CodeAnalysis.Rebuild (9)
CompilationFactory.cs (1)
43public abstract SyntaxTree CreateSyntaxTree(string filePath, SourceText sourceText);
CompilationOptionsReader.cs (4)
236var embeddedText = SourceText.From(stream, encoding: sourceTextInfo.SourceTextEncoding, checksumAlgorithm: sourceTextInfo.HashAlgorithm, canBeEmbedded: true); 289Func<string, SourceText, SyntaxTree> createSyntaxTreeFunc) 301SourceText sourceText;
CSharpCompilationFactory.cs (1)
44public override SyntaxTree CreateSyntaxTree(string filePath, SourceText sourceText)
IRebuildArtifactResolver.cs (1)
11SourceText ResolveSourceText(SourceTextInfo sourceTextInfo);
Records.cs (1)
16SourceText SourceText,
VisualBasicCompilationFactory.cs (1)
44public override SyntaxTree CreateSyntaxTree(string filePath, SourceText sourceText)
Microsoft.CodeAnalysis.Rebuild.UnitTests (3)
BasicDeterministicKeyBuilderTests.cs (1)
32SourceText.From(content, checksumAlgorithm: hashAlgorithm, encoding: Encoding.UTF8),
CompilationRebuildArtifactResolver.cs (1)
28public SourceText ResolveSourceText(SourceTextInfo sourceTextInfo) =>
DeterministicKeyBuilderTests.cs (1)
253protected static string GetChecksum(SourceText text)
Microsoft.CodeAnalysis.Remote.ServiceHub (5)
Host\RemoteWorkspace.SolutionCreator.cs (2)
89var sourceText = await serializableSourceText.GetTextAsync(cancellationToken).ConfigureAwait(false); 458var sourceText = await serializableSourceText.GetTextAsync(cancellationToken).ConfigureAwait(false);
Services\AssetSynchronization\RemoteAssetSynchronizationService.cs (2)
57var text = await TryGetSourceTextAsync(WorkspaceManager, workspace, documentId, baseTextChecksum, cancellationToken).ConfigureAwait(false); 76async static Task<SourceText?> TryGetSourceTextAsync(
Services\SemanticClassification\RemoteSemanticClassificationService.Caching.cs (1)
138var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
Microsoft.CodeAnalysis.Remote.Workspaces (1)
AbstractAssetProvider.cs (1)
91var text = await serializableSourceText.GetTextAsync(cancellationToken).ConfigureAwait(false);
Microsoft.CodeAnalysis.Scripting (12)
Hosting\CommandLine\CommandLineRunner.cs (5)
105SourceText code = null; 192private int RunScript(ScriptOptions options, SourceText code, ErrorLogger errorLogger, CancellationToken cancellationToken) 223var script = Script.CreateInitialScript<object>(_scriptCompiler, SourceText.From(initialScriptCodeOpt), options, globals.GetType(), assemblyLoaderOpt: null); 250var tree = _scriptCompiler.ParseSubmission(SourceText.From(input.ToString()), options.ParseOptions, cancellationToken); 275newScript = 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); 318internal Script(ScriptCompiler compiler, ScriptBuilder builder, SourceText sourceText, ScriptOptions options, Type globalsTypeOpt, Script previousOpt)
ScriptCompiler.cs (1)
20public abstract SyntaxTree ParseSubmission(SourceText text, ParseOptions parseOptions, CancellationToken cancellationToken);
Microsoft.CodeAnalysis.Scripting.TestUtilities (3)
TestCompilationFactory.cs (3)
24new[] { CSharp.SyntaxFactory.ParseSyntaxTree(SourceText.From(source, encoding: null, SourceHashAlgorithms.Default)) }, 33new[] { VisualBasic.SyntaxFactory.ParseSyntaxTree(SourceText.From(source, encoding: null, SourceHashAlgorithms.Default)) }, 42new[] { CSharp.SyntaxFactory.ParseSyntaxTree(SourceText.From(source, encoding: null, SourceHashAlgorithms.Default)) },
Microsoft.CodeAnalysis.Test.Utilities (23)
AssemblyLoadTestFixture.cs (1)
470syntaxTrees: new SyntaxTree[] { SyntaxFactory.ParseSyntaxTree(SourceText.From(csSource, encoding: null, SourceHashAlgorithms.Default)) },
CommonTestBase.cs (2)
360var tree = CSharp.SyntaxFactory.ParseSyntaxTree(SourceText.From(code, encoding: null, SourceHashAlgorithms.Default), options: parseOptions); 443trees[i] = VisualBasic.VisualBasicSyntaxTree.ParseText(SourceText.From(files[i], encoding, SourceHashAlgorithms.Default), options: parseOptions, path: sourceFileNames?[i]);
Compilation\CompilationExtensions.cs (1)
505new[] { CSharpSyntaxTree.ParseText(SourceText.From(source, encoding: null, SourceHashAlgorithms.Default)) },
Diagnostics\CommonDiagnosticAnalyzers.cs (4)
1611private readonly HashSet<SourceText> _textCallbackSet; 1651_textCallbackSet = new HashSet<SourceText>(SourceTextComparer.Instance); 1669private int GetCharacterCount(SourceText text) 2488var text = context.AdditionalFile.GetText();
Metadata\ILValidation.cs (4)
373public static Dictionary<int, string> GetSequencePointMarkers(XElement methodXml, Func<string, SourceText> getSource) 398var source = getSource(documentId); 407private static string SnippetFromSpan(SourceText text, XElement sequencePointXml) 421var subtext = text.GetSubText(span);
Metadata\MetadataReaderUtils.cs (1)
271public static SourceText GetEmbeddedSource(this MetadataReader reader, DocumentHandle document)
Mocks\TestAdditionalText.cs (3)
14private readonly SourceText? _text; 16public TestAdditionalText(string path, SourceText? text) 29public override SourceText? GetText(CancellationToken cancellationToken = default) => _text;
SourceGeneration\TestGenerators.cs (6)
38context.AddSource(hintName, SourceText.From(content, Encoding.UTF8)); 96context.AddSource("source", SourceText.From(_source, Encoding.UTF8)); 111private readonly SourceText _content; 116_content = SourceText.From(content, Encoding.UTF8); 121public override SourceText GetText(CancellationToken cancellationToken = default) => _content; 127public override SourceText GetText(CancellationToken cancellationToken = default) => throw new InvalidDataException("Binary content not supported");
TestBase.cs (1)
180var syntaxTree = Microsoft.CodeAnalysis.CSharp.SyntaxFactory.ParseSyntaxTree(SourceText.From(source, encoding: null, SourceHashAlgorithms.Default));
Microsoft.CodeAnalysis.TestAnalyzerReference (5)
HelloWorldGenerator.cs (2)
23context.AddSource(GeneratedEnglishClassName, SourceText.From(@" 34context.AddSource(GeneratedSpanishClassName, SourceText.From(@"
NonSourceFileRefactoring.cs (3)
29var text = await document.GetTextAsync(ct).ConfigureAwait(false); 30var newText = SourceText.From(text.ToString() + Environment.NewLine + "# Refactored");
Microsoft.CodeAnalysis.UnitTests (501)
EmbeddedTextTests.cs (29)
39Assert.Throws<ArgumentException>("text", () => EmbeddedText.FromSource("path", SourceText.From("source"))); 42Assert.Throws<ArgumentException>("text", () => EmbeddedText.FromSource("path", SourceText.From(new byte[0], 0, Encoding.UTF8, canBeEmbedded: false))); 43Assert.Throws<ArgumentException>("text", () => EmbeddedText.FromSource("path", SourceText.From(new MemoryStream(new byte[0]), Encoding.UTF8, canBeEmbedded: false))); 84AssertEx.Equal(SourceText.CalculateChecksum(new byte[0], 0, 0, SourceHashAlgorithm.Sha1), text.Checksum); 92var checksum = SourceText.CalculateChecksum(new byte[0], 0, 0, SourceHashAlgorithm.Sha1); 103var source = SourceText.From("", new UTF8Encoding(encoderShouldEmitUTF8Identifier: false), SourceHashAlgorithm.Sha1); 105var checksum = SourceText.CalculateChecksum(new byte[0], 0, 0, SourceHashAlgorithm.Sha1); 117var checksum = SourceText.CalculateChecksum(bytes, 0, bytes.Length, SourceHashAlgorithm.Sha1); 132var checksum = SourceText.CalculateChecksum(bytes, 0, bytes.Length, SourceHashAlgorithm.Sha1); 145var source = SourceText.From(SmallSource, Encoding.UTF8, SourceHashAlgorithm.Sha1); 159var checksum = SourceText.CalculateChecksum(bytes, 0, bytes.Length, SourceHashAlgorithms.Default); 174var checksum = SourceText.CalculateChecksum(bytes, 0, bytes.Length, SourceHashAlgorithms.Default); 187var source = SourceText.From(LargeSource, Encoding.Unicode, SourceHashAlgorithms.Default); 200var expected = SourceText.From(SmallSource, Encoding.UTF8, SourceHashAlgorithm.Sha1); 203var actual = SourceText.From(new StringReader(SmallSource), SmallSource.Length, Encoding.UTF8, SourceHashAlgorithm.Sha1); 215var expected = SourceText.From(LargeSource, Encoding.UTF8, SourceHashAlgorithm.Sha1); 218var actual = SourceText.From(new StringReader(LargeSource), LargeSource.Length, Encoding.UTF8, SourceHashAlgorithm.Sha1); 235var source = useStream ? 236SourceText.From(new MemoryStream(bytes), Encoding.ASCII, SourceHashAlgorithm.Sha1, canBeEmbedded: true) : 237SourceText.From(bytes, bytes.Length, Encoding.ASCII, SourceHashAlgorithm.Sha1, canBeEmbedded: true); 242AssertEx.Equal(SourceText.CalculateChecksum(bytes, 0, bytes.Length, SourceHashAlgorithm.Sha1), source.GetChecksum()); 252var source = EncodedStringText.Create(new MemoryStream(new byte[] { 0xA9, 0x0D, 0x0A }), canBeEmbedded: true);
Text\LargeTextTests.cs (24)
18private static SourceText CreateSourceText(string s, Encoding encoding = null) 31private static SourceText CreateSourceText(Stream stream, Encoding encoding = null) 36private static SourceText CreateSourceText(TextReader reader, int length, Encoding encoding = null) 46var text = CreateSourceText(HelloWorld); 56var text = CreateSourceText(stream); 64var text = CreateSourceText(HelloWorld); 76var text = CreateSourceText(HelloWorld); 123var text = SourceText.From(stream); 155private static void CheckLine(SourceText text, int lineNumber, int start, int length, int newlineLength, string lineText) 199var data = CreateSourceText("goo" + newline + " bar"); 212var data = CreateSourceText(text); 223var data = CreateSourceText("goo\r\nbar"); 232var data = CreateSourceText("goo\n\rbar\u2028"); 244var data = CreateSourceText("goo\r"); 254var data = CreateSourceText("goo\r\n"); 264var data = CreateSourceText("goo\r\rbar"); 277var data = CreateSourceText("goo" + cr + crLf + cr + "bar"); 292var data = CreateSourceText("goo" + cr + crLf + lf + "bar"); 303var data = CreateSourceText(""); 314var data = CreateSourceText(text); 324var data = CreateSourceText(text); 332var expectedSourceText = CreateSourceText(expected); 335var actualSourceText = CreateSourceText(actual, expected.Length);
Text\SourceTextStreamTests.cs (4)
27var sourceText = SourceText.From("hello world", s_utf8NoBom); 50var sourceText = SourceText.From(text, encoding);
Text\SourceTextTests.cs (88)
28TestIsEmpty(SourceText.From(string.Empty)); 29TestIsEmpty(SourceText.From(new byte[0], 0)); 30TestIsEmpty(SourceText.From(new MemoryStream())); 33private static void TestIsEmpty(SourceText text) 46Assert.Same(s_utf8, SourceText.From(HelloWorld, s_utf8).Encoding); 47Assert.Same(s_unicode, SourceText.From(HelloWorld, s_unicode).Encoding); 50Assert.Same(s_unicode, SourceText.From(bytes, bytes.Length, s_unicode).Encoding); 51Assert.Equal(utf8NoBOM, SourceText.From(bytes, bytes.Length, null).Encoding); 54Assert.Same(s_unicode, SourceText.From(stream, s_unicode).Encoding); 55Assert.Equal(utf8NoBOM, SourceText.From(stream, null).Encoding); 64Assert.Equal(utf8BOM, SourceText.From(bytes, bytes.Length, s_unicode).Encoding); 65Assert.Equal(utf8BOM, SourceText.From(bytes, bytes.Length, null).Encoding); 68Assert.Equal(utf8BOM, SourceText.From(stream, s_unicode).Encoding); 69Assert.Equal(utf8BOM, SourceText.From(stream, null).Encoding); 75Assert.Equal(SourceHashAlgorithm.Sha1, SourceText.From(HelloWorld).ChecksumAlgorithm); 78Assert.Equal(SourceHashAlgorithm.Sha1, SourceText.From(bytes, bytes.Length).ChecksumAlgorithm); 81Assert.Equal(SourceHashAlgorithm.Sha1, SourceText.From(stream).ChecksumAlgorithm); 89Assert.Equal(algorithm, SourceText.From(HelloWorld, checksumAlgorithm: algorithm).ChecksumAlgorithm); 92Assert.Equal(algorithm, SourceText.From(bytes, bytes.Length, checksumAlgorithm: algorithm).ChecksumAlgorithm); 95Assert.Equal(algorithm, SourceText.From(stream, checksumAlgorithm: algorithm).ChecksumAlgorithm); 111VerifyChecksum(SourceText.From(source, encodingNoBOM, checksumAlgorithm), checksumNoBOM); 112VerifyChecksum(SourceText.From(source, encodingBOM, checksumAlgorithm), checksumBOM); 121VerifyChecksum(SourceText.From(bytesNoBOM, bytesNoBOM.Length, null, checksumAlgorithm), checksumNoBOM); 122VerifyChecksum(SourceText.From(bytesNoBOM, bytesNoBOM.Length, encodingNoBOM, checksumAlgorithm), checksumNoBOM); 123VerifyChecksum(SourceText.From(bytesNoBOM, bytesNoBOM.Length, encodingBOM, checksumAlgorithm), checksumNoBOM); 126VerifyChecksum(SourceText.From(bytesBOM, bytesBOM.Length, null, checksumAlgorithm), checksumBOM); 127VerifyChecksum(SourceText.From(bytesBOM, bytesBOM.Length, encodingNoBOM, checksumAlgorithm), checksumBOM); 128VerifyChecksum(SourceText.From(bytesBOM, bytesBOM.Length, encodingBOM, checksumAlgorithm), checksumBOM); 131VerifyChecksum(SourceText.From(streamNoBOM, null, checksumAlgorithm), checksumNoBOM); 132VerifyChecksum(SourceText.From(streamNoBOM, encodingNoBOM, checksumAlgorithm), checksumNoBOM); 133VerifyChecksum(SourceText.From(streamNoBOM, encodingBOM, checksumAlgorithm), checksumNoBOM); 136VerifyChecksum(SourceText.From(streamBOM, null, checksumAlgorithm), checksumBOM); 137VerifyChecksum(SourceText.From(streamBOM, encodingNoBOM, checksumAlgorithm), checksumBOM); 138VerifyChecksum(SourceText.From(streamBOM, encodingBOM, checksumAlgorithm), checksumBOM); 156VerifyChecksum(FromChanges(SourceText.From(source, encodingNoBOM, checksumAlgorithm)), checksumNoBOM); 157VerifyChecksum(FromChanges(SourceText.From(source, encodingBOM, checksumAlgorithm)), checksumBOM); 162VerifyChecksum(FromChanges(SourceText.From(streamNoBOM, encodingNoBOM, checksumAlgorithm)), checksumNoBOM); 163VerifyChecksum(FromChanges(SourceText.From(streamNoBOM, encodingBOM, checksumAlgorithm)), checksumBOM); 166VerifyChecksum(FromChanges(SourceText.From(streamBOM, encodingNoBOM, checksumAlgorithm)), checksumBOM); 167VerifyChecksum(FromChanges(SourceText.From(streamBOM, encodingBOM, checksumAlgorithm)), checksumBOM); 170private static SourceText FromLargeTextWriter(string source, Encoding encoding, SourceHashAlgorithm checksumAlgorithm) 179private static SourceText FromChanges(SourceText text) 183var changed = text.WithChanges(change); 188private static void VerifyChecksum(SourceText text, ImmutableArray<byte> expectedChecksum) 197var f = SourceText.From(HelloWorld, s_utf8); 199Assert.True(f.ContentEquals(SourceText.From(HelloWorld, s_utf8))); 200Assert.False(f.ContentEquals(SourceText.From(HelloWorld + "o", s_utf8))); 201Assert.True(SourceText.From(HelloWorld, s_utf8).ContentEquals(SourceText.From(HelloWorld, s_utf8))); 203var e1 = EncodedStringText.Create(new MemoryStream(s_unicode.GetBytes(HelloWorld)), s_unicode); 204var e2 = EncodedStringText.Create(new MemoryStream(s_utf8.GetBytes(HelloWorld)), s_utf8); 218Assert.False(SourceText.IsBinary("")); 220Assert.False(SourceText.IsBinary("\0abc")); 221Assert.False(SourceText.IsBinary("a\0bc")); 222Assert.False(SourceText.IsBinary("abc\0")); 223Assert.False(SourceText.IsBinary("a\0b\0c")); 225Assert.True(SourceText.IsBinary("\0\0abc")); 226Assert.True(SourceText.IsBinary("a\0\0bc")); 227Assert.True(SourceText.IsBinary("abc\0\0")); 230Assert.False(SourceText.IsBinary(encoding.GetString(new byte[] { 0x81, 0x8D, 0x8F, 0x90, 0x9D }))); 232Assert.False(SourceText.IsBinary("abc def baz aeiouy \u00E4\u00EB\u00EF\u00F6\u00FC\u00FB")); 233Assert.True(SourceText.IsBinary(encoding.GetString(TestMetadata.ResourcesNet451.System))); 240Assert.Throws<InvalidDataException>(() => SourceText.From(bytes, bytes.Length, throwIfBinaryDetected: true)); 243Assert.Throws<InvalidDataException>(() => SourceText.From(stream, throwIfBinaryDetected: true)); 250var expectedSourceText = SourceText.From(expected); 253var actualSourceText = SourceText.From(actual, expected.Length); 257Assert.Same(s_utf8, SourceText.From(actual, expected.Length, s_utf8).Encoding); 258Assert.Same(s_unicode, SourceText.From(actual, expected.Length, s_unicode).Encoding); 259Assert.Null(SourceText.From(actual, expected.Length, null).Encoding); 265var expected = new string('l', SourceText.LargeObjectHeapLimitInChars); 266var expectedSourceText = SourceText.From(expected); 269var actualSourceText = SourceText.From(actual, expected.Length); 276Assert.Same(s_utf8, SourceText.From(actual, expected.Length, s_utf8).Encoding); 277Assert.Same(s_unicode, SourceText.From(actual, expected.Length, s_unicode).Encoding); 278Assert.Null(SourceText.From(actual, expected.Length, null).Encoding); 289Encoding actualEncoding = SourceText.TryReadByteOrderMark(data, validLength, out actualPreambleLength); 322var sourceText = SourceText.From("ABCDEFGHIJKLMNOPQRSTUVWXYZ"); 341var sourceText = SourceText.From(Text); 353SourceText.From("ABC").Write(TextWriter.Null, TextSpan.FromBounds(4, 4))); 362SourceText.From("ABC").Write(TextWriter.Null, TextSpan.FromBounds(2, 4)));
Text\StringText_LineTest.cs (26)
19var text = SourceText.From("goo" + newLine); 30var text = SourceText.From("goo" + Environment.NewLine); 41var text = SourceText.From("goo" + Environment.NewLine + "bar"); 52var text = SourceText.From("goo"); 61var text = SourceText.From("abcdef"); 68var text = SourceText.From("abcdef"); 75var text = SourceText.From("abcdef"); 82var text = SourceText.From("goo" + Environment.NewLine); 97var text = SourceText.From(Environment.NewLine); 106var text = SourceText.From("abcdef"); 113var text = SourceText.From("abcdef"); 120var text = SourceText.From("abcdef"); 127var text = SourceText.From("abcdef");
Text\StringTextDecodingTests.cs (20)
19private static SourceText CreateMemoryStreamBasedEncodedText(string text, Encoding writeEncoding, Encoding readEncodingOpt, SourceHashAlgorithm algorithm = SourceHashAlgorithm.Sha1) 26private static SourceText CreateMemoryStreamBasedEncodedText(byte[] bytes, Encoding readEncodingOpt, SourceHashAlgorithm algorithm = SourceHashAlgorithm.Sha1) 39private static SourceText CreateMemoryStreamBasedEncodedText(byte[] bytes, 59var data = CreateMemoryStreamBasedEncodedText(TestResources.General.ShiftJisSource, () => sjis); 69var data = CreateMemoryStreamBasedEncodedText(TestResources.General.ShiftJisSource, sjis); 78var data = CreateMemoryStreamBasedEncodedText("The quick brown fox jumps over the lazy dog", Encoding.ASCII, readEncodingOpt: null); 88var data = CreateMemoryStreamBasedEncodedText("The quick brown fox jumps over the lazy dog", Encoding.Unicode, readEncodingOpt: null); 97var data = CreateMemoryStreamBasedEncodedText("The quick brown fox jumps over the lazy dog", Encoding.BigEndianUnicode, readEncodingOpt: null); 106var data = CreateMemoryStreamBasedEncodedText("", Encoding.ASCII, readEncodingOpt: null); 116var data = CreateMemoryStreamBasedEncodedText("", Encoding.Unicode, readEncodingOpt: null); 125var data = CreateMemoryStreamBasedEncodedText("", Encoding.BigEndianUnicode, readEncodingOpt: null); 134var data = CreateMemoryStreamBasedEncodedText("", Encoding.UTF8, readEncodingOpt: null, algorithm: SourceHashAlgorithm.Sha256); 170var sourceText = EncodedStringText.Create(stream); 195var sourceText = EncodedStringText.Create(stream); 225var sourceText = EncodedStringText.Create(stream); 244var text = CreateMemoryStreamBasedEncodedText("goo", writeEncoding, readEncoding); 274var text = CreateMemoryStreamBasedEncodedText("goo", writeEncoding, readEncoding); 310var encodedText = EncodedStringText.Create(fs); 324var encodedText = EncodedStringText.Create(fs); 340var sourceText = EncodedStringText.Create(ms);
Text\StringTextTest.cs (37)
46var data = SourceText.From("goo", Encoding.UTF8); 54var data = SourceText.From("goo"); 61var data = SourceText.From(string.Empty); 69Assert.Throws<ArgumentNullException>(() => SourceText.From((string)null, Encoding.UTF8)); 75Assert.Throws<ArgumentNullException>(() => SourceText.From((Stream)null, Encoding.UTF8)); 76Assert.Throws<ArgumentException>(() => SourceText.From(new TestStream(canRead: false, canSeek: true), Encoding.UTF8)); 77Assert.Throws<NotImplementedException>(() => SourceText.From(new TestStream(canRead: true, canSeek: false), Encoding.UTF8)); 83var data = SourceText.From(string.Empty, Encoding.UTF8); 108private void CheckLine(SourceText text, int lineNumber, int start, int length, int newlineLength, string lineText) 152var data = SourceText.From("goo" + newLine + " bar"); 165var data = SourceText.From(text); 176var data = SourceText.From("goo\r\nbar"); 185var data = SourceText.From("goo\n\rbar\u2028"); 196var data = SourceText.From(""); 207var data = SourceText.From(text); 217var data = SourceText.From(text); 224var data = SourceText.From("The quick brown fox jumps over the lazy dog", Encoding.UTF8); 234var source = SourceText.From(new MemoryStream(bytes), Encoding.ASCII); 249var source = SourceText.From(new MemoryStream(bytes), Encoding.ASCII); 261var source = SourceText.From(new MemoryStream(bytes)); 276var source = SourceText.From(stream, Encoding.ASCII);
Text\StringTextTest_BigEndianUnicode.cs (1)
17protected override SourceText Create(string source)
Text\StringTextTest_Unicode.cs (1)
17protected override SourceText Create(string source)
Text\StringTextTest_Utf8.cs (1)
17protected override SourceText Create(string source)
Text\StringTextTest_Utf8NoBOM.cs (1)
17protected override SourceText Create(string source)
Text\StringTextTests_Default.cs (10)
26protected virtual SourceText Create(string source) 41var data = Create(string.Empty); 49var data = Create(String.Empty); 58var data = Create("goo" + newLine + " bar"); 71var data = Create(text); 81var data = Create("goo\r\nbar"); 90var data = Create("goo\n\rbar"); 97var data = Create( 108var data = Create("goo"); 147var encodedText = Create(originalText);
Text\TextChangeTests.cs (251)
32var text = SourceText.From("Hello World"); 33var subText = text.GetSubText(6); 40var text = SourceText.From("Hello World"); 41var subText = text.GetSubText(new TextSpan(0, 5)); 48var text = SourceText.From("Hello World"); 49var subText = text.GetSubText(new TextSpan(6, 5)); 56var text = SourceText.From("Hello World"); 57var subText = text.GetSubText(new TextSpan(4, 3)); 64var text = SourceText.From("Hello World"); 65var newText = text.Replace(6, 0, "Beautiful "); 72var text = SourceText.From("Hello World"); 73var newText = text.Replace(6, 0, "Beautiful "); 86var text = SourceText.From("Hello World"); 87var newText = text.WithChanges( 97var text = SourceText.From("Hello World"); 110var text = SourceText.From("Hello World"); 117var newText = text.WithChanges(changes); 124var text = SourceText.From("Hello World"); 132var newText = text.WithChanges(changes); 139var text = SourceText.From("Hello World"); 141var newText = text.WithChanges( 151var text = SourceText.From("Hello World"); 153var newText = text.WithChanges( 163var text = SourceText.From("Hello World"); 170var newText = text.WithChanges(changes); 177var text = SourceText.From("Hello World"); 179var newText = text.WithChanges( 189var text = SourceText.From("Hello World", Encoding.Unicode, SourceHashAlgorithms.Default); 190var newText = text.WithChanges( 194var subText = newText.GetSubText(new TextSpan(3, 4)); 204var text = SourceText.From("Hello World"); 205var newText = text.WithChanges( 214var text = SourceText.From("Hello World"); 215var newText = text.WithChanges( 231var text = SourceText.From(new string('.', 2048), Encoding.Unicode, SourceHashAlgorithms.Default); // start bigger than GetText() copy buffer 239var newText = text.WithChanges(changes); 270var changedText = SourceText.From(originalText).WithChanges(changes); 271Assert.Equal(SourceText.From(changedText.ToString()).Lines, changedText.Lines, new TextLineEqualityComparer()); 348var text = SourceText.From(str); 368var text = SourceText.From(str); 387var text = SourceText.From("abcdefghijklmnopqrstuvwxyz"); 392var subtext = text.GetSubText(new TextSpan(5, 10)); 401var text = SourceText.From("abcdefghijklmnopqrstuvwxyz"); 403var newText = text.Replace(new TextSpan(0, 20), ""); 412var text = SourceText.From("abcdefghijklmnopqrstuvwxyz"); 414var newText = text.Replace(new TextSpan(10, 6), ""); 423var text = SourceText.From("abcdefghijklmnopqrstuvwxyz"); 426var newText = text.Replace(new TextSpan(10, 1), ""); 439var text = SourceText.From("abcdefghijklmnopqrstuvwxyz"); 442var textWithSegments = text.Replace(new TextSpan(10, 0), "*"); 456var text = SourceText.From("abcdefghijklmnopqrstuvwxyz"); 459var textWithSegments = text.Replace(new TextSpan(10, 0), "*"); 463var textWithFewerSegments = textWithSegments.Replace(new TextSpan(9, 3), ""); 476var text = SourceText.From("abcdefghijklmnopqrstuvwxyz"); 479var textWithSegments = text.Replace(new TextSpan(0, text.Length), ""); 490var t = SourceText.From(a); 520var t = SourceText.From(a); 546SourceText secondEdit; 562private void CreateEdits(out WeakReference weakFirstEdit, out SourceText secondEdit) 564var text = SourceText.From("This is the old text"); 565var firstEdit = text.Replace(11, 3, "new"); 575var largeText = CreateLargeText(chunk1); 588private SourceText CreateLargeText(params char[][] chunks) 593private ImmutableArray<char[]> GetChunks(SourceText text) 610var text = SourceText.From("small preamble"); 612var largeText = CreateLargeText(chunk1); 635var original = SourceText.From("Hello World"); 636var change1 = original.WithChanges(new TextChange(new TextSpan(5, 6), string.Empty)); // prepare a ChangedText instance 637var change2 = change1.WithChanges(); // this should not cause exception 646var original = SourceText.From("Hello World"); 647var change1 = original.WithChanges(new TextChange(new TextSpan(5, 6), string.Empty)); // prepare a ChangedText instance 648var change2 = change1.WithChanges(new TextChange(new TextSpan(2, 0), string.Empty)); // this should not cause exception 656var original = SourceText.From("Hello World"); 657var change1 = original.WithChanges(new TextChange(new TextSpan(6, 0), "Cruel ")); 658var change2 = change1.WithChanges(new TextChange(new TextSpan(7, 3), "oo")); 671var original = SourceText.From("01234"); 672var change1 = original.WithChanges(new TextChange(new TextSpan(1, 3), "aa")); 673var change2 = change1.WithChanges(new TextChange(new TextSpan(2, 0), "bb")); 685var original = SourceText.From("012"); 686var change1 = original.WithChanges(new TextChange(new TextSpan(1, 1), "aaa")); 687var change2 = change1.WithChanges(new TextChange(new TextSpan(3, 0), "bb")); 699var original = SourceText.From("01234"); 700var change1 = original.WithChanges(new TextChange(new TextSpan(1, 3), "aa")); 701var change2 = change1.WithChanges(new TextChange(new TextSpan(2, 1), "bb")); 712var original = SourceText.From("Hello World"); 713var change1 = original.WithChanges(new TextChange(new TextSpan(6, 0), "Cruel ")); 714var change2 = change1.WithChanges(new TextChange(new TextSpan(2, 14), "ar")); 726var original = SourceText.From("Hello World"); 727var change1 = original.WithChanges(new TextChange(new TextSpan(6, 0), "Cruel ")); 728var change2 = change1.WithChanges(new TextChange(new TextSpan(4, 6), " Bel")); 740var original = SourceText.From("Hello World"); 741var change1 = original.WithChanges(new TextChange(new TextSpan(6, 0), "Cruel ")); 742var change2 = change1.WithChanges(new TextChange(new TextSpan(7, 6), "wazy V")); 754var original = SourceText.From("01234"); 755var change1 = original.WithChanges(new TextChange(new TextSpan(1, 0), "aa")); 756var change2 = change1.WithChanges(new TextChange(new TextSpan(1, 0), "bb")); 767var original = SourceText.From("01234"); 768var change1 = original.WithChanges(new TextChange(new TextSpan(1, 3), "aa")); 769var change2 = change1.WithChanges(new TextChange(new TextSpan(1, 0), "bb")); 780var original = SourceText.From("01234"); 781var change1 = original.WithChanges(new TextChange(new TextSpan(1, 0), "aa")); 782var change2 = change1.WithChanges(new TextChange(new TextSpan(1, 1), "bb")); 793var original = SourceText.From("01234"); 794var change1 = original.WithChanges(new TextChange(new TextSpan(1, 0), "aa")); 795var change2 = change1.WithChanges(new TextChange(new TextSpan(1, 2), "bb")); 806var original = SourceText.From("01234"); 807var change1 = original.WithChanges(new TextChange(new TextSpan(1, 0), "aa")); 808var change2 = change1.WithChanges(new TextChange(new TextSpan(1, 3), "bb")); 820var original = SourceText.From("01234"); 821var change1 = original.WithChanges(new TextChange(new TextSpan(1, 3), "aa")); 822var change2 = change1.WithChanges(new TextChange(new TextSpan(1, 1), "bb")); 834var original = SourceText.From("01234"); 835var change1 = original.WithChanges(new TextChange(new TextSpan(1, 3), "aa")); 836var change2 = change1.WithChanges(new TextChange(new TextSpan(1, 3), "bb")); 846var original = SourceText.From("Hell"); 847var change1 = original.WithChanges(new TextChange(new TextSpan(4, 0), "o ")); 848var change2 = change1.WithChanges(new TextChange(new TextSpan(6, 0), "World")); 860var original = SourceText.From("Hell "); 861var change1 = original.WithChanges(new TextChange(new TextSpan(4, 0), "o")); 862var change2 = change1.WithChanges(new TextChange(new TextSpan(6, 0), "World")); 876var original = SourceText.From("Hell Word"); 877var change1 = original.WithChanges(new TextChange(new TextSpan(8, 0), "l")); 878var change2 = change1.WithChanges(new TextChange(new TextSpan(4, 0), "o")); 892var original = SourceText.From("Hell"); 893var change1 = original.WithChanges(new TextChange(new TextSpan(4, 0), " World")); 895var change2 = change1.WithChanges(new TextChange(new TextSpan(4, 0), "o")); 907var original = SourceText.From("Hell"); 909var final = GetChangesWithoutMiddle( 965var originalText = SourceText.From(string.Join("", Enumerable.Range(0, random.Next(10)))); 989var change1 = originalText.WithChanges(oldChangesBuilder); 1008var change2 = change1.WithChanges(newChangesBuilder); 1046var originalText = SourceText.From("01234"); 1047var change1 = originalText.WithChanges(new TextChange(new TextSpan(0, 2), "a")); 1048var change2 = change1.WithChanges(new TextChange(new TextSpan(0, 2), "bb")); 1060var original = SourceText.From("01234"); 1061var change1 = original.WithChanges(new TextChange(new TextSpan(0, 0), "aa"), new TextChange(new TextSpan(1, 1), "aa")); 1062var change2 = change1.WithChanges(new TextChange(new TextSpan(0, 1), "b"), new TextChange(new TextSpan(2, 2), "")); 1074var originalText = SourceText.From("01234"); 1075var change1 = originalText.WithChanges(new TextChange(new TextSpan(0, 0), "a")); 1076var change2 = change1.WithChanges(new TextChange(new TextSpan(0, 2), ""), new TextChange(new TextSpan(2, 0), "bb")); 1088var originalText = SourceText.From("01234"); 1089var change1 = originalText.WithChanges(new TextChange(new TextSpan(0, 1), "aa"), new TextChange(new TextSpan(3, 1), "aa")); 1090var change2 = change1.WithChanges(new TextChange(new TextSpan(0, 0), "bbb")); 1101var originalText = SourceText.From("012345"); 1102var change1 = originalText.WithChanges(new TextChange(new TextSpan(0, 3), "a"), new TextChange(new TextSpan(5, 0), "aaa")); 1103var change2 = change1.WithChanges(new TextChange(new TextSpan(0, 2), ""), new TextChange(new TextSpan(3, 1), "bb")); 1115var originalText = SourceText.From("01234567"); 1116var change1 = originalText.WithChanges(new TextChange(new TextSpan(0, 1), "aaaaa"), new TextChange(new TextSpan(3, 1), "aaaa"), new TextChange(new TextSpan(6, 1), "aaaaa")); 1117var change2 = change1.WithChanges(new TextChange(new TextSpan(0, 0), "b"), new TextChange(new TextSpan(2, 0), "b"), new TextChange(new TextSpan(3, 4), "bbbbb"), new TextChange(new TextSpan(9, 5), "bbbbb"), new TextChange(new TextSpan(15, 3), "")); 1129var originalText = SourceText.From("01234"); 1130var change1 = originalText.WithChanges(new TextChange(new TextSpan(0, 1), "a")); 1131var change2 = change1.WithChanges(new TextChange(new TextSpan(0, 1), "b"), new TextChange(new TextSpan(2, 2), "b")); 1143var originalText = SourceText.From("01234"); 1144var change1 = originalText.WithChanges(new TextChange(new TextSpan(0, 1), "aa")); 1145var change2 = change1.WithChanges(new TextChange(new TextSpan(0, 0), "b"), new TextChange(new TextSpan(1, 2), "b")); 1157var originalText = SourceText.From("012345"); 1158var change1 = originalText.WithChanges(new TextChange(new TextSpan(0, 2), "a"), new TextChange(new TextSpan(3, 2), "a")); 1159var change2 = change1.WithChanges(new TextChange(new TextSpan(0, 3), "bbb")); 1171var originalText = SourceText.From("0123456"); 1172var change1 = originalText.WithChanges(new TextChange(new TextSpan(0, 4), ""), new TextChange(new TextSpan(5, 1), "")); 1173var change2 = change1.WithChanges(new TextChange(new TextSpan(0, 1), ""), new TextChange(new TextSpan(1, 0), "")); 1185var originalText = SourceText.From("012345"); 1186var change1 = originalText.WithChanges(new TextChange(new TextSpan(0, 2), ""), new TextChange(new TextSpan(3, 1), ""), new TextChange(new TextSpan(4, 0), ""), new TextChange(new TextSpan(4, 0), ""), new TextChange(new TextSpan(4, 0), "")); 1187var change2 = change1.WithChanges(new TextChange(new TextSpan(0, 1), ""), new TextChange(new TextSpan(1, 1), ""), new TextChange(new TextSpan(2, 0), "")); 1199var originalText = SourceText.From("01234"); 1200var change1 = originalText.WithChanges(new TextChange(new TextSpan(0, 1), ""), new TextChange(new TextSpan(2, 1), "")); 1201var change2 = change1.WithChanges(new TextChange(new TextSpan(0, 0), ""), new TextChange(new TextSpan(1, 1), "")); 1223var text = SourceText.From(content); 1233var changedText = text.WithChanges(edits1); 1244var changedText2 = changedText.WithChanges(edits2); 1255private SourceText GetChangesWithoutMiddle( 1256SourceText original, 1257Func<SourceText, SourceText> fnChange1, 1258Func<SourceText, SourceText> fnChange2) 1261SourceText change2; 1274SourceText original, 1275Func<SourceText, SourceText> fnChange1, 1276Func<SourceText, SourceText> fnChange2, 1278out SourceText change2) 1280var c1 = fnChange1(original);
Text\TextUtilitiesTests.cs (8)
35Assert.Equal(0, TextUtilities.GetLengthOfLineBreak(SourceText.From("aoeu"), 0)); 36Assert.Equal(0, TextUtilities.GetLengthOfLineBreak(SourceText.From("aoeu"), 2)); 45Assert.Equal(1, TextUtilities.GetLengthOfLineBreak(SourceText.From("\naoeu"), 0)); 46Assert.Equal(1, TextUtilities.GetLengthOfLineBreak(SourceText.From("a\nbaou"), 1)); 47Assert.Equal(0, TextUtilities.GetLengthOfLineBreak(SourceText.From("a\n"), 0)); 56Assert.Equal(2, TextUtilities.GetLengthOfLineBreak(SourceText.From("\r\n"), 0)); 57Assert.Equal(1, TextUtilities.GetLengthOfLineBreak(SourceText.From("\n\r"), 0)); 66Assert.Equal(1, TextUtilities.GetLengthOfLineBreak(SourceText.From("\r"), 0));
Microsoft.CodeAnalysis.VisualBasic (43)
Binding\Binder_Expressions.vb (1)
1081Dim 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)
266SourceText.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, 282Friend Shared Function MakeSourceText(text As String, offset As Integer) As SourceText 283Return 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)
100Public Overrides Function WithChangedText(newText As SourceText) As SyntaxTree 102Dim oldText As SourceText = Nothing 114Private Function WithChanges(newText As SourceText, changes As TextChangeRange()) As SyntaxTree 200Friend Shared Function CreateForDebugger(root As VisualBasicSyntaxNode, text As SourceText, options As VisualBasicParseOptions) As SyntaxTree 228Friend Shared Function ParseTextLazy(text As SourceText, 252SourceText.From(text, encoding), 263Public Shared Function ParseText(text As SourceText, 278text As SourceText, 623Public Shared Function ParseText(text As SourceText,
Microsoft.CodeAnalysis.VisualBasic.CodeStyle.Fixes (1)
VisualBasicIndentationService.Indenter.vb (1)
42text As SourceText,
Microsoft.CodeAnalysis.VisualBasic.CodeStyle.UnitTests (1)
Utils.vb (1)
14Dim text = SourceText.From(code)
Microsoft.CodeAnalysis.VisualBasic.EditorFeatures (4)
LineCommit\CommitFormatter.vb (1)
115Dim text As SourceText = Nothing
Utilities\NavigationPointHelpers.vb (3)
12Public Function GetNavigationPoint(text As SourceText, indentSize As Integer, eventBlock As EventBlockSyntax) As VirtualTreePoint 23Public Function GetNavigationPoint(text As SourceText, indentSize As Integer, methodBlock As MethodBlockBaseSyntax) As VirtualTreePoint 51Public Function GetNavigationPoint(text As SourceText, indentSize As Integer, beginStatement As StatementSyntax, lineNumber As Integer) As VirtualTreePoint
Microsoft.CodeAnalysis.VisualBasic.EditorFeatures.UnitTests (14)
Completion\CompletionProviders\AbstractContextTests.vb (2)
28Dim tree = SyntaxFactory.ParseSyntaxTree(SourceText.From(text)) 46Dim tree = SyntaxFactory.ParseSyntaxTree(SourceText.From(text))
Diagnostics\DiagnosticAnalyzerDriver\DiagnosticAnalyzerDriverTests.vb (1)
111Dim additionalText = New TestAdditionalText("add.config", SourceText.From("random text"))
EditAndContinue\VisualBasicEditAndContinueAnalyzerTests.vb (6)
36AddDocument("test.vb", SourceText.From(source, Encoding.UTF8), filePath:=Path.Combine(TempRoot.Root, "test.vb")).Project.Solution 476Dim newSolution = oldSolution.WithDocumentText(documentId, SourceText.From(source2)) 561Dim newSolution = oldSolution.WithDocumentText(documentId, SourceText.From(source2)) 619Dim newSolution = oldSolution.WithDocumentText(documentId, SourceText.From(source2)) 650Dim newSolution = oldSolution.WithDocumentText(documentId, SourceText.From(source2)) 681Dim newSolution = oldSolution.AddDocument(newDocId, "goo.vb", SourceText.From(source2), filePath:=Path.Combine(TempRoot.Root, "goo.vb"))
Formatting\CodeCleanUpTests.vb (3)
528project = project.AddAnalyzerConfigDocument(".editorconfig", SourceText.From(editorconfigText), filePath:="z:\\.editorconfig").Project 663Return solution.AddDocument(DocumentId.CreateNewId(project.Id), "new.vb", SourceText.From("")) 708Return solution.AddDocument(DocumentId.CreateNewId(project.Id), "new.vb", SourceText.From(""))
Recommendations\RecommendationTestHelpers.vb (1)
33Dim tree = DirectCast(SyntaxFactory.ParseSyntaxTree(SourceText.From(source), parseOptions), VisualBasicSyntaxTree)
Utils.vb (1)
14Dim text = SourceText.From(code)
Microsoft.CodeAnalysis.VisualBasic.Emit.UnitTests (2)
PDB\PDBTests.vb (2)
27Dim tree3 = SyntaxFactory.ParseSyntaxTree(SourceText.From("Class C : End Class", encoding:=Nothing), path:="Bar.vb") 45Dim tree4 = SyntaxFactory.ParseSyntaxTree(SourceText.From("Class D" & vbCrLf & "Sub F() : End Sub : End Class", New UTF8Encoding(False, False)), path:="Baz.vb")
Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator.ExpressionCompiler (7)
SyntaxHelpers.vb (7)
38Dim text = SourceText.From(expr, encoding:=Nothing, SourceHashAlgorithms.Default) 52Dim targetText = SourceText.From(target, encoding:=Nothing, SourceHashAlgorithms.Default) 61Dim assignmentText = SourceText.From(assignment.ToString(), encoding:=Nothing, SourceHashAlgorithms.Default) 154Dim text = SourceText.From(source, encoding:=Nothing, SourceHashAlgorithms.Default) 162Private Function ParseDebuggerExpressionInternal(source As SourceText, consumeFullText As Boolean) As InternalSyntax.ExpressionSyntax 174Dim text = SourceText.From(source, encoding:=Nothing, SourceHashAlgorithms.Default) 186Private Function CreateSyntaxTree(root As InternalSyntax.VisualBasicSyntaxNode, text As SourceText) As SyntaxTree
Microsoft.CodeAnalysis.VisualBasic.Features (32)
AddImport\VisualBasicAddMissingImportsFeatureService.vb (1)
25Protected Overrides Function GetFormatRules(text As SourceText) As ImmutableArray(Of AbstractFormattingRule)
BraceCompletion\BracketBraceCompletionService.vb (1)
43Protected Overrides Function IsValidOpenBraceTokenAtPosition(text As SourceText, token As SyntaxToken, position As Integer) As Boolean
BraceCompletion\InterpolatedStringBraceCompletionService.vb (1)
28Protected Overrides Function IsValidOpenBraceTokenAtPosition(text As SourceText, token As SyntaxToken, position As Integer) As Boolean
BraceCompletion\InterpolationBraceCompletionService.vb (1)
27Protected Overrides Function IsValidOpenBraceTokenAtPosition(text As SourceText, token As SyntaxToken, position As Integer) As Boolean
BraceCompletion\LessAndGreaterThanCompletionService.vb (1)
36Protected 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
CodeRefactorings\VisualBasicRefactoringHelpersService.vb (1)
25Public Overrides Function IsBetweenTypeMembers(sourceText As SourceText, root As SyntaxNode, position As Integer, ByRef typeDeclaration As SyntaxNode) As Boolean
Completion\CompletionProviders\CompletionUtilities.vb (5)
24Public Function GetCompletionItemSpan(text As SourceText, position As Integer) As TextSpan 47Public Function IsDefaultTriggerCharacter(text As SourceText, characterPosition As Integer, options As CompletionOptions) As Boolean 56Public Function IsDefaultTriggerCharacterOrParen(text As SourceText, characterPosition As Integer, options As CompletionOptions) As Boolean 65Public Function IsTriggerAfterSpaceOrStartOfWordCharacter(text As SourceText, characterPosition As Integer, options As CompletionOptions) As Boolean 72Private 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)
70Public Overrides Function IsInsertionTrigger(text As SourceText, characterPosition As Integer, options As CompletionOptions) As Boolean
Completion\CompletionProviders\ImplementsClauseCompletionProvider.vb (1)
30Public Overrides Function IsInsertionTrigger(text As SourceText, characterPosition As Integer, options As CompletionOptions) As Boolean
Completion\CompletionProviders\ImportCompletionProvider\ExtensionMethodImportCompletionProvider.vb (1)
39Public Overrides Function IsInsertionTrigger(text As SourceText, characterPosition As Integer, options As CompletionOptions) As Boolean
Completion\CompletionProviders\ImportCompletionProvider\TypeImportCompletionProvider.vb (1)
34Public 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)
176Public 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)
34Public Overrides Function IsInsertionTrigger(text As SourceText, characterPosition As Integer, options As CompletionOptions) As Boolean
Completion\CompletionProviders\ObjectInitializerCompletionProvider.vb (1)
99Public Overrides Function IsInsertionTrigger(text As SourceText, characterPosition As Integer, options As CompletionOptions) As Boolean
Completion\CompletionProviders\OverrideCompletionProvider.vb (2)
65Public Overrides Function IsInsertionTrigger(text As SourceText, characterPosition As Integer, options As CompletionOptions) As Boolean 72text As SourceText, startLine As Integer,
Completion\CompletionProviders\PartialTypeCompletionProvider.vb (1)
51Public Overrides Function IsInsertionTrigger(text As SourceText, characterPosition As Integer, options As CompletionOptions) As Boolean
Completion\CompletionProviders\PreprocessorCompletionProvider.vb (1)
31Public Overrides Function IsInsertionTrigger(text As SourceText, characterPosition As Integer, options As CompletionOptions) As Boolean
Completion\CompletionProviders\SymbolCompletionProvider.vb (1)
78Public Overrides Function IsInsertionTrigger(text As SourceText, characterPosition As Integer, options As CompletionOptions) As Boolean
Completion\CompletionProviders\XmlDocCommentCompletionProvider.vb (1)
36Public Overrides Function IsInsertionTrigger(text As SourceText, characterPosition As Integer, options As CompletionOptions) As Boolean
Completion\VisualBasicCompletionService.vb (1)
124Public 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)
27Return 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.Semantic.UnitTests (11)
SourceGeneration\GeneratorDriverTests_Attributes_FullyQualifiedName.vb (6)
1000driver = driver.RunGenerators(compilation.AddSyntaxTrees(compilation.SyntaxTrees.First().WithChangedText(SourceText.From("")))) 1042driver = driver.RunGenerators(compilation.AddSyntaxTrees(compilation.SyntaxTrees.First().WithChangedText(SourceText.From(" 1091driver = driver.RunGenerators(compilation.AddSyntaxTrees(compilation.SyntaxTrees.First().WithChangedText(SourceText.From(" 1144driver = driver.RunGenerators(compilation.AddSyntaxTrees(compilation.SyntaxTrees.First().WithChangedText(SourceText.From(" 1204compilation.SyntaxTrees.First().WithChangedText(SourceText.From(" 1258compilation.SyntaxTrees.First().WithChangedText(SourceText.From("
SourceGeneration\GeneratorDriverTests_Attributes_SimpleName.vb (5)
1209compilation.SyntaxTrees.Last().WithChangedText(SourceText.From(" 1250compilation.SyntaxTrees.Last().WithChangedText(SourceText.From(" 1414compilation.SyntaxTrees.First().WithChangedText(SourceText.From(" 1456compilation.SyntaxTrees.First().WithChangedText(SourceText.From(" 1509compilation.SyntaxTrees.Last().WithChangedText(SourceText.From("
Microsoft.CodeAnalysis.VisualBasic.Symbol.UnitTests (2)
SymbolsTests\Source\GroupClassTests.vb (1)
17SourceText.From(text, encoding:=Nothing, checksumAlgorithm:=SourceHashAlgorithms.Default),
SymbolsTests\Source\TypeTests.vb (1)
686Dim tree = VisualBasicSyntaxTree.ParseText(SourceText.From(text), VisualBasicParseOptions.Default, "")
Microsoft.CodeAnalysis.VisualBasic.Syntax.UnitTests (98)
IncrementalParser\IncrementalParser.vb (62)
81Dim text As SourceText = SourceText.From(_s) 104Dim text As SourceText = SourceText.From("") 124Dim oldText = SourceText.From(_s) 702Dim oldText = SourceText.From(code) 741Dim oldText = SourceText.From(code) 766Dim oldText = SourceText.From(code) 790Dim oldText = SourceText.From(code) 822Dim oldText = SourceText.From(source) 864Dim oldText = SourceText.From(source) 883Dim oldText = SourceText.From(source) 904Dim oldText = SourceText.From(source) 933Dim oldText = SourceText.From(source) 962Dim oldText = SourceText.From(source) 986Dim oldText = SourceText.From(source) 1008Dim oldText = SourceText.From(source) 1028Dim oldText = SourceText.From(source) 1051Dim oldText = SourceText.From(source) 1077Dim oldText = SourceText.From(source) 1103Dim oldText = SourceText.From(source) 1221Dim oldText = SourceText.From(code) 1239Dim oldText = SourceText.From(code) 1264Dim oldText = SourceText.From(source) 1288Dim oldText = SourceText.From(source) 1312Dim oldText = SourceText.From(source) 1336Dim oldText = SourceText.From(source) 1359Dim oldText = SourceText.From(source) 1382Dim oldText = SourceText.From(source) 1402Dim oldText = SourceText.From(source) 1422Dim oldText = SourceText.From(source) 1442Dim oldText = SourceText.From(source) 1462Dim oldText = SourceText.From(source) 1487Dim oldText = SourceText.From(source) 1517Dim oldText = SourceText.From(oldSource) 1551Dim oldText = SourceText.From(oldSource) 1582Dim oldText = SourceText.From(source) 1671Dim oldText = SourceText.From(code) 1765Dim oldText = SourceText.From(source) 1792Dim oldText = SourceText.From(source) 1821Dim oldText = SourceText.From(source) 1841Dim oldText = SourceText.From(source) 1860Dim oldText = SourceText.From(source) 1885Dim oldText = SourceText.From(source) 1917Dim oldText = SourceText.From(source) 1951Dim oldText = SourceText.From(source) 1982Dim oldText = SourceText.From(source) 2013Dim oldText = SourceText.From(source) 2045Dim oldText = SourceText.From(source) 2075Dim oldText = SourceText.From(source) 2106Dim oldText = SourceText.From(source) 2208Dim oldText = SourceText.From(source) 2240Dim oldText = SourceText.From(source) 2274Dim oldText = SourceText.From(source) 2300Dim oldText = SourceText.From(source) 2331Dim oldText = SourceText.From(source) 2365Dim oldText = SourceText.From(source) 2401Dim oldText = SourceText.From(source) 2429Dim oldText = SourceText.From(source) 2463Dim oldText = SourceText.From(source) 2492Dim oldText = SourceText.From(source) 2544Dim oldText = SourceText.From(source)
Parser\DeclarationTests.vb (1)
15Dim tree = VisualBasicSyntaxTree.ParseText(SourceText.From(text), VisualBasicParseOptions.Default, "")
Parser\ParseDirectives.vb (1)
1260Dim tree = VisualBasicSyntaxTree.ParseText(SourceText.From(text), options, "")
Parser\ParseExpression.vb (4)
2247Dim text = SourceText.From(source) 2264Dim text = SourceText.From(source) 2281Dim text = SourceText.From(source) 2299Dim text = SourceText.From(source)
QuickTokenTableTests.vb (4)
12Dim txt = SourceText.From(s) 28Dim txt = SourceText.From(s) 86Using scanner As New InternalSyntax.Scanner(SourceText.From(New String(buf)), TestOptions.Regular) 107Using scanner As New InternalSyntax.Scanner(SourceText.From(New String(buf)), TestOptions.Regular)
Scanner\ScanConditionalTests.vb (4)
19Using s As New InternalSyntax.Scanner(SourceText.From(Str), TestOptions.Regular) 37Using s As New InternalSyntax.Scanner(SourceText.From(Str), TestOptions.Regular) 78Using s As New InternalSyntax.Scanner(SourceText.From(Str), TestOptions.Regular) 118Using s As New InternalSyntax.Scanner(SourceText.From(Str), TestOptions.Regular)
Scanner\XmlScannerTests.vb (11)
16Dim str = SourceText.From(" <!-- hello there --> ") 43Dim str = SourceText.From(" <![CDATA[some data / > < % @ here ]]> ") 72Dim str = SourceText.From(" <E1 : E2 A1 = 'q q' BB= "" w&apos; &#x2F blah" & ChrW(8216) & ChrW(8217) & ChrW(8220) & ChrW(8221) & """ > Ha &lt; </E1 > ") 195Dim str = SourceText.From(" <E1 /> ") 216Dim str = SourceText.From(" <E1> q <a/> <b/> &lt; " & vbCrLf & " </E1>") 289Dim str = SourceText.From(ChrW(8216) & valueText & ChrW(8217)) 303str = SourceText.From(ChrW(8220) & valueText & ChrW(8221)) 324Using s As New InternalSyntax.Scanner(SourceText.From("&#x03C0;"), TestOptions.Regular) 331Using s = New InternalSyntax.Scanner(SourceText.From("&#x03C0"), TestOptions.Regular) 343Using s As New InternalSyntax.Scanner(SourceText.From("&#x103fe;"), TestOptions.Regular) 373tree = tree.WithChangedText(SourceText.From(text))
Syntax\ManualTests.vb (1)
225Dim text = SourceText.From(code)
Syntax\SyntaxTreeTests.vb (7)
34SourceText.From(""), 37Dim newTree = tree.WithChangedText(SourceText.From("Class B : End Class")) 44SourceText.From(""), 55SourceText.From(""), 66SourceText.From(""), 125Dim oldText = SourceText.From("Class B : End Class", Encoding.Unicode, SourceHashAlgorithms.Default) 165Dim oldText = SourceText.From("Class B : End Class", Encoding.Unicode, SourceHashAlgorithms.Default)
TestSyntaxNodes.vb (3)
1733Dim tree As SyntaxTree = VisualBasicSyntaxTree.ParseText(SourceText.From(" Module M1" & vbCrLf & "End Module")) 1763Dim tree As SyntaxTree = VisualBasicSyntaxTree.ParseText(SourceText.From("Module M1" & vbCrLf & "End")) 2817Dim st As SourceText = Nothing
Microsoft.CodeAnalysis.VisualBasic.Test.Utilities (16)
BasicTestSource.vb (3)
24Dim sourceTest = SourceText.From(text, If(encoding, Encoding.UTF8), checksumAlgorithm) 58Return New SyntaxTree() {VisualBasicSyntaxTree.ParseText(SourceText.From(source, encoding:=Nothing, SourceHashAlgorithms.Default), parseOptions)} 63Return sources.Select(Function(s) VisualBasicSyntaxTree.ParseText(SourceText.From(s, encoding:=Nothing, SourceHashAlgorithms.Default), parseOptions)).ToArray()
CompilationTestUtils.vb (4)
22Return source.Select(Function(s) VisualBasicSyntaxTree.ParseText(SourceText.From(s, encoding:=Nothing, SourceHashAlgorithms.Default), parseOptions)) 623Return VisualBasicSyntaxTree.ParseText(SourceText.From(FilterString(programElement.Value), Encoding.UTF8, SourceHashAlgorithms.Default), path:=If(programElement.@name, "")) 640Dim text = SourceText.From(codeWithoutMarker, Encoding.UTF8) 1011Private Function GetLineText(text As SourceText, position As Integer, ByRef offsetInLine As Integer) As String
ParserTestUtilities.vb (8)
113Dim tree = VisualBasicSyntaxTree.ParseText(SourceText.From(source, encoding), options:=If(options, VisualBasicParseOptions.Default), path:=fileName) 220Public Sub IncParseAndVerify(oldIText As SourceText, newIText As SourceText) 254Dim oldText = SourceText.From(node.oldText) 255Dim newText As SourceText = oldText 519Public Overrides Function GetText(Optional cancellationToken As CancellationToken = Nothing) As SourceText 523Public Overrides Function TryGetText(ByRef text As SourceText) As Boolean 545Public Overrides Function WithChangedText(newText As SourceText) As SyntaxTree
VBParser.vb (1)
18Dim tree = VisualBasicSyntaxTree.ParseText(SourceText.From(code, Encoding.UTF8, SourceHashAlgorithms.Default), _options, path:="")
Microsoft.CodeAnalysis.VisualBasic.Workspaces (13)
Classification\ClassificationHelpers.vb (2)
321Friend Sub AddLexicalClassifications(text As SourceText, textSpan As TextSpan, result As ArrayBuilder(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 ArrayBuilder(Of ClassifiedSpan), cancellationToken As CancellationToken) 43Public Overrides Function FixClassification(text As SourceText, classifiedSpan As ClassifiedSpan) As ClassifiedSpan
Classification\VisualBasicClassificationService.vb (2)
22Public Overrides Sub AddLexicalClassifications(text As SourceText, textSpan As TextSpan, result As ArrayBuilder(Of ClassifiedSpan), cancellationToken As CancellationToken) 26Public Overrides Function AdjustStaleClassification(text As SourceText, classifiedSpan As ClassifiedSpan) As ClassifiedSpan
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 27Public Sub New(lazyText As SourceText, root As VisualBasicSyntaxNode, options As VisualBasicParseOptions, filePath As String, encoding As Encoding, checksumAlgorithm As SourceHashAlgorithm) 37Public Overrides Function GetText(Optional cancellationToken As CancellationToken = Nothing) As SourceText 45Public Overrides Function TryGetText(<Out> ByRef text As SourceText) As Boolean
Workspace\LanguageServices\VisualBasicSyntaxTreeFactoryService.vb (1)
65Public Overrides Function ParseSyntaxTree(filePath As String, options As ParseOptions, text As SourceText, cancellationToken As CancellationToken) As SyntaxTree
Microsoft.CodeAnalysis.VisualBasic.Workspaces.UnitTests (5)
CaseCorrection\VisualBasicCaseCorrectionTestBase.vb (1)
17Dim document = project.AddDocument("Document", SourceText.From(code))
Formatting\FormattingTests.vb (1)
3016Dim document = project.AddDocument("Document", SourceText.From(inputOutput))
Formatting\VisualBasicFormattingTestBase.vb (1)
58Dim document = project.AddDocument("Document", SourceText.From(code))
OrganizeImports\OrganizeImportsTests.vb (2)
28Dim document = project.AddDocument("Document", SourceText.From(initial.Value.ReplaceLineEndings(If(endOfLine, Environment.NewLine)))) 49Dim document = project.AddDocument("Document", SourceText.From(initial.Value.NormalizeLineEndings()))
Microsoft.CodeAnalysis.Workspaces (334)
AbstractIndentation.cs (1)
29TSyntaxRoot root, SourceText text, TextLine lineToBeIndented, IndentationOptions options, AbstractFormattingRule baseFormattingRule);
AbstractIndentation.Indenter.cs (2)
36public readonly SourceText Text; 172var updatedSourceText = Text.WithChanges(changes);
AbstractSelectedMembers.cs (3)
46var text = await tree.GetTextAsync(cancellationToken).ConfigureAwait(false); 78SyntaxNode root, SourceText text, TextSpan textSpan, 165SourceText text, SyntaxNode root, SyntaxNode member, int position)
AbstractVirtualCharService.cs (1)
195protected static int ConvertTextAtIndexToRune(SourceText tokenText, int index, ImmutableSegmentedList<VirtualChar>.Builder result, int offset)
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;
AddParameterEditor.cs (2)
25var sourceText = declaration.SyntaxTree.GetText(cancellationToken); 159var text = parameters[0].SyntaxTree.GetText(cancellationToken);
Classification\AbstractClassificationService.cs (2)
23public abstract void AddLexicalClassifications(SourceText text, TextSpan textSpan, ArrayBuilder<ClassifiedSpan> result, CancellationToken cancellationToken); 24public abstract ClassifiedSpan AdjustStaleClassification(SourceText text, ClassifiedSpan classifiedSpan);
Classification\Classifier.cs (2)
97var sourceText = await semanticModel.SyntaxTree.GetTextAsync(cancellationToken).ConfigureAwait(false); 103SourceText sourceText, int startPosition, IEnumerable<ClassifiedSpan> classifiedSpans)
Classification\IClassificationService.cs (2)
27void AddLexicalClassifications(SourceText text, TextSpan textSpan, ArrayBuilder<ClassifiedSpan> result, CancellationToken cancellationToken); 70ClassifiedSpan AdjustStaleClassification(SourceText text, ClassifiedSpan classifiedSpan);
Classification\SyntaxClassification\AbstractSyntaxClassificationService.cs (2)
24public abstract void AddLexicalClassifications(SourceText text, TextSpan textSpan, ArrayBuilder<ClassifiedSpan> result, CancellationToken cancellationToken); 28public 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)
54var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
CodeCleanup\Providers\FormatCodeCleanupProvider.cs (2)
35return document.TryGetText(out var oldText) 46return (root.SyntaxTree != null && root.SyntaxTree.TryGetText(out var oldText))
CodeFixes\FixAllOccurrences\BatchFixAllProvider.cs (1)
261var newText = await textMerger.GetFinalMergedTextAsync(cancellationToken).ConfigureAwait(false);
CodeFixes\FixAllOccurrences\DocumentBasedFixAllProvider.cs (6)
53/// will only be examined for its content (e.g. it's <see cref="SyntaxTree"/> or <see cref="SourceText"/>. No 80private async Task<Dictionary<DocumentId, (SyntaxNode? node, SourceText? text)>> DetermineDiagnosticsAndGetFixedDocumentsAsync( 106private async Task<Dictionary<DocumentId, (SyntaxNode? node, SourceText? text)>> GetFixedDocumentsAsync( 112using var _2 = ArrayBuilder<Task<(DocumentId, (SyntaxNode? node, SourceText? text))>>.GetInstance(out var tasks); 114var docIdToNewRootOrText = new Dictionary<DocumentId, (SyntaxNode? node, SourceText? text)>(); 132var text = newDocument.SupportsSyntaxTree ? null : await newDocument.GetTextAsync(cancellationToken).ConfigureAwait(false);
CodeFixes\FixAllOccurrences\FixAllProvider.cs (2)
54/// examined for its content (e.g. it's <see cref="SyntaxTree"/> or <see cref="SourceText"/>. No other aspects 68/// examined for its content (e.g. it's <see cref="SyntaxTree"/> or <see cref="SourceText"/>. No other aspects
CodeFixes\FixAllOccurrences\TextChangeMerger.cs (3)
69public async Task<SourceText> GetFinalMergedTextAsync(CancellationToken cancellationToken) 74var oldText = await _oldDocument.GetTextAsync(cancellationToken).ConfigureAwait(false); 75var newText = oldText.WithChanges(changesToApply);
CodeFixesAndRefactorings\DocumentBasedFixAllProviderHelpers.cs (5)
30Func<TFixAllContext, IProgressTracker, Task<Dictionary<DocumentId, (SyntaxNode? node, SourceText? text)>>> getFixedDocumentsAsync) 59Func<TFixAllContext, IProgressTracker, Task<Dictionary<DocumentId, (SyntaxNode? node, SourceText? text)>>> getFixedDocumentsAsync) 79Dictionary<DocumentId, (SyntaxNode? node, SourceText? text)> docIdToNewRootOrText, 104using var _2 = ArrayBuilder<Task<(DocumentId docId, SourceText sourceText)>>.GetInstance(out var tasks); 114var cleanedText = await cleanedDocument.GetTextAsync(cancellationToken).ConfigureAwait(false);
CodeRefactorings\FixAllOccurences\DocumentBasedFixAllProvider.cs (5)
55/// (e.g. it's <see cref="SyntaxTree"/> or <see cref="SourceText"/>. No other aspects of document (like it's properties), 87private async Task<Dictionary<DocumentId, (SyntaxNode? node, SourceText? text)>> GetFixedDocumentsAsync( 96using var _2 = ArrayBuilder<Task<(DocumentId, (SyntaxNode? node, SourceText? text))>>.GetInstance(out var tasks); 98var docIdToNewRootOrText = new Dictionary<DocumentId, (SyntaxNode? node, SourceText? text)>(); 114var text = newDocument.SupportsSyntaxTree ? null : await newDocument.GetTextAsync(cancellationToken).ConfigureAwait(false);
CodeRefactorings\FixAllOccurences\FixAllProvider.cs (2)
55/// examined for its content (e.g. it's <see cref="SyntaxTree"/> or <see cref="SourceText"/>. No other aspects 69/// examined for its content (e.g. it's <see cref="SyntaxTree"/> or <see cref="SourceText"/>. No other aspects
CommonFormattingHelpers.cs (1)
153public static string GetText(this SourceText text, SyntaxToken token1, SyntaxToken token2)
Diagnostics\Extensions.cs (1)
50var text = await textDocument.GetTextAsync(cancellationToken).ConfigureAwait(false);
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)
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)
EncodedStringText.cs (11)
53/// Initializes an instance of <see cref="SourceText"/> from the provided stream. This version differs 54/// from <see cref="SourceText.From(Stream, Encoding, SourceHashAlgorithm, bool)"/> in two ways: 72internal static SourceText Create(Stream stream, 84internal static SourceText Create(Stream stream, 117/// Try to create a <see cref="SourceText"/> from the given stream using the given encoding. 124/// <returns>The <see cref="SourceText"/> decoded from the stream.</returns> 127private static SourceText Decode( 146return SourceText.From(bytes.Array, 156return SourceText.From(data, encoding, checksumAlgorithm, throwIfBinaryDetected, canBeEmbedded); 230internal static SourceText Create(Stream stream, Lazy<Encoding> getEncoding, Encoding defaultEncoding, SourceHashAlgorithm checksumAlgorithm, bool canBeEmbedded) 233internal static SourceText Decode(Stream data, Encoding encoding, SourceHashAlgorithm checksumAlgorithm, bool throwIfBinaryDetected, bool canBeEmbedded)
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 (2)
94var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); 136ImmutableArray<SyntaxToken> FindMatchingIdentifierTokensFromText(SourceText sourceText)
IIndentationService.cs (3)
67public static string GetIndentationString(this IndentationResult indentationResult, SourceText sourceText, bool useTabs, int tabSize) 78public static string GetIndentationString(this IndentationResult indentationResult, SourceText sourceText, SyntaxFormattingOptions options) 81public static string GetIndentationString(this IndentationResult indentationResult, SourceText sourceText, IndentationOptions options)
IVirtualCharService.cs (1)
33/// in the original <see cref="SourceText"/> that the language created that char from.
J\s\src\Compilers\Core\Portable\Syntax\SyntaxTreeExtensions.cs\SyntaxTreeExtensions.cs (1)
23var text = tree.GetText();
J\s\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\SyntaxTreeExtensions.cs\SyntaxTreeExtensions.cs (2)
25var text = tree.GetText(cancellationToken); 102var text = tree.GetText(cancellationToken);
LinkedFileDiffMerging\AbstractLinkedFileMergeConflictCommentAdditionService.cs (6)
19public IEnumerable<TextChange> CreateEdits(SourceText originalSourceText, IEnumerable<UnmergedDocumentChanges> unmergedChanges) 34private static IEnumerable<IEnumerable<TextChange>> PartitionChangesForDocument(IEnumerable<TextChange> changes, SourceText originalSourceText) 64private List<TextChange> GetCommentChangesForDocument(IEnumerable<IEnumerable<TextChange>> partitionedChanges, string projectName, SourceText oldDocumentText) 76var oldText = oldDocumentText.GetSubText(TextSpan.FromBounds(startLineStartPosition, endLineEndPosition)); 78var newText = oldText.WithChanges(adjustedChanges); 94private static string TrimBlankLines(SourceText text)
LinkedFileDiffMerging\IMergeConflictHandler.cs (1)
14IEnumerable<TextChange> CreateEdits(SourceText originalSourceText, IEnumerable<UnmergedDocumentChanges> unmergedChanges);
LinkedFileDiffMerging\LinkedFileDiffMergingSession.cs (2)
56SourceText mergedText; 105var originalSourceText = await originalDocument.GetTextAsync(cancellationToken).ConfigureAwait(false);
LinkedFileDiffMerging\LinkedFileMergeResult.cs (2)
16public SourceText MergedSourceText { get; internal set; } 20public LinkedFileMergeResult(IEnumerable<DocumentId> documentIds, SourceText mergedSourceText, IEnumerable<TextSpan> mergeConflictResolutionSpans)
ParsedDocument.cs (6)
21/// 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 27internal readonly record struct ParsedDocument(DocumentId Id, SourceText Text, SyntaxNode Root, HostLanguageServices HostLanguageServices) 36var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); 44var text = document.GetTextSynchronously(cancellationToken); 50public ParsedDocument WithChangedText(SourceText text, CancellationToken cancellationToken) 58var text = root.SyntaxTree.GetText(cancellationToken);
Remote\RemoteUtilities.cs (1)
55var text = await oldSolution.GetDocument(docId).GetTextAsync(cancellationToken).ConfigureAwait(false);
SemanticDocument.cs (2)
17private SemanticDocument(Document document, SourceText text, SyntaxNode root, SemanticModel semanticModel) 25var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
Serialization\SerializableSourceText.cs (12)
19/// Represents a <see cref="SourceText"/> which can be serialized for sending to another process. The text is not 26/// The storage location for <see cref="SourceText"/>. 34/// The <see cref="SourceText"/> in the current process. 39private readonly SourceText? _text; 45private readonly WeakReference<SourceText?> _computedText = new(target: null); 52public SerializableSourceText(SourceText text) 57private SerializableSourceText(ITemporaryTextStorageWithName? storage, SourceText? text) 70private SourceText? TryGetText() 78public async ValueTask<SourceText> GetTextAsync(CancellationToken cancellationToken) 80var text = TryGetText(); 90public SourceText GetText(CancellationToken cancellationToken) 92var text = TryGetText();
Serialization\SerializationExtensions.cs (1)
32SourceText _ => WellKnownSynchronizationKind.SourceText,
Serialization\SerializerService.cs (2)
94return Checksum.Create(((SourceText)value).GetChecksum()); 157SerializeSourceText(new SerializableSourceText((SourceText)value), writer, context, cancellationToken);
Serialization\SerializerService_Asset.cs (1)
27private SourceText DeserializeSourceText(ObjectReader reader, CancellationToken cancellationToken)
Shared\Extensions\FileLinePositionSpanExtensions.cs (4)
14public static TextSpan GetClampedTextSpan(this FileLinePositionSpan span, SourceText text) 18public static LinePositionSpan GetClampedSpan(this FileLinePositionSpan span, SourceText text) 28public static TextSpan GetClampedTextSpan(this LinePositionSpan span, SourceText text) 38public static LinePositionSpan GetClampedSpan(this LinePositionSpan span, SourceText text)
Shared\Extensions\ISolutionExtensions.cs (1)
41public static Solution WithTextDocumentText(this Solution solution, DocumentId documentId, SourceText text, PreservationMode mode = PreservationMode.PreserveIdentity)
Shared\Extensions\SourceTextExtensions.cs (12)
19public static void GetLineAndOffset(this SourceText text, int position, out int lineNumber, out int offset) 27public static int GetOffset(this SourceText text, int position) 34this SourceText text, 45public static TextChangeRange GetEncompassingTextChangeRange(this SourceText newText, SourceText oldText) 62public static int IndexOf(this SourceText text, string value, int startIndex, bool caseSensitive) 93public static int LastIndexOf(this SourceText text, string value, int startIndex, bool caseSensitive) 129public static bool ContentEquals(this SourceText text, int position, string value) 147public static int IndexOfNonWhiteSpace(this SourceText text, int start, int length) 163public static void WriteTo(this SourceText sourceText, ObjectWriter writer, CancellationToken cancellationToken) 181private 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)
SourceTextExtensions_SharedWithCodeStyle.cs (5)
17public static string GetLeadingWhitespaceOfLineAtPosition(this SourceText text, int position) 33this SourceText text, TextSpan span, Func<int, CancellationToken, bool> isPositionHidden, CancellationToken cancellationToken) 45this SourceText text, TextSpan span, Func<int, CancellationToken, bool> isPositionHidden, 83public static bool AreOnSameLine(this SourceText text, SyntaxToken token1, SyntaxToken token2) 88public static bool AreOnSameLine(this SourceText text, int pos1, int pos2)
SyntacticDocument.cs (3)
15public readonly SourceText Text; 18protected SyntacticDocument(Document document, SourceText text, SyntaxNode root) 30var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
TemporaryStorage\TemporaryStorageServiceFactory.cs (4)
218public SourceText ReadText(CancellationToken cancellationToken) 235public async Task<SourceText> ReadTextAsync(CancellationToken cancellationToken) 256public void WriteText(SourceText text, CancellationToken cancellationToken) 280public async Task WriteTextAsync(SourceText text, CancellationToken cancellationToken)
TextDocumentExtensions.cs (3)
15public static TextDocument WithText(this TextDocument textDocument, SourceText text) 36public static TextDocument WithAdditionalDocumentText(this TextDocument textDocument, SourceText text) 45public static TextDocument WithAnalyzerConfigDocumentText(this TextDocument textDocument, SourceText text)
TextLineExtensions.cs (2)
48var text = line.Text; 69var text = line.Text;
TreeData.cs (1)
21if (root.SyntaxTree == null || !root.SyntaxTree.TryGetText(out var text))
TreeData.Debug.cs (1)
16public Debug(SyntaxNode root, SourceText text)
TreeData.NodeAndText.cs (2)
15private readonly SourceText _text; 17public NodeAndText(SyntaxNode root, SourceText text)
TreeData.StructuredTrivia.cs (2)
27var text = GetText(); 48private SourceText? GetText()
VirtualChar.cs (2)
18/// value of <c>9</c> as well as what <see cref="TextSpan"/> in the original <see cref="SourceText"/> they occupied. 45/// The span of characters in the original <see cref="SourceText"/> that represent this <see
Workspace\AdhocWorkspace.cs (7)
113public Document AddDocument(ProjectId projectId, string name, SourceText text) 159var text = doc.GetTextSynchronously(CancellationToken.None); 172var text = doc.GetTextSynchronously(CancellationToken.None); 187var text = doc.GetTextSynchronously(CancellationToken.None); 200var text = doc.GetTextSynchronously(CancellationToken.None); 215var text = doc.GetTextSynchronously(CancellationToken.None); 228var text = doc.GetTextSynchronously(CancellationToken.None);
Workspace\Host\DocumentService\IDocumentExcerptService.cs (2)
45public readonly SourceText Content; 71public ExcerptResult(SourceText content, TextSpan mappedSpan, ImmutableArray<ClassifiedSpan> classifiedSpans, Document document, TextSpan span)
Workspace\Host\HostWorkspaceServices.cs (1)
80/// A factory that constructs <see cref="SourceText"/>.
Workspace\Host\SyntaxTreeFactory\AbstractSyntaxTreeFactoryService.cs (1)
24public abstract SyntaxTree ParseSyntaxTree(string filePath, ParseOptions options, SourceText text, CancellationToken cancellationToken);
Workspace\Host\SyntaxTreeFactory\ISyntaxTreeFactoryService.cs (1)
35SyntaxTree ParseSyntaxTree(string? filePath, ParseOptions options, SourceText text, CancellationToken cancellationToken);
Workspace\Host\TemporaryStorage\ITemporaryStorage.cs (8)
18SourceText ReadText(CancellationToken cancellationToken = default); 19Task<SourceText> ReadTextAsync(CancellationToken cancellationToken = default); 20void WriteText(SourceText text, CancellationToken cancellationToken = default); 21Task WriteTextAsync(SourceText text, CancellationToken cancellationToken = default); 38SourceText ReadText(CancellationToken cancellationToken = default); 39Task<SourceText> ReadTextAsync(CancellationToken cancellationToken = default); 40void WriteText(SourceText text, CancellationToken cancellationToken = default); 41Task WriteTextAsync(SourceText text, CancellationToken cancellationToken = default);
Workspace\Host\TemporaryStorage\ITemporaryTextStorageWithName.cs (7)
12/// Represents a <see cref="ITemporaryStorageWithName"/> which is used to hold data for <see cref="SourceText"/>. 17/// Gets the value for the <see cref="SourceText.ChecksumAlgorithm"/> property for the <see cref="SourceText"/> 23/// Gets the value for the <see cref="SourceText.Encoding"/> property for the <see cref="SourceText"/> 29/// Gets the checksum for the <see cref="SourceText"/> represented by this temporary storage. This is equivalent 30/// to calling <see cref="SourceText.GetChecksum"/>.
Workspace\Host\TemporaryStorage\LegacyTemporaryStorageService.cs (6)
89private SourceText? _sourceText; 94public SourceText ReadText(CancellationToken cancellationToken = default) 97public Task<SourceText> ReadTextAsync(CancellationToken cancellationToken = default) 100public void WriteText(SourceText text, CancellationToken cancellationToken = default) 105var existingValue = Interlocked.CompareExchange(ref _sourceText, text, null); 112public Task WriteTextAsync(SourceText text, CancellationToken cancellationToken = default)
Workspace\Host\TemporaryStorage\TrivialTemporaryStorageService.cs (6)
82private SourceText? _sourceText; 87public SourceText ReadText(CancellationToken cancellationToken) 90public Task<SourceText> ReadTextAsync(CancellationToken cancellationToken) 93public void WriteText(SourceText text, CancellationToken cancellationToken) 98var existingValue = Interlocked.CompareExchange(ref _sourceText, text, null); 105public 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)
41public new AdditionalDocumentState UpdateText(SourceText text, PreservationMode mode)
Workspace\Solution\AdditionalTextWithState.cs (4)
19/// Create a <see cref="SourceText"/> from a <see cref="AdditionalDocumentState"/>. 30/// Retrieves a <see cref="SourceText"/> with the contents of this file. 32public override SourceText GetText(CancellationToken cancellationToken = default) 34var text = _documentState.GetTextSynchronously(cancellationToken);
Workspace\Solution\AnalyzerConfigDocumentState.cs (1)
53public new AnalyzerConfigDocumentState UpdateText(SourceText text, PreservationMode mode)
Workspace\Solution\Document.cs (3)
330public Document WithText(SourceText text) 383if (this.TryGetText(out var text) && oldDocument.TryGetText(out var oldText))
Workspace\Solution\DocumentState.cs (12)
153var text = textAndVersion.Text; 226var newText = newTextAndVersion.Text; 229var oldText = oldTree.GetText(cancellationToken); 237private static TreeAndVersion MakeNewTreeAndVersion(SyntaxTree oldTree, SourceText oldText, VersionStamp oldVersion, SyntaxTree newTree, SourceText newText, VersionStamp newVersion) 246private static bool TopLevelChanged(SyntaxTree oldTree, SourceText oldText, SyntaxTree newTree, SourceText newText) 449public new DocumentState UpdateText(SourceText newText, PreservationMode mode) 509else if (TryGetText(out var priorText)) 548new AsyncLazy<SourceText>( 688SourceText newText, 690SourceText? oldText = null)
Workspace\Solution\DocumentState_TreeTextSource.cs (5)
20private readonly ValueSource<SourceText> _textSource; 26public TreeTextSource(ValueSource<SourceText> textSource, VersionStamp version) 34var text = await _textSource.GetValueAsync(cancellationToken).ConfigureAwait(false); 40var text = _textSource.GetValue(cancellationToken); 46if (_textSource.TryGetValue(out var text))
Workspace\Solution\FileTextLoader.cs (7)
70GetType(), _ => new StrongBox<bool>(new Func<Stream, Workspace, SourceText>(CreateText).Method.DeclaringType != typeof(FileTextLoader))).Value; 74/// Creates <see cref="SourceText"/> from <see cref="Stream"/>. 78protected virtual SourceText CreateText(Stream stream, Workspace? workspace) 82/// Creates <see cref="SourceText"/> from <see cref="Stream"/>. 85private protected virtual SourceText CreateText(Stream stream, LoadTextOptions options, CancellationToken cancellationToken) 181var text = CreateText(readStream, options, cancellationToken); 216var text = CreateText(stream, options, cancellationToken);
Workspace\Solution\ITextAndVersionSource.cs (1)
15/// True if <see cref="SourceText"/> can be reloaded.
Workspace\Solution\LoadTextOptions.cs (1)
12/// Options used to load <see cref="SourceText"/>.
Workspace\Solution\Project.cs (3)
676public Document AddDocument(string name, SourceText text, IEnumerable<string>? folders = null, string? filePath = null) 694public TextDocument AddAdditionalDocument(string name, SourceText text, IEnumerable<string>? folders = null, string? filePath = null) 712public TextDocument AddAnalyzerConfigDocument(string name, SourceText text, IEnumerable<string>? folders = null, string? filePath = null)
Workspace\Solution\RecoverableTextAndVersion.cs (6)
65if (recoverableText.TryGetValue(out var text) && recoverableText.LoadTextOptions == options) 142private sealed class RecoverableText : WeaklyCachedRecoverableValueSource<SourceText>, ITextVersionable 170public TextAndVersion ToTextAndVersion(SourceText text) 175protected override async Task<SourceText> RecoverAsync(CancellationToken cancellationToken) 185protected override SourceText Recover(CancellationToken cancellationToken) 195protected override async Task SaveAsync(SourceText text, CancellationToken cancellationToken)
Workspace\Solution\Solution.cs (15)
1005var sourceText = SourceText.From(text, encoding: null, checksumAlgorithm: project.ChecksumAlgorithm); 1014public Solution AddDocument(DocumentId documentId, string name, SourceText text, IEnumerable<string>? folders = null, string? filePath = null, bool isGenerated = false) 1045var sourceText = SourceText.From(string.Empty, encoding: null, project.ChecksumAlgorithm); 1051private Solution AddDocumentImpl(ProjectState project, DocumentId documentId, string name, SourceText text, IReadOnlyList<string>? folders, string? filePath, bool isGenerated) 1114=> this.AddAdditionalDocument(documentId, name, SourceText.From(text), folders, filePath); 1120public Solution AddAdditionalDocument(DocumentId documentId, string name, SourceText text, IEnumerable<string>? folders = null, string? filePath = null) 1159public Solution AddAnalyzerConfigDocument(DocumentId documentId, string name, SourceText text, IEnumerable<string>? folders = null, string? filePath = null) 1183private DocumentInfo CreateDocumentInfo(DocumentId documentId, string name, SourceText text, IEnumerable<string>? folders, string? filePath) 1370public Solution WithDocumentText(DocumentId documentId, SourceText text, PreservationMode mode = PreservationMode.PreserveValue) 1397public Solution WithAdditionalDocumentText(DocumentId documentId, SourceText text, PreservationMode mode = PreservationMode.PreserveValue) 1424public Solution WithAnalyzerConfigDocumentText(DocumentId documentId, SourceText text, PreservationMode mode = PreservationMode.PreserveValue) 1727public Solution WithDocumentText(IEnumerable<DocumentId?> documentIds, SourceText text, PreservationMode mode = PreservationMode.PreserveValue) 1758internal Document WithFrozenSourceGeneratedDocument(SourceGeneratedDocumentIdentity documentIdentity, SourceText text)
Workspace\Solution\SolutionState.cs (9)
1259public SolutionState WithDocumentText(DocumentId documentId, SourceText text, PreservationMode mode = PreservationMode.PreserveValue) 1262if (oldDocument.TryGetText(out var oldText) && text == oldText) 1274public SolutionState WithAdditionalDocumentText(DocumentId documentId, SourceText text, PreservationMode mode = PreservationMode.PreserveValue) 1277if (oldDocument.TryGetText(out var oldText) && text == oldText) 1289public SolutionState WithAnalyzerConfigDocumentText(DocumentId documentId, SourceText text, PreservationMode mode = PreservationMode.PreserveValue) 1292if (oldDocument.TryGetText(out var oldText) && text == oldText) 1745public SolutionState WithDocumentText(IEnumerable<DocumentId?> documentIds, SourceText text, PreservationMode mode) 1759if (!doc.TryGetText(out var existingText) || existingText != text) 1852public SolutionState WithFrozenSourceGeneratedDocument(SourceGeneratedDocumentIdentity documentIdentity, SourceText sourceText)
Workspace\Solution\SourceGeneratedDocumentState.cs (3)
19SourceText generatedSourceText, 71public SourceGeneratedDocumentState WithUpdatedGeneratedContent(SourceText sourceText, ParseOptions parseOptions) 73if (TryGetText(out var existingText) &&
Workspace\Solution\TextAndVersion.cs (4)
18public SourceText Text { get; } 36private TextAndVersion(SourceText text, VersionStamp version, string? filePath, Diagnostic? loadDiagnostic) 54public static TextAndVersion Create(SourceText text, VersionStamp version, string? filePath = null) 64internal static TextAndVersion Create(SourceText text, VersionStamp version, Diagnostic? loadDiagnostic)
Workspace\Solution\TextDocument.cs (3)
64public bool TryGetText([NotNullWhen(returnValue: true)] out SourceText? text) 76public Task<SourceText> GetTextAsync(CancellationToken cancellationToken = default) 84internal SourceText GetTextSynchronously(CancellationToken cancellationToken)
Workspace\Solution\TextDocumentState.cs (7)
64: CreateStrongText(TextAndVersion.Create(SourceText.From(string.Empty, encoding: null, loadTextOptions.ChecksumAlgorithm), VersionStamp.Default, info.FilePath)), 101public bool TryGetText([NotNullWhen(returnValue: true)] out SourceText? text) 138public ValueTask<SourceText> GetTextAsync(CancellationToken cancellationToken) 140if (TryGetText(out var text)) 142return new ValueTask<SourceText>(text); 152public SourceText GetTextSynchronously(CancellationToken cancellationToken) 185public TextDocumentState UpdateText(SourceText newText, PreservationMode mode)
Workspace\Solution\TextLoader.cs (5)
35/// True if <see cref="LoadTextAndVersionAsync(LoadTextOptions, CancellationToken)"/> reloads <see cref="SourceText"/> from its original binary representation (e.g. file on disk). 44/// Implementations of this method should use <see cref="LoadTextOptions.ChecksumAlgorithm"/> when creating <see cref="SourceText"/> from an original binary representation and 46/// 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"/> 170SourceText.From(string.Empty, Encoding.UTF8),
Workspace\TextExtensions.cs (5)
19public static ImmutableArray<Document> GetRelatedDocumentsWithChanges(this SourceText text) 51public static Document? GetOpenDocumentInCurrentContextWithChanges(this SourceText text) 58public static TextDocument? GetOpenTextDocumentInCurrentContextWithChanges(this SourceText text) 61private static TextDocument? GetOpenTextDocumentInCurrentContextWithChanges(this SourceText text, bool sourceDocumentOnly) 150internal static Document? GetDocumentWithFrozenPartialSemantics(this SourceText text, CancellationToken cancellationToken)
Workspace\Workspace.cs (17)
922protected internal void OnDocumentTextChanged(DocumentId documentId, SourceText newText, PreservationMode mode) 936protected internal void OnAdditionalDocumentTextChanged(DocumentId documentId, SourceText newText, PreservationMode mode) 950protected internal void OnAnalyzerConfigDocumentTextChanged(DocumentId documentId, SourceText newText, PreservationMode mode) 1650var text = document.GetTextSynchronously(CancellationToken.None); 1659var text = document.GetTextSynchronously(CancellationToken.None); 1668var text = document.GetTextSynchronously(CancellationToken.None); 1685var currentText = newDoc.GetTextSynchronously(CancellationToken.None); // needs wait 1695var currentText = newDoc.GetTextSynchronously(CancellationToken.None); // needs wait 1712if (!oldDoc.TryGetText(out var oldText)) 1717var currentText = newDoc.GetTextSynchronously(CancellationToken.None); // needs wait 1720else if (!newDoc.TryGetText(out var newText)) 1935protected virtual void ApplyDocumentAdded(DocumentInfo info, SourceText text) 1957protected virtual void ApplyDocumentTextChanged(DocumentId id, SourceText text) 1979protected virtual void ApplyAdditionalDocumentAdded(DocumentInfo info, SourceText text) 2001protected virtual void ApplyAdditionalDocumentTextChanged(DocumentId id, SourceText text) 2012protected virtual void ApplyAnalyzerConfigDocumentAdded(DocumentInfo info, SourceText text) 2034protected 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)
372var newText = data.textContainer.CurrentText; 373if (oldDocument.TryGetText(out var oldText) && 462private static TextAndVersion GetProperTextAndVersion(SourceText oldText, SourceText newText, VersionStamp version, string? filePath) 471private void SignupForTextChanges(DocumentId documentId, SourceTextContainer textContainer, bool isCurrentContext, Action<Workspace, DocumentId, SourceText, PreservationMode> onChangedHandler) 523Func<Solution, DocumentId, SourceText, PreservationMode, Solution> withDocumentText, 525Action<Workspace, DocumentId, SourceText, PreservationMode> onDocumentTextChanged) 538var oldText = oldDocument.GetTextSynchronously(CancellationToken.None); 541var newText = data.textContainer.CurrentText; 734private SourceText GetOpenDocumentText(Solution solution, DocumentId documentId) 739Contract.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 (6)
MSBuild\MSBuildWorkspace.cs (6)
367protected override void ApplyDocumentTextChanged(DocumentId documentId, SourceText text) 385protected override void ApplyAdditionalDocumentTextChanged(DocumentId documentId, SourceText text) 403private static Encoding? DetermineEncoding(SourceText text, TextDocument document) 418var onDiskText = EncodedStringText.Create(stream); 431protected override void ApplyDocumentAdded(DocumentInfo info, SourceText text) 471private void SaveDocumentText(DocumentId id, string fullPath, SourceText newText, Encoding encoding)
Microsoft.CodeAnalysis.Workspaces.MSBuild.UnitTests (43)
VisualStudioMSBuildWorkspaceTests.cs (43)
383var solution1 = solution.WithDocumentText(document.Id, SourceText.From("using test;")); 953var text = await getTextTask; 978var text = await doc.GetTextAsync(); 2002var newText = SourceText.From("public class Bar { }"); 2011var text2 = await document2.GetTextAsync(); 2043var originalText = await document.GetTextAsync(); 2045var newText = SourceText.From("public class Bar { }"); 2054var text2 = await document2.GetTextAsync(); 2062var text = await document.GetTextAsync(); 2077var originalText = await document.GetTextAsync(); 2090var text = await document.GetTextAsync(); 2104var text = await document.GetTextAsync(); 2105var newText = SourceText.From("using System.Diagnostics;\r\n" + text.ToString()); 2113var text2 = await document2.GetTextAsync(); 2131var text = await document.GetTextAsync(); 2132var newText = SourceText.From("New Text In Additional File.\r\n" + text.ToString()); 2140var text2 = await document2.GetTextAsync(); 2158var newText = SourceText.From("public class Bar { }"); 2166var text2 = await document2.GetTextAsync(); 2194workspace.TryApplyChanges(workspace.CurrentSolution.AddAdditionalDocument(DocumentId.CreateNewId(csProjectId), "foo.xaml", SourceText.From("<foo></foo>"))); 2227var text = await doc.GetTextAsync(); 2230workspace.TryApplyChanges(workspace.CurrentSolution.WithDocumentText(doc.Id, SourceText.From(newText), PreservationMode.PreserveIdentity)); 2257var text = await doc.GetTextAsync(); 2265SourceText.From(newText), 2341var text = await doc.GetTextAsync(); 2379var text = doc.State.GetTextSynchronously(CancellationToken.None); 2382var atext = adoc.State.GetTextSynchronously(CancellationToken.None); 2759var text = await document.GetTextAsync(); 2778var text = await document.GetTextAsync(); 2797var text = await document.GetTextAsync(); 2850var doc2text = await doc2.GetTextAsync(); 2857var text = await document.GetTextAsync(); 2863var doc3text = await doc3.GetTextAsync(); 2872var noEncodingDoc = document.WithText(SourceText.From(text.ToString(), encoding: null)); 2873var noEncodingDocText = await noEncodingDoc.GetTextAsync(); 2883var reloadedText = EncodedStringText.Create(stream); 3181var text = await analyzerConfigDocument.GetTextAsync(); 3244var text = await document.GetTextAsync();
Microsoft.CodeAnalysis.Workspaces.Test.Utilities (13)
Formatting\FormattingTestBase.cs (6)
54var document = project.AddDocument("Document", SourceText.From(code)); 89private static async Task AssertFormatAsync(SolutionServices services, string expected, SyntaxNode root, ImmutableArray<TextSpan> spans, SyntaxFormattingOptions options, SourceText sourceText) 96var resultText = sourceText.WithChanges(result); 105private static bool TryAdjustSpans(SourceText inputText, IList<TextChange> changes, SourceText outputText, ImmutableArray<TextSpan> inputSpans, out ImmutableArray<TextSpan> outputSpans) 133protected static void AssertResult(string expected, SourceText sourceText, IList<TextChange> result)
GenerateFileForEachAdditionalFileWithContentsCommented.cs (4)
26private static SourceText GenerateSourceForAdditionalFile(AdditionalText file, CancellationToken cancellationToken) 29var sourceText = file.GetText(cancellationToken); 33var generatedText = sourceText.WithChanges(changes); 35return SourceText.From(generatedText.ToString(), encoding: Encoding.UTF8);
TestTextLoader.cs (1)
20_textAndVersion = TextAndVersion.Create(SourceText.From(text, encoding: null, checksumAlgorithm), VersionStamp.Create());
WorkspaceExtensions.cs (2)
15public static DocumentId AddDocument(this Workspace workspace, ProjectId projectId, IEnumerable<string> folders, string name, SourceText initialText, SourceCodeKind sourceCodeKind = SourceCodeKind.Regular) 31public static void UpdateDocument(this Workspace workspace, DocumentId documentId, SourceText newText)
Microsoft.CodeAnalysis.Workspaces.UnitTests (275)
CodeCleanup\AddMissingTokensTests.cs (1)
2734.AddDocument("Document", SourceText.From(code));
CodeCleanup\CodeCleanupTests.cs (1)
425return project.AddDocument("Document", SourceText.From(code));
CodeCleanup\FixIncorrectTokenTests.cs (1)
759.AddDocument("Document", SourceText.From(code));
CodeCleanup\NormalizeModifiersOrOperatorsTests.cs (1)
1034return project.AddDocument("Document", SourceText.From(code));
CodeCleanup\ReduceTokenTests.cs (1)
2023.AddDocument("Document", SourceText.From(code));
CodeCleanup\RemoveUnnecessaryLineContinuationTests.cs (1)
1398return project.AddDocument("Document", SourceText.From(code));
EditorConfigParsing\NamingStyleParserTests.cs (4)
19var editorconfig = SourceText.From(DefaultDotNet6EditorConfigText); 48var editorconfig = SourceText.From(RoslynEditorConfigText);
FindAllDeclarationsTests.cs (1)
703solution = solution.AddDocument(did, "VBDocument.vb", SourceText.From(source));
FindAllDeclarationsTests.TestSolutionsAndProject.cs (2)
102solution = solution.AddDocument(did, "goo" + i + ".cs", SourceText.From(sourceTexts[i])); 119solution = solution.AddDocument(did, "goo" + i + ".cs", SourceText.From(sourceTexts[i]));
FindReferencesTests.cs (4)
39return solution.AddProject(pi).AddDocument(did, $"{projectName}.{suffix}", SourceText.From(code)); 49.AddDocument(did, "goo.cs", SourceText.From(sourceText)); 65solution = solution.AddDocument(did, $"goo{docCounter++}.cs", SourceText.From(sourceText)); 109.AddDocument(did, "goo.cs", SourceText.From(text));
Formatter\FormatterTests.cs (7)
42=> Task.FromResult(document.WithText(SourceText.From($"Formatted with options: {lineFormattingOptions.ToString().Replace("\r", "\\r").Replace("\n", "\\n")}"))); 52var document = workspace.AddDocument(project.Id, "File.dummy", SourceText.From("dummy")); 58var formattedText = await formattedDocument.GetTextAsync(); 71var document = workspace.AddDocument(project.Id, "File.dummy", SourceText.From("dummy")); 96var formattedText = await formattedDocument.GetTextAsync(); 116var csDocument = workspace.AddDocument(csProject.Id, "File.cs", SourceText.From("class C { }")); 117var vbDocument = workspace.AddDocument(vbProject.Id, "File.vb", SourceText.From("Class C : End Class"));
GeneratedCodeRecognitionTests.cs (2)
60SourceText.From(@" 66SourceText.From(@"
LinkedFileDiffMerging\LinkedFileDiffMergingTests.cs (3)
21var startSourceText = SourceText.From(startText); 46.WithDocumentText(documentIds[i], SourceText.From(text));
SemanticModelReuse\SemanticModelReuseTests.cs (25)
29.AddDocument("Document", SourceText.From(code)); 89var document2 = document1.WithText(SourceText.From("class C { void M() { return null; } }")); 106var document2 = document1.WithText(SourceText.From("class C { long M() { return; } }")); 112var document3 = document2.WithText(SourceText.From("class C { long M() { return 0; } }")); 129var document2 = document1.WithText(SourceText.From("class C { void M() { return 0; } }")); 135var document3 = document1.WithText(SourceText.From("class C { void M() { return 1; } }")); 152var document2 = document1.WithText(SourceText.From("class C { int M { get { return 1; } } }")); 158var document3 = document1.WithText(SourceText.From("class C { int M { get { return 2; } } }")); 175var document2 = document1.WithText(SourceText.From("class C { event System.Action E { add { return 1; } } }")); 181var document3 = document1.WithText(SourceText.From("class C { event System.Action E { add { return 2; } } }")); 198var document2 = document1.WithText(SourceText.From("class C { int this[int i] { get { return 1; } } }")); 204var document3 = document1.WithText(SourceText.From("class C { int this[int i] { get { return 2; } } }")); 223var document2 = document1.WithText(SourceText.From("class C { void M() { return null; } }")); 251var document2 = document1.WithText(SourceText.From(source2)); 335var document2 = document1.WithText(SourceText.From(@" 368var document2 = document1.WithText(SourceText.From(source2)); 374var document3 = document2.WithText(SourceText.From(@" 401var document2 = document1.WithText(SourceText.From(@" 412var document3 = document1.WithText(SourceText.From(@" 441var document2 = document1.WithText(SourceText.From(@" 454var document3 = document1.WithText(SourceText.From(@" 485var document2 = document1.WithText(SourceText.From(@" 498var document3 = document1.WithText(SourceText.From(@" 529var document2 = document1.WithText(SourceText.From(@" 561var document2 = document1.WithText(SourceText.From(@"
SerializationTests.cs (1)
33.AddDocument(did, "goo.cs", SourceText.From(sourceText));
Simplifier\SimplifierTests.cs (3)
31return workspace.AddDocument(project.Id, "CSharpFile.cs", SourceText.From("class C { }")); 80var csDocument = workspace.AddDocument(csProject.Id, "File.cs", SourceText.From("class C { }")); 81var vbDocument = workspace.AddDocument(vbProject.Id, "File.vb", SourceText.From("Class C : End Class"));
SolutionTests\ProjectSemanticVersionTests.cs (16)
43var text = await document.GetTextAsync(); 57var text = await document.GetTextAsync(); 71var text = await document.GetTextAsync(); 85var text = await document.GetTextAsync(); 99var text = await document.GetTextAsync(); 113var text = await document.GetTextAsync(); 127var text = await document.GetTextAsync(); 141var text = await document.GetTextAsync(); 155var text = await document.GetTextAsync(); 169var text = await document.GetTextAsync(); 183var text = await document.GetTextAsync(); 197var text = await document.GetTextAsync(); 211var text = await document.GetTextAsync(); 225var text = await document.GetTextAsync(); 239var text = await document.GetTextAsync(); 253var text = await document.GetTextAsync();
SolutionTests\SolutionTests.cs (111)
56.AddDocument(DocumentId.CreateNewId(projectId), "goo.cs", SourceText.From("public class Goo { }", Encoding.UTF8, SourceHashAlgorithms.Default)) 57.AddAdditionalDocument(DocumentId.CreateNewId(projectId), "add.txt", SourceText.From("text", Encoding.UTF8, SourceHashAlgorithms.Default)) 58.AddAnalyzerConfigDocument(DocumentId.CreateNewId(projectId), "editorcfg", SourceText.From("config", Encoding.UTF8, SourceHashAlgorithms.Default), filePath: "/a/b"))); 78.AddDocument(DocumentId.CreateNewId(projectId1), "goo.cs", SourceText.From(docContents, Encoding.UTF8, SourceHashAlgorithms.Default), filePath: "goo.cs") 79.AddAdditionalDocument(DocumentId.CreateNewId(projectId1), "add.txt", SourceText.From("text", Encoding.UTF8, SourceHashAlgorithms.Default), filePath: "add.txt") 80.AddAnalyzerConfigDocument(DocumentId.CreateNewId(projectId1), "editorcfg", SourceText.From("config", Encoding.UTF8, SourceHashAlgorithms.Default), filePath: "/a/b") 82.AddDocument(DocumentId.CreateNewId(projectId2), "goo.cs", SourceText.From(docContents, Encoding.UTF8, SourceHashAlgorithms.Default), filePath: "goo.cs") 83.AddAdditionalDocument(DocumentId.CreateNewId(projectId2), "add.txt", SourceText.From("text", Encoding.UTF8, SourceHashAlgorithms.Default), filePath: "add.txt") 84.AddAnalyzerConfigDocument(DocumentId.CreateNewId(projectId2), "editorcfg", SourceText.From("config", Encoding.UTF8, SourceHashAlgorithms.Default), filePath: "/a/b"))); 310.AddAnalyzerConfigDocument(DocumentId.CreateNewId(projectId), "editorcfg", SourceText.From("config")); 326var text = SourceText.From("new text", encoding: null, SourceHashAlgorithm.Sha1); 331Assert.True(newDocument1.TryGetText(out var actualText)); 337Assert.Throws<ArgumentNullException>(() => solution.WithDocumentText(documentId, (SourceText)null!, PreservationMode.PreserveIdentity)); 350var textAndVersion = TextAndVersion.Create(SourceText.From("new text"), VersionStamp.Default); 353Assert.True(newSolution1.GetDocument(documentId)!.TryGetText(out var actualText)); 361Assert.Throws<ArgumentNullException>(() => solution.WithDocumentText(documentId, (SourceText)null!, PreservationMode.PreserveIdentity)); 374var text = SourceText.From("new text"); 377Assert.True(newSolution1.GetDocument(documentId)!.TryGetText(out var actualText)); 413var text1 = await document1.GetTextAsync(); 414var text2 = await document2.GetTextAsync(); 427var text = SourceText.From("new text", encoding: null, SourceHashAlgorithm.Sha1); 472private static Solution UpdateSolution(PreservationMode mode, TextUpdateType updateType, Solution solution, DocumentId documentId1, SourceText text, TextAndVersion textAndVersion) 501var text1 = await document1.GetTextAsync(); 502var text2 = await document2.GetTextAsync(); 515var text = SourceText.From("new text", encoding: null, SourceHashAlgorithm.Sha1); 580var text1 = await document1.GetTextAsync(); 581var text2 = await document2.GetTextAsync(); 598var text = SourceText.From("new text without pp directives", encoding: null, SourceHashAlgorithm.Sha1); 666var text1 = await document1.GetTextAsync(); 667var text2 = await document2.GetTextAsync(); 681var text = SourceText.From("#if true", encoding: null, SourceHashAlgorithm.Sha1); 743var text1 = await document1.GetTextAsync(); 744var text2 = await document2.GetTextAsync(); 757var text = SourceText.From("new text", encoding: null, SourceHashAlgorithm.Sha1); 808var text = SourceText.From("new text"); 811Assert.True(newSolution1.GetAdditionalDocument(documentId)!.TryGetText(out var actualText)); 817Assert.Throws<ArgumentNullException>(() => solution.WithAdditionalDocumentText(documentId, (SourceText)null!, PreservationMode.PreserveIdentity)); 830var textAndVersion = TextAndVersion.Create(SourceText.From("new text"), VersionStamp.Default); 833Assert.True(newSolution1.GetAdditionalDocument(documentId)!.TryGetText(out var actualText)); 841Assert.Throws<ArgumentNullException>(() => solution.WithAdditionalDocumentText(documentId, (SourceText)null!, PreservationMode.PreserveIdentity)); 854var text = SourceText.From("new text"); 857Assert.True(newSolution1.GetAnalyzerConfigDocument(documentId)!.TryGetText(out var actualText)); 863Assert.Throws<ArgumentNullException>(() => solution.WithAnalyzerConfigDocumentText(documentId, (SourceText)null!, PreservationMode.PreserveIdentity)); 876var textAndVersion = TextAndVersion.Create(SourceText.From("new text"), VersionStamp.Default); 879Assert.True(newSolution1.GetAnalyzerConfigDocument(documentId)!.TryGetText(out var actualText)); 887Assert.Throws<ArgumentNullException>(() => solution.WithAnalyzerConfigDocumentText(documentId, (SourceText)null!, PreservationMode.PreserveIdentity)); 1114var textC = SourceText.From("class C {}", encoding: null, checksumAlgorithm: SourceHashAlgorithm.Sha1); 1750var sourceText = document.GetTextSynchronously(default); 1775var sourceText = SourceText.From("text", checksumAlgorithm: SourceHashAlgorithms.Default); 1789Assert.Throws<ArgumentNullException>("text", () => solution.AddDocument(documentId, "name", text: (SourceText)null!)); 1836var root = CSharp.SyntaxFactory.ParseSyntaxTree(SourceText.From("class C {}", encoding: null, SourceHashAlgorithm.Sha1)).GetRoot(); 1841var sourceText = document2.GetTextSynchronously(default); 1870var sourceText = document2.GetTextSynchronously(default); 2513.AddDocument(documentId, "DocumentName", SourceText.From("class Class{}")); 2553var text2 = tree2.GetText(); 2676var observedText2 = sol.GetDocument(did).GetTextAsync().Result; 2694var docText = doc.GetTextAsync().Result; 2716var docText = doc.GetTextAsync().Result; 2741var docText = doc.GetTextAsync().Result; 2887private static ObjectReference<SourceText> GetObservedText(Solution solution, DocumentId documentId, string expectedText = null) 2889var observedText = solution.GetDocument(documentId).GetTextAsync().Result; 2896return new ObjectReference<SourceText>(observedText); 2918private static ObjectReference<SourceText> GetObservedTextAsync(Solution solution, DocumentId documentId, string expectedText = null) 2920var observedText = solution.GetDocument(documentId).GetTextAsync().Result; 2927return new ObjectReference<SourceText>(observedText); 3135.AddDocument(did, "test", SourceText.From(language == LanguageNames.CSharp ? "class C {}" : "Class C : End Class", Encoding.UTF8, SourceHashAlgorithm.Sha256), filePath: "old path"); 3277var text = await doc.GetTextAsync().ConfigureAwait(false); 3339var solution2 = solution.WithDocumentText(did3, SourceText.From(text4)); 3352var doc = ws.AddDocument(proj.Id, "a.cs", SourceText.From("public class c { }", Encoding.UTF32)); 3413workspace.AddDocument(project1.Id, "Broken.cs", SourceText.From("class ")); 3435project = project.AddDocument("Extra.cs", SourceText.From("class Extra { }")).Project; 3437var documentToFreeze = project.AddDocument("DocumentToFreeze.cs", SourceText.From("")); 3460project = project.AddDocument("Extra.cs", SourceText.From("class Extra { }")).Project; 3462var documentToFreezeOriginal = project.AddDocument("DocumentToFreeze.cs", SourceText.From("class DocumentToFreeze { void M() { } }")); 3466var solution = project.Solution.WithDocumentText(documentToFreezeOriginal.Id, SourceText.From("class DocumentToFreeze { void M() { /*no top level change*/ } }")); 3505project = project.AddDocument("Extra.cs", SourceText.From("class Extra { }")).Project; 3507var documentToFreezeOriginal = project.AddDocument("DocumentToFreeze.cs", SourceText.From("class DocumentToFreeze { void M() { } }")); 3511var solution = project.Solution.WithDocumentText(documentToFreezeOriginal.Id, SourceText.From("class DocumentToFreeze { void M() { } public void NewMethod() { } }")); 3569var document = workspace.AddDocument(project2.Id, "Test.cs", SourceText.From("")); 3668document = document.WithText(SourceText.From("// Source File with Changes")); 3695.WithDocumentText(documentId1, SourceText.From("// Document 1 Changed")) 3696.WithDocumentText(documentId2, SourceText.From("// Document 2 Changed")) 3697.WithDocumentText(documentId3, SourceText.From("// Document 3 Changed")); 3799var text = SourceText.From("// empty", encoding: null, SourceHashAlgorithms.Default); 3802var sourceText = strongTree.GetText(); 3935loader: TextLoader.From(TextAndVersion.Create(SourceText.From("[*.*]\r\n\r\ndotnet_diagnostic.CA1234.severity = error"), VersionStamp.Default))))); 3969loader: TextLoader.From(TextAndVersion.Create(SourceText.From("[*.*]\r\n\r\ndotnet_diagnostic.CA1234.severity = error"), VersionStamp.Default))))); 4011loader: TextLoader.From(TextAndVersion.Create(SourceText.From("[*.*]\r\n\r\ndotnet_diagnostic.CA1234.severity = error"), VersionStamp.Default))))); 4023TextLoader.From(TextAndVersion.Create(SourceText.From("[*.*]\r\n\r\ndotnet_diagnostic.CA6789.severity = error"), VersionStamp.Default)), 4059loader: TextLoader.From(TextAndVersion.Create(SourceText.From("is_global = true\r\n\r\ndotnet_diagnostic.CA1234.severity = error"), VersionStamp.Default))))); 4105loader: TextLoader.From(TextAndVersion.Create(SourceText.From("[*.*]\r\n\r\ngenerated_code = true"), VersionStamp.Default))))); 4292var text = SourceText.From("public class C { }"); 4313var newDocText = await newDoc.GetTextAsync(); 4314var sameText = await newDoc.GetTextAsync(); 4318var treeText = newDocTree.GetText(); 4340var sourceTextToRelease = ObjectReference.CreateFromFactory(static () => SourceText.From(Guid.NewGuid().ToString())); 4388.AddDocument(documentId, "test.cs", SourceText.From("public class C { }"), filePath: sourcePath) 4389.AddAnalyzerConfigDocument(DocumentId.CreateNewId(projectId), ".editorconfig", SourceText.From($"[{pattern}]\nindent_style = tab"), filePath: configPath);
SolutionTests\SolutionWithSourceGeneratorTests.cs (18)
196project = project.AdditionalDocuments.First().WithAdditionalDocumentText(SourceText.From("Changed text!")).Project; 220project = project.AddDocument("Source.cs", SourceText.From("")).Project; 253project = project.Solution.WithDocumentText(documentId, SourceText.From("// Changed Source File")).Projects.Single(); 296project = project.Solution.WithAdditionalDocumentText(additionalDocumentId, SourceText.From("Hello, everyone!")).Projects.Single(); 301project = project.Solution.WithAdditionalDocumentText(additionalDocumentId, SourceText.From("Good evening, everyone!")).Projects.Single(); 357SourceText.From("Hello, world!!!!")).Projects.Single(); 470project = project.Documents.Single().WithText(SourceText.From("// Change")).Project; 546var existingText = await project.Documents.Single().GetTextAsync(); 547var newText = existingText.WithChanges(new TextChange(new TextSpan(existingText.Length, length: 0), " With Change")); 576var differentOpenTextContainer = SourceText.From("// Open Text").Container; 600var differentOpenTextContainer = SourceText.From("// StaticContent", Encoding.UTF8).Container; 615.AddAdditionalDocument("Test.txt", SourceText.From("")); 620var differentOpenTextContainer = SourceText.From("// Open Text").Container; 651var differentOpenTextContainer = SourceText.From("// Open Text").Container; 678var differentOpenTextContainer = SourceText.From("// Open Text").Container; 715documentToFreeze = documentToFreeze.WithText(SourceText.From("// Changed Source File")); 744document = document.WithText(SourceText.From("// Something else")); 776document = document.WithText(SourceText.From("// Something else"));
SolutionTests\TextLoaderTests.cs (3)
82public static readonly TextAndVersion Value = TextAndVersion.Create(SourceText.From(""), VersionStamp.Default); 91public static new readonly TextAndVersion Value = TextAndVersion.Create(SourceText.From(""), VersionStamp.Default); 100public static readonly TextAndVersion Value = TextAndVersion.Create(SourceText.From(""), VersionStamp.Default);
SolutionTests\TryApplyChangesTests.cs (1)
166Assert.True(workspace.TryApplyChanges(project.AddAnalyzerConfigDocument(".editorconfig", SourceText.From("")).Project.Solution));
SymbolKeyTests.cs (7)
791var sourceText = SourceText.From(text); 803var updated = sourceText.WithChanges(new TextChange(new TextSpan(position, 0), "insertion")); 838var sourceText = SourceText.From(text); 850var updated = sourceText.WithChanges(new TextChange(new TextSpan(position, 0), "insertion")); 1345var text = syntaxTree.GetText();
SyntaxPathTests.cs (14)
90var text = SourceText.From(string.Empty); 95var newText = text.WithChanges(new TextChange(new TextSpan(0, 0), "class C {}")); 104var text = SourceText.From("class C {}"); 109var newText = text.WithChanges(new TextChange(new TextSpan(0, text.Length), "")); 397var text = SourceText.From("using X; class C {}"); 402var newText = WithReplaceFirst(text, "using X;", ""); 409internal static SourceText WithReplaceFirst(SourceText text, string oldText, string newText) 416return SourceText.From(newFullText); 429var oldFullText = syntaxTree.GetText(); 430var newFullText = oldFullText.WithChanges(new TextChange(new TextSpan(offset, length), newText));
SyntaxReferenceTests.cs (2)
41.AddDocument(did, "Test.cs", SourceText.From(source)); 51.AddDocument(did, "Test.vb", SourceText.From(source));
UtilityTest\SourceTextSerializationTests.cs (4)
32var originalText = CreateSourceText(sb, i); 44var recovered = SourceTextExtensions.ReadFrom(textService, reader, originalText.Encoding, originalText.ChecksumAlgorithm, CancellationToken.None); 50private static SourceText CreateSourceText(StringBuilder sb, int size) 57return SourceText.From(sb.ToString());
WorkspaceServiceTests\TemporaryStorageServiceTests.cs (12)
32var text = SourceText.From(new string(' ', 4096) + "public class A {}"); 36text = SourceText.From(string.Empty); 40text = SourceText.From(new string(' ', 1024 * 1024) + "public class A {}"); 69private static void TestTemporaryStorage(ITemporaryStorageServiceInternal temporaryStorageService, SourceText text) 78var text2 = temporaryStorage.ReadTextAsync().Result; 100var text = SourceText.From(new string(' ', 4096) + "public class A {}"); 340var text = SourceText.From(new string(' ', 4096) + "public class A {}", Encoding.ASCII); 344text = SourceText.From(string.Empty); 348text = SourceText.From(new string(' ', 1024 * 1024) + "public class A {}");
WorkspaceTests\AdhocWorkspaceTests.cs (22)
76var doc = ws.AddDocument(project.Id, name, SourceText.From(source)); 158loader: TextLoader.From(TextAndVersion.Create(SourceText.From(""), VersionStamp.Create()))); 216var text = SourceText.From("public class C { }"); 230Assert.False(doc.TryGetText(out var currentText)); 250var text = SourceText.From("public class C { }"); 264Assert.False(doc.TryGetText(out var currentText)); 284var text = SourceText.From("public class C { }"); 304Assert.False(doc.TryGetText(out var currentText)); 344var text = SourceText.From("public class C { }"); 358Assert.False(doc.TryGetText(out var currentText)); 390var actualText = await newDoc.GetTextAsync(); 402var docid1 = ws.AddDocument(projid, "A.cs", SourceText.From("public class A { }")).Id; 403var docid2 = ws.AddDocument(projid, "B.cs", SourceText.From("public class B { }")).Id; 439var originalDoc = ws.AddDocument(projectId, "TestDocument", SourceText.From("")); 470var originalDoc = ws.AddDocument(projectId, "TestDocument", SourceText.From("")); 506var originalDoc = ws.AddDocument(projectId, "TestDocument", SourceText.From("")); 538var originalDoc = ws.AddDocument(projectId, "TestDocument", SourceText.From("")); 569var originalDoc = ws.AddDocument(projectId, "TestDocument", SourceText.From(""));
WorkspaceTests\WorkspaceTests.cs (7)
28var originalDoc = ws.AddDocument(projectId, "TestDocument", SourceText.From("")); 30var changedDoc = originalDoc.WithText(SourceText.From("new")); 41var originalDoc = ws.AddDocument(projectId, "TestDocument", SourceText.From("")); 57var originalDoc = ws.AddDocument(projectId, "TestDocument", SourceText.From("")); 76var originalDoc = ws.AddDocument(projectId, "TestDocument", SourceText.From("")); 93var originalDoc = ws.AddDocument(projectId, "TestDocument", SourceText.From("")); 150public Document AddDocument(ProjectId projectId, string name, SourceText text)
Microsoft.VisualStudio.LanguageServices (121)
EditorConfigSettings\Analyzers\View\AnalyzerSettingsView.xaml.cs (2)
33public Task<SourceText> UpdateEditorConfigAsync(SourceText sourceText) => _viewModel.UpdateEditorConfigAsync(sourceText);
EditorConfigSettings\CodeStyle\View\CodeStyleSettingsView.xaml.cs (2)
34public Task<SourceText> UpdateEditorConfigAsync(SourceText sourceText) => _viewModel.UpdateEditorConfigAsync(sourceText);
EditorConfigSettings\Common\SettingsViewModelBase.cs (2)
90public Task<SourceText> UpdateEditorConfigAsync(SourceText sourceText) => _data.GetChangedEditorConfigAsync(sourceText);
EditorConfigSettings\ISettingsEditorView.cs (2)
16Task<SourceText> UpdateEditorConfigAsync(SourceText sourceText);
EditorConfigSettings\NamingStyle\View\NamingStyleSettingsView.xaml.cs (2)
30public Task<SourceText> UpdateEditorConfigAsync(SourceText sourceText) => _viewModel.UpdateEditorConfigAsync(sourceText);
EditorConfigSettings\SettingsEditorControl.xaml.cs (2)
93var originalText = await analyzerConfigDocument.GetTextAsync(default).ConfigureAwait(false); 94var updatedText = originalText;
EditorConfigSettings\Whitespace\View\WhitespaceSettingsView.xaml.cs (2)
33public Task<SourceText> UpdateEditorConfigAsync(SourceText sourceText) => _viewModel.UpdateEditorConfigAsync(sourceText);
Extensions\DocumentExtensions.cs (1)
25var text = document.GetTextSynchronously(cancellationToken);
Extensions\SourceTextExtensions.cs (3)
15public static VsTextSpan GetVsTextSpanForSpan(this SourceText text, TextSpan textSpan) 29public static VsTextSpan GetVsTextSpanForLineOffset(this SourceText text, int lineNumber, int offset) 41public static VsTextSpan GetVsTextSpanForPosition(this SourceText text, int position, int virtualSpace)
FindReferences\Contexts\AbstractTableDataSourceFindUsagesContext.cs (3)
362var sourceText = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); 391private static async Task<(ExcerptResult, SourceText)> ExcerptAsync( 392SourceText sourceText, DocumentSpan documentSpan, ClassificationOptions options, CancellationToken cancellationToken)
FindReferences\Contexts\WithoutReferencesFindUsagesContext.cs (2)
132var sourceText = await documentSpan.Document.GetTextAsync(cancellationToken).ConfigureAwait(false); 134var lineText = AbstractDocumentSpanEntry.GetLineContainingPosition(sourceText, documentSpan.SourceSpan.Start);
FindReferences\Entries\AbstractDocumentSpanEntry.cs (5)
27private readonly SourceText _lineText; 34SourceText lineText, 58public static async Task<MappedSpanResult?> TryMapAndGetFirstAsync(DocumentSpan documentSpan, SourceText sourceText, CancellationToken cancellationToken) 79public static SourceText GetLineContainingPosition(SourceText text, int position)
FindReferences\Entries\DefinitionItemEntry.cs (1)
30SourceText lineText,
FindReferences\Entries\DocumentSpanEntry.cs (4)
62SourceText lineText, 118SourceText lineText, 226var sourceText = document.GetTextSynchronously(CancellationToken.None); 272private static Span GetRegionSpanForReference(SourceText sourceText, TextSpan sourceSpan)
Implementation\AbstractEditorFactory.cs (5)
352var unformattedText = await addedDocument.GetTextAsync(cancellationToken).ConfigureAwait(true); 354var formattedText = formattedRoot.GetText(unformattedText.Encoding, unformattedText.ChecksumAlgorithm); 359var originalText = formattedText; 404var text = IOUtilities.PerformIO(() => 407return SourceText.From(stream);
LanguageService\AbstractLanguageService`2.IVsLanguageTextOps.cs (1)
57var text = documentSyntax.Text;
LanguageService\AbstractLanguageService`2.VsLanguageDebugInfo.cs (1)
238var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
Preview\FileChange.cs (9)
55var bufferText = left != null 78var oldText = left.GetTextSynchronously(cancellationToken); 79var newText = right.GetTextSynchronously(cancellationToken); 97private ChangeList GetChangeList(IHierarchicalDifferenceCollection diff, DocumentId id, SourceText oldText, SourceText newText) 185private SourceText UpdateBufferText() 194return SourceText.From(_buffer.CurrentSnapshot.GetText(), _encoding); 241var oldText = left.GetTextSynchronously(cancellationToken); 242var newText = right.GetTextSynchronously(cancellationToken);
Preview\PreviewUpdater.cs (1)
71var currentDocumentText = currentDocument.GetTextSynchronously(CancellationToken.None);
Preview\PreviewUpdater.PreviewDialogWorkspace.cs (3)
25public void CloseDocument(TextDocument document, SourceText text) 48private readonly SourceText _text; 50internal PreviewTextLoader(SourceText documentText)
Preview\TopLevelChange.cs (3)
77var updatedDocumentTextOpt = updatedTextDocument?.GetTextAsync().Result; 113SourceText updateDocumentTextOpt, 160solution = solution.AddAnalyzerConfigDocument(oldDocument.Id, oldDocument.Name, SourceText.From(oldText), oldDocument.Folders, oldDocument.FilePath);
Progression\GraphBuilder.cs (1)
747var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
ProjectSystem\MiscellaneousFilesWorkspace.cs (1)
320protected override void ApplyDocumentTextChanged(DocumentId documentId, SourceText newText)
ProjectSystem\TextEditApplication.cs (4)
15internal static void UpdateText(SourceText newText, ITextBuffer buffer, EditOptions options) 18var oldText = oldSnapshot.AsText(); 26var oldText = oldSnapshot.AsText(); 31private static void UpdateText(ImmutableArray<TextChange> textChanges, ITextBuffer buffer, ITextSnapshot oldSnapshot, SourceText oldText, EditOptions options)
ProjectSystem\VisualStudioWorkspaceImpl.AbstractAddDocumentUndoUnit.cs (2)
16protected readonly SourceText Text; 21SourceText text)
ProjectSystem\VisualStudioWorkspaceImpl.AddAdditionalDocumentUndoUnit.cs (1)
18SourceText text)
ProjectSystem\VisualStudioWorkspaceImpl.AddAnalyzerConfigDocumentUndoUnit.cs (1)
17SourceText text)
ProjectSystem\VisualStudioWorkspaceImpl.AddDocumentUndoUnit.cs (1)
17SourceText text)
ProjectSystem\VisualStudioWorkspaceImpl.cs (12)
766protected override void ApplyDocumentAdded(DocumentInfo info, SourceText text) 769protected override void ApplyAdditionalDocumentAdded(DocumentInfo info, SourceText text) 772protected override void ApplyAnalyzerConfigDocumentAdded(DocumentInfo info, SourceText text) 775private void AddDocumentCore(DocumentInfo info, SourceText initialText, TextDocumentKind documentKind) 883SourceText? initialText = null, 902SourceText? initialText = null, 922SourceText? initialText, 959var text = document.GetTextSynchronously(CancellationToken.None); 1129protected override void ApplyDocumentTextChanged(DocumentId documentId, SourceText newText) 1132protected override void ApplyAdditionalDocumentTextChanged(DocumentId documentId, SourceText newText) 1135protected override void ApplyAnalyzerConfigDocumentTextChanged(DocumentId documentId, SourceText newText) 1138private void ApplyTextDocumentChange(DocumentId documentId, SourceText newText)
Snippets\AbstractSnippetCommandHandler.cs (1)
283var currentText = subjectBuffer.AsTextContainer().CurrentText;
StackTraceExplorer\StackFrameViewModel.cs (1)
122var sourceText = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
TableDataSource\AbstractTableEntriesSnapshot.cs (1)
137if (!document.TryGetText(out var text))
TableDataSource\Extensions.cs (1)
32if (!document.TryGetText(out var text))
TableDataSource\Suppression\VisualStudioDiagnosticListSuppressionStateService.cs (1)
296var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
TableDataSource\Suppression\VisualStudioSuppressionFixService.cs (1)
192var text = await tree.GetTextAsync(cancellationToken).ConfigureAwait(false);
TaskList\ProjectExternalErrorReporter.cs (1)
331var text = tree.GetText();
Utilities\IVsEditorAdaptersFactoryServiceExtensions.cs (1)
43var text = document.GetTextSynchronously(cancellationToken);
ValueTracking\TreeItemViewModel.cs (2)
21private readonly SourceText _sourceText; 46SourceText sourceText,
Venus\ContainedDocument.cs (13)
211public void UpdateText(SourceText newText) 213var originalText = SubjectBuffer.CurrentSnapshot.AsText(); 236private ITextSnapshot ApplyChanges(SourceText originalText, IEnumerable<TextChange> changes) 264private IEnumerable<TextChange> FilterTextChanges(SourceText originalText, List<TextSpan> editorVisibleSpansInOriginal, IEnumerable<TextChange> changes) 351private IEnumerable<TextChange> GetSubTextChanges(SourceText originalText, TextChange changeInOriginalText, TextSpan visibleSpanInOriginalText) 368SourceText originalText, TextSpan visibleSpanInOriginalText, string leftText, string rightText, int offsetInOriginalText, List<TextChange> changes) 402SourceText originalText, TextSpan visibleSpanInOriginalText, string leftText, string rightText, int offsetInOriginalText) 506SourceText originalText, TextSpan visibleSpanInOriginalText, 827public BaseIndentationFormattingRule GetBaseIndentationRule(SyntaxNode root, SourceText text, List<TextSpan> spans, int spanIndex) 875private static void GetVisibleAndTextSpan(SourceText text, List<TextSpan> spans, int spanIndex, out TextSpan visibleSpan, out TextSpan visibleTextSpan) 887private int GetBaseIndentation(SyntaxNode root, SourceText text, TextSpan span) 914private static TextSpan GetVisibleTextSpan(SourceText text, TextSpan visibleSpan, bool uptoFirstAndLastLine = false) 952private int GetAdditionalIndentation(SyntaxNode root, SourceText text, TextSpan span, int hostIndentationSize)
Venus\ContainedDocument.DocumentServiceProvider.cs (4)
58private static ITextSnapshot GetRoslynSnapshot(SourceText sourceText) 90var sourceText = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); 139var sourceText = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); 277private static (SourceText, TextSpan) GetContentAndMappedSpan(ExcerptMode mode, SnapshotSpan primarySpan, SnapshotSpan contentSpan)
Workspace\SourceGeneratedFileManager.cs (2)
316SourceText? generatedSource = null; 496var sourceText = _textBuffer.CurrentSnapshot.AsText();
Workspace\VisualStudioDocumentNavigationService.cs (12)
71var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); 89var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); 107var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); 156var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); 162static VsTextSpan GetVsTextSpan(SourceText text, int lineNumber, int offset) 182var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); 191static VsTextSpan GetVsTextSpan(SourceText text, int position, int virtualSpace) 213Func<SourceText, VsTextSpan> getVsTextSpan, 236Func<SourceText, VsTextSpan> getVsTextSpan, 296Func<SourceText, VsTextSpan> getVsTextSpan) 317var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); 397private static VsTextSpan GetVsTextSpan(SourceText text, TextSpan textSpan, bool allowInvalidSpan)
Workspace\VisualStudioFormattingRuleFactoryServiceFactory.cs (1)
60var text = document.Text;
Microsoft.VisualStudio.LanguageServices.CSharp (41)
CodeModel\CSharpCodeModelService.cs (6)
40private static readonly SyntaxTree s_emptyTree = SyntaxFactory.ParseSyntaxTree(SourceText.From("", encoding: null, SourceHashAlgorithms.Default)); 1277var text = memberDeclaration.SyntaxTree.GetText(CancellationToken.None); 1357var text = memberDeclaration.SyntaxTree.GetText(CancellationToken.None); 1415var text = memberDeclaration.SyntaxTree.GetText(CancellationToken.None); 2800var text = document.GetTextSynchronously(CancellationToken.None); 2841var text = document.GetTextSynchronously(CancellationToken.None);
CodeModel\CSharpCodeModelService.NodeLocator.cs (31)
34protected override VirtualTreePoint? GetStartPoint(SourceText text, LineFormattingOptions options, SyntaxNode node, EnvDTE.vsCMPart part) 85protected override VirtualTreePoint? GetEndPoint(SourceText text, LineFormattingOptions options, SyntaxNode node, EnvDTE.vsCMPart part) 136private static VirtualTreePoint GetBodyStartPoint(SourceText text, SyntaxToken openBrace) 148private static VirtualTreePoint GetBodyStartPoint(SourceText text, LineFormattingOptions options, SyntaxToken openBrace, SyntaxToken closeBrace, int memberStartColumn) 212private static VirtualTreePoint GetBodyEndPoint(SourceText text, SyntaxToken closeBrace) 222private static VirtualTreePoint GetStartPoint(SourceText text, ArrowExpressionClauseSyntax node, EnvDTE.vsCMPart part) 243private static VirtualTreePoint GetStartPoint(SourceText text, AttributeSyntax node, EnvDTE.vsCMPart part) 276private static VirtualTreePoint GetStartPoint(SourceText text, AttributeArgumentSyntax node, EnvDTE.vsCMPart part) 306private static VirtualTreePoint GetStartPoint(SourceText text, BaseTypeDeclarationSyntax node, EnvDTE.vsCMPart part) 354private static VirtualTreePoint GetStartPoint(SourceText text, LineFormattingOptions options, BaseMethodDeclarationSyntax node, EnvDTE.vsCMPart part) 443private static VirtualTreePoint GetStartPoint(SourceText text, LineFormattingOptions options, BasePropertyDeclarationSyntax node, EnvDTE.vsCMPart part) 508private static VirtualTreePoint GetStartPoint(SourceText text, LineFormattingOptions options, AccessorDeclarationSyntax node, EnvDTE.vsCMPart part) 557private static VirtualTreePoint GetStartPoint(SourceText text, BaseNamespaceDeclarationSyntax node, EnvDTE.vsCMPart part) 606private static VirtualTreePoint GetStartPoint(SourceText text, DelegateDeclarationSyntax node, EnvDTE.vsCMPart part) 646private static VirtualTreePoint GetStartPoint(SourceText text, UsingDirectiveSyntax node, EnvDTE.vsCMPart part) 679private static VirtualTreePoint GetStartPoint(SourceText text, VariableDeclaratorSyntax node, EnvDTE.vsCMPart part) 720private static VirtualTreePoint GetStartPoint(SourceText text, EnumMemberDeclarationSyntax node, EnvDTE.vsCMPart part) 760private static VirtualTreePoint GetStartPoint(SourceText text, ParameterSyntax node, EnvDTE.vsCMPart part) 800private static VirtualTreePoint GetEndPoint(SourceText text, ArrowExpressionClauseSyntax node, EnvDTE.vsCMPart part) 818private static VirtualTreePoint GetEndPoint(SourceText text, AttributeSyntax node, EnvDTE.vsCMPart part) 851private static VirtualTreePoint GetEndPoint(SourceText text, AttributeArgumentSyntax node, EnvDTE.vsCMPart part) 881private static VirtualTreePoint GetEndPoint(SourceText text, BaseTypeDeclarationSyntax node, EnvDTE.vsCMPart part) 922private static VirtualTreePoint GetEndPoint(SourceText text, BaseMethodDeclarationSyntax node, EnvDTE.vsCMPart part) 996private static VirtualTreePoint GetEndPoint(SourceText text, BasePropertyDeclarationSyntax node, EnvDTE.vsCMPart part) 1056private static VirtualTreePoint GetEndPoint(SourceText text, AccessorDeclarationSyntax node, EnvDTE.vsCMPart part) 1095private static VirtualTreePoint GetEndPoint(SourceText text, DelegateDeclarationSyntax node, EnvDTE.vsCMPart part) 1136private static VirtualTreePoint GetEndPoint(SourceText text, BaseNamespaceDeclarationSyntax node, EnvDTE.vsCMPart part) 1185private static VirtualTreePoint GetEndPoint(SourceText text, UsingDirectiveSyntax node, EnvDTE.vsCMPart part) 1218private static VirtualTreePoint GetEndPoint(SourceText text, EnumMemberDeclarationSyntax node, EnvDTE.vsCMPart part) 1259private static VirtualTreePoint GetEndPoint(SourceText text, VariableDeclaratorSyntax node, EnvDTE.vsCMPart part) 1301private static VirtualTreePoint GetEndPoint(SourceText text, ParameterSyntax node, EnvDTE.vsCMPart part)
Interactive\CSharpInteractiveWindowCommandCompletionProvider.cs (1)
42public override bool IsInsertionTrigger(SourceText text, int characterPosition, CompletionOptions options)
LanguageService\CSharpHelpContextService.cs (1)
78var text = await syntaxTree.GetTextAsync(cancellationToken).ConfigureAwait(false);
ProjectSystemShim\TempPECompilerService.cs (2)
45var sourceText = SourceText.From(fileContents[i], parsedArguments.Encoding, parsedArguments.ChecksumAlgorithm);
Microsoft.VisualStudio.LanguageServices.CSharp.UnitTests (8)
CodeModel\FileCodeFunctionTests.cs (2)
495var text = await (GetCurrentDocument()).GetTextAsync(); 508var text = await (GetCurrentDocument()).GetTextAsync();
DocumentOutline\DocumentOutlineTestsBase.cs (2)
126var documentText = await solution.GetRequiredDocument(document.Id).GetTextAsync(CancellationToken.None); 127solution = solution.WithDocumentText(document.Id, SourceText.From(documentText.ToString(), System.Text.Encoding.UTF8));
EditorConfigSettings\Aggregator\SettingsAggregatorTests.cs (1)
33.AddAnalyzerConfigDocument(DocumentId.CreateNewId(projectId), "editorcfg", SourceText.From("config"), filePath: "/a/b")));
EditorConfigSettings\DataProvider\DataProviderTests.cs (1)
34.AddAnalyzerConfigDocument(DocumentId.CreateNewId(projectId), "editorcfg", SourceText.From("config"), filePath: "/a/b")));
EditorConfigSettings\DataProvider\DataProviderTests.TestViewModel.cs (2)
19Task<SourceText> ISettingsEditorViewModel.UpdateEditorConfigAsync(SourceText sourceText)
Microsoft.VisualStudio.LanguageServices.Implementation (7)
CodeModel\AbstractCodeModelService.AbstractNodeLocator.cs (4)
25protected abstract VirtualTreePoint? GetStartPoint(SourceText text, LineFormattingOptions options, SyntaxNode node, EnvDTE.vsCMPart part); 26protected abstract VirtualTreePoint? GetEndPoint(SourceText text, LineFormattingOptions options, SyntaxNode node, EnvDTE.vsCMPart part); 30var text = node.SyntaxTree.GetText(); 36var text = node.SyntaxTree.GetText();
CodeModel\AbstractCodeModelService.cs (1)
80protected string GetNewLineCharacter(SourceText text)
CodeModel\MethodXml\AbstractMethodXmlBuilder.cs (1)
67protected readonly SourceText Text;
Options\AbstractOptionPreviewViewModel.cs (1)
137var document = project.AddDocument("document", SourceText.From(text, Encoding.UTF8));
Microsoft.VisualStudio.LanguageServices.LiveShare (7)
Client\Projects\WorkspaceFileTextLoaderNoException.cs (1)
32return Task.FromResult(TextAndVersion.Create(SourceText.From("", encoding: null, options.ChecksumAlgorithm), VersionStamp.Create()));
Client\RemoteLanguageServiceWorkspace.cs (6)
312var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); 318text = SourceText.From(File.ReadAllText(document.FilePath)); 490protected override void ApplyDocumentTextChanged(DocumentId documentId, SourceText text) 499var sourceText = await document.GetTextAsync().ConfigureAwait(false); 526private static void UpdateText(ITextBuffer textBuffer, SourceText text) 531var oldText = oldSnapshot.AsText();
Microsoft.VisualStudio.LanguageServices.Test.Utilities2 (1)
CodeModel\Mocks\MockVisualStudioWorkspace.vb (1)
48Protected Overrides Sub ApplyDocumentTextChanged(documentId As DocumentId, newText As SourceText)
Microsoft.VisualStudio.LanguageServices.UnitTests (5)
Completion\MockCompletionProvider.vb (1)
22Public Overrides Function IsInsertionTrigger(text As SourceText, characterPosition As Integer, options As CompletionOptions) As Boolean
Diagnostics\ExternalDiagnosticUpdateSourceTests.vb (1)
563document = document.WithText(SourceText.From("class C2 { }"))
ProjectSystemShim\VisualStudioProjectTests\WorkspaceChangedEventTests.vb (1)
130project.AddSourceTextContainer(SourceText.From("// Test").Container, "Z:\Test.cs")
SolutionExplorer\SourceGeneratorItemTests.vb (1)
218SourceText.From("Changed"),
Venus\DocumentService_IntegrationTests.vb (1)
185Dim newDocument = document.WithText(SourceText.From(""))
Microsoft.VisualStudio.LanguageServices.VisualBasic (47)
CodeModel\VisualBasicCodeModelService.NodeLocator.vb (44)
38Protected Overrides Function GetStartPoint(text As SourceText, options As LineFormattingOptions, node As SyntaxNode, part As EnvDTE.vsCMPart) As VirtualTreePoint? 128Protected Overrides Function GetEndPoint(text As SourceText, options As LineFormattingOptions, node As SyntaxNode, part As EnvDTE.vsCMPart) As VirtualTreePoint? 218Private Shared Function GetAttributesStartPoint(text As SourceText, attributes As SyntaxList(Of AttributeListSyntax), part As EnvDTE.vsCMPart) As VirtualTreePoint? 252Private Shared Function GetAttributesEndPoint(text As SourceText, attributes As SyntaxList(Of AttributeListSyntax), part As EnvDTE.vsCMPart) As VirtualTreePoint? 300Private Shared Function GetTypeBlockStartPoint(text As SourceText, options As LineFormattingOptions, typeBlock As TypeBlockSyntax, part As EnvDTE.vsCMPart) As VirtualTreePoint? 360Private Shared Function GetTypeBlockEndPoint(text As SourceText, typeBlock As TypeBlockSyntax, part As EnvDTE.vsCMPart) As VirtualTreePoint? 386Private Shared Function GetEnumBlockStartPoint(text As SourceText, options As LineFormattingOptions, enumBlock As EnumBlockSyntax, part As EnvDTE.vsCMPart) As VirtualTreePoint? 431Private Shared Function GetEnumBlockEndPoint(text As SourceText, enumBlock As EnumBlockSyntax, part As EnvDTE.vsCMPart) As VirtualTreePoint? 457Private Shared Function GetMethodBlockStartPoint(text As SourceText, options As LineFormattingOptions, methodBlock As MethodBlockBaseSyntax, part As EnvDTE.vsCMPart) As VirtualTreePoint? 516Private Shared Function GetDeclareStatementStartPoint(text As SourceText, declareStatement As DeclareStatementSyntax, part As EnvDTE.vsCMPart) As VirtualTreePoint? 552Private Shared Function GetDeclareStatementEndPoint(text As SourceText, declareStatement As DeclareStatementSyntax, part As EnvDTE.vsCMPart) As VirtualTreePoint? 581Private Shared Function GetMethodStatementStartPoint(text As SourceText, methodStatement As MethodStatementSyntax, part As EnvDTE.vsCMPart) As VirtualTreePoint? 617Private Shared Function GetMethodBlockEndPoint(text As SourceText, methodBlock As MethodBlockBaseSyntax, part As EnvDTE.vsCMPart) As VirtualTreePoint? 672Private Shared Function GetMethodStatementEndPoint(text As SourceText, methodStatement As MethodStatementSyntax, part As EnvDTE.vsCMPart) As VirtualTreePoint? 701Private Shared Function GetPropertyBlockStartPoint(text As SourceText, propertyBlock As PropertyBlockSyntax, part As EnvDTE.vsCMPart) As VirtualTreePoint? 705Private Shared Function GetPropertyStatementStartPoint(text As SourceText, propertyStatement As PropertyStatementSyntax, part As EnvDTE.vsCMPart) As VirtualTreePoint? 740Private Shared Function GetPropertyBlockEndPoint(text As SourceText, propertyBlock As PropertyBlockSyntax, part As EnvDTE.vsCMPart) As VirtualTreePoint? 744Private Shared Function GetPropertyStatementEndPoint(text As SourceText, propertyStatement As PropertyStatementSyntax, part As EnvDTE.vsCMPart) As VirtualTreePoint? 785Private Shared Function GetEventBlockStartPoint(text As SourceText, options As LineFormattingOptions, eventBlock As EventBlockSyntax, part As EnvDTE.vsCMPart) As VirtualTreePoint? 825Private Shared Function GetEventStatementStartPoint(text As SourceText, eventStatement As EventStatementSyntax, part As EnvDTE.vsCMPart) As VirtualTreePoint? 862Private Shared Function GetEventBlockEndPoint(text As SourceText, eventBlock As EventBlockSyntax, part As EnvDTE.vsCMPart) As VirtualTreePoint? 866Private Shared Function GetEventStatementEndPoint(text As SourceText, eventStatement As EventStatementSyntax, part As EnvDTE.vsCMPart) As VirtualTreePoint? 907Private Shared Function GetDelegateStatementStartPoint(text As SourceText, delegateStatement As DelegateStatementSyntax, part As EnvDTE.vsCMPart) As VirtualTreePoint? 943Private Shared Function GetDelegateStatementEndPoint(text As SourceText, delegateStatement As DelegateStatementSyntax, part As EnvDTE.vsCMPart) As VirtualTreePoint? 982Private Shared Function GetNamespaceBlockStartPoint(text As SourceText, options As LineFormattingOptions, namespaceBlock As NamespaceBlockSyntax, part As EnvDTE.vsCMPart) As VirtualTreePoint? 1038Private Shared Function GetNamespaceBlockEndPoint(text As SourceText, namespaceBlock As NamespaceBlockSyntax, part As EnvDTE.vsCMPart) As VirtualTreePoint? 1069Private Shared Function GetVariableStartPoint(text As SourceText, variable As ModifiedIdentifierSyntax, part As EnvDTE.vsCMPart) As VirtualTreePoint? 1101Private Shared Function GetVariableStartPoint(text As SourceText, enumMember As EnumMemberDeclarationSyntax, part As EnvDTE.vsCMPart) As VirtualTreePoint? 1126Private Shared Function GetVariableEndPoint(text As SourceText, variable As ModifiedIdentifierSyntax, part As EnvDTE.vsCMPart) As VirtualTreePoint? 1153Private Shared Function GetVariableEndPoint(text As SourceText, enumMember As EnumMemberDeclarationSyntax, part As EnvDTE.vsCMPart) As VirtualTreePoint? 1177Private Shared Function GetParameterStartPoint(text As SourceText, parameter As ParameterSyntax, part As EnvDTE.vsCMPart) As VirtualTreePoint? 1207Private Shared Function GetParameterEndPoint(text As SourceText, parameter As ParameterSyntax, part As EnvDTE.vsCMPart) As VirtualTreePoint? 1231Private Shared Function GetImportsStatementStartPoint(text As SourceText, importsStatement As ImportsStatementSyntax, part As EnvDTE.vsCMPart) As VirtualTreePoint? 1257Private Shared Function GetImportsStatementEndPoint(text As SourceText, importsStatement As ImportsStatementSyntax, part As EnvDTE.vsCMPart) As VirtualTreePoint? 1283Private Shared Function GetOptionStatementStartPoint(text As SourceText, optionStatement As OptionStatementSyntax, part As EnvDTE.vsCMPart) As VirtualTreePoint? 1309Private Shared Function GetOptionStatementEndPoint(text As SourceText, optionStatement As OptionStatementSyntax, part As EnvDTE.vsCMPart) As VirtualTreePoint? 1335Private Shared Function GetInheritsStatementStartPoint(text As SourceText, inheritsStatement As InheritsStatementSyntax, part As EnvDTE.vsCMPart) As VirtualTreePoint? 1361Private Shared Function GetInheritsStatementEndPoint(text As SourceText, inheritsStatement As InheritsStatementSyntax, part As EnvDTE.vsCMPart) As VirtualTreePoint? 1387Private Shared Function GetImplementsStatementStartPoint(text As SourceText, implementsStatement As ImplementsStatementSyntax, part As EnvDTE.vsCMPart) As VirtualTreePoint? 1413Private Shared Function GetImplementsStatementEndPoint(text As SourceText, implementsStatement As ImplementsStatementSyntax, part As EnvDTE.vsCMPart) As VirtualTreePoint? 1439Private Shared Function GetAttributeStartPoint(text As SourceText, attribute As AttributeSyntax, part As EnvDTE.vsCMPart) As VirtualTreePoint? 1468Private Shared Function GetAttributeEndPoint(text As SourceText, attribute As AttributeSyntax, part As EnvDTE.vsCMPart) As VirtualTreePoint? 1496Private Shared Function GetAttributeArgumentStartPoint(text As SourceText, argument As ArgumentSyntax, part As EnvDTE.vsCMPart) As VirtualTreePoint? 1531Private Shared Function GetAttributeArgumentEndPoint(text As SourceText, argument As ArgumentSyntax, part As EnvDTE.vsCMPart) As VirtualTreePoint?
CodeModel\VisualBasicCodeModelService.vb (1)
36Private Shared ReadOnly s_emptyTree As SyntaxTree = SyntaxFactory.ParseSyntaxTree(SourceText.From("", encoding:=Nothing, SourceHashAlgorithms.Default))
ProjectSystemShim\TempPECompiler.TempPEProject.vb (1)
36Return SyntaxFactory.ParseSyntaxTree(SourceText.From(stream), options:=_parseOptions, path:=path)
Snippets\SnippetCompletionProvider.vb (1)
115Public Overrides Function IsInsertionTrigger(text As SourceText, characterPosition As Integer, options As CompletionOptions) As Boolean
Microsoft.VisualStudio.LanguageServices.Xaml (15)
Features\InlineRename\XamlEditorInlineRenameService.cs (2)
164var oldSource = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); 165var newSource = oldSource.WithChanges(group.Select(l => new TextChange(l.TextSpan, replacementText)));
Implementation\LanguageServer\Handler\Completion\CompletionHandler.cs (2)
65var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); 81private static CompletionItem CreateCompletionItem(XamlCompletionItem xamlCompletion, DocumentId documentId, SourceText text, Position position, TextDocumentIdentifier textDocument, Dictionary<XamlCompletionKind, ImmutableArray<VSInternalCommitCharacter>> commitCharactersCach)
Implementation\LanguageServer\Handler\Definitions\GoToDefinitionHandler.cs (2)
130var sourceText = SourceText.From(fileStream);
Implementation\LanguageServer\Handler\Diagnostics\AbstractPullDiagnosticHandler.cs (2)
97var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); 120private static VSDiagnostic[]? ConvertToVSDiagnostics(ImmutableArray<XamlDiagnostic>? xamlDiagnostics, Document document, SourceText text)
Implementation\LanguageServer\Handler\FoldingRanges\FoldingRangesHandler.cs (1)
56var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
Implementation\LanguageServer\Handler\Formatting\AbstractFormatDocumentHandlerBase.cs (1)
36var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
Implementation\LanguageServer\Handler\Formatting\FormatDocumentOnTypeHandler.cs (1)
54var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
Implementation\LanguageServer\Handler\Hover\HoverHandler.cs (1)
82var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
Implementation\LanguageServer\Handler\OnAutoInsert\OnAutoInsertHandler.cs (1)
48var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
Implementation\LanguageServer\Handler\OnTypeRename\OnTypeRenameHandler.cs (1)
80var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
Implementation\XamlProjectService.cs (1)
170var hasText = document.TryGetText(out var text);
Roslyn.VisualStudio.DiagnosticsWindow (3)
Panels\WorkspacePanel.xaml.cs (3)
91var snapshotText = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); 95var fileText = SourceText.From(fileStream, snapshotText.Encoding, snapshotText.ChecksumAlgorithm);
Roslyn.VisualStudio.Next.UnitTests (39)
Remote\RemoteHostClientServiceFactoryTests.cs (3)
53var document = workspace.AddDocument(project.Id, "doc.cs", SourceText.From("code")); 55var oldText = document.GetTextSynchronously(CancellationToken.None); 56var newText = oldText.WithChanges(new[] { new TextChange(new TextSpan(0, 1), "abc") });
Remote\SnapshotSerializationTests.cs (14)
59var document1 = project1.AddDocument("Document1", SourceText.From(csCode)); 63var document2 = project2.AddDocument("Document2", SourceText.From(vbCode)); 69.AddAdditionalDocument("Additional", SourceText.From("hello"), ImmutableArray.Create("test"), @".\Add").Project.Solution; 78loader: TextLoader.From(TextAndVersion.Create(SourceText.From("root = true"), VersionStamp.Create()))))); 159var document = workspace.CurrentSolution.AddProject("Project", "Project.dll", LanguageNames.CSharp).AddDocument("Document", SourceText.From(code)); 182var document = solution.AddProject("Project", "Project.dll", LanguageNames.CSharp).AddDocument("Document", SourceText.From(code)); 531var document = CreateWorkspace().CurrentSolution.AddProject("empty", "empty", LanguageNames.CSharp).AddDocument("empty", SourceText.From("")); 605var sourceText = SourceText.From("Hello", Encoding.UTF8); 619var newText = serializer.Deserialize<SourceText>(sourceText.GetWellKnownSynchronizationKind(), objectReader, CancellationToken.None); 624sourceText = SourceText.From("Hello", new NotSerializableEncoding()); 638var newText = serializer.Deserialize<SourceText>(sourceText.GetWellKnownSynchronizationKind(), objectReader, CancellationToken.None);
Services\ServiceHubServicesTests.cs (7)
81var oldText = await oldDocument.GetTextAsync(); 84var newText = oldText.WithChanges(new TextChange(TextSpan.FromBounds(0, 0), "/* test */")); 438private static SourceText GetNewText(Document document, string csAddition, string vbAddition) 442return SourceText.From(document.State.GetTextSynchronously(CancellationToken.None).ToString() + csAddition); 445return SourceText.From(document.State.GetTextSynchronously(CancellationToken.None).ToString() + vbAddition); 552solution = current.AddDocument($"Document{i}", SourceText.From(documents[i])).Project.Solution; 558solution = current.AddAdditionalDocument($"AdditionalDocument{i}", SourceText.From(additionalDocuments[i])).Project.Solution;
Services\SolutionServiceTests.cs (15)
156await VerifySolutionUpdate(code, s => s.WithDocumentText(s.Projects.First().DocumentIds.First(), SourceText.From(code + " "))); 227project = project.AddDocument("newDocument", SourceText.From("// new text")).Project; 247loader: TextLoader.From(TextAndVersion.Create(SourceText.From("test"), VersionStamp.Create()))); 258return s.WithAdditionalDocumentText(additionalDocumentId, SourceText.From("changed")); 279loader: TextLoader.From(TextAndVersion.Create(SourceText.From("root = true"), VersionStamp.Create(), filePath: configPath)), 291return s.WithAnalyzerConfigDocumentText(analyzerConfigDocumentId, SourceText.From("root = false")); 311loader: TextLoader.From(TextAndVersion.Create(SourceText.From("class A { }"), VersionStamp.Create()))); 322return s.WithDocumentText(documentId, SourceText.From("class Changed { }")); 370remoteSolution = remoteSolution.WithDocumentText(remoteSolution.Projects.First().Documents.First().Id, SourceText.From(code + " class Test2 { }")); 396var currentSolution = remoteSolution1.WithDocumentText(remoteSolution1.Projects.First().Documents.First().Id, SourceText.From(code + " class Test2 { }")); 405currentSolution = oopSolution2.WithDocumentText(oopSolution2.Projects.First().Documents.First().Id, SourceText.From(code + " class Test3 { }")); 500var frozenText1 = SourceText.From("// Hello, World!"); 509var frozenText2 = SourceText.From("// Hello, World! A second time!");
StackDepthTest (1)
Program.cs (1)
79var tree = SyntaxFactory.ParseSyntaxTree(SourceText.From(stringText, encoding: null, SourceHashAlgorithm.Sha256), parseOptions);