9 types derived from SourceText
Microsoft.CodeAnalysis (6)
Text\ChangedText.cs (1)
14internal sealed class ChangedText : SourceText
Text\CompositeText.cs (1)
20internal sealed class CompositeText : SourceText
Text\LargeText.cs (1)
21internal sealed class LargeText : SourceText
Text\StringBuilderText.cs (1)
15internal sealed partial class StringBuilderText : SourceText
Text\StringText.cs (1)
18internal sealed class StringText : SourceText
Text\SubText.cs (1)
15internal sealed class SubText : SourceText
Microsoft.CodeAnalysis.CSharp.Features (1)
EmbeddedLanguages\CSharpTestEmbeddedLanguageClassifier.cs (1)
274private sealed class VirtualCharSequenceSourceText : 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
3759 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)
ConfigurationSchemaGenerator.Tests (2)
GeneratorTests.cs (2)
30private static readonly SyntaxTree s_implicitUsingsSyntaxTree = SyntaxFactory.ParseSyntaxTree(SourceText.From( 1561var sourceSyntaxTree = SyntaxFactory.ParseSyntaxTree(SourceText.From(sourceText));
CSharpSyntaxGenerator (6)
SourceGenerator.cs (6)
64var inputText = input.GetText(); 110var sourcesBuilder = ImmutableArray.CreateBuilder<(string hintName, SourceText sourceText)>(); 126var sourceText = SourceText.From(new StringBuilderReader(stringBuilder), stringBuilder.Length, encoding: Encoding.UTF8); 133private readonly SourceText _sourceText; 136public SourceTextReader(SourceText sourceText)
IdeCoreBenchmarks (12)
IncrementalSourceGeneratorBenchmarks.cs (2)
159var sourceText = syntaxTree.GetText(); 167var 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);
SyntacticChangeRangeBenchmark.cs (6)
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 ")); 72var newText = _text.WithChanges(new TextChange(new TextSpan(0, addedText.Length), addedText)); 81var newText = _text.WithChanges(new TextChange(new TextSpan(_text.Length - addedText.Length, addedText.Length), addedText));
Microsoft.Analyzers.Extra.Tests (10)
Resources\FileVisibleToAnalyzer.cs (2)
26public override SourceText? GetText(CancellationToken cancellationToken = default) => SourceText.From(File.ReadAllText(Path));
Resources\RoslynTestUtils.cs (8)
379var s = await proj.FindDocument(l[i]).GetTextAsync().ConfigureAwait(false); 387var s = await proj.FindDocument($"src-{i}.cs").GetTextAsync().ConfigureAwait(false); 394var s = await proj.FindDocument(extraFile).GetTextAsync().ConfigureAwait(false); 470var s = await proj.FindDocument(l[i]).GetTextAsync().ConfigureAwait(false); 478var s = await proj.FindDocument($"src-{i}.cs").GetTextAsync().ConfigureAwait(false); 485var s = await proj.FindDocument(extraFile).GetTextAsync().ConfigureAwait(false); 506var newText = await document.GetTextAsync().ConfigureAwait(false); 507return document.WithText(SourceText.From(newText.ToString(), newText.Encoding, newText.ChecksumAlgorithm));
Microsoft.Analyzers.Local.Tests (10)
Resources\FileVisibleToAnalyzer.cs (2)
26public override SourceText? GetText(CancellationToken cancellationToken = default) => SourceText.From(File.ReadAllText(Path));
Resources\RoslynTestUtils.cs (8)
380var s = await proj.FindDocument(l[i]).GetTextAsync().ConfigureAwait(false); 388var s = await proj.FindDocument($"src-{i}.cs").GetTextAsync().ConfigureAwait(false); 395var s = await proj.FindDocument(extraFile).GetTextAsync().ConfigureAwait(false); 471var s = await proj.FindDocument(l[i]).GetTextAsync().ConfigureAwait(false); 479var s = await proj.FindDocument($"src-{i}.cs").GetTextAsync().ConfigureAwait(false); 486var s = await proj.FindDocument(extraFile).GetTextAsync().ConfigureAwait(false); 507var newText = await document.GetTextAsync().ConfigureAwait(false); 508return document.WithText(SourceText.From(newText.ToString(), newText.Encoding, newText.ChecksumAlgorithm));
Microsoft.AspNetCore.Analyzer.Testing (3)
CodeFixRunner.cs (1)
40var sourceText = await updatedDocument.GetTextAsync();
DiagnosticProject.cs (1)
80solution = solution.AddDocument(documentId, newFileName, SourceText.From(sources[i]));
DiagnosticVerifier.cs (1)
181Solution = Solution.AddDocument(documentId, newFileName, SourceText.From(source));
Microsoft.AspNetCore.App.Analyzers (14)
Infrastructure\VirtualChars\AbstractVirtualCharService.cs (1)
193protected static int ConvertTextAtIndexToRune(SourceText tokenText, int index, ImmutableList<VirtualChar>.Builder result, int offset)
Infrastructure\VirtualChars\AbstractVirtualCharService.ITextInfo.cs (4)
11/// Abstraction to allow generic algorithms to run over a string or <see cref="SourceText"/> without any 20private struct SourceTextTextInfo : ITextInfo<SourceText> 22public char Get(SourceText text, int index) => text[index]; 23public int Length(SourceText text) => text.Length;
Infrastructure\VirtualChars\CSharpVirtualCharService.cs (3)
199var parentSourceText = parentExpression.SyntaxTree.GetText(); 204var tokenSourceText = SourceText.From(token.Text);
Infrastructure\VirtualChars\IVirtualCharService.cs (1)
33/// in the original <see cref="SourceText"/> that the language created that char from.
Infrastructure\VirtualChars\TextLineExtensions.cs (1)
12var text = line.Text;
Infrastructure\VirtualChars\VirtualChar.cs (2)
16/// value of <c>9</c> as well as what <see cref="TextSpan"/> in the original <see cref="SourceText"/> they occupied. 43/// The span of characters in the original <see cref="SourceText"/> that represent this <see
RouteEmbeddedLanguage\FrameworkParametersCompletionProvider.cs (1)
51public override bool ShouldTriggerCompletion(SourceText text, int caretPosition, CompletionTrigger trigger, OptionSet options)
RouteEmbeddedLanguage\RoutePatternCompletionProvider.cs (1)
45public override bool ShouldTriggerCompletion(SourceText text, int caretPosition, CompletionTrigger trigger, OptionSet options)
Microsoft.AspNetCore.App.Analyzers.Test (7)
RouteEmbeddedLanguage\RoutePatternParserTests.cs (5)
134private (RoutePatternTree, SourceText) TryParseTree( 148var sourceText = token.SyntaxTree.GetText(); 247private static string TreeToText(SourceText text, RoutePatternTree tree) 282private static XElement CreateDiagnosticsElement(SourceText text, RoutePatternTree tree) 290private static XAttribute GetTextAttribute(SourceText text, TextSpan span)
TestDiagnosticAnalyzer.cs (1)
50var originalText = await doc.GetTextAsync().ConfigureAwait(false);
Verifiers\CSharpSourceGeneratorVerifier.cs (1)
27(typeof(TSourceGenerator), generatedFileName, SourceText.From(generatedSource, Encoding.UTF8))
Microsoft.AspNetCore.Components.Analyzers.Tests (1)
Helpers\DiagnosticVerifier.Helper.cs (1)
164solution = solution.AddDocument(documentId, newFileName, SourceText.From(source));
Microsoft.AspNetCore.Components.SdkAnalyzers.Tests (1)
Helpers\DiagnosticVerifier.Helper.cs (1)
164solution = solution.AddDocument(documentId, newFileName, SourceText.From(source));
Microsoft.AspNetCore.Http.Extensions.Tests (16)
RequestDelegateGenerator\CompileTimeCreationTests.cs (10)
56project = project.AddDocument("TestMapActions.cs", SourceText.From(source, Encoding.UTF8)).Project; 57project = project.AddDocument("OtherTestMapActions.cs", SourceText.From(otherSource, Encoding.UTF8)).Project; 82project = project.AddDocument("TestMapActions.cs", SourceText.From(source, Encoding.UTF8)).Project; 83project = project.AddDocument("OtherTestMapActions.cs", SourceText.From(otherSource, Encoding.UTF8)).Project; 165project = project.AddDocument("TestMapActions.cs", SourceText.From(source, Encoding.UTF8), filePath: Path.Combine(currentDirectory, "TestMapActions.cs")).Project; 232project = project.AddDocument("TestMapActions.cs", SourceText.From(source, Encoding.UTF8)).Project; 286project = project.AddDocument("TestMapActions.cs", SourceText.From(source, Encoding.UTF8)).Project; 333project = project.AddDocument("TestMapActions.cs", SourceText.From(source, Encoding.UTF8)).Project; 669project = project.AddDocument("TestMapActions.cs", SourceText.From(source, Encoding.UTF8)).Project; 726project = project.AddDocument("TestMapActions.cs", SourceText.From(source, Encoding.UTF8)).Project;
RequestDelegateGenerator\RequestDelegateCreationTestBase.cs (6)
136var text = syntaxTree.GetText(); 139var sourceText = SourceText.From(buffer, buffer.Length, encoding, canBeEmbedded: true); 306var project = _baseProject.AddDocument("TestMapActions.cs", SourceText.From(source, Encoding.UTF8)).Project; 361var generatedCode = await generatedSyntaxTree.GetTextAsync(); 382private static bool CompareLines(string[] expectedLines, SourceText sourceText, out string message)
Microsoft.AspNetCore.Http.Microbenchmarks (7)
RequestDelegateGeneratorBenchmarks.cs (1)
32project = project.AddDocument("TestMapActions.cs", SourceText.From(source, Encoding.UTF8)).Project;
src\Http\Http.Extensions\test\RequestDelegateGenerator\RequestDelegateCreationTestBase.cs (6)
136var text = syntaxTree.GetText(); 139var sourceText = SourceText.From(buffer, buffer.Length, encoding, canBeEmbedded: true); 306var project = _baseProject.AddDocument("TestMapActions.cs", SourceText.From(source, Encoding.UTF8)).Project; 361var generatedCode = await generatedSyntaxTree.GetTextAsync(); 382private static bool CompareLines(string[] expectedLines, SourceText sourceText, out string message)
Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation (3)
CSharpCompiler.cs (1)
73public SyntaxTree CreateSyntaxTree(SourceText sourceText)
RuntimeViewCompiler.cs (2)
374var sourceText = SourceText.From(compilationContent, Encoding.UTF8);
Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation.Test (1)
CSharpCompilerTest.cs (1)
266var syntaxTree = compiler.CreateSyntaxTree(SourceText.From(content));
Microsoft.AspNetCore.SignalR.Client.SourceGenerator (4)
HubClientProxyGenerator.Emitter.cs (2)
123_context.AddSource("HubClientProxy.g.cs", SourceText.From(extensions.ToString(), Encoding.UTF8)); 192_context.AddSource($"HubClientProxy.{typeSpec.TypeName}.g.cs", SourceText.From(registrationMethodBody.ToString(), Encoding.UTF8));
HubServerProxyGenerator.Emitter.cs (2)
75_context.AddSource("HubServerProxy.g.cs", SourceText.From(getProxy.ToString(), Encoding.UTF8)); 163_context.AddSource($"HubServerProxy.{classSpec.ClassTypeName}.g.cs", SourceText.From(proxy.ToString(), Encoding.UTF8));
Microsoft.CodeAnalysis (248)
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)
180return Parse(SourceText.From(text), pathToFile); 187public static AnalyzerConfig Parse(SourceText text, string? pathToFile)
CommandLine\CommonCompiler.cs (3)
256internal SourceText? TryReadFileContent(CommandLineSourceFile file, IList<DiagnosticInfo> diagnostics) 268internal SourceText? TryReadFileContent(CommandLineSourceFile file, IList<DiagnosticInfo> diagnostics, out string? normalizedFilePath) 1164var 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\AdditionalTextComparer.cs (3)
35var xText = GetTextOrNullIfBinary(x); 36var yText = GetTextOrNullIfBinary(y); 59private static SourceText? GetTextOrNullIfBinary(AdditionalText text)
DiagnosticAnalyzer\AnalysisContextInfo.cs (1)
111var text = _file.Value.SourceTree.GetText();
DiagnosticAnalyzer\DiagnosticAnalysisContext.cs (6)
237/// <param name="text"><see cref="SourceText"/> for which the value is queried.</param> 241public bool TryGetValue<TValue>(SourceText text, SourceTextValueProvider<TValue> valueProvider, [MaybeNullWhen(false)] out TValue value) 501/// <param name="text"><see cref="SourceText"/> for which the value is queried.</param> 505public bool TryGetValue<TValue>(SourceText text, SourceTextValueProvider<TValue> valueProvider, [MaybeNullWhen(false)] out TValue value) 623/// <param name="text"><see cref="SourceText"/> for which the value is queried.</param> 627public bool TryGetValue<TValue>(SourceText text, SourceTextValueProvider<TValue> valueProvider, [MaybeNullWhen(false)] out TValue value)
DiagnosticAnalyzer\SourceTextValueProvider.cs (8)
12/// Provides custom values associated with <see cref="SourceText"/> instances using the given computeValue delegate. 16internal AnalysisValueProvider<SourceText, TValue> CoreValueProvider { get; private set; } 19/// Provides custom values associated with <see cref="SourceText"/> instances using the given <paramref name="computeValue"/>. 21/// <param name="computeValue">Delegate to compute the value associated with a given <see cref="SourceText"/> instance.</param> 22/// <param name="sourceTextComparer">Optional equality comparer to determine equivalent <see cref="SourceText"/> instances that have the same value. 24public SourceTextValueProvider(Func<SourceText, TValue> computeValue, IEqualityComparer<SourceText>? sourceTextComparer = null) 26CoreValueProvider = new AnalysisValueProvider<SourceText, TValue>(computeValue, sourceTextComparer ?? SourceTextComparer.Instance);
EmbeddedText.cs (8)
85/// Constructs a <see cref="EmbeddedText"/> for embedding the given <see cref="SourceText"/>. 95/// <paramref name="text"/> cannot be embedded (see <see cref="SourceText.CanBeEmbedded"/>). 97public static EmbeddedText FromSource(string filePath, SourceText text) 150SourceText.ValidateChecksumAlgorithm(checksumAlgorithm); 154SourceText.CalculateChecksum(stream, checksumAlgorithm), 184SourceText.ValidateChecksumAlgorithm(checksumAlgorithm); 188SourceText.CalculateChecksum(bytes.Array, bytes.Offset, bytes.Count, checksumAlgorithm), 293private static ImmutableArray<byte> CreateBlob(SourceText text)
EncodedStringText.cs (11)
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)
SourceGeneration\AdditionalSourcesCollection.cs (1)
36public 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); 274public void AddSource(string hintName, string source) => AddSource(hintName, SourceText.From(source, Encoding.UTF8)); 277/// Adds a <see cref="SourceText"/> to the compilation that will be available during subsequent phases 280/// <param name="sourceText">The <see cref="SourceText"/> to add to the compilation</param> 284public void AddSource(string hintName, SourceText sourceText) => _additionalSources.Add(hintName, sourceText);
SourceGeneration\IncrementalContexts.cs (8)
121public void AddSource(string hintName, string source) => AddSource(hintName, SourceText.From(source, Encoding.UTF8)); 124/// Adds a <see cref="SourceText"/> to the compilation that will be available during subsequent phases 127/// <param name="sourceText">The <see cref="SourceText"/> to add to the compilation</param> 131public void AddSource(string hintName, SourceText sourceText) => AdditionalSources.Add(hintName, sourceText); 158public void AddSource(string hintName, string source) => AddSource(hintName, SourceText.From(source, Encoding.UTF8)); 161/// Adds a <see cref="SourceText"/> to the compilation 164/// <param name="sourceText">The <see cref="SourceText"/> to add to the compilation</param> 168public void AddSource(string hintName, SourceText sourceText) => Sources.Add(hintName, sourceText);
SourceGeneration\ISourceGenerator.cs (1)
36/// to add source files via the <see cref="GeneratorExecutionContext.AddSource(string, SourceText)"/>
SourceGeneration\RunResults.cs (4)
58/// The <see cref="SyntaxTree"/>s produced during this generation pass by parsing each <see cref="SourceText"/> added by each generator. 163/// Represents the results of an <see cref="ISourceGenerator"/> calling <see cref="GeneratorExecutionContext.AddSource(string, SourceText)"/>. 170internal GeneratedSourceResult(SyntaxTree tree, SourceText text, string hintName) 185public 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)
314/// Gets the full text of this node as a new <see cref="SourceText"/> instance. 319/// If the encoding is not specified the <see cref="SourceText"/> isn't debuggable. 320/// If an encoding-less <see cref="SourceText"/> is written to a file a <see cref="Encoding.UTF8"/> shall be used as a default. 326public 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); 374var text = this.GetText();
Syntax\SyntaxTreeExtensions.cs (1)
23var text = tree.GetText();
Text\ChangedText.cs (19)
16private readonly SourceText _newText; 19public ChangedText(SourceText oldText, SourceText newText, ImmutableArray<TextChangeRange> changeRanges) 30_info = new ChangeInfo(changeRanges, new WeakReference<SourceText>(oldText), (oldText as ChangedText)?._info); 34SourceText oldText, SourceText newText, ImmutableArray<TextChangeRange> changeRanges) 65public WeakReference<SourceText> WeakOldText { get; } 69public ChangeInfo(ImmutableArray<TextChangeRange> changeRanges, WeakReference<SourceText> weakOldText, ChangeInfo? previous) 84SourceText? tmp; 122internal override ImmutableArray<SourceText> Segments 127internal override SourceText StorageKey 142public override SourceText GetSubText(TextSpan span) 152public override SourceText WithChanges(IEnumerable<TextChange> changes) 169public override IReadOnlyList<TextChangeRange> GetChangeRanges(SourceText oldText) 182SourceText? actualOldText; 209private bool IsChangedFrom(SourceText oldText) 213SourceText? text; 223private static IReadOnlyList<ImmutableArray<TextChangeRange>> GetChangesBetween(SourceText oldText, ChangedText newText) 232SourceText? actualOldText;
Text\CompositeText.cs (37)
18/// A composite of a sequence of <see cref="SourceText"/>s. 22private readonly ImmutableArray<SourceText> _segments; 28private CompositeText(ImmutableArray<SourceText> segments, Encoding? encoding, SourceHashAlgorithm checksumAlgorithm) 67internal override ImmutableArray<SourceText> Segments 83public override SourceText GetSubText(TextSpan span) 94var newSegments = ArrayBuilder<SourceText>.GetInstance(); 99var segment = _segments[segIndex]; 157var segment = _segments[segIndex]; 169internal static void AddSegments(ArrayBuilder<SourceText> segments, SourceText text) 182internal static SourceText ToSourceText(ArrayBuilder<SourceText> segments, SourceText original, bool adjustSegments) 194return SourceText.From(string.Empty, original.Encoding, original.ChecksumAlgorithm); 206private static void RemoveSplitLineBreaksAndEmptySegments(ArrayBuilder<SourceText> segments) 216var prevSegment = segments[i - 1]; 217var curSegment = segments[i]; 223segments.Insert(i, SourceText.From("\r\n")); 246private static void ReduceSegmentCountIfNecessary(ArrayBuilder<SourceText> segments) 267private static int GetMinimalSegmentSizeToUseForCombining(ArrayBuilder<SourceText> segments) 287private static int GetSegmentCountIfCombined(ArrayBuilder<SourceText> segments, int segmentSize) 322private static void CombineSegments(ArrayBuilder<SourceText> segments, int segmentSize) 354var newText = writer.ToSourceText(); 363private static readonly ObjectPool<HashSet<SourceText>> s_uniqueSourcesPool 364= new ObjectPool<HashSet<SourceText>>(() => new HashSet<SourceText>(), 5); 369private static void ComputeLengthAndStorageSize(IReadOnlyList<SourceText> segments, out int length, out int size) 376var segment = segments[i]; 382foreach (var segment in uniqueSources) 394private static void TrimInaccessibleText(ArrayBuilder<SourceText> segments) 406foreach (var segment in segments) 446var segment = compositeText.Segments[i]; 480var segment = _compositeText.Segments[segmentIndex]; 500var firstSegment = _compositeText.Segments[firstSegmentIndexInclusive]; 510var nextSegment = _compositeText.Segments[nextSegmentIndex]; 522var lastSegment = _compositeText.Segments[lastSegmentIndexInclusive]; 554var previousSegment = _compositeText.Segments[firstSegmentIndexInclusive - 1];
Text\LargeText.cs (7)
18/// A <see cref="SourceText"/> optimized for very large sources. The text is stored as 26internal const int ChunkSize = SourceText.LargeObjectHeapLimitInChars; // 40K Unicode chars is 80KB which is less than the large object heap limit. 55internal static SourceText Decode(Stream stream, Encoding encoding, SourceHashAlgorithm checksumAlgorithm, bool throwIfBinaryDetected, bool canBeEmbedded) 62return SourceText.From(string.Empty, encoding, checksumAlgorithm); 81internal static SourceText Decode(TextReader reader, int length, Encoding? encodingOpt, SourceHashAlgorithm checksumAlgorithm) 85return SourceText.From(string.Empty, encodingOpt, checksumAlgorithm); 227/// Called from <see cref="SourceText.Lines"/> to initialize the <see cref="TextLineCollection"/>. Thereafter,
Text\LargeTextWriter.cs (1)
30public override SourceText ToSourceText()
Text\SourceText.cs (54)
91/// Constructs a <see cref="SourceText"/> from text in a string. 97/// If the encoding is not specified the resulting <see cref="SourceText"/> isn't debuggable. 98/// If an encoding-less <see cref="SourceText"/> is written to a file a <see cref="Encoding.UTF8"/> shall be used as a default. 105public static SourceText From(string text, Encoding? encoding = null, SourceHashAlgorithm checksumAlgorithm = SourceHashAlgorithm.Sha1) 116/// Constructs a <see cref="SourceText"/> from text in a string. 123/// If the encoding is not specified the resulting <see cref="SourceText"/> isn't debuggable. 124/// If an encoding-less <see cref="SourceText"/> is written to a file a <see cref="Encoding.UTF8"/> shall be used as a default. 131public static SourceText From( 154public static SourceText From(Stream stream, Encoding? encoding, SourceHashAlgorithm checksumAlgorithm, bool throwIfBinaryDetected) 158/// Constructs a <see cref="SourceText"/> from stream content. 180public static SourceText From( 225public static SourceText From(byte[] buffer, int length, Encoding? encoding, SourceHashAlgorithm checksumAlgorithm, bool throwIfBinaryDetected) 229/// Constructs a <see cref="SourceText"/> from a byte array. 249public static SourceText From( 392/// If an encoding-less <see cref="SourceText"/> is written to a file a <see cref="Encoding.UTF8"/> shall be used as a default. 410internal virtual ImmutableArray<SourceText> Segments 412get { return ImmutableArray<SourceText>.Empty; } 415internal virtual SourceText StorageKey 471/// The container of this <see cref="SourceText"/>. 497/// Gets a <see cref="SourceText"/> that contains the characters in the specified span of this text. 499public virtual SourceText GetSubText(TextSpan span) 506return SourceText.From(string.Empty, this.Encoding, this.ChecksumAlgorithm); 519/// Returns a <see cref="SourceText"/> that has the contents of this text including and after the start position. 521public SourceText GetSubText(int start) 539/// Write this <see cref="SourceText"/> to a text writer. 576/// that were used to produce this <see cref="SourceText"/> (if any of the <c>From</c> methods were used that 577/// take a <c>byte[]</c> or <see cref="Stream"/>). Otherwise, computed by writing this <see cref="SourceText"/> 582/// Two different <see cref="SourceText"/> instances with the same content (see <see cref="ContentEquals"/>) may 588/// Similarly, two different <see cref="SourceText"/> instances with <em>different</em> contents can have the 609/// Produces a hash of this <see cref="SourceText"/> based solely on the contents it contains. Two different 610/// <see cref="SourceText"/> instances that are <see cref="ContentEquals"/> will have the same content hash. Two 611/// instances of <see cref="SourceText"/> with different content are virtually certain to not have the same 748public virtual SourceText WithChanges(IEnumerable<TextChange> changes) 760var segments = ArrayBuilder<SourceText>.GetInstance(); 798var subText = this.GetSubText(new TextSpan(position, change.Span.Start - position)); 804var segment = SourceText.From(change.NewText!, this.Encoding, this.ChecksumAlgorithm); 821var subText = this.GetSubText(new TextSpan(position, this.Length - position)); 825var newText = CompositeText.ToSourceText(segments, this, adjustSegments: true); 849/// <exception cref="ArgumentException">If any changes are not in bounds of this <see cref="SourceText"/>.</exception> 851public SourceText WithChanges(params TextChange[] changes) 859public SourceText Replace(TextSpan span, string newText) 867public SourceText Replace(int start, int length, string newText) 877public virtual IReadOnlyList<TextChangeRange> GetChangeRanges(SourceText oldText) 899public virtual IReadOnlyList<TextChange> GetTextChanges(SourceText oldText) 964private readonly SourceText _text; 968public LineInfo(SourceText text, SegmentedList<int> lineStarts) 1139/// Compares the content with content of another <see cref="SourceText"/>. 1141public bool ContentEquals(SourceText other) 1166/// Implements equality comparison of the content of two different instances of <see cref="SourceText"/>. 1168protected virtual bool ContentEqualsImpl(SourceText other) 1262private readonly SourceText _text; 1264public StaticContainer(SourceText text) 1269public 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)
13/// A <see cref="SourceText"/> that represents a subrange of another <see cref="SourceText"/>. 17public SubText(SourceText text, TextSpan span) 39public SourceText UnderlyingText { get; } 50internal override SourceText StorageKey 78public override SourceText GetSubText(TextSpan span)
Text\TextChangeEventArgs.cs (6)
24public TextChangeEventArgs(SourceText oldText, SourceText newText, IEnumerable<TextChangeRange> changes) 42public TextChangeEventArgs(SourceText oldText, SourceText newText, params TextChangeRange[] changes) 50public SourceText OldText { get; } 55public SourceText NewText { get; }
Text\TextLine.cs (5)
16private readonly SourceText? _text; 20private TextLine(SourceText text, int start, int endIncludingBreaks) 34public static TextLine FromSpan(SourceText text, TextSpan span) 88internal static TextLine FromSpanUnsafe(SourceText text, TextSpan span) 99public 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 (55)
src\Analyzers\Core\Analyzers\Formatting\AbstractFormattingAnalyzer.cs (3)
49var oldText = tree.GetText(cancellationToken); 72if (oldText.GetSubText(new TextSpan(change.Span.Start + offset, change.NewText.Length)).ContentEquals(SourceText.From(change.NewText))) 81if (oldText.GetSubText(new TextSpan(change.Span.Start, change.NewText.Length)).ContentEquals(SourceText.From(change.NewText)))
src\Compilers\Core\Portable\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)
src\Compilers\Core\Portable\Syntax\SyntaxTreeExtensions.cs (1)
23var text = tree.GetText();
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EditorConfig\Parsing\EditorConfigParser.cs (2)
40return Parse<TEditorConfigFile, TResult, TAccumulator>(SourceText.From(text), pathToFile, accumulator); 43public static TEditorConfigFile Parse<TEditorConfigFile, TEditorConfigOption, TAccumulator>(SourceText text, string? pathToFile, TAccumulator accumulator)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EditorConfig\Parsing\NamingStyles\EditorConfigNamingStylesParser.cs (5)
18=> Parse(SourceText.From(editorConfigText), pathToEditorConfigFile); 21/// Parses a <see cref="SourceText"/> and returns all discovered naming style options and their locations 23/// <param name="editorConfigText">The <see cref="SourceText"/> contents of the editorconfig file.</param> 25/// <returns>A type that represents all discovered naming style options in the given <see cref="SourceText"/>.</returns> 26public static EditorConfigNamingStyles Parse(SourceText editorConfigText, string? pathToEditorConfigFile = null)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EmbeddedLanguages\VirtualChars\AbstractVirtualCharService.cs (1)
195protected static int ConvertTextAtIndexToRune(SourceText tokenText, int index, ImmutableSegmentedList<VirtualChar>.Builder result, int offset)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EmbeddedLanguages\VirtualChars\AbstractVirtualCharService.ITextInfo.cs (4)
12/// Abstraction to allow generic algorithms to run over a string or <see cref="SourceText"/> without any 21private struct SourceTextTextInfo : ITextInfo<SourceText> 23public readonly char Get(SourceText text, int index) => text[index]; 24public readonly int Length(SourceText text) => text.Length;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EmbeddedLanguages\VirtualChars\IVirtualCharService.cs (1)
33/// in the original <see cref="SourceText"/> that the language created that char from.
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EmbeddedLanguages\VirtualChars\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
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\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)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\SyntaxTreeExtensions.cs (2)
25var text = tree.GetText(cancellationToken); 102var text = tree.GetText(cancellationToken);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\TextLineExtensions.cs (3)
14var text = line.Text!; 46var text = line.Text; 67var text = line.Text;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Engine\TreeData.cs (1)
21if (root.SyntaxTree == null || !root.SyntaxTree.TryGetText(out var text))
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Engine\TreeData.Debug.cs (1)
12private sealed class Debug(SyntaxNode root, SourceText text) : NodeAndText(root, text)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Engine\TreeData.NodeAndText.cs (2)
15private readonly SourceText _text; 17public NodeAndText(SyntaxNode root, SourceText text)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Engine\TreeData.StructuredTrivia.cs (2)
27var text = GetText(); 48private SourceText? GetText()
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Indentation\AbstractIndentation.cs (1)
29TSyntaxRoot root, SourceText text, TextLine lineToBeIndented, IndentationOptions options, AbstractFormattingRule baseFormattingRule);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Indentation\AbstractIndentation.Indenter.cs (3)
36public readonly SourceText Text; 44SourceText text, 173var updatedSourceText = Text.WithChanges(changes);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Services\SelectedMembers\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)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\CommonFormattingHelpers.cs (1)
157public static string GetText(this SourceText text, SyntaxToken token1, SyntaxToken token2)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\InterceptsLocationUtilities.cs (1)
15/// (See <see cref="SourceText.GetContentHash()"/>)</param>
Microsoft.CodeAnalysis.CodeStyle.Fixes (44)
src\Analyzers\Core\CodeFixes\ConflictMarkerResolution\AbstractConflictMarkerCodeFixProvider.cs (15)
74var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false); 84SyntaxNode root, SourceText text, int position, 145SourceText text, int position, 209var text = startLine.Text!; 227var text = startLine.Text!; 245var text = currentLine.Text!; 315Action<SourceText, ArrayBuilder<TextChange>, int, int, int, int> addEdits, 318var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false); 323var finalText = text.WithChanges(edits); 328SourceText text, ArrayBuilder<TextChange> edits, 341SourceText text, ArrayBuilder<TextChange> edits, 354SourceText text, ArrayBuilder<TextChange> edits, 388private static int GetEndIncludingLineBreak(SourceText text, int position) 404var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false); 443var finalText = text.WithChanges(edits);
src\Analyzers\Core\CodeFixes\Formatting\FormattingCodeFixProvider.cs (1)
65var text = root.GetText();
src\Analyzers\Core\CodeFixes\UseConditionalExpression\AbstractUseConditionalExpressionCodeFixProvider.cs (1)
141var sourceText = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeRefactorings\AbstractRefactoringHelpersService.cs (4)
24public abstract bool IsBetweenTypeMembers(SourceText sourceText, SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? typeDeclaration); 214var sourceText = document.Text; 233SourceText sourceText, SyntaxToken tokenOnLocation, int location) 536var sourceText = document.Text;
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeRefactorings\CodeRefactoringHelpers.cs (1)
111var sourceText = document.Text;
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeRefactorings\IRefactoringHelpersService.cs (1)
25bool IsBetweenTypeMembers(SourceText sourceText, SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? typeDeclaration);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Editing\AddParameterEditor.cs (2)
25var sourceText = declaration.SyntaxTree.GetText(cancellationToken); 159var text = parameters[0].SyntaxTree.GetText(cancellationToken);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Extensions\TextDocumentExtensions.cs (6)
15public static ValueTask<SourceText> GetValueTextAsync(this TextDocument document, CancellationToken cancellationToken) 17if (document.TryGetText(out var text)) 20return new ValueTask<SourceText>(document.GetTextAsync(cancellationToken)); 27public static TextDocument WithText(this TextDocument textDocument, SourceText text) 48public static TextDocument WithAdditionalDocumentText(this TextDocument textDocument, SourceText text) 57public static TextDocument WithAnalyzerConfigDocumentText(this TextDocument textDocument, SourceText text)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Indentation\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)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Utilities\ParsedDocument.cs (5)
22/// 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 28internal readonly record struct ParsedDocument(DocumentId Id, SourceText Text, SyntaxNode Root, HostLanguageServices HostLanguageServices) 37var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false); 51public ParsedDocument WithChangedText(SourceText text, CancellationToken cancellationToken) 59var text = root.SyntaxTree.GetText(cancellationToken);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Utilities\SemanticDocument.cs (2)
12internal sealed class SemanticDocument(Document document, SourceText text, SyntaxNode root, SemanticModel semanticModel) 19var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Utilities\SyntacticDocument.cs (3)
15public readonly SourceText Text; 18protected SyntacticDocument(Document document, SourceText text, SyntaxNode root) 30var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false);
Microsoft.CodeAnalysis.CodeStyle.UnitTestUtilities (5)
src\Features\DiagnosticsTestUtilities\CodeActions\CodeFixVerifierHelper.cs (4)
95var text = ConvertOptionsToAnalyzerConfig(options.DefaultExtension, explicitEditorConfig: string.Empty, options); 99public static SourceText? ConvertOptionsToAnalyzerConfig(string defaultFileExtension, string? explicitEditorConfig, OptionsCollection options) 103return explicitEditorConfig is object ? SourceText.From(explicitEditorConfig, Encoding.UTF8) : null; 132return SourceText.From(analyzerConfig.ToString(), Encoding.UTF8);
src\Features\DiagnosticsTestUtilities\CodeActions\SharedVerifierState.cs (1)
52var analyzerConfigSource = CodeFixVerifierHelper.ConvertOptionsToAnalyzerConfig(_defaultFileExt, EditorConfig, Options);
Microsoft.CodeAnalysis.CSharp (50)
CommandLine\CSharpCompiler.cs (1)
204SourceText content,
Compilation\CSharpCompilation.cs (1)
1099var text = tree.GetText();
Compilation\CSharpSemanticModel.cs (1)
5224var text = tree.GetText(cancellationToken);
Compilation\SyntaxAndDeclarationManager.cs (1)
240var 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); 374using var tempLexer = new Lexer(SourceText.From(expressionText), options, allowPreprocessorDirectives: false, interpolationFollowedByColon: interpolation.HasColon); 465using var tempLexer = new Lexer(SourceText.From(fakeString), this.Options, allowPreprocessorDirectives: false);
Parser\Lexer.cs (3)
113public Lexer(SourceText text, CSharpParseOptions options, bool allowPreprocessorDirectives = true, bool interpolationFollowedByColon = false) 2011var text = TextWindow.Text.GetSubText(TextSpan.FromBounds(savePosition, TextWindow.Position)); 2086var 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) 180public override LineVisibility GetLineVisibility(SourceText sourceText, int position) 228internal override FileLinePositionSpan TranslateSpanAndVisibility(SourceText sourceText, string treeFilePath, TextSpan span, out bool isHiddenPosition)
Syntax\CSharpSyntaxTree.cs (10)
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) 911SourceText text, 928=> ParseText(SourceText.From(text, encoding, SourceHashAlgorithm.Sha1), options, path, diagnosticOptions, isGeneratedCode: null, cancellationToken);
Syntax\CSharpSyntaxTree.DebuggerSyntaxTree.cs (1)
16public DebuggerSyntaxTree(CSharpSyntaxNode root, SourceText text, CSharpParseOptions options)
Syntax\CSharpSyntaxTree.Dummy.cs (4)
33public override SourceText GetText(CancellationToken cancellationToken) 35return SourceText.From(string.Empty, Encoding, ChecksumAlgorithm); 38public override bool TryGetText(out SourceText text) 40text = SourceText.From(string.Empty, Encoding, ChecksumAlgorithm);
Syntax\CSharpSyntaxTree.LazySyntaxTree.cs (4)
19private readonly SourceText _text; 26SourceText text, 44public override SourceText GetText(CancellationToken cancellationToken) 49public override bool TryGetText([NotNullWhen(true)] out SourceText? text)
Syntax\CSharpSyntaxTree.ParsedSyntaxTree.cs (4)
29private SourceText? _lazyText; 32SourceText? textOpt, 62public override SourceText GetText(CancellationToken cancellationToken) 72public override bool TryGetText([NotNullWhen(true)] out SourceText? text)
Syntax\SyntaxFactory.cs (10)
1562return CSharpSyntaxTree.ParseText(SourceText.From(text, encoding, SourceHashAlgorithm.Sha1), (CSharpParseOptions?)options, path, diagnosticOptions: null, isGeneratedCode: null, cancellationToken); 1566/// <inheritdoc cref="CSharpSyntaxTree.ParseText(SourceText, CSharpParseOptions?, string, CancellationToken)"/> 1568SourceText text, 1682public static SyntaxTokenParser CreateTokenParser(SourceText sourceText, CSharpParseOptions? options = null) 1911private static SourceText MakeSourceText(string text, int offset) 1913return SourceText.From(text, Encoding.UTF8).GetSubText(offset); 2790return ParseSyntaxTree(SourceText.From(text, encoding), options, path, diagnosticOptions, isGeneratedCode: null, cancellationToken); 2797SourceText text, 2818return ParseSyntaxTree(SourceText.From(text, encoding), options, path, diagnosticOptions, isGeneratedCode, cancellationToken); 2825SourceText text,
Microsoft.CodeAnalysis.CSharp.CodeStyle (20)
src\Analyzers\CSharp\Analyzers\NewLines\ConsecutiveBracePlacement\ConsecutiveBracePlacementDiagnosticAnalyzer.cs (4)
51var text = tree.GetText(cancellationToken); 78private void ProcessToken(SyntaxTreeAnalysisContext context, NotificationOption2 notificationOption, SourceText text, SyntaxToken token) 93SourceText text, SyntaxToken token, 134var text = textLine.Text!;
src\Analyzers\CSharp\Analyzers\NewLines\ConstructorInitializerPlacement\ConstructorInitializerPlacementDiagnosticAnalyzer.cs (1)
69var sourceText = context.Tree.GetText(context.CancellationToken);
src\Analyzers\CSharp\Analyzers\UseCollectionExpression\CSharpUseCollectionExpressionForFluentDiagnosticAnalyzer.cs (3)
94var sourceText = semanticModel.SyntaxTree.GetText(cancellationToken); 116SourceText text, 149SourceText text,
src\Analyzers\CSharp\Analyzers\UseCollectionExpression\UseCollectionExpressionHelpers.cs (2)
646SourceText sourceText, 668SourceText sourceText,
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\EmbeddedLanguages\VirtualChars\CSharpVirtualCharService.cs (3)
188var parentSourceText = parentExpression.SyntaxTree.GetText(); 193var tokenSourceText = SourceText.From(token.Text);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxNodeExtensions.cs (2)
59this SyntaxNode node, SourceText? sourceText = null, 69this SyntaxToken token, SourceText? sourceText = null,
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxTokenExtensions.cs (1)
160public static bool IsFirstTokenOnLine(this SyntaxToken token, SourceText text)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxTreeExtensions.cs (1)
347var sourceText = token.SyntaxTree!.GetText(cancellationToken);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Indentation\CSharpSmartTokenFormatter.cs (2)
29private readonly SourceText _text; 35SourceText text)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\FormattingRangeHelper.cs (1)
300if (tree != null && tree.TryGetText(out var text))
Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes (17)
src\Analyzers\CSharp\CodeFixes\AddInheritdoc\AddInheritdocCodeFixProvider.cs (1)
82SourceText? sourceText = null;
src\Analyzers\CSharp\CodeFixes\ConvertNamespace\ConvertNamespaceTransform.cs (4)
62public static (SourceText text, TextSpan semicolonSpan) ConvertNamespaceDeclaration(ParsedDocument document, NamespaceDeclarationSyntax namespaceDeclaration, SyntaxFormattingOptions options, CancellationToken cancellationToken) 108private static (SourceText text, TextSpan semicolonSpan) DedentNamespace( 194private static SourceText IndentNamespace( 255var indentedText = IndentNamespace(updatedParsedDocument, indentation, annotation, cancellationToken);
src\Analyzers\CSharp\CodeFixes\InlineDeclaration\CSharpInlineDeclarationCodeFixProvider.cs (2)
106var sourceText = currentRoot.GetText(); 281SourceText sourceText, IdentifierNameSyntax identifier,
src\Analyzers\CSharp\CodeFixes\NewLines\ArrowExpressionClausePlacement\ArrowExpressionClausePlacementCodeFixProvider.cs (1)
66SourceText text,
src\Analyzers\CSharp\CodeFixes\NewLines\ConditionalExpressionPlacement\ConditionalExpressionPlacementCodeFixProvider.cs (1)
67SourceText text,
src\Analyzers\CSharp\CodeFixes\NewLines\ConsecutiveBracePlacement\ConsecutiveBracePlacementCodeFixProvider.cs (1)
62SyntaxNode root, SourceText text,
src\Analyzers\CSharp\CodeFixes\UseCollectionExpression\CSharpUseCollectionExpressionForArrayCodeFixProvider.cs (2)
56var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); 97static bool IsOnSingleLine(SourceText sourceText, SyntaxNode node)
src\Analyzers\CSharp\CodeFixes\UseCollectionExpression\CSharpUseCollectionExpressionForFluentCodeFixProvider.cs (2)
57var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); 149var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeRefactorings\CSharpRefactoringHelpersService.cs (1)
29public override bool IsBetweenTypeMembers(SourceText sourceText, SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? typeDeclaration)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Indentation\CSharpIndentationService.cs (1)
145var text = node.SyntaxTree.GetText();
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Indentation\CSharpIndentationService.Indenter.cs (1)
29CompilationUnitSyntax root, SourceText text, TextLine lineToBeIndented,
Microsoft.CodeAnalysis.CSharp.CommandLine.UnitTests (2)
CommandLineTests.cs (2)
2494SourceText embeddedSource = mdReader.GetEmbeddedSource(handle); 14041context.AddSource("hint2", SourceText.From("class G2 { void F() {} }", Encoding.UTF8, checksumAlgorithm: SourceHashAlgorithm.Sha1));
Microsoft.CodeAnalysis.CSharp.EditorFeatures (43)
AutomaticCompletion\AutomaticLineEnderCommandHandler.cs (3)
140var text = document.Text; 196private static bool CheckLocation(SourceText text, int position, SyntaxNode owningNode, SyntaxToken lastToken) 253private static bool TryGetLastToken(SourceText text, int position, SyntaxNode owningNode, out SyntaxToken lastToken)
ConvertNamespace\ConvertNamespaceCommandHandler.cs (1)
98private (SourceText? convertedText, TextSpan semicolonSpan) ConvertNamespace(
EventHookup\EventHookupCommandHandler_TabKeyCommand.cs (1)
286var newText = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
InlineRename\CSharpEditorInlineRenameService.cs (1)
108void AddSpanOfInterest(SourceText documentText, string filePath, TextSpan fallbackSpan, TextSpan? surroundingSpanOfInterest, ArrayBuilder<(string filePath, string content)> resultBuilder)
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)
37protected readonly SourceText TextBeforePaste; 42protected readonly SourceText TextAfterPaste; 138SourceText textAfterChange, ImmutableArray<TextSpan> textContentSpansAfterChange) 153SourceText textAfterChange, ImmutableArray<TextSpan> textContentSpansAfterChange)
StringCopyPaste\KnownSourcePasteProcessor.cs (4)
158out SourceText textAfterBasicPaste, out ImmutableArray<TextSpan> contentSpansAfterBasicPaste) 285SourceText? lastContentSourceText = null; 289var sourceText = SourceText.From(content.TextValue);
StringCopyPaste\StringCopyPasteCommandHandler.cs (5)
144var newTextAfterChanges = snapshotBeforePaste.AsText().WithChanges(textChanges); 237SourceText textBeforePaste, 296SourceText newTextAfterChanges) 305var originalStringContentsAfterPaste = snapshotAfterPaste.AsText().GetSubText(spanAfterPaste); 306var newStringContentsAfterEdit = newTextAfterChanges.GetSubText(spanAfterPaste);
StringCopyPaste\StringCopyPasteHelpers.cs (11)
29public static char SafeCharAt(SourceText text, int index) 104public static int GetFirstNonWhitespaceIndex(SourceText text, TextLine line) 169public static int SkipU8Suffix(SourceText text, int end) 183public static int GetLongestQuoteSequence(SourceText text, TextSpan span) 186public static int GetLongestOpenBraceSequence(SourceText text, TextSpan span) 189public static int GetLongestCloseBraceSequence(SourceText text, TextSpan span) 197private static int GetLongestCharacterSequence(SourceText text, TextSpan span, char character) 503var text = SourceText.From(change.NewText); 521private static string? GetCommonIndentationPrefix(string? commonIndentPrefix, SourceText text, TextSpan lineWhitespaceSpan) 542public static bool RawContentMustBeMultiLine(SourceText text, ImmutableArray<TextSpan> spans)
StringCopyPaste\StringInfo.cs (5)
62public static StringInfo GetStringInfo(SourceText text, ExpressionSyntax stringExpression) 70private static StringInfo GetStringLiteralInfo(SourceText text, LiteralExpressionSyntax literal) 84private static StringInfo GetRawStringLiteralInfo(SourceText text, LiteralExpressionSyntax literal) 156private static StringInfo GetNormalStringLiteralStringInfo(SourceText text, LiteralExpressionSyntax literal) 182SourceText text, InterpolatedStringExpressionSyntax interpolatedString)
StringCopyPaste\UnknownSourcePasteProcessor.cs (6)
145/// <inheritdoc cref="AbstractPasteProcessor.GetQuotesToAddToRawString(SourceText, ImmutableArray{TextSpan})" /> 149/// <inheritdoc cref="AbstractPasteProcessor.GetDollarSignsToAddToRawString(SourceText, ImmutableArray{TextSpan})" /> 171SourceText? textOfCurrentChange = null; 178textOfCurrentChange = SourceText.From(change.NewText); 245var textOfCurrentChange = SourceText.From(change.NewText);
Microsoft.CodeAnalysis.CSharp.EditorFeatures.UnitTests (109)
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"));
Completion\CompletionProviders\LoadDirectiveCompletionProviderTests.cs (1)
87Assert.Equal(expectedResult, provider.ShouldTriggerCompletion(languageServices.LanguageServices, SourceText.From(text), position, trigger: default, CompletionOptions.Default, OptionSet.Empty));
Completion\CompletionProviders\ReferenceDirectiveCompletionProviderTests.cs (1)
128Assert.Equal(expectedResult, provider.ShouldTriggerCompletion(languageServices.LanguageServices, SourceText.From(text), position, trigger: default, CompletionOptions.Default, OptionSet.Empty));
Completion\CompletionServiceTests.cs (7)
49var text = SourceText.From("class C { }"); 80public override bool ShouldTriggerCompletion(SourceText text, int caretPosition, CompletionTrigger trigger, OptionSet options) 107var text = SourceText.From("class C { }"); 139var text = await document.GetTextAsync(); 221document = document.WithText(SourceText.From(sourceMarkup.Replace("C1", "C2")));
Diagnostics\DiagnosticAnalyzerDriver\DiagnosticAnalyzerDriverTests.cs (1)
165var additionalText = new TestAdditionalText("add.config", SourceText.From("random text"));
EditorConfigSettings\Updater\SettingsUpdaterTests.cs (12)
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)
11218.AddDocument("Document", SourceText.From(""));
Formatting\CodeCleanupTests.cs (2)
808project = project.AddAnalyzerConfigDocument(".editorconfig", SourceText.From(editorconfigText), filePath: @"z:\\.editorconfig").Project; 904project = project.AddAnalyzerConfigDocument(".editorconfig", SourceText.From(editorconfigText), filePath: @"z:\\.editorconfig").Project;
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)
565SourceText.From(code).Lines.IndexOf(position), 632SourceText.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)
112testDocument.Update(SourceText.From(currentDocumentText));
PdbSourceDocument\AbstractPdbSourceDocumentTests.cs (10)
121protected static async Task<(SourceText?, TextSpan)> GetGeneratedSourceTextAsync( 162var result = pdbService.TryAddDocumentToWorkspace((MetadataAsSourceWorkspace)masWorkspace!, file.FilePath, new StaticSourceTextContainer(SourceText.From(string.Empty)), out _); 199var sourceText = SourceText.From(source, encoding: encoding ?? Encoding.UTF8); 207SourceText source, 249protected static void CompileTestSource(string path, SourceText source, Project project, Location pdbLocation, Location sourceLocation, bool buildReferenceAssembly, bool windowsPdb, Encoding? fallbackEncoding = null) 259protected 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) 264protected 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) 345protected class StaticSourceTextContainer(SourceText sourceText) : SourceTextContainer 347public override SourceText CurrentText => sourceText;
PdbSourceDocument\ImplementationAssemblyLookupServiceTests.cs (28)
43var sourceText = SourceText.From(metadataSource, encoding: Encoding.UTF8); 81var sourceText = SourceText.From(metadataSource, encoding: Encoding.UTF8); 123var sourceText = SourceText.From(metadataSource, encoding: Encoding.UTF8); 161var sourceText = SourceText.From(metadataSource, Encoding.UTF8); 185sourceText = SourceText.From(typeForwardSource, Encoding.UTF8); 222var sourceText = SourceText.From(metadataSource, encoding: Encoding.UTF8); 245sourceText = SourceText.From(typeForwardSource, Encoding.UTF8); 283var sourceText = SourceText.From(metadataSource, encoding: Encoding.UTF8); 306sourceText = SourceText.From(typeForwardSource, Encoding.UTF8); 338var sourceText = SourceText.From(metadataSource, encoding: Encoding.UTF8); 361sourceText = SourceText.From(typeForwardSource, Encoding.UTF8); 389var sourceText = SourceText.From(metadataSource, encoding: Encoding.UTF8); 412sourceText = SourceText.From(typeForwardSource, Encoding.UTF8); 454var sourceText = SourceText.From(metadataSource, encoding: Encoding.UTF8); 477sourceText = SourceText.From(typeForwardSource, Encoding.UTF8); 512var sourceText = SourceText.From(metadataSource, encoding: Encoding.UTF8); 535var typeForwardSourceText = SourceText.From(typeForwardSource, Encoding.UTF8);
PdbSourceDocument\PdbSourceDocumentTests.cs (20)
409var sourceText = SourceText.From(metadataSource, encoding: Encoding.UTF8); 439var sourceText = SourceText.From(metadataSource, encoding: Encoding.UTF8); 475var sourceText = SourceText.From(metadataSource, Encoding.UTF8); 522var sourceText = SourceText.From(metadataSource, Encoding.UTF8); 548sourceText = SourceText.From(typeForwardSource, Encoding.UTF8); 725CompileTestSource(path, SourceText.From(source2, Encoding.UTF8), project, Location.OnDisk, Location.OnDisk, buildReferenceAssembly: false, windowsPdb: false); 876var sourceText = SourceText.From(source, Encoding.UTF8); 927var sourceText1 = SourceText.From(source1, Encoding.UTF8); 928var sourceText2 = SourceText.From(source2, Encoding.UTF8); 975var result = service.TryAddDocumentToWorkspace(requestPath, new StaticSourceTextContainer(SourceText.From(string.Empty)), out var documentId); 998var openResult = service.TryAddDocumentToWorkspace(file.FilePath, new StaticSourceTextContainer(SourceText.From(string.Empty)), out var documentId); 1049var openResult = service.TryAddDocumentToWorkspace(fileOne.FilePath, new StaticSourceTextContainer(SourceText.From(string.Empty)), out var documentId); 1060Assert.Throws<System.InvalidOperationException>(() => service.TryAddDocumentToWorkspace(fileTwo.FilePath, new StaticSourceTextContainer(SourceText.From(string.Empty)), out var documentIdTwo));
StringIndentation\StringIndentationTests.cs (3)
42var text = SourceText.From(val); 61var changedText = text.WithChanges(changes);
Workspaces\WorkspaceTests_EditorFeatures.cs (8)
514var docZText = await docZ.GetTextAsync(); 733var newSolution = oldSolution.WithDocumentText(document.Id, SourceText.From(newText)); 761var newSolution = oldSolution.AddDocument(DocumentId.CreateNewId(project1.Id), "Doc2", SourceText.From(doc2Text)); 1114var newSolution = oldSolution.WithAdditionalDocumentText(additionalDoc.Id, SourceText.From(newText)); 1147var newSolution = oldSolution.WithAnalyzerConfigDocumentText(analyzerConfigDoc.Id, SourceText.From(newText)); 1273var newSolution = oldSolution.AddAnalyzerConfigDocument(newDocId, "app.config", SourceText.From("text")); 1337var doc = project.AddAnalyzerConfigDocument("app.config", SourceText.From("text")); 1421workspace.GetTestDocument(originalDocumentId).Update(SourceText.From("class Program2 { }"));
Microsoft.CodeAnalysis.CSharp.EditorFeatures2.UnitTests (5)
EmbeddedLanguages\RegularExpressions\CSharpRegexParserTests.cs (5)
124private (RegexTree, SourceText) TryParseTree( 140var sourceText = token.SyntaxTree.GetText(); 198private static string TreeToText(SourceText text, RegexTree tree) 217private static XElement CreateDiagnosticsElement(SourceText text, RegexTree tree) 225private static XAttribute GetTextAttribute(SourceText text, TextSpan span)
Microsoft.CodeAnalysis.CSharp.Emit.UnitTests (3)
CodeGen\CodeGenTupleTest.cs (3)
22612var text = SourceText.From(source1); 22617var newText = text.WithChanges(new TextChange(new TextSpan(pos, 0), " ")); // add space before closing-paren
Microsoft.CodeAnalysis.CSharp.Emit2.UnitTests (6)
PDB\CSharpPDBTestBase.cs (2)
39var text = SourceText.From(source);
PDB\PDBTests.cs (4)
47var tree3 = SyntaxFactory.ParseSyntaxTree(SourceText.From("class C { }", encoding: null), path: "Bar.cs"); 68var tree4 = SyntaxFactory.ParseSyntaxTree(SourceText.From("class D { public void F() { } }", new UTF8Encoding(false, false)), path: "Baz.cs"); 104context.AddSource("hint2", SourceText.From("class G2 { void F() {} }", Encoding.UTF8, checksumAlgorithm: SourceHashAlgorithm.Sha256)); 106Assert.Throws<ArgumentException>(() => context.AddSource("hint3", SourceText.From("class G3 { void F() {} }", encoding: null, checksumAlgorithm: SourceHashAlgorithm.Sha256)));
Microsoft.CodeAnalysis.CSharp.Features (119)
AddImport\CSharpAddMissingImportsFeatureService.cs (1)
30protected override ImmutableArray<AbstractFormattingRule> GetFormatRules(SourceText text)
BraceCompletion\AbstractCurlyBraceOrBracketCompletionService.cs (5)
68private static bool ContainsOnlyWhitespace(SourceText text, int openingPosition, int closingBraceEndPoint) 94var originalDocumentText = document.Text; 163static TextLine GetLineBetweenCurlys(int closingPosition, SourceText text) 169static LinePosition GetIndentedLinePosition(ParsedDocument document, SourceText sourceText, int lineNumber, IndentationOptions options, CancellationToken cancellationToken) 181static ImmutableArray<TextChange> GetMergedChanges(TextChange? newLineEdit, ImmutableArray<TextChange> formattingChanges, SourceText formattedText)
BraceCompletion\InterpolatedStringBraceCompletionService.cs (2)
42protected override bool IsValidOpenBraceTokenAtPosition(SourceText text, SyntaxToken token, int position) 50var text = document.Text;
BraceCompletion\InterpolationBraceCompletionService.cs (1)
38protected override bool IsValidOpenBraceTokenAtPosition(SourceText text, SyntaxToken token, int position)
BraceCompletion\ParenthesisBraceCompletionService.cs (1)
30protected override bool IsValidOpenBraceTokenAtPosition(SourceText text, SyntaxToken token, int position)
BraceCompletion\StringLiteralBraceCompletionService.cs (2)
31var text = document.Text; 54protected override bool IsValidOpenBraceTokenAtPosition(SourceText text, SyntaxToken token, int position)
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 (2)
53public override bool IsInsertionTrigger(SourceText text, int characterPosition, CompletionOptions options) 227private static TextSpan GetCompletionItemSpan(SourceText text, int position)
Completion\CompletionProviders\DeclarationName\DeclarationNameCompletionProvider.cs (1)
35public 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)
34public override bool IsInsertionTrigger(SourceText text, int characterPosition, CompletionOptions options)
Completion\CompletionProviders\ExplicitInterfaceTypeCompletionProvider.cs (1)
38public override bool IsInsertionTrigger(SourceText text, int insertedCharacterPosition, CompletionOptions options)
Completion\CompletionProviders\ExternAliasCompletionProvider.cs (1)
34public override bool IsInsertionTrigger(SourceText text, int characterPosition, CompletionOptions options)
Completion\CompletionProviders\FunctionPointerUnmanagedCallingConventionCompletionProvider.cs (1)
36public override bool IsInsertionTrigger(SourceText text, int characterPosition, CompletionOptions options)
Completion\CompletionProviders\ImportCompletion\ExtensionMethodImportCompletionProvider.cs (1)
33public override bool IsInsertionTrigger(SourceText text, int characterPosition, CompletionOptions options)
Completion\CompletionProviders\ImportCompletion\TypeImportCompletionProvider.cs (1)
33public override bool IsInsertionTrigger(SourceText text, int characterPosition, CompletionOptions options)
Completion\CompletionProviders\InternalsVisibleToCompletionProvider.cs (1)
59protected override bool ShouldTriggerAfterQuotes(SourceText text, int insertedCharacterPosition)
Completion\CompletionProviders\KeywordCompletionProvider.cs (1)
180public override bool IsInsertionTrigger(SourceText text, int characterPosition, CompletionOptions options)
Completion\CompletionProviders\NamedParameterCompletionProvider.cs (1)
48public override bool IsInsertionTrigger(SourceText text, int characterPosition, CompletionOptions options)
Completion\CompletionProviders\ObjectAndWithInitializerCompletionProvider.cs (1)
102public override bool IsInsertionTrigger(SourceText text, int characterPosition, CompletionOptions options)
Completion\CompletionProviders\ObjectCreationCompletionProvider.cs (1)
36public override bool IsInsertionTrigger(SourceText text, int characterPosition, CompletionOptions options)
Completion\CompletionProviders\OperatorsAndIndexer\UnnamedSymbolCompletionProvider.cs (1)
65public override bool IsInsertionTrigger(SourceText text, int insertedCharacterPosition, CompletionOptions options)
Completion\CompletionProviders\OverrideCompletionProvider.cs (2)
44public override bool IsInsertionTrigger(SourceText text, int characterPosition, CompletionOptions options) 79SourceText text,
Completion\CompletionProviders\PartialMethodCompletionProvider.cs (3)
76public override bool IsInsertionTrigger(SourceText text, int characterPosition, CompletionOptions options) 92var text = tree.GetText(cancellationToken); 133private 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)
28public override bool IsInsertionTrigger(SourceText text, int characterPosition, CompletionOptions options)
Completion\CompletionProviders\PropertySubPatternCompletionProvider.cs (1)
165public override bool IsInsertionTrigger(SourceText text, int characterPosition, CompletionOptions options)
Completion\CompletionProviders\SnippetCompletionProvider.cs (1)
67public override bool IsInsertionTrigger(SourceText text, int characterPosition, CompletionOptions options)
Completion\CompletionProviders\SpeculativeTCompletionProvider.cs (1)
35public override bool IsInsertionTrigger(SourceText text, int characterPosition, CompletionOptions options)
Completion\CompletionProviders\SymbolCompletionProvider.cs (1)
142public override bool IsInsertionTrigger(SourceText text, int characterPosition, CompletionOptions options)
Completion\CompletionProviders\XmlDocCommentCompletionProvider.cs (1)
62public override bool IsInsertionTrigger(SourceText text, int characterPosition, CompletionOptions options)
Completion\CSharpCompletionService.cs (1)
40public override TextSpan GetDefaultCompletionListSpan(SourceText text, int caretPosition)
ConvertToRawString\ConvertInterpolatedStringToRawStringCodeRefactoringProvider.cs (6)
288var text = stringExpression.GetText(); 346SourceText text, 464private static string GetIndentationStringForToken(SourceText text, SyntaxFormattingOptions options, SyntaxToken token) 467private static string GetIndentationStringForPosition(SourceText text, SyntaxFormattingOptions options, int position) 484SourceText? text = null; 525var text = stringExpression.GetText();
EditAndContinue\BreakpointSpans.cs (1)
20var source = tree.GetText(cancellationToken);
EmbeddedLanguages\CSharpTestEmbeddedLanguageClassifier.cs (4)
72var text = semanticModel.SyntaxTree.GetText(cancellationToken); 136/// cref="SourceText"/> (which only cares about their <see cref="char"/> value), as well as the way to then map 137/// positions/spans within that <see cref="SourceText"/> to actual full virtual char spans in the original 271/// Trivial implementation of a <see cref="SourceText"/> that directly maps over a <see
ExtractMethod\CSharpSelectionValidator.cs (5)
35var text = SemanticDocument.Text; 86private SelectionInfo ApplySpecialCases(SelectionInfo selectionInfo, SourceText text, ParseOptions options, bool localFunction) 186private SelectionInfo GetInitialSelectionInfo(SyntaxNode root, SourceText text) 428private static SelectionInfo AssignFinalSpan(SelectionInfo selectionInfo, SourceText text) 517private static TextSpan GetAdjustedSpan(SourceText text, TextSpan textSpan)
InvertIf\CSharpInvertIfCodeRefactoringProvider.cs (1)
133SourceText sourceText,
SemanticSearch\CSharpSemanticSearchService.cs (1)
24SourceText query,
Snippets\AbstractCSharpAutoPropertySnippetProvider.cs (1)
75protected override int GetTargetCaretPosition(PropertyDeclarationSyntax propertyDeclaration, SourceText sourceText)
Snippets\AbstractCSharpForLoopSnippetProvider.cs (1)
115protected override int GetTargetCaretPosition(ForStatementSyntax forStatement, SourceText sourceText)
Snippets\AbstractCSharpTypeSnippetProvider.cs (1)
82protected override int GetTargetCaretPosition(TTypeDeclarationSyntax typeDeclaration, SourceText sourceText)
Snippets\CSharpConstructorSnippetProvider.cs (1)
78protected override int GetTargetCaretPosition(ConstructorDeclarationSyntax constructorDeclaration, SourceText sourceText)
Snippets\CSharpDoWhileLoopSnippetProvider.cs (1)
43protected override int GetTargetCaretPosition(DoStatementSyntax doStatement, SourceText sourceText)
Snippets\CSharpElseSnippetProvider.cs (1)
63protected override int GetTargetCaretPosition(ElseClauseSyntax elseClause, SourceText sourceText)
Snippets\CSharpForEachLoopSnippetProvider.cs (1)
123protected override int GetTargetCaretPosition(ForEachStatementSyntax forEachStatement, SourceText sourceText)
Snippets\CSharpIfSnippetProvider.cs (1)
33protected override int GetTargetCaretPosition(IfStatementSyntax ifStatement, SourceText sourceText)
Snippets\CSharpIntMainSnippetProvider.cs (1)
39protected override int GetTargetCaretPosition(MethodDeclarationSyntax methodDeclaration, SourceText sourceText)
Snippets\CSharpLockSnippetProvider.cs (1)
34protected override int GetTargetCaretPosition(LockStatementSyntax lockStatement, SourceText sourceText)
Snippets\CSharpSnippetHelpers.cs (1)
18public static int GetTargetCaretPositionInBlock<TTargetNode>(TTargetNode caretTarget, Func<TTargetNode, BlockSyntax> getBlock, SourceText sourceText)
Snippets\CSharpVoidMainSnippetProvider.cs (1)
36protected override int GetTargetCaretPosition(MethodDeclarationSyntax methodDeclaration, SourceText sourceText)
Snippets\CSharpWhileLoopSnippetProvider.cs (1)
33protected override int GetTargetCaretPosition(WhileStatementSyntax whileStatement, SourceText sourceText)
src\Analyzers\CSharp\Analyzers\NewLines\ConsecutiveBracePlacement\ConsecutiveBracePlacementDiagnosticAnalyzer.cs (4)
51var text = tree.GetText(cancellationToken); 78private void ProcessToken(SyntaxTreeAnalysisContext context, NotificationOption2 notificationOption, SourceText text, SyntaxToken token) 93SourceText text, SyntaxToken token, 134var text = textLine.Text!;
src\Analyzers\CSharp\Analyzers\NewLines\ConstructorInitializerPlacement\ConstructorInitializerPlacementDiagnosticAnalyzer.cs (1)
69var sourceText = context.Tree.GetText(context.CancellationToken);
src\Analyzers\CSharp\Analyzers\UseCollectionExpression\CSharpUseCollectionExpressionForFluentDiagnosticAnalyzer.cs (3)
94var sourceText = semanticModel.SyntaxTree.GetText(cancellationToken); 116SourceText text, 149SourceText text,
src\Analyzers\CSharp\Analyzers\UseCollectionExpression\UseCollectionExpressionHelpers.cs (2)
646SourceText sourceText, 668SourceText sourceText,
src\Analyzers\CSharp\CodeFixes\AddInheritdoc\AddInheritdocCodeFixProvider.cs (1)
82SourceText? sourceText = null;
src\Analyzers\CSharp\CodeFixes\ConvertNamespace\ConvertNamespaceTransform.cs (8)
62public static (SourceText text, TextSpan semicolonSpan) ConvertNamespaceDeclaration(ParsedDocument document, NamespaceDeclarationSyntax namespaceDeclaration, SyntaxFormattingOptions options, CancellationToken cancellationToken) 108private static (SourceText text, TextSpan semicolonSpan) DedentNamespace( 112var text = document.Text; 125var dedentedText = text.WithChanges(changes); 194private static SourceText IndentNamespace( 198var text = document.Text; 209var dedentedText = text.WithChanges(changes); 255var indentedText = IndentNamespace(updatedParsedDocument, indentation, annotation, cancellationToken);
src\Analyzers\CSharp\CodeFixes\InlineDeclaration\CSharpInlineDeclarationCodeFixProvider.cs (2)
106var sourceText = currentRoot.GetText(); 281SourceText sourceText, IdentifierNameSyntax identifier,
src\Analyzers\CSharp\CodeFixes\NewLines\ArrowExpressionClausePlacement\ArrowExpressionClausePlacementCodeFixProvider.cs (1)
66SourceText text,
src\Analyzers\CSharp\CodeFixes\NewLines\ConditionalExpressionPlacement\ConditionalExpressionPlacementCodeFixProvider.cs (1)
67SourceText text,
src\Analyzers\CSharp\CodeFixes\NewLines\ConsecutiveBracePlacement\ConsecutiveBracePlacementCodeFixProvider.cs (1)
62SyntaxNode root, SourceText text,
src\Analyzers\CSharp\CodeFixes\UseCollectionExpression\CSharpCollectionExpressionRewriter.cs (1)
844var text = document.Text;
src\Analyzers\CSharp\CodeFixes\UseCollectionExpression\CSharpUseCollectionExpressionForArrayCodeFixProvider.cs (2)
56var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); 97static bool IsOnSingleLine(SourceText sourceText, SyntaxNode node)
src\Analyzers\CSharp\CodeFixes\UseCollectionExpression\CSharpUseCollectionExpressionForFluentCodeFixProvider.cs (2)
57var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); 149var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
StringIndentation\CSharpStringIndentationService.cs (4)
78SourceText text, SyntaxToken token, ref TemporaryArray<StringIndentationRegion> result, CancellationToken cancellationToken) 93SourceText text, InterpolatedStringExpressionSyntax interpolatedString, ref TemporaryArray<StringIndentationRegion> result, CancellationToken cancellationToken) 136private static bool IgnoreInterpolation(SourceText text, int offset, InterpolationSyntax interpolation) 157private static bool TryGetIndentSpan(SourceText text, ExpressionSyntax expression, out int offset, out TextSpan indentSpan)
Structure\Providers\ArgumentListStructureProvider.cs (1)
36var text = node.SyntaxTree.GetText(cancellationToken);
Structure\Providers\DisabledTextTriviaStructureProvider.cs (1)
71var text = syntaxTree.GetText(cancellationToken);
Structure\Providers\IfDirectiveTriviaStructureProvider.cs (1)
27SourceText? text = null;
Structure\Providers\StringLiteralExpressionStructureProvider.cs (1)
49var sourceText = node.SyntaxTree.GetText(cancellationToken);
UseExpressionBody\UseExpressionBodyCodeRefactoringProvider.cs (1)
94UseExpressionBodyHelper helper, SourceText text, SyntaxNode node, int position)
Microsoft.CodeAnalysis.CSharp.Features.UnitTests (13)
EditAndContinue\CSharpEditAndContinueAnalyzerTests.cs (13)
45AddDocument("test.cs", SourceText.From(source, Encoding.UTF8), filePath: Path.Combine(TempRoot.Root, "test.cs")).Project.Solution; 304var oldText = await oldDocument.GetTextAsync(); 307var newSolution = oldSolution.WithDocumentText(documentId, SourceText.From(source2)); 309var newText = await newDocument.GetTextAsync(); 372var newSolution = oldSolution.WithDocumentText(documentId, SourceText.From(source2)); 434var newSolution = oldSolution.WithDocumentText(documentId, SourceText.From(source2)); 516var newSolution = workspace.CurrentSolution.WithDocumentText(documentId, SourceText.From(source2)); 585var newSolution = oldSolution.WithDocumentText(documentId, SourceText.From(source2)); 624var newSolution = oldSolution.WithDocumentText(documentId, SourceText.From(source2)); 665var newSolution = oldSolution.AddDocument(newDocId, "goo.cs", SourceText.From(source2), filePath: Path.Combine(TempRoot.Root, "goo.cs")); 711var newSolution = oldSolution.AddDocument(newDocId, "goo.cs", SourceText.From(source2), filePath: Path.Combine(TempRoot.Root, "goo.cs")); 744var newSolution = oldSolution.AddDocument(documentId, "goo.cs", SourceText.From(source2), filePath: filePath); 799var newSolution = oldSolution.WithDocumentText(documentId, SourceText.From(source2));
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)
27SourceText text = tree.GetText(); 30SourceText newText = text.WithChanges(change);
Semantics\TopLevelStatementsTests.cs (2)
8788var 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)
460sgc.AddSource("test", SourceText.From("public class D{}", Encoding.UTF8)); 463Assert.Throws<ArgumentException>("hintName", () => sgc.AddSource("test", SourceText.From("public class D{}", Encoding.UTF8))); 466Assert.Throws<ArgumentException>("hintName", () => sgc.AddSource("test.cs", SourceText.From("public class D{}", Encoding.UTF8))); 491spc.AddSource("test", SourceText.From("public class D{}", Encoding.UTF8)); 494Assert.Throws<ArgumentException>("hintName", () => spc.AddSource("test", SourceText.From("public class D{}", Encoding.UTF8))); 497Assert.Throws<ArgumentException>("hintName", () => spc.AddSource("test.cs", SourceText.From("public class D{}", Encoding.UTF8))); 504spc.AddSource("test", SourceText.From("public class D{}", Encoding.UTF8)); 586var generator = new CallbackGenerator((ic) => { }, (sgc) => { sgc.AddSource("test", SourceText.From("public class D {}", Encoding.UTF8)); }); 616var 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)); }); 756e.AddSource("a", SourceText.From("public class E {}", Encoding.UTF8)); 780var generator = new CallbackGenerator((ic) => { }, (sgc) => { sgc.AddSource("a", SourceText.From("")); });
SourceGeneration\GeneratorDriverTests_Attributes_FullyQualifiedName.cs (6)
1525driver = driver.RunGenerators(compilation.AddSyntaxTrees(compilation.SyntaxTrees.First().WithChangedText(SourceText.From("")))); 1567driver = driver.RunGenerators(compilation.AddSyntaxTrees(compilation.SyntaxTrees.First().WithChangedText(SourceText.From(""" 1615driver = driver.RunGenerators(compilation.AddSyntaxTrees(compilation.SyntaxTrees.First().WithChangedText(SourceText.From(""" 1668driver = driver.RunGenerators(compilation.AddSyntaxTrees(compilation.SyntaxTrees.First().WithChangedText(SourceText.From(""" 1729compilation.SyntaxTrees.First().WithChangedText(SourceText.From(""" 1781compilation.SyntaxTrees.First().WithChangedText(SourceText.From("""
SourceGeneration\GeneratorDriverTests_Attributes_SimpleName.cs (8)
1160compilation.SyntaxTrees.Last().WithChangedText(SourceText.From(""" 1210compilation.SyntaxTrees.Last().WithChangedText(SourceText.From(""" 1266compilation.SyntaxTrees.First().WithChangedText(SourceText.From(""" 1423compilation.SyntaxTrees.First().WithChangedText(SourceText.From(""" 1468compilation.SyntaxTrees.First().WithChangedText(SourceText.From(""" 1520compilation.SyntaxTrees.First().WithChangedText(SourceText.From(""" 1571compilation.SyntaxTrees.First().WithChangedText(SourceText.From(""" 1633compilation.SyntaxTrees.Last().WithChangedText(SourceText.From("""
SourceGeneration\SyntaxAwareGeneratorTests.cs (3)
420onExecute: (e) => { e.AddSource("test", SourceText.From("public class D{}", Encoding.UTF8)); } 510onExecute: (e) => { receiver = e.SyntaxReceiver; e.AddSource("test", SourceText.From("public class D{}", Encoding.UTF8)); } 2052onExecute: (e) => { e.AddSource("test", SourceText.From("public class D{}", Encoding.UTF8)); }
Microsoft.CodeAnalysis.CSharp.Symbol.UnitTests (5)
DeclarationTests.cs (3)
973public override SourceText GetText(CancellationToken cancellationToken) 978public override bool TryGetText(out SourceText text) 1001public override SyntaxTree WithChangedText(SourceText newText)
Symbols\Metadata\MetadataTypeTests.cs (2)
363var oldIText = oldTree.GetText(); 367var newIText = oldIText.WithChanges(change);
Microsoft.CodeAnalysis.CSharp.Syntax.UnitTests (334)
Diagnostics\LineSpanDirectiveTests.cs (18)
27var textA = SourceText.From(sourceA); 73var textA = SourceText.From(sourceA); 166var textA = SourceText.From(sourceA); 217var textA = SourceText.From(sourceA); 245var textB = SourceText.From(sourceB); 286var textA = SourceText.From(sourceA); 335var textA = SourceText.From(sourceA); 389var textA = SourceText.From(sourceA); 471private static (string, string) GetTextMapping(SourceText mappedText, SyntaxTree unmappedText, SyntaxNode syntax) 484static string getMapping(SourceText mappedText, SyntaxTree unmappedText, SyntaxNode syntax)
Diagnostics\LocationsTests.cs (1)
76var text = tree.GetText();
IncrementalParsing\IncrementalParsingTests.cs (227)
29var itext = SourceText.From(text); 36var itext = SourceText.From(text); 495var text = tree.GetText(); 527var text = tree.GetText(); 568var text = tree.GetText(); 619var initialText = initialTree.GetText(); 627var withOpenBraceDeletedText = initialText.WithChanges(new TextChange(openBraceLine.SpanIncludingLineBreak, "")); 838var withCloseBraceDeletedText = withOpenBraceDeletedText.WithChanges(new TextChange(closeBraceLine.SpanIncludingLineBreak, "")); 961var text = SourceText.From(@"partial class C{}"); 965var newText = text.WithChanges(new TextChange(new TextSpan(0, 8), "")); 975var text = SourceText.From(@"partial class C{}"); 979var newText = text.WithChanges(new TextChange(new TextSpan(0, 8), "")); 989SourceText oldText = SourceText.From(@" 1005SourceText oldText = SourceText.From(@" 1021SourceText oldText = SourceText.From(@" 1038SourceText oldText = SourceText.From(@" 1054SourceText oldText = SourceText.From(@" 1067SourceText oldText = SourceText.From(@" 1083SourceText oldText = SourceText.From(@" 1095SourceText oldText = SourceText.From(@" 1107SourceText oldText = SourceText.From(@" class A 1123SourceText oldText = SourceText.From(@"public class TestClass 1136SourceText oldText = SourceText.From(@"using System; 1151SourceText oldText = SourceText.From(@"public class MyClass { 1163SourceText oldText = SourceText.From(@" 1177SourceText startingText = SourceText.From(@" 1198SourceText startingText = SourceText.From(@" 1217SourceText startingText = SourceText.From(@" 1237SourceText oldText = SourceText.From(@"class MyClass 1257SourceText oldText = SourceText.From(@" 1281SourceText oldText = SourceText.From(@" 1305SourceText oldText = SourceText.From(@"interface IGoo 1329SourceText oldText = SourceText.From(@"interface IGoo 1353SourceText oldText = SourceText.From(@"using System.Runtime.CompilerServices; 1375SourceText oldText = SourceText.From(@"class A 1399SourceText oldText = SourceText.From(@"public class MyClass { 1421SourceText oldText = SourceText.From(@"public class MyClass { 1512SourceText oldText = SourceText.From(@"class filesystem{ 1531SourceText oldText = SourceText.From(@"class CSTR020mod{ public static void CSTR020() { ON ERROR GOTO ErrorTrap; } }"); 1547SourceText oldText = SourceText.From(@"class A 1567SourceText oldText = SourceText.From(@"public class DynClassDrived 1589SourceText oldText = SourceText.From(@"public class MemberClass 1609SourceText oldText = SourceText.From(@"public class MemberClass 1628SourceText oldText = SourceText.From(@"class Test 1650SourceText oldText = SourceText.From( 1677SourceText oldText = SourceText.From( 1703SourceText oldText = SourceText.From( 1728SourceText oldText = SourceText.From( 1750SourceText oldText = SourceText.From( 1805SourceText oldText = SourceText.From( 1827SourceText oldText = SourceText.From( 1848SourceText oldText = SourceText.From( 1869SourceText oldText = SourceText.From( 1892SourceText oldText = SourceText.From( 1913SourceText oldText = SourceText.From( 1933SourceText oldText = SourceText.From( 1951SourceText oldText = SourceText.From( 1972SourceText oldText = SourceText.From( 1995SourceText oldText = SourceText.From( 2012SourceText oldText = SourceText.From( 2030SourceText oldText = SourceText.From( 2048SourceText oldText = SourceText.From( 2069SourceText oldText = SourceText.From( 2104SourceText oldText = SourceText.From( 2128SourceText oldText = SourceText.From( 2146SourceText oldText = SourceText.From( 2164SourceText oldText = SourceText.From( 2183SourceText oldText = SourceText.From( 2214SourceText oldText = SourceText.From( 2239SourceText oldText = SourceText.From( 2258SourceText oldText = SourceText.From( 2276SourceText oldText = SourceText.From( 2295SourceText oldText = SourceText.From( 2314SourceText oldText = SourceText.From( 2335SourceText oldText = SourceText.From( 2354SourceText oldText = SourceText.From( 2381SourceText oldText = SourceText.From( 2409SourceText oldText = SourceText.From( 2431SourceText oldText = SourceText.From( 2450SourceText oldText = SourceText.From( 2482SourceText oldText = SourceText.From( 2515SourceText oldText = SourceText.From( 2541SourceText oldText = SourceText.From( 2566SourceText oldText = SourceText.From( 2596SourceText oldText = SourceText.From( 2625SourceText oldText = SourceText.From( 2646SourceText oldText = SourceText.From( 2678SourceText oldText = SourceText.From( 2706SourceText oldText = SourceText.From( 2744var text = SourceText.From(str); 2747var text2 = text.WithChanges( 2762SourceText oldText = SourceText.From(@" 2770var newText = oldText.WithChanges(new TextChange(new TextSpan(0, 0), "{")); 2780SourceText oldText = SourceText.From(@"System.Console.WriteLine(true) 2786var newText = oldText.WithChanges(new TextChange(new TextSpan(0, 0), @"System.Console.WriteLine(false) 2809SourceText oldText = SourceText.From(@"System.Console.WriteLine(true) 2815var newText = oldText.WithInsertAt( 2839SourceText oldText = SourceText.From(@"System.Console.WriteLine(true) 2845var newText = oldText.WithChanges(new TextChange(new TextSpan(0, 0), @"if (false) 2899var oldIText = oldTree.GetText(); 2903var newIText = oldIText.WithChanges(change); 2977var currIText = currTree.GetText(); 3017var currIText = currTree.GetText(); 3097var oldText = SourceText.From(items[0]); 3101var newText = oldText.WithChanges(change); // f is a method decl parameter 3128var oldText = SourceText.From(@" 3154var newText = SourceText.From(@" 3197var text = tree.GetText(); 3218var text = tree.GetText(); 3239var text = tree.GetText(); 3260var text = tree.GetText(); 3281var text = tree.GetText(); 3302var text = tree.GetText(); 3326var text = tree.GetText(); 3350var text = tree.GetText(); 3374var text = tree.GetText(); 3398var text = tree.GetText(); 3422var text = tree.GetText(); 3448var text = tree.GetText(); 3474var text = tree.GetText(); 3499var text = tree.GetText(); 3525var text = tree.GetText(); 3543var text = tree.GetText(); 3561var text = tree.GetText(); 3579var text = tree.GetText(); 3594var text = tree.GetText(); 3608var text = tree.GetText(); 3622var text = tree.GetText(); 3660var text = tree.GetText(); 3687private static void CommentOutText(SourceText oldText, int locationOfChange, int widthOfChange, out SyntaxTree incrementalTree, out SyntaxTree parsedTree) 3689var newText = oldText.WithChanges( 3699private static void RemoveText(SourceText oldText, int locationOfChange, int widthOfChange, out SyntaxTree incrementalTree, out SyntaxTree parsedTree) 3701var newText = oldText.WithChanges(new TextChange(new TextSpan(locationOfChange, widthOfChange), "")); 3721private static void CharByCharIncrementalParse(SourceText oldText, char newChar, out SyntaxTree incrementalTree, out SyntaxTree parsedTree) 3727var newText = oldText.WithChanges(new TextChange(new TextSpan(oldText.Length, 0), newChar.ToString())); 3732private static void TokenByTokenBottomUp(SourceText oldText, string token, out SyntaxTree incrementalTree, out SyntaxTree parsedTree) 3735SourceText 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)
73using (var lexer = new InternalSyntax.Lexer(SourceText.From(text), _options)) 86using (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\SyntaxTokenParserTests.cs (32)
19var sourceText = SourceText.From("class C { }"); 29var sourceText = SourceText.From(""" 66var sourceText = SourceText.From(""" 110var sourceText = SourceText.From(""" 149var sourceText = SourceText.From(""" 183var sourceText = SourceText.From("""class"""); 193var sourceText = SourceText.From("class C { }"); 202var sourceText = SourceText.From("class C { }"); 212var sourceText = SourceText.From(""" 261var sourceText = SourceText.From("when identifier class"); 272var sourceText = SourceText.From("class C { }"); 291var sourceText = SourceText.From("/* test */ class C { }"); 320var sourceText = SourceText.From(""" 354var sourceText = SourceText.From("class C { }"); 368var sourceText = SourceText.From("/* test */ class C { }"); 387var sourceText = SourceText.From("""
LexicalAndXml\XmlDocCommentTests.cs (2)
34var itext = SourceText.From(text);
Parsing\ParsingTests.cs (1)
371var 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)
45var text = SyntaxFactory.SyntaxTree(SyntaxFactory.CompilationUnit(), encoding: null).GetText(); 53var text = SyntaxFactory.CompilationUnit().SyntaxTree.GetText();
Syntax\SyntaxNodeTests.cs (1)
3588SourceText 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)
41var 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 (26)
Classification\ClassificationHelpers.cs (2)
498internal static void AddLexicalClassifications(SourceText text, TextSpan textSpan, SegmentedList<ClassifiedSpan> result, CancellationToken cancellationToken) 506internal static ClassifiedSpan AdjustStaleClassification(SourceText rawText, ClassifiedSpan classifiedSpan)
Classification\CSharpClassificationService.cs (2)
21public override void AddLexicalClassifications(SourceText text, TextSpan textSpan, SegmentedList<ClassifiedSpan> result, CancellationToken cancellationToken) 24public override ClassifiedSpan AdjustStaleClassification(SourceText text, ClassifiedSpan classifiedSpan)
Classification\SyntaxClassification\CSharpSyntaxClassificationService.cs (2)
36public override void AddLexicalClassifications(SourceText text, TextSpan textSpan, SegmentedList<ClassifiedSpan> result, CancellationToken cancellationToken) 47public override ClassifiedSpan FixClassification(SourceText rawText, ClassifiedSpan classifiedSpan)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\EmbeddedLanguages\VirtualChars\CSharpVirtualCharService.cs (3)
188var parentSourceText = parentExpression.SyntaxTree.GetText(); 193var tokenSourceText = SourceText.From(token.Text);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxNodeExtensions.cs (2)
59this SyntaxNode node, SourceText? sourceText = null, 69this SyntaxToken token, SourceText? sourceText = null,
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxTokenExtensions.cs (1)
160public static bool IsFirstTokenOnLine(this SyntaxToken token, SourceText text)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxTreeExtensions.cs (1)
347var sourceText = token.SyntaxTree!.GetText(cancellationToken);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Indentation\CSharpSmartTokenFormatter.cs (2)
29private readonly SourceText _text; 35SourceText text)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\FormattingRangeHelper.cs (1)
300if (tree != null && tree.TryGetText(out var text))
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeRefactorings\CSharpRefactoringHelpersService.cs (1)
29public override bool IsBetweenTypeMembers(SourceText sourceText, SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? typeDeclaration)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Indentation\CSharpIndentationService.cs (1)
145var text = node.SyntaxTree.GetText();
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Indentation\CSharpIndentationService.Indenter.cs (1)
29CompilationUnitSyntax root, SourceText text, TextLine lineToBeIndented,
Workspace\LanguageServices\CSharpSyntaxTreeFactoryService.cs (2)
58public override SyntaxTree CreateSyntaxTree(string filePath, ParseOptions options, SourceText text, Encoding encoding, SourceHashAlgorithm checksumAlgorithm, SyntaxNode root) 64public override SyntaxTree ParseSyntaxTree(string filePath, ParseOptions options, SourceText text, CancellationToken cancellationToken)
Workspace\LanguageServices\CSharpSyntaxTreeFactoryService.ParsedSyntaxTree.cs (5)
15/// Parsed <see cref="CSharpSyntaxTree"/> that creates <see cref="SourceText"/> with given encoding and checksum algorithm. 26private SourceText? _lazyText; 29SourceText? lazyText, 45public override SourceText GetText(CancellationToken cancellationToken) 55public override bool TryGetText([NotNullWhen(true)] out SourceText? text)
Microsoft.CodeAnalysis.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 (106)
AutomaticCompletion\AbstractAutomaticLineEnderCommandHandler.cs (1)
176var text = document.Text;
Classification\Syntactic\SyntacticClassificationTaggerProvider.TagComputer.cs (1)
543var currentText = currentSnapshot.AsText();
CommentSelection\AbstractCommentSelectionBase.cs (1)
148var newText = subjectBuffer.CurrentSnapshot.AsText();
CommentSelection\CommentUncommentSelectionCommandHandler.cs (1)
236var text = span.Snapshot.AsText();
CommentSelection\ToggleBlockCommentCommandHandler.cs (1)
41var allText = snapshot.AsText();
EditAndContinue\ActiveStatementTrackingService.cs (1)
299if (!document.TryGetText(out var source))
Editor\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)
EditorConfigSettings\DataProvider\CombinedProvider.cs (2)
15public async Task<SourceText> GetChangedEditorConfigAsync(SourceText sourceText)
EditorConfigSettings\DataProvider\ISettingsProvider.cs (2)
15Task<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)
13Task<SourceText> UpdateEditorConfigAsync(SourceText sourceText);
EditorConfigSettings\Updater\AnalyzerSettingsUpdater.cs (2)
14protected override SourceText? GetNewText(SourceText sourceText,
EditorConfigSettings\Updater\ISettingUpdater.cs (2)
14Task<SourceText?> GetChangedEditorConfigAsync(SourceText sourceText, CancellationToken token);
EditorConfigSettings\Updater\NamingStyles\NamingStyleSettingsUpdater.cs (4)
24protected override SourceText? GetNewText( 25SourceText analyzerConfigDocument, 90static SourceText UpdateDocument(SourceText sourceText, string newLine, TextSpan? potentialSpan, TextSpan backupSpan)
EditorConfigSettings\Updater\NamingStyles\SourceTextExtensions.cs (6)
24public static SourceText WithNamingStyles(this SourceText sourceText, IGlobalOptionService globalOptions) 33private static SourceText WithNamingStyles(SourceText sourceText, IEnumerable<NamingRule> rules, Language language) 57static SourceText WithChanges(SourceText sourceText, TextSpan span, string newText)
EditorConfigSettings\Updater\OptionUpdater.cs (2)
14protected 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 (8)
24protected abstract SourceText? GetNewText(SourceText analyzerConfigDocument, IReadOnlyList<(TOption option, TValue value)> settingsToUpdate, CancellationToken token); 50public async Task<SourceText?> GetChangedEditorConfigAsync(AnalyzerConfigDocument? analyzerConfigDocument, CancellationToken token) 58var newText = GetNewText(originalText, _queue, token); 78var newText = await GetChangedEditorConfigAsync(analyzerConfigDocument, token).ConfigureAwait(false); 88public async Task<SourceText?> GetChangedEditorConfigAsync(SourceText originalText, CancellationToken token) 92var newText = GetNewText(originalText, _queue, token);
InlineRename\InlineRenameSession.cs (5)
201private class NullTextBufferException(Document document, SourceText text) : Exception("Cannot retrieve textbuffer from document.") 205private readonly SourceText _text = text; 925async Task<ImmutableArray<(DocumentId documentId, string newName, SyntaxNode newRoot, SourceText newText)>> CalculateFinalDocumentChangesAsync( 931using var _ = PooledObjects.ArrayBuilder<(DocumentId documentId, string newName, SyntaxNode newRoot, SourceText newText)>.GetInstance(out var result); 952ImmutableArray<(DocumentId documentId, string newName, SyntaxNode newRoot, SourceText newText)> documentChanges)
InlineRename\InlineRenameSession.OpenTextBufferManager.cs (4)
214var sourceText = document.GetTextSynchronously(CancellationToken.None); 409var firstDocumentNewText = conflictResolution.NewSolution.GetDocument(firstDocumentReplacements.document.Id).GetTextSynchronously(cancellationToken); 418var documentNewText = conflictResolution.NewSolution.GetDocument(document.Id).GetTextSynchronously(cancellationToken); 597var preMergeDocumentText = preMergeDocument.GetTextSynchronously(cancellationToken);
IntelliSense\AsyncCompletion\CompletionSource.cs (4)
133var sourceText = document.GetTextSynchronously(cancellationToken); 152SourceText sourceText, 173ITextBuffer buffer, int caretPoint, SourceText text, LanguageServices services, CompletionRules rules) 596SourceText text, int questionPosition, ISyntaxFactsService syntaxFacts)
Interactive\InteractiveSession.cs (1)
207var newSubmissionText = submissionBuffer.CurrentSnapshot.AsText();
Interactive\InteractiveWorkspace.cs (2)
35protected override void ApplyDocumentTextChanged(DocumentId document, SourceText newText) 47var oldText = _openTextContainer.CurrentText;
Navigation\IDocumentNavigationServiceExtensions.cs (1)
85var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
Preview\AbstractPreviewFactoryService.cs (2)
794var oldText = oldDocument.GetTextSynchronously(cancellationToken); 795var newText = newDocument.GetTextSynchronously(cancellationToken);
RenameTracking\RenameTrackingTaggerProvider.cs (2)
74document.TryGetText(out var text)) 112if (document != null && document.TryGetText(out var text))
RenameTracking\RenameTrackingTaggerProvider.RenameTrackingCodeAction.cs (1)
89if (_document.TryGetText(out var text))
RenameTracking\RenameTrackingTaggerProvider.RenameTrackingCommitter.cs (2)
186var fullText = syntaxTree.GetText(cancellationToken); 189var newFullText = fullText.WithChanges(textChange);
RenameTracking\RenameTrackingTaggerProvider.StateMachine.cs (2)
172var beforeText = eventArgs.Before.AsText(); 287Document document, SourceText text, TextSpan userSpan,
SemanticSearch\SemanticSearchEditorWorkspace.cs (2)
44protected override void ApplyDocumentTextChanged(DocumentId documentId, SourceText newText) 52protected override void ApplyQueryDocumentTextChanged(SourceText newText)
Shared\Utilities\VirtualTreePoint.cs (2)
14public VirtualTreePoint(SyntaxTree tree, SourceText text, int position, int virtualSpaces = 0) 47public SourceText Text { get; }
TextDiffing\TextDifferencingServiceExtensions.cs (2)
13public static IHierarchicalDifferenceCollection DiffSourceTexts(this ITextDifferencingService diffService, SourceText oldText, SourceText newText, StringDifferenceOptions options)
Undo\DefaultSourceTextUndoService.cs (1)
24public ISourceTextUndoTransaction RegisterUndoTransaction(SourceText sourceText, string description)
Undo\EditorSourceTextUndoService.cs (5)
23private readonly Dictionary<SourceText, SourceTextUndoTransaction> _transactions = []; 27public ISourceTextUndoTransaction RegisterUndoTransaction(SourceText sourceText, string description) 41var sourceText = snapshot?.AsText(); 65private sealed class SourceTextUndoTransaction(ISourceTextUndoService service, SourceText sourceText, string description) : ISourceTextUndoTransaction 68public SourceText SourceText { get; } = sourceText;
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)
32public SourceText CreateText(Stream stream, Encoding? defaultEncoding, SourceHashAlgorithm checksumAlgorithm, CancellationToken cancellationToken) 65public SourceText CreateText(TextReader reader, Encoding? encoding, SourceHashAlgorithm checksumAlgorithm, CancellationToken cancellationToken) 77private SourceText CreateTextInternal(Stream stream, Encoding encoding, SourceHashAlgorithm checksumAlgorithm, CancellationToken cancellationToken)
Microsoft.CodeAnalysis.EditorFeatures.Test.Utilities (27)
BracePairs\AbstractBracePairsTests.cs (1)
33var text = await document.GetTextAsync();
Completion\AbstractCompletionProviderTests.cs (4)
656var text = await document.GetTextAsync(); 657var newText = text.WithChanges(commit.TextChange); 744var text = await document.GetTextAsync(); 1274var text = hostDocument.GetTextBuffer().CurrentSnapshot.AsText();
LanguageServer\AbstractLanguageServerProtocolTests.cs (8)
174private protected static string ApplyTextEdits(LSP.TextEdit[] edits, SourceText originalMarkup) 176var text = originalMarkup; 350solution = solution.WithDocumentText(document.Id, SourceText.From(documentText.ToString(), System.Text.Encoding.UTF8, SourceHashAlgorithms.Default)); 417var loader = TextLoader.From(TextAndVersion.Create(SourceText.From(markup), version, TestSpanMapper.GeneratedFileName)); 477static LSP.Location ConvertTextSpanWithTextToLocation(TextSpan span, SourceText text, Uri documentUri) 660public async Task<SourceText> GetDocumentTextAsync(Uri uri) 701var sourceText = await GetDocumentTextAsync(documentUri).ConfigureAwait(false); 793internal ImmutableArray<SourceText> GetTrackedTexts() => GetManager().GetTrackedLspText().Values.Select(v => v.Text).ToImmutableArray();
ObsoleteSymbol\AbstractObsoleteSymbolTests.cs (1)
34var text = await document.GetTextAsync();
ReassignedVariable\AbstractReassignedVariableTests.cs (1)
33var 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)
31var sourceText = document.GetTextBuffer().CurrentSnapshot.AsText();
Workspaces\EditorTestHostDocument.cs (2)
215internal void Update(SourceText newText) 219var oldText = buffer.CurrentSnapshot.AsText();
Workspaces\EditorTestWorkspace.cs (3)
135protected override void ApplyDocumentTextChanged(DocumentId document, SourceText newText) 142protected override void ApplyAdditionalDocumentTextChanged(DocumentId document, SourceText newText) 149protected override void ApplyAnalyzerConfigDocumentTextChanged(DocumentId document, SourceText newText)
Microsoft.CodeAnalysis.EditorFeatures.Text (20)
Extensions.cs (6)
24/// Returns the <see cref="ITextSnapshot"/> behind this <see cref="SourceText"/>, or null if it wasn't created from one. 26/// Note that multiple <see cref="ITextSnapshot"/>s may map to the same <see cref="SourceText"/> instance if it's 30public static ITextSnapshot? FindCorrespondingEditorTextSnapshot(this SourceText? text) 33internal static ITextImage? TryFindCorrespondingEditorTextImage(this SourceText? text) 39public static SourceText AsText(this ITextSnapshot textSnapshot) 45internal static SourceText AsRoslynText(this ITextSnapshot textSnapshot, ITextBufferCloneService textBufferCloneServiceOpt, Encoding? encoding, SourceHashAlgorithm checksumAlgorithm)
Extensions.SnapshotSourceText.cs (5)
71public static SourceText From(ITextBufferCloneService? textBufferCloneService, ITextSnapshot editorSnapshot) 95internal static SourceText From(ITextBufferCloneService? textBufferCloneService, ITextSnapshot editorSnapshot, TextBufferContainer container) 185public override SourceText WithChanges(IEnumerable<TextChange> changes) 288public override IReadOnlyList<TextChangeRange> GetChangeRanges(SourceText oldText) 318public 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)
28/// get new <see cref="ITextBuffer"/> from <see cref="SourceText"/> with <see cref="ContentTypeNames.RoslynContentType"/> 30ITextBuffer CloneWithRoslynContentType(SourceText sourceText); 33/// get new <see cref="ITextBuffer"/> from <see cref="SourceText"/> with <see cref="IContentType"/> 35ITextBuffer 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 (50)
CodeFixes\CodeFixServiceTests.cs (6)
922var text = context.AdditionalFile.GetText(context.CancellationToken); 948var text = await document.GetTextAsync(ct).ConfigureAwait(false); 949var newText = SourceText.From(text.ToString() + Title); 1069sourceDocument = sourceDocument.WithText(SourceText.From(code)); 1155var text = await sourceDocument.GetTextAsync();
CodeGeneration\AbstractCodeGenerationTests.cs (1)
36.AddDocument("Fake Document", SourceText.From(normalizedSyntax));
CodeRefactorings\CodeRefactoringServiceTest.cs (5)
206.AddAnalyzerConfigDocument(".editorconfig", SourceText.From(""), filePath: "c:\\.editorconfig").Project 207.AddAnalyzerConfigDocument(".globalconfig", SourceText.From("is_global = true"), filePath: "c:\\.globalconfig").Project; 245var text = await document.GetTextAsync(ct).ConfigureAwait(false); 246var newText = SourceText.From(text.ToString() + Title);
Completion\CompletionServiceTests.cs (2)
101public override bool ShouldTriggerCompletion(SourceText text, int caretPosition, CompletionTrigger trigger, OptionSet options) 137var text = root.GetText();
Diagnostics\DiagnosticAnalyzerServiceTests.cs (8)
173project = project.AddAnalyzerConfigDocument(".editorconfig", filePath: "z:\\.editorconfig", text: SourceText.From(editorconfigText)).Project; 176var document = project.AddDocument("test.cs", SourceText.From("class A {}"), filePath: "z:\\test.cs"); 312loader: TextLoader.From(TextAndVersion.Create(SourceText.From("class A {}"), VersionStamp.Create(), filePath: "test.cs")), 361text: SourceText.From(analyzerConfigText), 391loader: TextLoader.From(TextAndVersion.Create(SourceText.From("class A {}"), VersionStamp.Create(), filePath: "test.cs")), 469var text = await additionalDoc.GetTextAsync(); 634var text = await document.GetTextAsync(); 891return workspace.AddDocument(project.Id, "Empty.cs", SourceText.From("class A { B B {get} }"));
Diagnostics\DiagnosticDataTests.cs (1)
128var text = await document.GetTextAsync();
EditAndContinue\EditAndContinueLanguageServiceTests.cs (5)
77public SourceText Text { get; set; } 79public override SourceText CurrentText => Text; 119.AddDocument(documentId = DocumentId.CreateNewId(projectId), "test.cs", SourceText.From("class C { }", Encoding.UTF8), filePath: "test.cs")); 262var document1 = await solution.GetDocument(documentId).GetTextAsync(); 270Text = SourceText.From(source3, Encoding.UTF8, SourceHashAlgorithm.Sha1)
EditorAdapter\TextSnapshotImplementationTest.cs (5)
19private static Tuple<ITextSnapshot, SourceText> Create(params string[] lines) 23var text = buffer.CurrentSnapshot.AsText(); 31var text = tuple.Item2; 41var text = tuple.Item2; 52var text = tuple.Item2;
Extensions\ITextExtensionsTests.cs (2)
129var text = SourceText.From(code);
Extensions\ITextLineExtensionsTests.cs (2)
129var text = SourceText.From(codeLine);
LinkedFiles\LinkedFileDiffMergingEditorTests.cs (1)
104var sourceText = await linkedDocument.GetTextAsync();
MetadataAsSource\AbstractMetadataAsSourceTests.cs (1)
60var text = await document.GetTextAsync();
Preview\PreviewWorkspaceTests.cs (2)
80var changedSolution = previewWorkspace.CurrentSolution.Projects.First().Documents.First().WithText(SourceText.From(text)).Project.Solution; 100var sourceTextContainer = SourceText.From("Text").Container;
SymbolFinder\DependentTypeFinderTests.cs (1)
40return solution.AddProject(pi).AddDocument(did, $"{projectName}.{suffix}", SourceText.From(code));
TextEditor\TryGetDocumentTests.cs (3)
42var newSourceText = newDocument.GetTextAsync().Result; 58var text = buffer.CurrentSnapshot.AsText(); 72var newText = buffer.CurrentSnapshot.AsText();
Workspaces\TextFactoryTests.cs (5)
85var text = SourceText.From("Hello, World!"); 105var text = SourceText.From("Hello, World!", Encoding.ASCII); 121var text = textFactoryService.CreateText(stream, defaultEncoding, SourceHashAlgorithms.Default, CancellationToken.None);
Microsoft.CodeAnalysis.EditorFeatures.Wpf (4)
InlineDiagnostics\AbstractDiagnosticsTaggerProvider.SingleDiagnosticKindPullTaggerProvider.cs (1)
116var sourceText = snapshot.AsText();
QuickInfo\Extensions.cs (3)
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)"/>
Microsoft.CodeAnalysis.EditorFeatures2.UnitTests (26)
Classification\ClassificationTests.vb (3)
239Private Shared Function ToTestString(text As SourceText, span As ClassifiedSpan) As String 342Public Sub AddLexicalClassifications(text As SourceText, textSpan As TextSpan, result As SegmentedList(Of ClassifiedSpan), cancellationToken As CancellationToken) Implements IClassificationService.AddLexicalClassifications 356Public Function AdjustStaleClassification(text As SourceText, classifiedSpan As ClassifiedSpan) As ClassifiedSpan Implements IClassificationService.AdjustStaleClassification
Diagnostics\AdditionalFileDiagnosticsTests.vb (2)
45Dim newSln = workspace.CurrentSolution.AddAdditionalDocument(DocumentId.CreateNewId(project.Id), "App.Config", SourceText.From("false")) 120Dim newSln = appConfigDoc.Project.Solution.WithAdditionalDocumentText(appConfigDoc.Id, SourceText.From("true", text.Encoding))
Diagnostics\DiagnosticServiceTests.vb (1)
1418additionalDoc = additionalDoc.WithText(SourceText.From(newAdditionalDocText))
FindReferences\FindReferencesTests.vb (3)
404Dim text As SourceText = Nothing 523solution = solution.WithDocumentText(document2.Id, SourceText.From("")) 532solution = 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)
4207Public Overrides Function IsInsertionTrigger(text As SourceText, characterPosition As Integer, options As CompletionOptions) As Boolean 8225Public Overrides Function ShouldTriggerCompletion(text As SourceText, caretPosition As Integer, trigger As CompletionTrigger, options As OptionSet) As Boolean 8270Public Overrides Function ShouldTriggerCompletion(text As SourceText, caretPosition As Integer, trigger As CompletionTrigger, options As OptionSet) As Boolean 9612Public Overrides Function ShouldTriggerCompletion(text As SourceText, caretPosition As Integer, trigger As CompletionTrigger, options As OptionSet) As Boolean 10273Public Overrides Function IsInsertionTrigger(text As SourceText, characterPosition As Integer, options As CompletionOptions) As Boolean 10346Public Overrides Function IsInsertionTrigger(text As SourceText, characterPosition As Integer, options As CompletionOptions) As Boolean 10639Public Overrides Function IsInsertionTrigger(text As SourceText, characterPosition As Integer, options As CompletionOptions) As Boolean 10775Public Overrides Function ShouldTriggerCompletion(text As SourceText, caretPosition As Integer, trigger As CompletionTrigger, options As OptionSet) As Boolean
IntelliSense\CSharpCompletionCommandHandlerTests_DefaultsSource.vb (2)
440Public Overrides Function ShouldTriggerCompletion(text As SourceText, caretPosition As Integer, trigger As CompletionTrigger, options As OptionSet) As Boolean 688text As SourceText,
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 (12)
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)
35public void AddLexicalClassifications(SourceText text, TextSpan textSpan, SegmentedList<ClassifiedSpan> result, CancellationToken cancellationToken) 62public 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);
Microsoft.CodeAnalysis.ExternalAccess.OmniSharp (2)
DocumentationComments\OmniSharpDocumentationCommentsSnippetService.cs (2)
19SourceText text, 31SourceText 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 (144)
AddImport\CodeActions\InstallPackageAndAddImportCodeAction.cs (4)
98SourceText oldText, 99SourceText newText, 103private readonly SourceText _oldText = oldText; 104private readonly SourceText _newText = 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)
ClassifiedSpansAndHighlightSpanFactory.cs (1)
44private static TextSpan GetLineSpanForReference(SourceText sourceText, TextSpan referenceSpan)
CodeFixes\Configuration\ConfigurationUpdater.cs (7)
274var newText = GetNewAnalyzerConfigDocumentText(originalText, editorConfigDocument); 396private SourceText? GetNewAnalyzerConfigDocumentText(SourceText originalText, AnalyzerConfigDocument editorConfigDocument) 416private (SourceText? newText, TextLine? lastValidHeaderSpanEnd, TextLine? lastValidSpecificHeaderSpanEnd) CheckIfRuleExistsAndReplaceInFile( 417SourceText result, 674private SourceText? AddMissingRule( 675SourceText result,
CodeFixes\Suppression\AbstractSuppressionBatchFixAllProvider.cs (3)
270private static async Task<ImmutableArray<(DocumentId documentId, SourceText newText)>> GetDocumentIdToFinalTextAsync( 283var documentIdToFinalText = new ConcurrentDictionary<DocumentId, SourceText>(); 298ConcurrentDictionary<DocumentId, SourceText> documentIdToFinalText,
CodeRefactorings\AddMissingImports\AbstractAddMissingImportsFeatureService.cs (3)
29protected abstract ImmutableArray<AbstractFormattingRule> GetFormatRules(SourceText text); 249protected sealed class CleanUpNewLinesFormatter(SourceText text) : AbstractFormattingRule 251private readonly SourceText _text = text;
Completion\CommonCompletionProvider.cs (4)
34public sealed override bool ShouldTriggerCompletion(SourceText text, int caretPosition, CompletionTrigger trigger, OptionSet options) 42internal override bool ShouldTriggerCompletion(LanguageServices languageServices, SourceText text, int caretPosition, CompletionTrigger trigger, CompletionOptions options, OptionSet passThroughOptions) 45private bool ShouldTriggerCompletionImpl(SourceText text, int caretPosition, CompletionTrigger trigger, in CompletionOptions options) 50public virtual bool IsInsertionTrigger(SourceText text, int insertedCharacterPosition, CompletionOptions options)
Completion\CommonCompletionUtilities.cs (4)
27public static TextSpan GetWordSpan(SourceText text, int position, 33public static TextSpan GetWordSpan(SourceText text, int position, 60public static bool IsStartingNewWord(SourceText text, int characterPosition, Func<char, bool> isWordStartCharacter, Func<char, bool> isWordCharacter) 207internal 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 (4)
95SourceText text, 134SourceText text, 175public virtual TextSpan GetDefaultItemSpan(SourceText text, int caretPosition) 178public virtual TextSpan GetDefaultCompletionListSpan(SourceText text, int caretPosition)
Completion\CompletionService_GetCompletions.cs (2)
130Document document, ConcatImmutableArray<CompletionProvider> providers, int caretPosition, CompletionOptions options, CompletionTrigger trigger, ImmutableHashSet<string>? roles, SourceText text) 190Document 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\AbstractInternalsVisibleToCompletionProvider.cs (2)
26public sealed override bool IsInsertionTrigger(SourceText text, int insertedCharacterPosition, CompletionOptions options) 51protected abstract bool ShouldTriggerAfterQuotes(SourceText text, int insertedCharacterPosition);
Completion\Providers\AbstractMemberInsertingCompletionProvider.cs (1)
170var text = insertionRoot.GetText();
Completion\Providers\AbstractOverrideCompletionProvider.cs (2)
20public abstract bool TryDetermineModifiers(SyntaxToken startToken, SourceText text, int startLine, out Accessibility seenAccessibility, out DeclarationModifiers modifiers); 67protected static bool IsOnStartLine(int position, SourceText text, int startLine)
Completion\Providers\AbstractOverrideCompletionProvider.ItemGetter.cs (2)
30private readonly SourceText _text; 38SourceText text,
Completion\Providers\EmbeddedLanguageCompletionProvider.cs (1)
22public abstract bool ShouldTriggerCompletion(SourceText text, int caretPosition, CompletionTrigger trigger);
Completion\Providers\Scripting\AbstractDirectivePathCompletionProvider.cs (1)
66public sealed override bool ShouldTriggerCompletion(SourceText text, int caretPosition, CompletionTrigger trigger, OptionSet options)
Completion\Utilities.cs (1)
18public static TextChange Collapse(SourceText newText, ImmutableArray<TextChange> changes)
DocumentationComments\AbstractDocumentationCommentSnippetService.cs (8)
58var text = document.Text; 87private List<string>? GetDocumentationCommentLines(SyntaxToken token, SourceText text, in DocumentationCommentOptions options, out string? indentText, out int caretOffset, out int spanToReplaceLength) 118private List<string>? GetDocumentationCommentLinesNoIndentation(SyntaxToken token, SourceText text, in DocumentationCommentOptions options, out int caretOffset, out int spanToReplaceLength) 134private List<string>? GetDocumentationStubLines(SyntaxToken token, SourceText text, in DocumentationCommentOptions options, out int caretOffset, out int spanToReplaceLength, out string? existingCommentText) 178var text = document.Text; 255var text = document.Text; 298var text = document.Text; 338var text = document.Text;
EditAndContinue\AbstractEditAndContinueAnalyzer.cs (8)
509private static readonly SourceText s_emptySource = SourceText.From(""); 539SourceText oldText; 713static void LogRudeEdits(ArrayBuilder<RudeEditDiagnostic> diagnostics, SourceText text, string filePath) 784SourceText newText, 938SourceText newText, 1307private static bool TryGetTrackedStatement(ImmutableArray<ActiveStatementLineSpan> activeStatementSpans, ActiveStatementId id, SourceText text, MemberBody body, [NotNullWhen(true)] out SyntaxNode? trackedStatement, out int trackedStatementPart) 2505SourceText newText,
EditAndContinue\ActiveStatementsMap.cs (2)
180internal ImmutableArray<UnmappedActiveStatement> GetOldActiveStatements(IEditAndContinueAnalyzer analyzer, SyntaxTree oldSyntaxTree, SourceText oldText, SyntaxNode oldRoot, CancellationToken cancellationToken) 190private ImmutableArray<UnmappedActiveStatement> CalculateOldActiveStatementsAndExceptionRegions(IEditAndContinueAnalyzer analyzer, SyntaxTree oldTree, SourceText oldText, SyntaxNode oldRoot, CancellationToken cancellationToken)
EditAndContinue\CommittedSolution.cs (9)
309private async ValueTask<(Optional<SourceText?> matchingSourceText, bool? hasDocument)> TryGetMatchingSourceTextAsync(Document document, SourceText sourceText, Document? currentDocument, CancellationToken cancellationToken) 321private static async ValueTask<Optional<SourceText?>> TryGetMatchingSourceTextAsync( 322SourceText sourceText, string filePath, Document? currentDocument, IPdbMatchingSourceTextProvider sourceTextProvider, ImmutableArray<byte> requiredChecksum, SourceHashAlgorithm checksumAlgorithm, CancellationToken cancellationToken) 341return SourceText.From(text, sourceText.Encoding, checksumAlgorithm); 436private static bool IsMatchingSourceText(SourceText sourceText, ImmutableArray<byte> requiredChecksum, SourceHashAlgorithm checksumAlgorithm) 439private static Optional<SourceText?> TryGetPdbMatchingSourceTextFromDisk(string sourceFilePath, Encoding? encoding, ImmutableArray<byte> requiredChecksum, SourceHashAlgorithm checksumAlgorithm) 449var sourceText = SourceText.From(fileStream, encoding, checksumAlgorithm);
EditAndContinue\EditSession.cs (2)
212private static TextSpan GetFirstLineDifferenceSpan(SourceText oldText, SourceText newText)
EmbeddedLanguages\DateAndTime\DateAndTimeEmbeddedCompletionProvider.cs (1)
36public override bool ShouldTriggerCompletion(SourceText text, int caretPosition, CompletionTrigger trigger)
EmbeddedLanguages\DateAndTime\EmbeddedCompletionContext.cs (1)
37SourceText text,
EmbeddedLanguages\RegularExpressions\LanguageServices\RegexEmbeddedCompletionProvider.cs (1)
43public override bool ShouldTriggerCompletion(SourceText text, int caretPosition, CompletionTrigger trigger)
ExternalAccess\Pythia\Api\PythiaCompletionProviderBase.cs (2)
72public sealed override bool IsInsertionTrigger(SourceText text, int insertedCharacterPosition, CompletionOptions options) 75protected virtual bool IsInsertionTriggerWorker(SourceText text, int insertedCharacterPosition)
ExternalAccess\UnitTesting\SolutionCrawler\AbstractUnitTestingDocumentDifferenceService.cs (2)
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)
InvertIf\AbstractInvertIfCodeRefactoringProvider.cs (2)
73SourceText sourceText, 425SourceText text,
MetadataAsSource\MetadataAsSourceGeneratedFileInfo.cs (2)
74var assemblyInfoSourceText = SourceText.From(assemblyInfoString, Encoding, ChecksumAlgorithm);
NavigateTo\NavigateToUtilities.cs (1)
29public static TextSpan GetBoundedSpan(INavigableItem item, SourceText sourceText)
Navigation\IDefinitionLocationService.cs (1)
61var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
Navigation\INavigableItem.cs (3)
72/// Get the <see cref="SourceText"/> of the <see cref="CodeAnalysis.Document"/> within 77internal async ValueTask<SourceText> GetTextAsync(Solution solution, CancellationToken cancellationToken) 83internal SourceText? TryGetTextSynchronously(Solution solution, CancellationToken cancellationToken)
PdbSourceDocument\PdbSourceDocumentLoaderService.cs (2)
195var sourceText = SourceText.From(stream, encoding, sourceDocument.ChecksumAlgorithm, throwIfBinaryDetected: true);
QuickInfo\IndentationHelper.cs (2)
28SourceText text, 84SourceText text,
ReplaceDocCommentTextWithTag\AbstractReplaceDocCommentTextWithTagCodeRefactoringProvider.cs (4)
112var sourceText = semanticModel.SyntaxTree.GetText(cancellationToken); 160private static TextSpan ExpandSpan(SourceText sourceText, TextSpan span, bool fullyQualifiedName) 185SourceText sourceText, int endExclusive, bool fullyQualifiedName) 206SourceText sourceText, int startInclusive, bool fullyQualifiedName)
SemanticSearch\AbstractSemanticSearchService.cs (2)
58protected abstract Compilation CreateCompilation(SourceText query, IEnumerable<MetadataReference> references, SolutionServices services, out SyntaxTree queryTree, CancellationToken cancellationToken); 77var queryText = SemanticSearchUtilities.CreateSourceText(query);
SemanticSearch\SemanticSearchUtilities.cs (2)
63public static SourceText CreateSourceText(string query) 64=> SourceText.From(query, Encoding.UTF8, SourceHashAlgorithm.Sha256);
SemanticSearch\SemanticSearchWorkspace.cs (2)
24SourceText? newText = null; 72protected virtual void ApplyQueryDocumentTextChanged(SourceText newText)
Snippets\SnippetProviders\AbstractConsoleSnippetProvider.cs (1)
64protected sealed override int GetTargetCaretPosition(TExpressionSyntax caretTarget, SourceText sourceText)
Snippets\SnippetProviders\AbstractInlineStatementSnippetProvider.cs (2)
105var sourceText = parentNode.SyntaxTree.GetText(cancellationToken); 138var sourceText = parentNode.SyntaxTree.GetText(cancellationToken);
Snippets\SnippetProviders\AbstractSnippetProvider.cs (1)
46protected abstract int GetTargetCaretPosition(TSnippetSyntax caretTarget, SourceText sourceText);
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))
src\Analyzers\Core\Analyzers\Formatting\AbstractFormattingAnalyzer.cs (3)
49var oldText = tree.GetText(cancellationToken); 72if (oldText.GetSubText(new TextSpan(change.Span.Start + offset, change.NewText.Length)).ContentEquals(SourceText.From(change.NewText))) 81if (oldText.GetSubText(new TextSpan(change.Span.Start, change.NewText.Length)).ContentEquals(SourceText.From(change.NewText)))
src\Analyzers\Core\CodeFixes\ConflictMarkerResolution\AbstractConflictMarkerCodeFixProvider.cs (10)
84SyntaxNode root, SourceText text, int position, 145SourceText text, int position, 209var text = startLine.Text!; 227var text = startLine.Text!; 245var text = currentLine.Text!; 315Action<SourceText, ArrayBuilder<TextChange>, int, int, int, int> addEdits, 328SourceText text, ArrayBuilder<TextChange> edits, 341SourceText text, ArrayBuilder<TextChange> edits, 354SourceText text, ArrayBuilder<TextChange> edits, 388private static int GetEndIncludingLineBreak(SourceText text, int position)
src\Compilers\Core\Portable\Text\TextUtilities.cs (3)
14internal static int GetLengthOfLineBreak(SourceText text, int index) 30private static int GetLengthOfLineBreakSlow(SourceText text, int index, char c) 52public static void GetStartAndLengthOfLineBreakEndingAt(SourceText text, int index, out int startLinebreak, out int lengthLinebreak)
TaskList\AbstractTaskListService.cs (1)
128var text = document.Text;
ValueTracking\ValueTrackedItem.cs (3)
20public SourceText SourceText { get; } 25SourceText sourceText, 41var subText = SourceText.GetSubText(Span);
Wrapping\AbstractCodeActionComputer.cs (3)
50protected readonly SourceText OriginalSourceText; 66SourceText originalSourceText, 89var newSourceText = OriginalSourceText.WithChanges(
Wrapping\BinaryExpression\BinaryExpressionCodeActionComputer.cs (1)
49SourceText originalSourceText,
Wrapping\ChainedExpression\ChainedExpressionCodeActionComputer.cs (1)
70SourceText originalSourceText,
Wrapping\SeparatedSyntaxList\SeparatedSyntaxListCodeActionComputer.cs (1)
77SourceText sourceText,
Microsoft.CodeAnalysis.Features.Test.Utilities (21)
Diagnostics\TestDiagnosticAnalyzerDriver.cs (1)
50var 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\EditAndContinueTestVerifier.cs (3)
163var oldText = oldDocument.GetTextSynchronously(default); 164var newText = newDocument.GetTextSynchronously(default); 483var text = tree.GetText();
EditAndContinue\EditAndContinueWorkspaceTestBase.cs (8)
81internal static SourceText GetAnalyzerConfigText((string key, string value)[] analyzerConfig) 275var sourceText = SourceText.From(new MemoryStream(encoding.GetBytesWithPreamble(source.content)), encoding, checksumAlgorithm); 335internal static SourceText CreateText(string source) 336=> SourceText.From(source, Encoding.UTF8, SourceHashAlgorithms.Default); 338internal static SourceText CreateTextFromFile(string path) 341return SourceText.From(stream, Encoding.UTF8, SourceHashAlgorithms.Default); 367var sourceText = CreateText("class DTO {}");
EditAndContinue\Extensions.cs (2)
27public static IEnumerable<RudeEditDiagnosticDescription> ToDescription(this IEnumerable<RudeEditDiagnostic> diagnostics, SourceText newSource, bool includeFirstLines) 77SourceText.From(source, Encoding.UTF8, SourceHashAlgorithms.Default),
Snippets\AbstractSnippetProviderTests.cs (3)
44var editorConfigDoc = document.Project.AddAnalyzerConfigDocument(".editorconfig", SourceText.From(editorconfig), filePath: "/.editorconfig"); 63var documentSourceText = await document.GetTextAsync(); 64var documentTextAfterSnippet = documentSourceText.WithChanges(snippetChange.TextChanges);
Microsoft.CodeAnalysis.Features.UnitTests (34)
EditAndContinue\ActiveStatementsMapTests.cs (3)
118.AddDocument("doc", SourceText.From(source, Encoding.UTF8), filePath: "a.cs").Project.Solution; 173.AddDocument("doc", SourceText.From(source, Encoding.UTF8), filePath: "a.cs").Project.Solution; 224.AddDocument("doc", SourceText.From(source, Encoding.UTF8), filePath: "a.cs").Project.Solution;
EditAndContinue\CompileTimeSolutionProviderTests.cs (5)
48AddAdditionalDocument(additionalDocumentId, "additional", SourceText.From(""), filePath: additionalFilePath). 49AddAnalyzerConfigDocument(analyzerConfigId, "config", SourceText.From(""), filePath: "RazorSourceGenerator.razorencconfig"). 102context.AddSource("hint", SourceText.From(s)); 117.AddAdditionalDocument(additionalDocumentId, "additional", SourceText.From(""), filePath: "additional.razor") 118.AddAnalyzerConfigDocument(analyzerConfigId, "config", SourceText.From(analyzerConfigText), filePath: "Z:\\RazorSourceGenerator.razorencconfig"),
EditAndContinue\EditAndContinueWorkspaceServiceTests.cs (11)
67var sourceTreeA1 = SyntaxFactory.ParseSyntaxTree(SourceText.From(sourceBytesA1, sourceBytesA1.Length, encodingA, SourceHashAlgorithms.Default), TestOptions.Regular, sourceFileA.Path); 68var sourceTreeB1 = SyntaxFactory.ParseSyntaxTree(SourceText.From(sourceBytesB1, sourceBytesB1.Length, encodingB, SourceHashAlgorithms.Default), TestOptions.Regular, sourceFileB.Path); 69var sourceTreeC1 = SyntaxFactory.ParseSyntaxTree(SourceText.From(sourceBytesC1, sourceBytesC1.Length, encodingC, SourceHashAlgorithm.Sha1), TestOptions.Regular, sourceFileC.Path); 345var sourceText = CreateText("class D {}"); 407solution = solution.AddDocument(designTimeOnlyDocumentId, designTimeOnlyFileName, SourceText.From(sourceDesignTimeOnly, Encoding.UTF8), filePath: designTimeOnlyFilePath); 427solution = solution.AddDocument(designTimeOnlyDocumentId, designTimeOnlyFileName, SourceText.From(sourceDesignTimeOnly, Encoding.UTF8), filePath: designTimeOnlyFilePath); 622AddDocument("a.cs", SourceText.From(source1, Encoding.UTF8, SourceHashAlgorithm.Sha1), filePath: sourceFile.Path); 922AddDocument(documentId, "test.cs", SourceText.From(source1, encoding, SourceHashAlgorithm.Sha1), filePath: sourceFile.Path); 1790context.AddSource("generated.cs", SourceText.From("generated: " + additionalText, Encoding.UTF8, SourceHashAlgorithm.Sha256)); 2139solution = solution.WithDocumentText(document1.Id, SourceText.From("class C1 { void M() { System.Console.WriteLine(2); } }", encoding: null, SourceHashAlgorithms.Default)); 3602DocumentId AddProjectAndLinkDocument(string projectName, Document doc, SourceText text)
EditAndContinue\EditSessionActiveStatementsTests.cs (12)
77var text = SourceText.From(SourceMarkers.Clear(markedSources[i]), Encoding.UTF8); 321var baseText = SourceText.From(baseSource); 322var updatedText = SourceText.From(updatedSource); 473var sourceTextV1 = SourceText.From(markedSourceV1); 474var sourceTextV2 = SourceText.From(markedSourceV2); 475var sourceTextV3 = SourceText.From(markedSourceV3);
EditAndContinue\EmitSolutionUpdateResultsTests.cs (1)
73AddDocument(sourcePath, SourceText.From("class C {}", Encoding.UTF8), filePath: Path.Combine(TempRoot.Root, sourcePath));
EditAndContinue\RemoteEditAndContinueServiceTests.cs (1)
81.AddDocument(documentId, "test.cs", SourceText.From("class C { }", Encoding.UTF8), filePath: "test.cs")
EditAndContinue\WatchHotReloadServiceTests.cs (1)
136context.AddSource("generated.cs", SourceText.From("generated: " + additionalText, Encoding.UTF8, SourceHashAlgorithm.Sha256));
Microsoft.CodeAnalysis.LanguageServer (4)
HostWorkspace\LanguageServerWorkspace.cs (2)
56ValueTask ILspWorkspace.UpdateTextIfPresentAsync(DocumentId documentId, SourceText sourceText, CancellationToken cancellationToken) 116var documentText = document.GetTextSynchronously(cancellationToken);
HostWorkspace\RazorDynamicFileInfoProvider.cs (1)
112return Task.FromResult(TextAndVersion.Create(SourceText.From(""), VersionStamp.Default));
Testing\TestDiscoverer.cs (1)
81var text = await document.GetTextAsync(cancellationToken);
Microsoft.CodeAnalysis.LanguageServer.Protocol (88)
Extensions\ProtocolConversions.cs (7)
277public static LSP.TextDocumentPositionParams PositionToTextDocumentPositionParams(int position, SourceText text, Document document) 298public static TextSpan RangeToTextSpan(LSP.Range range, SourceText text) 327public static LSP.TextEdit TextChangeToTextEdit(TextChange textChange, SourceText oldText) 337public static TextChange TextEditToTextChange(LSP.TextEdit edit, SourceText oldText) 340public static TextChange ContentChangeEventToTextChange(LSP.TextDocumentContentChangeEvent changeEvent, SourceText text) 349public static LSP.Range TextSpanToRange(TextSpan textSpan, SourceText text) 511static LSP.Location ConvertTextSpanWithTextToLocation(TextSpan span, SourceText text, Uri documentUri)
ExternalAccess\Razor\FormatNewFileHandler.cs (2)
50var source = SourceText.From(request.Contents);
ExternalAccess\Razor\SimplifyMethodHandler.cs (2)
54var originalSourceText = await originalDocument.GetTextAsync(cancellationToken).ConfigureAwait(false); 56var newSourceText = originalSourceText.WithChanges(pendingChange);
Features\CodeFixes\CodeFixService.cs (1)
257SourceText text, ImmutableArray<DiagnosticData> diagnostics)
Features\DecompiledSource\CSharpCodeDecompilerDecompilationService.cs (1)
77return document.WithText(SourceText.From(text, encoding: null, checksumAlgorithm: SourceHashAlgorithms.Default));
Features\Diagnostics\EngineV2\DiagnosticIncrementalAnalyzer.IncrementalMemberEditAnalyzer.cs (3)
262var text = tree.GetText(cancellationToken); 293SourceText text, 377static DiagnosticData UpdateLocations(DiagnosticData diagnostic, SyntaxTree tree, SourceText text, int delta)
Features\Diagnostics\EngineV2\DiagnosticIncrementalAnalyzer_GetDiagnosticsForSpan.cs (2)
58private readonly SourceText _text; 158SourceText text,
Features\UnifiedSuggestions\UnifiedSuggestedActionsSource.cs (3)
67SourceText text, 280SourceText text, 388SourceText text,
Handler\CodeActions\CodeActionHelpers.cs (2)
215SourceText documentText, 245SourceText documentText,
Handler\CodeLens\CodeLensHandler.cs (2)
86SourceText text, 112SourceText text,
Handler\Completion\CompletionHandler.cs (2)
116SourceText sourceText, 193SourceText sourceText,
Handler\Completion\CompletionResultFactory.cs (7)
311SourceText documentText, 361SourceText documentText, 478SourceText documentText, 500SourceText documentText, 529var sourceText = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); 655var sourceText = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); 680var documentText = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
Handler\DocumentChanges\DidChangeHandler.cs (3)
31var text = context.GetTrackedDocumentSourceText(request.TextDocument.Uri); 56private static SourceText GetUpdatedSourceText(TextDocumentContentChangeEvent[] contentChanges, SourceText text)
Handler\DocumentChanges\DidOpenHandler.cs (2)
39var sourceText = SourceText.From(request.TextDocument.Text, System.Text.Encoding.UTF8, SourceHashAlgorithms.OpenDocumentChecksumAlgorithm);
Handler\FoldingRanges\FoldingRangesHandler.cs (1)
82private static FoldingRange[] GetFoldingRanges(BlockStructure blockStructure, SourceText text)
Handler\Highlights\DocumentHighlightHandler.cs (2)
76private static async Task<ImmutableArray<DocumentHighlight>> GetKeywordHighlightsAsync(IHighlightingService highlightingService, Document document, SourceText text, int position, CancellationToken cancellationToken) 90private static async Task<ImmutableArray<DocumentHighlight>> GetReferenceHighlightsAsync(IGlobalOptionService globalOptions, Document document, SourceText text, int position, CancellationToken cancellationToken)
Handler\IDocumentChangeTracker.cs (4)
19ValueTask StartTrackingAsync(Uri documentUri, SourceText initialText, string languageId, CancellationToken cancellationToken); 20void UpdateTrackedDocument(Uri documentUri, SourceText text); 26public ValueTask StartTrackingAsync(Uri documentUri, SourceText initialText, string languageId, CancellationToken cancellationToken) 36public void UpdateTrackedDocument(Uri documentUri, SourceText text)
Handler\InlineCompletions\InlineCompletionsHandler.cs (5)
169SourceText originalSourceText, 182var documentWithSnippetText = originalSourceText.WithChanges(textChange); 189var formattedText = documentWithSnippetText.WithChanges(formattingChanges); 223var formattedLspSnippetText = formattedText.GetSubText(spanContainingFormattedSnippet).WithChanges(lspTextChanges); 247SourceText originalSourceText,
Handler\MapCode\MapCodeHandler.cs (2)
109var oldText = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); 121var focusText = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
Handler\OnAutoInsert\OnAutoInsertHandler.cs (5)
173var indentedText = GetIndentedText(newSourceText, caretLine, desiredCaretLinePosition, options); 205static SourceText GetIndentedText( 206SourceText textToIndent, 216var indentedText = textToIndent.WithChanges(new TextChange(new TextSpan(lineToIndent.End, 0), indentText)); 227static string GetTextChangeTextWithCaretAtLocation(SourceText sourceText, TextChange textChange, LinePosition desiredCaretLinePosition)
Handler\References\FindUsagesLSPContext.cs (1)
327SourceText docText)
Handler\Rename\PrepareRenameHandler.cs (1)
40var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
Handler\RequestContext.cs (5)
45private readonly ImmutableDictionary<Uri, (SourceText Text, string LanguageId)> _trackedDocuments; 177ImmutableDictionary<Uri, (SourceText Text, string LanguageId)> trackedDocuments, 305public ValueTask StartTrackingAsync(Uri uri, SourceText initialText, string languageId, CancellationToken cancellationToken) 312public void UpdateTrackedDocument(Uri uri, SourceText changedText) 315public SourceText GetTrackedDocumentSourceText(Uri documentUri)
Handler\SemanticTokens\SemanticTokensHelpers.cs (2)
149private static void ConvertMultiLineToSingleLineSpans(SourceText text, SegmentedList<ClassifiedSpan> classifiedSpans, SegmentedList<ClassifiedSpan> updatedClassifiedSpans) 173SourceText text,
Handler\SourceGenerators\SourceGeneratedDocumentCache.cs (3)
17internal sealed class SourceGeneratedDocumentCache(string uniqueKey) : VersionedPullCache<(SourceGeneratorExecutionVersion, VersionStamp), object?, SourceGeneratedDocumentGetTextState, SourceText?>(uniqueKey), ILspService 33public override Checksum ComputeChecksum(SourceText? data) 38public override async Task<SourceText?> ComputeDataAsync(SourceGeneratedDocumentGetTextState state, CancellationToken cancellationToken)
Handler\Symbols\DocumentSymbolsHandler.cs (3)
89RoslynNavigationBarItem item, Document document, SourceText text, string? containerName, bool supportsVSExtensions) 109RoslynNavigationBarItem item, SourceText text, CancellationToken cancellationToken) 136ImmutableArray<RoslynNavigationBarItem> items, SourceText text, CancellationToken cancellationToken)
Workspaces\ILspWorkspace.cs (1)
40ValueTask UpdateTextIfPresentAsync(DocumentId documentId, SourceText sourceText, CancellationToken cancellationToken);
Workspaces\LspMiscellaneousFilesWorkspace.cs (5)
39public Document? AddMiscellaneousDocument(Uri uri, SourceText documentText, string languageId, ILspLogger logger) 73/// Calls to this method and <see cref="AddMiscellaneousDocument(Uri, SourceText, string, ILspLogger)"/> are made 104public ValueTask UpdateTextIfPresentAsync(DocumentId documentId, SourceText sourceText, CancellationToken cancellationToken) 110private class StaticSourceTextContainer(SourceText text) : SourceTextContainer 112public override SourceText CurrentText => text;
Workspaces\LspWorkspaceManager.cs (7)
115private ImmutableDictionary<Uri, (SourceText Text, string LanguageId)> _trackedDocuments = ImmutableDictionary<Uri, (SourceText, string)>.Empty.WithComparers(LspUriComparer.Instance); 156public async ValueTask StartTrackingAsync(Uri uri, SourceText documentText, string languageId, CancellationToken cancellationToken) 234public void UpdateTrackedDocument(Uri uri, SourceText newSourceText) 247public ImmutableDictionary<Uri, (SourceText Text, string LanguageId)> GetTrackedLspText() => _trackedDocuments; 478ImmutableArray<(SourceGeneratedDocumentIdentity Identity, DateTime Generated, SourceText Text)> sourceGenereatedDocuments, 522private static async ValueTask<bool> AreChecksumsEqualAsync(TextDocument document, SourceText lspText, CancellationToken cancellationToken)
Workspaces\SourceTextLoader.cs (2)
13private readonly SourceText _sourceText; 16public SourceTextLoader(SourceText sourceText, string fileUri)
Microsoft.CodeAnalysis.LanguageServer.Protocol.UnitTests (36)
Completion\CompletionFeaturesTests.cs (4)
583Project project, LanguageServices languageServices, SourceText text, int caretPosition, CompletionTrigger trigger, 597var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); 876Project project, LanguageServices languageServices, SourceText text, int caretPosition, CompletionTrigger trigger, 890var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
Completion\CompletionResolveTests.cs (1)
511internal 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)
223var sourceText = await document.GetTextAsync();
DocumentChanges\DocumentChangesTests.cs (7)
51var document = testLspServer.GetTrackedTexts().Single(); 82var document = testLspServer.GetTrackedTexts().FirstOrDefault(); 203var document = testLspServer.GetTrackedTexts().FirstOrDefault(); 281var document = testLspServer.GetTrackedTexts().FirstOrDefault(); 320var document = testLspServer.GetTrackedTexts().FirstOrDefault(); 360var document = testLspServer.GetTrackedTexts().FirstOrDefault(); 444var document = testLspServer.GetTrackedTexts().FirstOrDefault();
InlayHint\AbstractInlayHintTests.cs (1)
27var text = await document.GetTextAsync(CancellationToken.None);
MapCode\MapCodeTests.cs (2)
37var text = await document.GetTextAsync(cancellationToken); 38var newText = text.Replace(focusLocations.Single().Item2, contents.Single());
ProtocolConversionsTests.cs (12)
192var sourceText = SourceText.From(markup); 205var sourceText = SourceText.From(markup); 219var sourceText = SourceText.From(markup); 238var sourceText = SourceText.From(markup); 252var sourceText = SourceText.From(markup); 262var sourceText = SourceText.From(markup);
SemanticTokens\AbstractSemanticTokensTests.cs (1)
65var text = await document.GetTextAsync().ConfigureAwait(false);
SpellCheck\SpellCheckTests.cs (1)
650var sourceText = await document.GetTextAsync();
Workspaces\LspWorkspaceManagerTests.cs (5)
88await testLspServer.TestWorkspace.ChangeDocumentAsync(firstDocument.Id, SourceText.From($"Some more text{markupOne}", System.Text.Encoding.UTF8, SourceHashAlgorithms.Default)); 122await testLspServer.TestWorkspace.ChangeDocumentAsync(secondDocument.Id, SourceText.From("Two is now three!", System.Text.Encoding.UTF8, SourceHashAlgorithms.Default)); 224var newSolution = testLspServer.TestWorkspace.CurrentSolution.AddDocument(newDocumentId, "NewDoc.cs", SourceText.From("New Doc", System.Text.Encoding.UTF8, SourceHashAlgorithms.Default), filePath: @"C:\NewDoc.cs"); 558.AddDocument(filePath, SourceText.From("ProjectSystemText"), filePath: filePath) 615testLspServer.TestWorkspace.CurrentSolution.WithDocumentText(document.Id, SourceText.From("New Disk Contents")));
Workspaces\SourceGeneratedDocumentTests.cs (1)
173await testLspServer.TestWorkspace.ChangeDocumentAsync(testLspServer.TestWorkspace.Documents.Single(d => !d.IsSourceGenerated).Id, SourceText.From("new text"));
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 (2)
Host\RemoteWorkspace.SolutionCreator.cs (1)
95var frozenDocuments = new FixedSizeArrayBuilder<(SourceGeneratedDocumentIdentity identity, DateTime generationDateTime, SourceText text)>(count);
Services\AssetSynchronization\RemoteAssetSynchronizationService.cs (1)
84async static Task<SourceText?> TryGetSourceTextAsync(
Microsoft.CodeAnalysis.Remote.Workspaces (1)
IRemoteAssetSynchronizationService.cs (1)
23/// cref="SourceText"/> that is built based off of retrieving the remote source text with a checksum corresponding
Microsoft.CodeAnalysis.Scripting (12)
Hosting\CommandLine\CommandLineRunner.cs (5)
110SourceText? code = null; 202private int RunScript(ScriptOptions? options, SourceText? code, ErrorLogger? errorLogger, CancellationToken cancellationToken) 233var script = Script.CreateInitialScript<object>(_scriptCompiler, SourceText.From(initialScriptCodeOpt), options, globals.GetType(), assemblyLoaderOpt: null); 260var tree = _scriptCompiler.ParseSubmission(SourceText.From(input.ToString()), options.ParseOptions, cancellationToken); 285newScript = Script.CreateInitialScript<object>(_scriptCompiler, SourceText.From(code ?? string.Empty), options, globals.GetType(), assemblyLoaderOpt: null);
Script.cs (6)
40internal Script(ScriptCompiler compiler, ScriptBuilder builder, SourceText sourceText, ScriptOptions options, Type globalsTypeOpt, Script previousOpt) 55internal static Script<T> CreateInitialScript<T>(ScriptCompiler compiler, SourceText sourceText, ScriptOptions optionsOpt, Type globalsTypeOpt, InteractiveAssemblyLoader assemblyLoaderOpt) 80internal SourceText SourceText { get; } 118return new Script<TResult>(Compiler, Builder, SourceText.From(code ?? "", options.FileEncoding), options, GlobalsType, this); 131return new Script<TResult>(Compiler, Builder, SourceText.From(code, options.FileEncoding), options, GlobalsType, this); 345internal 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 (32)
AssemblyLoadTestFixture.cs (1)
532syntaxTrees: new SyntaxTree[] { SyntaxFactory.ParseSyntaxTree(SourceText.From(csSource, encoding: null, SourceHashAlgorithms.Default)) },
CommonTestBase.cs (2)
388var tree = CSharp.SyntaxFactory.ParseSyntaxTree(SourceText.From(code, encoding: null, SourceHashAlgorithms.Default), options: parseOptions); 478trees[i] = VisualBasic.VisualBasicSyntaxTree.ParseText(SourceText.From(files[i], encoding, SourceHashAlgorithms.Default), options: parseOptions, path: sourceFileNames?[i]);
Compilation\CompilationExtensions.cs (1)
510new[] { CSharpSyntaxTree.ParseText(SourceText.From(source, encoding: null, SourceHashAlgorithms.Default)) },
Diagnostics\CommonDiagnosticAnalyzers.cs (4)
1721private readonly HashSet<SourceText> _textCallbackSet; 1761_textCallbackSet = new HashSet<SourceText>(SourceTextComparer.Instance); 1779private int GetCharacterCount(SourceText text) 2659var text = context.AdditionalFile.GetText();
Metadata\ILValidation.cs (4)
375public static Dictionary<int, string> GetSequencePointMarkers(XElement methodXml, Func<string, SourceText> getSource) 400var source = getSource(documentId); 409private static string SnippetFromSpan(SourceText text, XElement sequencePointXml) 423var subtext = text.GetSubText(span);
Metadata\MetadataReaderUtils.cs (1)
271public static SourceText GetEmbeddedSource(this MetadataReader reader, DocumentHandle document)
Mocks\Silverlight.cs (4)
88CSharpSyntaxTree.ParseText(SourceText.From(TestResources.NetFX.Minimal.mincorlib_cs)), 89CSharpSyntaxTree.ParseText(SourceText.From(corlibExtraCode)), 90CSharpSyntaxTree.ParseText(SourceText.From(assemblyAttributes)), 98syntaxTrees: [CSharpSyntaxTree.ParseText(SourceText.From(assemblyAttributes))],
Mocks\StdOle.cs (2)
75CSharpSyntaxTree.ParseText(SourceText.From(code)), 76CSharpSyntaxTree.ParseText(SourceText.From(assemblyAttributes))
Mocks\TestAdditionalText.cs (3)
14private readonly SourceText? _text; 16public TestAdditionalText(string path, SourceText? text) 29public override SourceText? GetText(CancellationToken cancellationToken = default) => _text;
Platform\Desktop\TestHelpers.cs (1)
82new SyntaxTree[] { SyntaxFactory.ParseSyntaxTree(SourceText.From(analyzerSource, encoding: null, SourceHashAlgorithms.Default)) },
SourceGeneration\TestGenerators.cs (8)
40context.AddSource(hintName, SourceText.From(content, Encoding.UTF8)); 84Func<ImmutableArray<(string hintName, SourceText? sourceText)>> computeSourceTexts) 98: SourceText.From(source, Encoding.UTF8))); 109: SourceText.From(source, Encoding.UTF8))); 140private readonly SourceText _content; 145_content = SourceText.From(content, Encoding.UTF8); 150public override SourceText GetText(CancellationToken cancellationToken = default) => _content; 156public override SourceText GetText(CancellationToken cancellationToken = default) => throw new InvalidDataException("Binary content not supported");
TestBase.cs (1)
192var syntaxTree = Microsoft.CodeAnalysis.CSharp.SyntaxFactory.ParseSyntaxTree(SourceText.From(source, encoding: null, SourceHashAlgorithms.Default));
Microsoft.CodeAnalysis.TestAnalyzerReference (6)
HelloWorldGenerator.cs (3)
27context.AddSource(GeneratedEnglishClassName, SourceText.From($$""" 38context.AddSource(GeneratedSpanishClassName, SourceText.From($$""" 48context.AddSource(GeneratedEnglishClassName + "WithTime", SourceText.From($$"""
NonSourceFileRefactoring.cs (3)
27var text = await document.GetTextAsync(ct).ConfigureAwait(false); 28var newText = SourceText.From(text.ToString() + Environment.NewLine + "# Refactored");
Microsoft.CodeAnalysis.UnitTests (514)
AnalyzerAssemblyLoaderTests.cs (2)
1213[CSharpSyntaxTree.ParseText(SourceText.From(testCode, encoding: null, checksumAlgorithm: SourceHashAlgorithms.Default))], 1315[CSharpSyntaxTree.ParseText(SourceText.From(analyzerCode, encoding: null, checksumAlgorithm: SourceHashAlgorithms.Default))],
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\CompositeTextTests.cs (8)
54private static IEnumerable<(SourceText, CompositeText)> CreateSourceAndCompositeTexts(string contents, int minSourceTextCount = 2, int maxSourceTextCount = 4) 56var sourceText = SourceText.From(contents); 62var sourceTextsBuilder = ArrayBuilder<SourceText>.GetInstance(); 71private static IEnumerable<SourceText[]> CreateSourceTextPermutations(string contents, int requestedSourceTextCount) 75yield return [SourceText.From(contents)]; 82var sourceText = SourceText.From(contents[..i]);
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 (91)
29SourceText[] texts = [SourceText.From(string.Empty), SourceText.From([], 0), SourceText.From(new MemoryStream())]; 31foreach (var text1 in texts) 35foreach (var text2 in texts) 43private static void TestIsEmpty(SourceText text) 56Assert.Same(s_utf8, SourceText.From(HelloWorld, s_utf8).Encoding); 57Assert.Same(s_unicode, SourceText.From(HelloWorld, s_unicode).Encoding); 60Assert.Same(s_unicode, SourceText.From(bytes, bytes.Length, s_unicode).Encoding); 61Assert.Equal(utf8NoBOM, SourceText.From(bytes, bytes.Length, null).Encoding); 64Assert.Same(s_unicode, SourceText.From(stream, s_unicode).Encoding); 65Assert.Equal(utf8NoBOM, SourceText.From(stream, null).Encoding); 74Assert.Equal(utf8BOM, SourceText.From(bytes, bytes.Length, s_unicode).Encoding); 75Assert.Equal(utf8BOM, SourceText.From(bytes, bytes.Length, null).Encoding); 78Assert.Equal(utf8BOM, SourceText.From(stream, s_unicode).Encoding); 79Assert.Equal(utf8BOM, SourceText.From(stream, null).Encoding); 85Assert.Equal(SourceHashAlgorithm.Sha1, SourceText.From(HelloWorld).ChecksumAlgorithm); 88Assert.Equal(SourceHashAlgorithm.Sha1, SourceText.From(bytes, bytes.Length).ChecksumAlgorithm); 91Assert.Equal(SourceHashAlgorithm.Sha1, SourceText.From(stream).ChecksumAlgorithm); 99Assert.Equal(algorithm, SourceText.From(HelloWorld, checksumAlgorithm: algorithm).ChecksumAlgorithm); 102Assert.Equal(algorithm, SourceText.From(bytes, bytes.Length, checksumAlgorithm: algorithm).ChecksumAlgorithm); 105Assert.Equal(algorithm, SourceText.From(stream, checksumAlgorithm: algorithm).ChecksumAlgorithm); 121verifyChecksumAndContentHash(SourceText.From(HelloWorld, encodingNoBOM, checksumAlgorithm), checksumNoBOM, expectedContentHash); 122verifyChecksumAndContentHash(SourceText.From(HelloWorld, encodingBOM, checksumAlgorithm), checksumBOM, expectedContentHash); 131verifyChecksumAndContentHash(SourceText.From(bytesNoBOM, bytesNoBOM.Length, null, checksumAlgorithm), checksumNoBOM, expectedContentHash); 132verifyChecksumAndContentHash(SourceText.From(bytesNoBOM, bytesNoBOM.Length, encodingNoBOM, checksumAlgorithm), checksumNoBOM, expectedContentHash); 133verifyChecksumAndContentHash(SourceText.From(bytesNoBOM, bytesNoBOM.Length, encodingBOM, checksumAlgorithm), checksumNoBOM, expectedContentHash); 136verifyChecksumAndContentHash(SourceText.From(bytesBOM, bytesBOM.Length, null, checksumAlgorithm), checksumBOM, expectedContentHash); 137verifyChecksumAndContentHash(SourceText.From(bytesBOM, bytesBOM.Length, encodingNoBOM, checksumAlgorithm), checksumBOM, expectedContentHash); 138verifyChecksumAndContentHash(SourceText.From(bytesBOM, bytesBOM.Length, encodingBOM, checksumAlgorithm), checksumBOM, expectedContentHash); 141verifyChecksumAndContentHash(SourceText.From(streamNoBOM, null, checksumAlgorithm), checksumNoBOM, expectedContentHash); 142verifyChecksumAndContentHash(SourceText.From(streamNoBOM, encodingNoBOM, checksumAlgorithm), checksumNoBOM, expectedContentHash); 143verifyChecksumAndContentHash(SourceText.From(streamNoBOM, encodingBOM, checksumAlgorithm), checksumNoBOM, expectedContentHash); 146verifyChecksumAndContentHash(SourceText.From(streamBOM, null, checksumAlgorithm), checksumBOM, expectedContentHash); 147verifyChecksumAndContentHash(SourceText.From(streamBOM, encodingNoBOM, checksumAlgorithm), checksumBOM, expectedContentHash); 148verifyChecksumAndContentHash(SourceText.From(streamBOM, encodingBOM, checksumAlgorithm), checksumBOM, expectedContentHash); 166verifyChecksumAndContentHash(fromChanges(SourceText.From(HelloWorld, encodingNoBOM, checksumAlgorithm)), checksumNoBOM, expectedContentHash); 167verifyChecksumAndContentHash(fromChanges(SourceText.From(HelloWorld, encodingBOM, checksumAlgorithm)), checksumBOM, expectedContentHash); 172verifyChecksumAndContentHash(fromChanges(SourceText.From(streamNoBOM, encodingNoBOM, checksumAlgorithm)), checksumNoBOM, expectedContentHash); 173verifyChecksumAndContentHash(fromChanges(SourceText.From(streamNoBOM, encodingBOM, checksumAlgorithm)), checksumBOM, expectedContentHash); 176verifyChecksumAndContentHash(fromChanges(SourceText.From(streamBOM, encodingNoBOM, checksumAlgorithm)), checksumBOM, expectedContentHash); 177verifyChecksumAndContentHash(fromChanges(SourceText.From(streamBOM, encodingBOM, checksumAlgorithm)), checksumBOM, expectedContentHash); 181static void verifyChecksumAndContentHash(SourceText text, ImmutableArray<byte> expectedChecksum, ImmutableArray<byte> expectedContentHash) 189static SourceText fromChanges(SourceText text) 193var changed = text.WithChanges(change); 201private static SourceText FromLargeTextWriter(string source, Encoding encoding, SourceHashAlgorithm checksumAlgorithm) 213var f = SourceText.From(HelloWorld, s_utf8); 215Assert.True(f.ContentEquals(SourceText.From(HelloWorld, s_utf8))); 216Assert.False(f.ContentEquals(SourceText.From(HelloWorld + "o", s_utf8))); 217Assert.True(SourceText.From(HelloWorld, s_utf8).ContentEquals(SourceText.From(HelloWorld, s_utf8))); 219var e1 = EncodedStringText.Create(new MemoryStream(s_unicode.GetBytes(HelloWorld)), s_unicode); 220var e2 = EncodedStringText.Create(new MemoryStream(s_utf8.GetBytes(HelloWorld)), s_utf8); 256var allSourceTexts = new List<SourceText>(); 269foreach (var sourceText1 in allSourceTexts) 271foreach (var sourceText2 in allSourceTexts) 321Assert.False(SourceText.IsBinary("")); 323Assert.False(SourceText.IsBinary("\0abc")); 324Assert.False(SourceText.IsBinary("a\0bc")); 325Assert.False(SourceText.IsBinary("abc\0")); 326Assert.False(SourceText.IsBinary("a\0b\0c")); 328Assert.True(SourceText.IsBinary("\0\0abc")); 329Assert.True(SourceText.IsBinary("a\0\0bc")); 330Assert.True(SourceText.IsBinary("abc\0\0")); 333Assert.False(SourceText.IsBinary(encoding.GetString(new byte[] { 0x81, 0x8D, 0x8F, 0x90, 0x9D }))); 335Assert.False(SourceText.IsBinary("abc def baz aeiouy \u00E4\u00EB\u00EF\u00F6\u00FC\u00FB")); 336Assert.True(SourceText.IsBinary(encoding.GetString(Net461.Resources.System))); 343Assert.Throws<InvalidDataException>(() => SourceText.From(bytes, bytes.Length, throwIfBinaryDetected: true)); 346Assert.Throws<InvalidDataException>(() => SourceText.From(stream, throwIfBinaryDetected: true)); 353var expectedSourceText = SourceText.From(expected); 356var actualSourceText = SourceText.From(actual, expected.Length); 360Assert.Same(s_utf8, SourceText.From(actual, expected.Length, s_utf8).Encoding); 361Assert.Same(s_unicode, SourceText.From(actual, expected.Length, s_unicode).Encoding); 362Assert.Null(SourceText.From(actual, expected.Length, null).Encoding); 368var expected = new string('l', SourceText.LargeObjectHeapLimitInChars); 369var expectedSourceText = SourceText.From(expected); 372var actualSourceText = SourceText.From(actual, expected.Length); 379Assert.Same(s_utf8, SourceText.From(actual, expected.Length, s_utf8).Encoding); 380Assert.Same(s_unicode, SourceText.From(actual, expected.Length, s_unicode).Encoding); 381Assert.Null(SourceText.From(actual, expected.Length, null).Encoding); 392Encoding actualEncoding = SourceText.TryReadByteOrderMark(data, validLength, out actualPreambleLength); 425var sourceText = SourceText.From("ABCDEFGHIJKLMNOPQRSTUVWXYZ"); 444var sourceText = SourceText.From(Text); 456SourceText.From("ABC").Write(TextWriter.Null, TextSpan.FromBounds(4, 4))); 465SourceText.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)
1102Dim tree = VisualBasicSyntaxTree.ParseText(SourceText.From(codeToParse))
CommandLine\CommandLineDiagnosticFormatter.vb (2)
34Dim text As SourceText = Nothing 130Private Function GetDiagnosticSpanAndFileText(diagnostic As Diagnostic, <Out> ByRef text As SourceText) As TextSpan?
Compilation\VisualBasicCompilation.vb (1)
267SourceText.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 (2)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\CodeRefactorings\VisualBasicRefactoringHelpersService.vb (1)
25Public Overrides Function IsBetweenTypeMembers(sourceText As SourceText, root As SyntaxNode, position As Integer, ByRef typeDeclaration As SyntaxNode) As Boolean
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\Indentation\VisualBasicIndentationService.Indenter.vb (1)
42text As SourceText,
Microsoft.CodeAnalysis.VisualBasic.CodeStyle.UnitTests (1)
src\Features\VisualBasicTest\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.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.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 (31)
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
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)
38Public Overrides Function IsInsertionTrigger(text As SourceText, characterPosition As Integer, options As CompletionOptions) As Boolean
Completion\CompletionProviders\ImportCompletionProvider\TypeImportCompletionProvider.vb (1)
33Public Overrides Function IsInsertionTrigger(text As SourceText, characterPosition As Integer, options As CompletionOptions) As Boolean
Completion\CompletionProviders\InternalsVisibleToCompletionProvider.vb (1)
55Protected Overrides Function ShouldTriggerAfterQuotes(text As SourceText, insertedCharacterPosition As Integer) As Boolean
Completion\CompletionProviders\KeywordCompletionProvider.vb (1)
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)
82Public Overrides Function IsInsertionTrigger(text As SourceText, characterPosition As Integer, options As CompletionOptions) As Boolean
Completion\CompletionProviders\XmlDocCommentCompletionProvider.vb (1)
47Public 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.Features.UnitTests (7)
EditAndContinue\VisualBasicEditAndContinueAnalyzerTests.vb (6)
30AddDocument("test.vb", SourceText.From(source, Encoding.UTF8), filePath:=Path.Combine(TempRoot.Root, "test.vb")).Project.Solution 470Dim newSolution = oldSolution.WithDocumentText(documentId, SourceText.From(source2)) 555Dim newSolution = oldSolution.WithDocumentText(documentId, SourceText.From(source2)) 613Dim newSolution = oldSolution.WithDocumentText(documentId, SourceText.From(source2)) 644Dim newSolution = oldSolution.WithDocumentText(documentId, SourceText.From(source2)) 675Dim newSolution = oldSolution.AddDocument(newDocId, "goo.vb", SourceText.From(source2), filePath:=Path.Combine(TempRoot.Root, "goo.vb"))
Utils.vb (1)
14Dim text = SourceText.From(code)
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)
687Dim 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) 49SourceText.From(source, encoding:=Nothing, SourceHashAlgorithms.Default), 56Return sources.Select(Function(s) VisualBasicSyntaxTree.ParseText(SourceText.From(s, encoding:=Nothing, SourceHashAlgorithms.Default), If(parseOptions, TestOptions.RegularLatest))).ToArray()
CompilationTestUtils.vb (4)
22Return source.Select(Function(s) VisualBasicSyntaxTree.ParseText(SourceText.From(s, encoding:=Nothing, SourceHashAlgorithms.Default), parseOptions)) 636Return VisualBasicSyntaxTree.ParseText(SourceText.From(FilterString(programElement.Value), Encoding.UTF8, SourceHashAlgorithms.Default), path:=If(programElement.@name, "")) 653Dim text = SourceText.From(codeWithoutMarker, Encoding.UTF8) 1024Private 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, TestOptions.RegularLatest), 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 (15)
Classification\ClassificationHelpers.vb (2)
322Friend Sub AddLexicalClassifications(text As SourceText, textSpan As TextSpan, result As SegmentedList(Of ClassifiedSpan), cancellationToken As CancellationToken) 329Friend Function AdjustStaleClassification(text As SourceText, classifiedSpan As ClassifiedSpan) As ClassifiedSpan
Classification\SyntaxClassification\VisualBasicSyntaxClassificationService.vb (2)
35Public Overrides Sub AddLexicalClassifications(text As SourceText, textSpan As TextSpan, result As SegmentedList(Of ClassifiedSpan), cancellationToken As CancellationToken) 45Public Overrides Function FixClassification(text As SourceText, classifiedSpan As ClassifiedSpan) As ClassifiedSpan
Classification\VisualBasicClassificationService.vb (2)
23Public Overrides Sub AddLexicalClassifications(text As SourceText, textSpan As TextSpan, result As SegmentedList(Of ClassifiedSpan), cancellationToken As CancellationToken) 27Public Overrides Function AdjustStaleClassification(text As SourceText, classifiedSpan As ClassifiedSpan) As ClassifiedSpan
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\CodeRefactorings\VisualBasicRefactoringHelpersService.vb (1)
25Public Overrides Function IsBetweenTypeMembers(sourceText As SourceText, root As SyntaxNode, position As Integer, ByRef typeDeclaration As SyntaxNode) As Boolean
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\Indentation\VisualBasicIndentationService.Indenter.vb (1)
42text As SourceText,
Workspace\LanguageServices\VisualBasicSyntaxTreeFactoryService.ParsedSyntaxTree.vb (5)
13''' Parsed <see cref="VisualBasicSyntaxTree"/> that creates <see cref="SourceText"/> with given encoding And checksum algorithm. 25Private _lazyText As SourceText 28lazyText As SourceText, 42Public Overrides Function GetText(Optional cancellationToken As CancellationToken = Nothing) As SourceText 50Public Overrides Function TryGetText(<Out> ByRef text As SourceText) As Boolean
Workspace\LanguageServices\VisualBasicSyntaxTreeFactoryService.vb (2)
65Public Overrides Function ParseSyntaxTree(filePath As String, options As ParseOptions, text As SourceText, cancellationToken As CancellationToken) As SyntaxTree 73Public Overrides Function CreateSyntaxTree(filePath As String, options As ParseOptions, text As SourceText, encoding As Encoding, checksumAlgorithm As SourceHashAlgorithm, root As SyntaxNode) As SyntaxTree
Microsoft.CodeAnalysis.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 (352)
Classification\AbstractClassificationService.cs (2)
31public abstract void AddLexicalClassifications(SourceText text, TextSpan textSpan, SegmentedList<ClassifiedSpan> result, CancellationToken cancellationToken); 32public abstract ClassifiedSpan AdjustStaleClassification(SourceText text, ClassifiedSpan classifiedSpan);
Classification\Classifier.cs (2)
118var sourceText = await semanticModel.SyntaxTree.GetTextAsync(cancellationToken).ConfigureAwait(false); 124SourceText sourceText, int startPosition, IEnumerable<ClassifiedSpan> classifiedSpans)
Classification\IClassificationService.cs (2)
28void AddLexicalClassifications(SourceText text, TextSpan textSpan, SegmentedList<ClassifiedSpan> result, CancellationToken cancellationToken); 85ClassifiedSpan AdjustStaleClassification(SourceText text, ClassifiedSpan classifiedSpan);
Classification\SyntaxClassification\AbstractSyntaxClassificationService.cs (2)
19public abstract void AddLexicalClassifications(SourceText text, TextSpan textSpan, SegmentedList<ClassifiedSpan> result, CancellationToken cancellationToken); 23public abstract ClassifiedSpan FixClassification(SourceText text, ClassifiedSpan classifiedSpan);
Classification\SyntaxClassification\ISyntaxClassificationService.cs (2)
21void AddLexicalClassifications(SourceText text, 56ClassifiedSpan FixClassification(SourceText text, ClassifiedSpan classifiedSpan);
CodeCleanup\CodeCleaner.cs (1)
52var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false);
CodeCleanup\Providers\FormatCodeCleanupProvider.cs (2)
27return document.TryGetText(out var oldText) 38return (root.SyntaxTree != null && root.SyntaxTree.TryGetText(out var oldText))
CodeFixes\FixAllOccurrences\DocumentBasedFixAllProvider.cs (1)
46/// will only be examined for its content (e.g. it's <see cref="SyntaxTree"/> or <see cref="SourceText"/>. No
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.GetValueTextAsync(cancellationToken).ConfigureAwait(false); 75var newText = oldText.WithChanges(changesToApply);
CodeFixesAndRefactorings\DocumentBasedFixAllProviderHelpers.cs (2)
70var changedRootsAndTexts = await ProducerConsumer<(DocumentId documentId, (SyntaxNode? node, SourceText? text))>.RunParallelAsync( 91var newText = newDocument.SupportsSyntaxTree ? null : await newDocument.GetValueTextAsync(cancellationToken).ConfigureAwait(false);
CodeRefactorings\FixAllOccurences\DocumentBasedFixAllProvider.cs (1)
48/// (e.g. it's <see cref="SyntaxTree"/> or <see cref="SourceText"/>. No other aspects of document (like it's properties),
CodeRefactorings\FixAllOccurences\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
Diagnostics\Extensions.cs (1)
49var text = await textDocument.GetValueTextAsync(cancellationToken).ConfigureAwait(false);
ExternalAccess\UnitTesting\Api\UnitTestingEncodedStringTextAccessor.cs (1)
13public static SourceText Create(Stream stream, Encoding defaultEncoding)
ExternalAccess\VSTypeScript\Api\VSTypeScriptTextExtensions.cs (1)
15public static Document? GetOpenDocumentInCurrentContextWithChanges(this SourceText text)
FindSymbols\FindReferences\FindReferenceCache.cs (3)
35var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false); 52public readonly SourceText Text; 74Document document, SourceText text, SemanticModel semanticModel, SemanticModel nullableEnabledSemanticModel, SyntaxNode root, SyntaxTreeIndex syntaxTreeIndex)
LinkedFileDiffMerging\AbstractLinkedFileMergeConflictCommentAdditionService.cs (6)
21public ImmutableArray<TextChange> CreateEdits(SourceText originalSourceText, ArrayBuilder<UnmergedDocumentChanges> unmergedChanges) 36private static List<List<TextChange>> PartitionChangesForDocument(IEnumerable<TextChange> changes, SourceText originalSourceText) 67private List<TextChange> GetCommentChangesForDocument(IEnumerable<IEnumerable<TextChange>> partitionedChanges, string projectName, SourceText oldDocumentText) 79var oldText = oldDocumentText.GetSubText(TextSpan.FromBounds(startLineStartPosition, endLineEndPosition)); 81var newText = oldText.WithChanges(adjustedChanges); 97private static string TrimBlankLines(SourceText text)
LinkedFileDiffMerging\IMergeConflictHandler.cs (1)
13ImmutableArray<TextChange> CreateEdits(SourceText originalSourceText, ArrayBuilder<UnmergedDocumentChanges> unmergedChanges);
LinkedFileDiffMerging\LinkedFileDiffMergingSession.cs (3)
39var newText = await newDocument.GetValueTextAsync(cancellationToken).ConfigureAwait(false); 67var firstSourceText = await firstNewDocument.GetValueTextAsync(cancellationToken).ConfigureAwait(false); 103var firstOldSourceText = await firstOldDocument.GetValueTextAsync(cancellationToken).ConfigureAwait(false);
LinkedFileDiffMerging\LinkedFileMergeResult.cs (2)
10internal readonly struct LinkedFileMergeResult(ImmutableArray<DocumentId> documentIds, SourceText mergedSourceText, ImmutableArray<TextSpan> mergeConflictResolutionSpans) 13public readonly SourceText MergedSourceText = mergedSourceText;
Remote\RemoteUtilities.cs (2)
58var oldText = await oldSolution.GetDocument(tuple.documentId).GetValueTextAsync(cancellationToken).ConfigureAwait(false); 59var newText = oldText.WithChanges(tuple.textChanges);
Serialization\SerializableSourceText.cs (14)
26/// Represents a <see cref="SourceText"/> which can be serialized for sending to another process. The text is not 33/// The storage location for <see cref="SourceText"/>. 41/// The <see cref="SourceText"/> in the current process. 46private readonly SourceText? _text; 52private readonly WeakReference<SourceText?> _computedText = new(target: null); 55/// Checksum of the contents (see <see cref="SourceText.GetContentHash"/>) of the text. 64public SerializableSourceText(SourceText text, ImmutableArray<byte> contentHash) 69public SerializableSourceText(SourceText text, Checksum contentChecksum) 74private SerializableSourceText(TemporaryStorageTextHandle? storageHandle, SourceText? text, Checksum contentChecksum) 93private SourceText? TryGetText() 96public async ValueTask<SourceText> GetTextAsync(CancellationToken cancellationToken) 98var text = TryGetText(); 108public SourceText GetText(CancellationToken cancellationToken) 110var text = TryGetText();
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)
56public static Solution WithTextDocumentText(this Solution solution, DocumentId documentId, SourceText text, PreservationMode mode = PreservationMode.PreserveIdentity)
Shared\Extensions\SourceTextExtensions.cs (12)
35public static void GetLineAndOffset(this SourceText text, int position, out int lineNumber, out int offset) 43public static int GetOffset(this SourceText text, int position) 50this SourceText text, 61public static TextChangeRange GetEncompassingTextChangeRange(this SourceText newText, SourceText oldText) 78public static int IndexOf(this SourceText text, string value, int startIndex, bool caseSensitive) 109public static int LastIndexOf(this SourceText text, string value, int startIndex, bool caseSensitive) 145public static bool ContentEquals(this SourceText text, int position, string value) 163public static int IndexOfNonWhiteSpace(this SourceText text, int start, int length) 176public static void WriteTo(this SourceText sourceText, ObjectWriter writer, CancellationToken cancellationToken) 194private static void WriteChunksTo(SourceText sourceText, ObjectWriter writer, int length, CancellationToken cancellationToken) 225public static SourceText ReadFrom(ITextFactoryService textService, ObjectReader reader, Encoding? encoding, SourceHashAlgorithm checksumAlgorithm, CancellationToken cancellationToken)
SourceGeneration\IRemoteSourceGenerationService.cs (3)
73/// <param name="OriginalSourceTextContentHash">Checksum originally produced from <see cref="SourceText.GetChecksum"/> on 77/// <param name="EncodingName">Result of <see cref="SourceText.Encoding"/>'s <see cref="Encoding.WebName"/>.</param> 78/// <param name="ChecksumAlgorithm">Result of <see cref="SourceText.ChecksumAlgorithm"/>.</param>
src\Compilers\Core\Portable\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)
src\Compilers\Core\Portable\Syntax\SyntaxTreeExtensions.cs (1)
23var text = tree.GetText();
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EditorConfig\Parsing\EditorConfigParser.cs (2)
40return Parse<TEditorConfigFile, TResult, TAccumulator>(SourceText.From(text), pathToFile, accumulator); 43public static TEditorConfigFile Parse<TEditorConfigFile, TEditorConfigOption, TAccumulator>(SourceText text, string? pathToFile, TAccumulator accumulator)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EditorConfig\Parsing\NamingStyles\EditorConfigNamingStylesParser.cs (5)
18=> Parse(SourceText.From(editorConfigText), pathToEditorConfigFile); 21/// Parses a <see cref="SourceText"/> and returns all discovered naming style options and their locations 23/// <param name="editorConfigText">The <see cref="SourceText"/> contents of the editorconfig file.</param> 25/// <returns>A type that represents all discovered naming style options in the given <see cref="SourceText"/>.</returns> 26public static EditorConfigNamingStyles Parse(SourceText editorConfigText, string? pathToEditorConfigFile = null)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EmbeddedLanguages\VirtualChars\AbstractVirtualCharService.cs (1)
195protected static int ConvertTextAtIndexToRune(SourceText tokenText, int index, ImmutableSegmentedList<VirtualChar>.Builder result, int offset)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EmbeddedLanguages\VirtualChars\AbstractVirtualCharService.ITextInfo.cs (4)
12/// Abstraction to allow generic algorithms to run over a string or <see cref="SourceText"/> without any 21private struct SourceTextTextInfo : ITextInfo<SourceText> 23public readonly char Get(SourceText text, int index) => text[index]; 24public readonly int Length(SourceText text) => text.Length;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EmbeddedLanguages\VirtualChars\IVirtualCharService.cs (1)
33/// in the original <see cref="SourceText"/> that the language created that char from.
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EmbeddedLanguages\VirtualChars\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
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\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)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\SyntaxTreeExtensions.cs (2)
25var text = tree.GetText(cancellationToken); 102var text = tree.GetText(cancellationToken);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\TextLineExtensions.cs (3)
14var text = line.Text!; 46var text = line.Text; 67var text = line.Text;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Engine\TreeData.cs (1)
21if (root.SyntaxTree == null || !root.SyntaxTree.TryGetText(out var text))
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Engine\TreeData.Debug.cs (1)
12private sealed class Debug(SyntaxNode root, SourceText text) : NodeAndText(root, text)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Engine\TreeData.NodeAndText.cs (2)
15private readonly SourceText _text; 17public NodeAndText(SyntaxNode root, SourceText text)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Engine\TreeData.StructuredTrivia.cs (2)
27var text = GetText(); 48private SourceText? GetText()
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Indentation\AbstractIndentation.cs (1)
29TSyntaxRoot root, SourceText text, TextLine lineToBeIndented, IndentationOptions options, AbstractFormattingRule baseFormattingRule);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Indentation\AbstractIndentation.Indenter.cs (3)
36public readonly SourceText Text; 44SourceText text, 173var updatedSourceText = Text.WithChanges(changes);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Services\SelectedMembers\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)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\CommonFormattingHelpers.cs (1)
157public static string GetText(this SourceText text, SyntaxToken token1, SyntaxToken token2)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\InterceptsLocationUtilities.cs (1)
15/// (See <see cref="SourceText.GetContentHash()"/>)</param>
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeRefactorings\AbstractRefactoringHelpersService.cs (4)
24public abstract bool IsBetweenTypeMembers(SourceText sourceText, SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? typeDeclaration); 214var sourceText = document.Text; 233SourceText sourceText, SyntaxToken tokenOnLocation, int location) 536var sourceText = document.Text;
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeRefactorings\CodeRefactoringHelpers.cs (1)
111var sourceText = document.Text;
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeRefactorings\IRefactoringHelpersService.cs (1)
25bool IsBetweenTypeMembers(SourceText sourceText, SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? typeDeclaration);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Editing\AddParameterEditor.cs (2)
25var sourceText = declaration.SyntaxTree.GetText(cancellationToken); 159var text = parameters[0].SyntaxTree.GetText(cancellationToken);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Extensions\TextDocumentExtensions.cs (3)
27public static TextDocument WithText(this TextDocument textDocument, SourceText text) 48public static TextDocument WithAdditionalDocumentText(this TextDocument textDocument, SourceText text) 57public static TextDocument WithAnalyzerConfigDocumentText(this TextDocument textDocument, SourceText text)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Indentation\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)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Utilities\ParsedDocument.cs (6)
22/// 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 28internal readonly record struct ParsedDocument(DocumentId Id, SourceText Text, SyntaxNode Root, HostLanguageServices HostLanguageServices) 37var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false); 45var text = document.GetTextSynchronously(cancellationToken); 51public ParsedDocument WithChangedText(SourceText text, CancellationToken cancellationToken) 59var text = root.SyntaxTree.GetText(cancellationToken);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Utilities\SemanticDocument.cs (2)
12internal sealed class SemanticDocument(Document document, SourceText text, SyntaxNode root, SemanticModel semanticModel) 19var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Utilities\SyntacticDocument.cs (3)
15public readonly SourceText Text; 18protected SyntacticDocument(Document document, SourceText text, SyntaxNode root) 30var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false);
TemporaryStorage\TemporaryStorageService.cs (6)
96ITemporaryStorageTextHandle ITemporaryStorageServiceInternal.WriteToTemporaryStorage(SourceText text, CancellationToken cancellationToken) 99async Task<ITemporaryStorageTextHandle> ITemporaryStorageServiceInternal.WriteToTemporaryStorageAsync(SourceText text, CancellationToken cancellationToken) 102public TemporaryStorageTextHandle WriteToTemporaryStorage(SourceText text, CancellationToken cancellationToken) 128public async Task<TemporaryStorageTextHandle> WriteToTemporaryStorageAsync(SourceText text, CancellationToken cancellationToken) 257public async Task<SourceText> ReadFromTemporaryStorageAsync(CancellationToken cancellationToken) 278public SourceText ReadFromTemporaryStorage(CancellationToken cancellationToken)
TemporaryStorage\TrivialTemporaryStorageService.cs (6)
29public ITemporaryStorageTextHandle WriteToTemporaryStorage(SourceText text, CancellationToken cancellationToken) 34public Task<ITemporaryStorageTextHandle> WriteToTemporaryStorageAsync(SourceText text, CancellationToken cancellationToken) 61private readonly SourceText _sourceText; 65public TextStorage(SourceText sourceText) 71public SourceText ReadFromTemporaryStorage(CancellationToken cancellationToken) 76public Task<SourceText> ReadFromTemporaryStorageAsync(CancellationToken cancellationToken)
Workspace\AdhocWorkspace.cs (1)
108public Document AddDocument(ProjectId projectId, string name, SourceText text)
Workspace\Host\DocumentService\IDocumentExcerptService.cs (2)
40internal readonly struct ExcerptResult(SourceText content, TextSpan mappedSpan, ImmutableArray<ClassifiedSpan> classifiedSpans, Document document, TextSpan span) 45public readonly SourceText Content = content;
Workspace\Host\HostWorkspaceServices.cs (1)
118/// A factory that constructs <see cref="SourceText"/>.
Workspace\Host\SyntaxTreeFactory\AbstractSyntaxTreeFactoryService.cs (2)
20public abstract SyntaxTree CreateSyntaxTree(string filePath, ParseOptions options, SourceText text, Encoding encoding, SourceHashAlgorithm checksumAlgorithm, SyntaxNode root); 21public abstract SyntaxTree ParseSyntaxTree(string filePath, ParseOptions options, SourceText text, CancellationToken cancellationToken);
Workspace\Host\SyntaxTreeFactory\ISyntaxTreeFactoryService.cs (2)
30SyntaxTree CreateSyntaxTree(string? filePath, ParseOptions options, SourceText? text, Encoding? encoding, SourceHashAlgorithm checksumAlgorithm, SyntaxNode root); 33SyntaxTree ParseSyntaxTree(string? filePath, ParseOptions options, SourceText text, CancellationToken cancellationToken);
Workspace\Host\TemporaryStorage\ITemporaryStorage.cs (4)
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);
Workspace\Host\TemporaryStorage\ITemporaryStorageService.cs (3)
54ITemporaryStorageTextHandle WriteToTemporaryStorage(SourceText text, CancellationToken cancellationToken); 56/// <inheritdoc cref="WriteToTemporaryStorage(SourceText, CancellationToken)"/>"/> 57Task<ITemporaryStorageTextHandle> WriteToTemporaryStorageAsync(SourceText text, CancellationToken cancellationToken);
Workspace\Host\TemporaryStorage\ITemporaryStorageTextHandle.cs (2)
15SourceText ReadFromTemporaryStorage(CancellationToken cancellationToken); 16Task<SourceText> ReadFromTemporaryStorageAsync(CancellationToken cancellationToken);
Workspace\Host\TemporaryStorage\LegacyTemporaryStorageService.cs (6)
87private SourceText? _sourceText; 92public SourceText ReadText(CancellationToken cancellationToken = default) 95public Task<SourceText> ReadTextAsync(CancellationToken cancellationToken = default) 98public void WriteText(SourceText text, CancellationToken cancellationToken = default) 103var existingValue = Interlocked.CompareExchange(ref _sourceText, text, null); 110public Task WriteTextAsync(SourceText text, CancellationToken cancellationToken = default)
Workspace\Host\TextFactory\ITextFactoryService.cs (6)
13/// A factory for creating <see cref="SourceText"/> instances. 18/// Creates <see cref="SourceText"/> from a stream. 33SourceText CreateText(Stream stream, Encoding? defaultEncoding, SourceHashAlgorithm checksumAlgorithm, CancellationToken cancellationToken); 36/// Creates <see cref="SourceText"/> from a reader with given <paramref name="encoding"/>. 39/// <param name="encoding">Specifies an encoding for the <see cref="SourceText"/>SourceText. 43SourceText CreateText(TextReader reader, Encoding? encoding, SourceHashAlgorithm checksumAlgorithm, CancellationToken cancellationToken);
Workspace\Host\TextFactory\TextFactoryService.cs (4)
25public SourceText CreateText(Stream stream, Encoding? defaultEncoding, SourceHashAlgorithm checksumAlgorithm, CancellationToken cancellationToken) 31public SourceText CreateText(TextReader reader, Encoding? encoding, SourceHashAlgorithm checksumAlgorithm, CancellationToken cancellationToken) 36? SourceText.From(textReaderWithLength, textReaderWithLength.Length, encoding, checksumAlgorithm) 37: SourceText.From(reader.ReadToEnd(), encoding, checksumAlgorithm);
Workspace\Solution\AdditionalDocumentState.cs (1)
53public new AdditionalDocumentState UpdateText(SourceText text, PreservationMode mode)
Workspace\Solution\AdditionalTextWithState.cs (3)
15/// Create a <see cref="SourceText"/> from a <see cref="AdditionalDocumentState"/>. 27/// Retrieves a <see cref="SourceText"/> with the contents of this file. 29public override SourceText GetText(CancellationToken cancellationToken = default)
Workspace\Solution\AnalyzerConfigDocumentState.cs (1)
63public new AnalyzerConfigDocumentState UpdateText(SourceText text, PreservationMode mode)
Workspace\Solution\Document.cs (3)
391public Document WithText(SourceText text) 438if (this.TryGetText(out var text) && oldDocument.TryGetText(out var oldText))
Workspace\Solution\DocumentState.cs (11)
108var text = await this.GetTextAsync(cancellationToken).ConfigureAwait(false); 168var text = textAndVersion.Text; 241var newText = newTextAndVersion.Text; 252private static TreeAndVersion MakeNewTreeAndVersion(SyntaxTree oldTree, SourceText oldText, VersionStamp oldVersion, SyntaxTree newTree, SourceText newText, VersionStamp newVersion) 261private static bool TopLevelChanged(SyntaxTree oldTree, SourceText oldText, SyntaxTree newTree, SourceText newText) 446public new DocumentState UpdateText(SourceText newText, PreservationMode mode) 506else if (TryGetText(out var priorText)) 685SourceText newText, 687SourceText? oldText = null)
Workspace\Solution\DocumentState_LinkedFileReuse.cs (1)
153siblingTree.TryGetText(out var lazyText);
Workspace\Solution\DocumentState_TreeTextSource.cs (1)
18private sealed class TreeTextSource(AsyncLazy<SourceText> textSource, VersionStamp version) : ITextAndVersionSource
Workspace\Solution\FileTextLoader.cs (7)
68GetType(), _ => new StrongBox<bool>(new Func<Stream, Workspace, SourceText>(CreateText).Method.DeclaringType != typeof(FileTextLoader))).Value; 72/// Creates <see cref="SourceText"/> from <see cref="Stream"/>. 76protected virtual SourceText CreateText(Stream stream, Workspace? workspace) 80/// Creates <see cref="SourceText"/> from <see cref="Stream"/>. 83private protected virtual SourceText CreateText(Stream stream, LoadTextOptions options, CancellationToken cancellationToken) 183var text = t.self.CreateText(readStream, t.options, t.cancellationToken); 207var text = t.self.CreateText(stream, t.options, t.cancellationToken);
Workspace\Solution\LoadTextOptions.cs (1)
11/// Options used to load <see cref="SourceText"/>.
Workspace\Solution\Project.cs (3)
711public Document AddDocument(string name, SourceText text, IEnumerable<string>? folders = null, string? filePath = null) 729public TextDocument AddAdditionalDocument(string name, SourceText text, IEnumerable<string>? folders = null, string? filePath = null) 747public TextDocument AddAnalyzerConfigDocument(string name, SourceText text, IEnumerable<string>? folders = null, string? filePath = null)
Workspace\Solution\ProjectState.cs (1)
149var text = await documentState.GetTextAsync(cancellationToken).ConfigureAwait(false);
Workspace\Solution\Solution.cs (17)
938var sourceText = SourceText.From(text, encoding: null, checksumAlgorithm: project.ChecksumAlgorithm); 947public Solution AddDocument(DocumentId documentId, string name, SourceText text, IEnumerable<string>? folders = null, string? filePath = null, bool isGenerated = false) 978var sourceText = SourceText.From(string.Empty, encoding: null, project.ChecksumAlgorithm); 984private Solution AddDocumentImpl(ProjectState project, DocumentId documentId, string name, SourceText text, IReadOnlyList<string>? folders, string? filePath, bool isGenerated) 1039=> this.AddAdditionalDocument(documentId, name, SourceText.From(text), folders, filePath); 1045public Solution AddAdditionalDocument(DocumentId documentId, string name, SourceText text, IEnumerable<string>? folders = null, string? filePath = null) 1076public Solution AddAnalyzerConfigDocument(DocumentId documentId, string name, SourceText text, IEnumerable<string>? folders = null, string? filePath = null) 1100private DocumentInfo CreateDocumentInfo(DocumentId documentId, string name, SourceText text, IEnumerable<string>? folders, string? filePath) 1238public Solution WithDocumentText(DocumentId documentId, SourceText text, PreservationMode mode = PreservationMode.PreserveValue) 1241internal Solution WithDocumentTexts(ImmutableArray<(DocumentId documentId, SourceText text)> texts, PreservationMode mode = PreservationMode.PreserveValue) 1261public Solution WithAdditionalDocumentText(DocumentId documentId, SourceText text, PreservationMode mode = PreservationMode.PreserveValue) 1282public Solution WithAnalyzerConfigDocumentText(DocumentId documentId, SourceText text, PreservationMode mode = PreservationMode.PreserveValue) 1592public Solution WithDocumentText(IEnumerable<DocumentId?> documentIds, SourceText text, PreservationMode mode = PreservationMode.PreserveValue) 1618SourceGeneratedDocumentIdentity documentIdentity, DateTime generationDateTime, SourceText text) 1630internal Solution WithFrozenSourceGeneratedDocuments(ImmutableArray<(SourceGeneratedDocumentIdentity documentIdentity, DateTime generationDateTime, SourceText text)> documents)
Workspace\Solution\SolutionCompilationState.cs (11)
781internal SolutionCompilationState WithDocumentTexts(ImmutableArray<(DocumentId documentId, SourceText text)> texts, PreservationMode mode) 782=> UpdateDocumentsInMultipleProjects<DocumentState, SourceText, PreservationMode>( 788private static bool SourceTextIsUnchanged(DocumentState oldDocument, SourceText text) 789=> oldDocument.TryGetText(out var oldText) && text == oldText; 906/// <inheritdoc cref="SolutionState.WithAdditionalDocumentText(DocumentId, SourceText, PreservationMode)"/> 908DocumentId documentId, SourceText text, PreservationMode mode) 914/// <inheritdoc cref="SolutionState.WithAnalyzerConfigDocumentText(DocumentId, SourceText, PreservationMode)"/> 916DocumentId documentId, SourceText text, PreservationMode mode) 1315ImmutableArray<(SourceGeneratedDocumentIdentity documentIdentity, DateTime generationDateTime, SourceText sourceText)> documents) 1759public SolutionCompilationState WithDocumentText(IEnumerable<DocumentId?> documentIds, SourceText text, PreservationMode mode) 1761using var _ = ArrayBuilder<(DocumentId, SourceText)>.GetInstance(out var changedDocuments);
Workspace\Solution\SolutionCompilationState.RegularCompilationTracker_Generators.cs (2)
190var sourceText = SourceText.From(
Workspace\Solution\SolutionState.cs (6)
951public StateChange WithDocumentText(DocumentId documentId, SourceText text, PreservationMode mode = PreservationMode.PreserveValue) 954if (oldDocument.TryGetText(out var oldText) && text == oldText) 979public StateChange WithAdditionalDocumentText(DocumentId documentId, SourceText text, PreservationMode mode = PreservationMode.PreserveValue) 982if (oldDocument.TryGetText(out var oldText) && text == oldText) 995public StateChange WithAnalyzerConfigDocumentText(DocumentId documentId, SourceText text, PreservationMode mode = PreservationMode.PreserveValue) 998if (oldDocument.TryGetText(out var oldText) && text == oldText)
Workspace\Solution\SourceGeneratedDocumentState.cs (7)
29public SourceText SourceText { get; } 33/// different from the checksum acquired from <see cref="SourceText.GetChecksum"/>. Specifically, the original 46SourceText generatedSourceText, 63SourceText generatedSourceText, 107SourceText text, 121private static Checksum ComputeContentHash(SourceText text) 139public SourceGeneratedDocumentState WithText(SourceText sourceText)
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 (4)
64public bool TryGetText([NotNullWhen(returnValue: true)] out SourceText? text) 76public Task<SourceText> GetTextAsync(CancellationToken cancellationToken = default) 79internal ValueTask<SourceText> GetValueTextAsync(CancellationToken cancellationToken) 87internal SourceText GetTextSynchronously(CancellationToken cancellationToken)
Workspace\Solution\TextDocumentState.cs (7)
80public bool TryGetText([NotNullWhen(returnValue: true)] out SourceText? text) 100public ValueTask<SourceText> GetTextAsync(CancellationToken cancellationToken) 102if (TryGetText(out var text)) 104return new ValueTask<SourceText>(text); 114public SourceText GetTextSynchronously(CancellationToken cancellationToken) 145public TextDocumentState UpdateText(SourceText newText, PreservationMode mode) 164: CreateStrongText(TextAndVersion.Create(SourceText.From(string.Empty, encoding: null, loadTextOptions.ChecksumAlgorithm), VersionStamp.Default, filePath));
Workspace\Solution\TextLoader.cs (5)
42/// True if <see cref="LoadTextAndVersionAsync(LoadTextOptions, CancellationToken)"/> reloads <see cref="SourceText"/> from its original binary representation (e.g. file on disk). 51/// Implementations of this method should use <see cref="LoadTextOptions.ChecksumAlgorithm"/> when creating <see cref="SourceText"/> from an original binary representation and 53/// Callers of this method should pass <see cref="LoadTextOptions"/> specifying the desired properties of <see cref="SourceText"/>. The implementation may return a <see cref="SourceText"/> 177SourceText.From(string.Empty, Encoding.UTF8),
Workspace\Solution\VersionSource\ITextAndVersionSource.cs (1)
15/// True if <see cref="SourceText"/> can be reloaded.
Workspace\Solution\VersionSource\RecoverableTextAndVersion.cs (4)
166public TextAndVersion ToTextAndVersion(SourceText text) 171private async Task<SourceText> RecoverAsync(CancellationToken cancellationToken) 181private SourceText Recover(CancellationToken cancellationToken) 191private async Task SaveAsync(SourceText text, CancellationToken cancellationToken)
Workspace\Solution\VersionSource\RecoverableTextAndVersion.RecoverableText.cs (14)
19/// This class holds onto a <see cref="SourceText"/> value weakly, but can save its value and recover it on demand 27private static readonly AsyncBatchingWorkQueue<(RecoverableText recoverableText, SourceText sourceText)> s_saveQueue = 47private SourceText? _initialValue; 53private WeakReference<SourceText>? _weakReference; 61private bool TryGetWeakValue([NotNullWhen(true)] out SourceText? value) 71private bool TryGetStrongOrWeakValue([NotNullWhen(true)] out SourceText? value) 82public bool TryGetValue([MaybeNullWhen(false)] out SourceText value) 85public SourceText GetValue(CancellationToken cancellationToken) 91if (TryGetWeakValue(out var instance)) 107public async Task<SourceText> GetValueAsync(CancellationToken cancellationToken) 113if (TryGetWeakValue(out var instance)) 132private void UpdateWeakReferenceAndEnqueueSaveTask_NoLock(SourceText instance) 136_weakReference ??= new WeakReference<SourceText>(instance); 149ImmutableSegmentedList<(RecoverableText recoverableText, SourceText sourceText)> list, CancellationToken cancellationToken)
Workspace\TextExtensions.cs (5)
19public static ImmutableArray<Document> GetRelatedDocumentsWithChanges(this SourceText text) 49public static Document? GetOpenDocumentInCurrentContextWithChanges(this SourceText text) 56public static TextDocument? GetOpenTextDocumentInCurrentContextWithChanges(this SourceText text) 59private static TextDocument? GetOpenTextDocumentInCurrentContextWithChanges(this SourceText text, bool sourceDocumentOnly) 144internal static Document? GetDocumentWithFrozenPartialSemantics(this SourceText text, CancellationToken cancellationToken)
Workspace\Workspace.cs (18)
1100protected internal void OnDocumentTextChanged(DocumentId documentId, SourceText newText, PreservationMode mode) 1103private protected void OnDocumentTextChanged(DocumentId documentId, SourceText newText, PreservationMode mode, bool requireDocumentPresent) 1118protected internal void OnAdditionalDocumentTextChanged(DocumentId documentId, SourceText newText, PreservationMode mode) 1133protected internal void OnAnalyzerConfigDocumentTextChanged(DocumentId documentId, SourceText newText, PreservationMode mode) 1900var text = document.GetTextSynchronously(CancellationToken.None); 1909var text = document.GetTextSynchronously(CancellationToken.None); 1918var text = document.GetTextSynchronously(CancellationToken.None); 1935var currentText = newDoc.GetTextSynchronously(CancellationToken.None); // needs wait 1945var currentText = newDoc.GetTextSynchronously(CancellationToken.None); // needs wait 1962if (!oldDoc.TryGetText(out var oldText)) 1967var currentText = newDoc.GetTextSynchronously(CancellationToken.None); // needs wait 1970else if (!newDoc.TryGetText(out var newText)) 2175protected virtual void ApplyDocumentAdded(DocumentInfo info, SourceText text) 2197protected virtual void ApplyDocumentTextChanged(DocumentId id, SourceText text) 2219protected virtual void ApplyAdditionalDocumentAdded(DocumentInfo info, SourceText text) 2241protected virtual void ApplyAdditionalDocumentTextChanged(DocumentId id, SourceText text) 2252protected virtual void ApplyAnalyzerConfigDocumentAdded(DocumentInfo info, SourceText text) 2274protected 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)
395var newText = textContainer.CurrentText; 396if (oldDocument.TryGetText(out var oldText) && 485private static TextAndVersion GetProperTextAndVersion(SourceText oldText, SourceText newText, VersionStamp version, string? filePath) 494private void SignupForTextChanges(DocumentId documentId, SourceTextContainer textContainer, bool isCurrentContext, Action<Workspace, DocumentId, SourceText, PreservationMode> onChangedHandler) 555Func<Solution, DocumentId, SourceText, PreservationMode, Solution> withDocumentText, 557Action<Workspace, DocumentId, SourceText, PreservationMode> onDocumentTextChanged) 587var oldText = oldDocument.GetTextSynchronously(CancellationToken.None); 590var newText = data.textContainer.CurrentText; 849private SourceText GetOpenDocumentText(Solution solution, DocumentId documentId) 854Contract.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 (5)
MSBuild\MSBuildWorkspace.cs (5)
385protected override void ApplyDocumentTextChanged(DocumentId documentId, SourceText text) 403protected override void ApplyAdditionalDocumentTextChanged(DocumentId documentId, SourceText text) 421private static Encoding? DetermineEncoding(SourceText text, TextDocument document) 449protected override void ApplyDocumentAdded(DocumentInfo info, SourceText text) 487private void SaveDocumentText(DocumentId id, string fullPath, SourceText newText, Encoding encoding)
Microsoft.CodeAnalysis.Workspaces.MSBuild.UnitTests (42)
VisualStudioMSBuildWorkspaceTests.cs (42)
398var solution1 = solution.WithDocumentText(document.Id, SourceText.From("using test;")); 965var text = await getTextTask; 990var text = await doc.GetTextAsync(); 2014var newText = SourceText.From("public class Bar { }"); 2023var text2 = await document2.GetTextAsync(); 2055var originalText = await document.GetTextAsync(); 2057var newText = SourceText.From("public class Bar { }"); 2066var text2 = await document2.GetTextAsync(); 2074var text = await document.GetTextAsync(); 2089var originalText = await document.GetTextAsync(); 2102var text = await document.GetTextAsync(); 2116var text = await document.GetTextAsync(); 2117var newText = SourceText.From("using System.Diagnostics;\r\n" + text.ToString()); 2125var text2 = await document2.GetTextAsync(); 2143var text = await document.GetTextAsync(); 2144var newText = SourceText.From("New Text In Additional File.\r\n" + text.ToString()); 2152var text2 = await document2.GetTextAsync(); 2170var newText = SourceText.From("public class Bar { }"); 2178var text2 = await document2.GetTextAsync(); 2206workspace.TryApplyChanges(workspace.CurrentSolution.AddAdditionalDocument(DocumentId.CreateNewId(csProjectId), "foo.xaml", SourceText.From("<foo></foo>"))); 2239var text = await doc.GetTextAsync(); 2242workspace.TryApplyChanges(workspace.CurrentSolution.WithDocumentText(doc.Id, SourceText.From(newText), PreservationMode.PreserveIdentity)); 2269var text = await doc.GetTextAsync(); 2277SourceText.From(newText), 2353var text = await doc.GetTextAsync(); 2371var documentText = document.GetTextSynchronously(CancellationToken.None); 2375var additionalDocumentText = additionalDocument.GetTextSynchronously(CancellationToken.None); 2794var text = await document.GetTextAsync(); 2813var text = await document.GetTextAsync(); 2832var text = await document.GetTextAsync(); 2885var doc2text = await doc2.GetTextAsync(); 2892var text = await document.GetTextAsync(); 2898var doc3text = await doc3.GetTextAsync(); 2907var noEncodingDoc = document.WithText(SourceText.From(text.ToString(), encoding: null)); 2908var noEncodingDocText = await noEncodingDoc.GetTextAsync(); 3246var text = await analyzerConfigDocument.GetTextAsync(); 3309var text = await document.GetTextAsync();
Microsoft.CodeAnalysis.Workspaces.Test.Utilities (23)
Formatting\FormattingTestBase.cs (6)
49var document = project.AddDocument("Document", SourceText.From(code)); 83private static async Task AssertFormatAsync(SolutionServices services, string expected, SyntaxNode root, ImmutableArray<TextSpan> spans, SyntaxFormattingOptions options, SourceText sourceText) 90var resultText = sourceText.WithChanges(result); 99private static bool TryAdjustSpans(SourceText inputText, IList<TextChange> changes, SourceText outputText, ImmutableArray<TextSpan> inputSpans, out ImmutableArray<TextSpan> outputSpans) 127protected 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)
Workspaces\TestHostDocument.cs (1)
189=> Task.FromResult(TextAndVersion.Create(SourceText.From(_text, encoding: null, options.ChecksumAlgorithm), VersionStamp.Create(), _hostDocument.FilePath));
Workspaces\TestWorkspace_ILspWorkspace.cs (1)
17ValueTask ILspWorkspace.UpdateTextIfPresentAsync(DocumentId documentId, SourceText sourceText, CancellationToken cancellationToken)
Workspaces\TestWorkspace_XmlConsumption.cs (2)
790var sourceText = SourceText.From(referencedCode, encoding: null, SourceHashAlgorithms.Default);
Workspaces\TestWorkspace`1.cs (6)
391protected override void ApplyDocumentAdded(DocumentInfo info, SourceText text) 417protected override void ApplyAdditionalDocumentAdded(DocumentInfo info, SourceText text) 441protected override void ApplyAnalyzerConfigDocumentAdded(DocumentInfo info, SourceText text) 540public Task ChangeDocumentAsync(DocumentId documentId, SourceText text) 561public void ChangeAdditionalDocument(DocumentId documentId, SourceText text) 568public void ChangeAnalyzerConfigDocument(DocumentId documentId, SourceText text)
Microsoft.CodeAnalysis.Workspaces.UnitTests (296)
CodeCleanup\AddMissingTokensTests.cs (1)
2733.AddDocument("Document", SourceText.From(code));
CodeCleanup\CodeCleanupTests.cs (1)
420return project.AddDocument("Document", SourceText.From(code));
CodeCleanup\FixIncorrectTokenTests.cs (1)
758.AddDocument("Document", SourceText.From(code));
CodeCleanup\NormalizeModifiersOrOperatorsTests.cs (1)
1033return project.AddDocument("Document", SourceText.From(code));
CodeCleanup\ReduceTokenTests.cs (1)
2021.AddDocument("Document", SourceText.From(code));
CodeCleanup\RemoveUnnecessaryLineContinuationTests.cs (1)
1463return 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 (5)
40return solution.AddProject(pi).AddDocument(did, $"{projectName}.{suffix}", SourceText.From(code)); 56return solution.AddProject(pi).AddDocument(did, $"{projectName}.{suffix}", SourceText.From(code)); 66.AddDocument(did, "goo.cs", SourceText.From(sourceText)); 82solution = solution.AddDocument(did, $"goo{docCounter++}.cs", SourceText.From(sourceText)); 126.AddDocument(did, "goo.cs", SourceText.From(text));
Formatter\FormatterTests.cs (6)
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(); 70var document = workspace.AddDocument(project.Id, "File.dummy", SourceText.From("dummy")); 115var csDocument = workspace.AddDocument(csProject.Id, "File.cs", SourceText.From("class C { }")); 116var 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)
30.AddDocument("Document", SourceText.From(code)); 90var document2 = document1.WithText(SourceText.From("class C { void M() { return null; } }")); 107var document2 = document1.WithText(SourceText.From("class C { long M() { return; } }")); 113var document3 = document2.WithText(SourceText.From("class C { long M() { return 0; } }")); 130var document2 = document1.WithText(SourceText.From("class C { void M() { return 0; } }")); 136var document3 = document1.WithText(SourceText.From("class C { void M() { return 1; } }")); 153var document2 = document1.WithText(SourceText.From("class C { int M { get { return 1; } } }")); 159var document3 = document1.WithText(SourceText.From("class C { int M { get { return 2; } } }")); 176var document2 = document1.WithText(SourceText.From("class C { event System.Action E { add { return 1; } } }")); 182var document3 = document1.WithText(SourceText.From("class C { event System.Action E { add { return 2; } } }")); 199var document2 = document1.WithText(SourceText.From("class C { int this[int i] { get { return 1; } } }")); 205var 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; } }")); 250var document2 = document1.WithText(SourceText.From(source2)); 334var document2 = document1.WithText(SourceText.From(@" 367var document2 = document1.WithText(SourceText.From(source2)); 373var document3 = document2.WithText(SourceText.From(@" 400var document2 = document1.WithText(SourceText.From(@" 411var document3 = document1.WithText(SourceText.From(@" 440var document2 = document1.WithText(SourceText.From(@" 453var document3 = document1.WithText(SourceText.From(@" 484var document2 = document1.WithText(SourceText.From(@" 497var document3 = document1.WithText(SourceText.From(@" 527var document2 = document1.WithText(SourceText.From(@" 558var document2 = document1.WithText(SourceText.From(@"
Simplifier\SimplifierTests.cs (3)
29return workspace.AddDocument(project.Id, "CSharpFile.cs", SourceText.From("class C { }")); 78var csDocument = workspace.AddDocument(csProject.Id, "File.cs", SourceText.From("class C { }")); 79var 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 (131)
60.AddDocument(DocumentId.CreateNewId(projectId), "goo.cs", SourceText.From("public class Goo { }", Encoding.UTF8, SourceHashAlgorithms.Default), filePath: Path.Combine(s_projectDir, "goo.cs")) 61.AddAdditionalDocument(DocumentId.CreateNewId(projectId), "add.txt", SourceText.From("text", Encoding.UTF8, SourceHashAlgorithms.Default)) 62.AddAnalyzerConfigDocument(DocumentId.CreateNewId(projectId), "editorcfg", SourceText.From(editorConfig ?? "#empty", Encoding.UTF8, SourceHashAlgorithms.Default), filePath: Path.Combine(s_projectDir, "editorcfg")))); 82.AddDocument(DocumentId.CreateNewId(projectId1), "goo.cs", SourceText.From(docContents, Encoding.UTF8, SourceHashAlgorithms.Default), filePath: "goo.cs") 83.AddAdditionalDocument(DocumentId.CreateNewId(projectId1), "add.txt", SourceText.From("text", Encoding.UTF8, SourceHashAlgorithms.Default), filePath: "add.txt") 84.AddAnalyzerConfigDocument(DocumentId.CreateNewId(projectId1), "editorcfg", SourceText.From("config", Encoding.UTF8, SourceHashAlgorithms.Default), filePath: "/a/b") 86.AddDocument(DocumentId.CreateNewId(projectId2), "goo.cs", SourceText.From(docContents, Encoding.UTF8, SourceHashAlgorithms.Default), filePath: "goo.cs") 87.AddAdditionalDocument(DocumentId.CreateNewId(projectId2), "add.txt", SourceText.From("text", Encoding.UTF8, SourceHashAlgorithms.Default), filePath: "add.txt") 88.AddAnalyzerConfigDocument(DocumentId.CreateNewId(projectId2), "editorcfg", SourceText.From("config", Encoding.UTF8, SourceHashAlgorithms.Default), filePath: "/a/b"))); 334.AddAnalyzerConfigDocument(DocumentId.CreateNewId(projectId), "editorcfg", SourceText.From("config")); 350var text = SourceText.From("new text", encoding: null, SourceHashAlgorithm.Sha1); 361Assert.Throws<ArgumentNullException>(() => solution.WithDocumentText(documentId, (SourceText)null!, PreservationMode.PreserveIdentity)); 374var textAndVersion = TextAndVersion.Create(SourceText.From("new text"), VersionStamp.Default); 377Assert.True(newSolution1.GetDocument(documentId)!.TryGetText(out var actualText)); 385Assert.Throws<ArgumentNullException>(() => solution.WithDocumentText(documentId, (SourceText)null!, PreservationMode.PreserveIdentity)); 398var text = SourceText.From("new text"); 451var text = SourceText.From("new text", encoding: null, SourceHashAlgorithm.Sha1); 496private static Solution UpdateSolution(PreservationMode mode, TextUpdateType updateType, Solution solution, DocumentId documentId1, SourceText text, TextAndVersion textAndVersion) 539var text = SourceText.From("new text", encoding: null, SourceHashAlgorithm.Sha1); 622var text = SourceText.From("new text without pp directives", encoding: null, SourceHashAlgorithm.Sha1); 705var text = SourceText.From("#if true", encoding: null, SourceHashAlgorithm.Sha1); 781var text = SourceText.From("new text", encoding: null, SourceHashAlgorithm.Sha1); 843.AddDocument(DocumentId.CreateNewId(projectId1), "goo.cs", SourceText.From(docContents, Encoding.UTF8, SourceHashAlgorithms.Default), filePath: "goo.cs") 845.AddDocument(DocumentId.CreateNewId(projectId2), "goo.cs", SourceText.From(docContents, Encoding.UTF8, SourceHashAlgorithms.Default), filePath: "goo.cs"))); 868var text = SourceText.From(" ", encoding: null, SourceHashAlgorithm.Sha1); 920var text = SourceText.From("new text"); 923Assert.True(newSolution1.GetAdditionalDocument(documentId)!.TryGetText(out var actualText)); 929Assert.Throws<ArgumentNullException>(() => solution.WithAdditionalDocumentText(documentId, (SourceText)null!, PreservationMode.PreserveIdentity)); 942var textAndVersion = TextAndVersion.Create(SourceText.From("new text"), VersionStamp.Default); 945Assert.True(newSolution1.GetAdditionalDocument(documentId)!.TryGetText(out var actualText)); 953Assert.Throws<ArgumentNullException>(() => solution.WithAdditionalDocumentText(documentId, (SourceText)null!, PreservationMode.PreserveIdentity)); 966var text = SourceText.From("new text"); 969Assert.True(newSolution1.GetAnalyzerConfigDocument(documentId)!.TryGetText(out var actualText)); 975Assert.Throws<ArgumentNullException>(() => solution.WithAnalyzerConfigDocumentText(documentId, (SourceText)null!, PreservationMode.PreserveIdentity)); 988var textAndVersion = TextAndVersion.Create(SourceText.From("new text"), VersionStamp.Default); 991Assert.True(newSolution1.GetAnalyzerConfigDocument(documentId)!.TryGetText(out var actualText)); 999Assert.Throws<ArgumentNullException>(() => solution.WithAnalyzerConfigDocumentText(documentId, (SourceText)null!, PreservationMode.PreserveIdentity)); 1093.AddDocument(d1, "d1.cs", SourceText.From("class D1;", Encoding.UTF8, SourceHashAlgorithms.Default), filePath: Path.Combine(s_projectDir, "d1.cs")) 1094.AddDocument(d2, "d2.cs", SourceText.From("class D2;", Encoding.UTF8, SourceHashAlgorithms.Default), filePath: Path.Combine(s_projectDir, "d2.cs")) 1095.AddAdditionalDocument(a1, "a1.txt", SourceText.From("text1", Encoding.UTF8, SourceHashAlgorithms.Default)) 1096.AddAdditionalDocument(a2, "a2.txt", SourceText.From("text2", Encoding.UTF8, SourceHashAlgorithms.Default)) 1097.AddAnalyzerConfigDocument(c1, "c1", SourceText.From("#empty1", Encoding.UTF8, SourceHashAlgorithms.Default), filePath: Path.Combine(s_projectDir, "editorcfg")) 1098.AddAnalyzerConfigDocument(c2, "c2", SourceText.From("#empty2", Encoding.UTF8, SourceHashAlgorithms.Default), filePath: Path.Combine(s_projectDir, "editorcfg")); 1108loader: TextLoader.From(TextAndVersion.Create(SourceText.From("class NewD1;", Encoding.UTF32, SourceHashAlgorithm.Sha256), VersionStamp.Create(), filePath: Path.Combine(s_projectDir, "newD1.cs"))), 1117loader: TextLoader.From(TextAndVersion.Create(SourceText.From("class NewD3;", Encoding.UTF8, SourceHashAlgorithms.Default), VersionStamp.Create(), filePath: Path.Combine(s_projectDir, "newD3.cs"))), 1127loader: TextLoader.From(TextAndVersion.Create(SourceText.From("new text1", Encoding.UTF32, SourceHashAlgorithm.Sha256), VersionStamp.Create(), filePath: Path.Combine(s_projectDir, "newD1.cs"))), 1136loader: TextLoader.From(TextAndVersion.Create(SourceText.From("new text3", Encoding.UTF8, SourceHashAlgorithms.Default), VersionStamp.Create(), filePath: Path.Combine(s_projectDir, "newD3.cs"))), 1146loader: TextLoader.From(TextAndVersion.Create(SourceText.From("#new empty1", Encoding.UTF32, SourceHashAlgorithm.Sha256), VersionStamp.Create(), filePath: Path.Combine(s_projectDir, "newD1.cs"))), 1155loader: TextLoader.From(TextAndVersion.Create(SourceText.From("#new empty3", Encoding.UTF8, SourceHashAlgorithms.Default), VersionStamp.Create(), filePath: Path.Combine(s_projectDir, "newD3.cs"))), 1619var textC = SourceText.From("class C {}", encoding: null, checksumAlgorithm: SourceHashAlgorithm.Sha1); 2311var solution4 = solution3.AddAnalyzerConfigDocument(editorConfigId, ".editorconfig", SourceText.From(editorConfigContent), filePath: Path.Combine(s_projectDir, "subfolder", ".editorconfig")); 2422var sourceText = SourceText.From("text", checksumAlgorithm: SourceHashAlgorithms.Default); 2436Assert.Throws<ArgumentNullException>("text", () => solution.AddDocument(documentId, "name", text: (SourceText)null!)); 2483var root = CSharp.SyntaxFactory.ParseSyntaxTree(SourceText.From("class C {}", encoding: null, SourceHashAlgorithm.Sha1)).GetRoot(); 3161.AddDocument(documentId, "DocumentName", SourceText.From("class Class{}")); 3201var text2 = tree2.GetText(); 3314var observedText2 = sol.GetDocument(did).GetTextAsync().Result; 3332var docText = doc.GetTextAsync().Result; 3354var docText = doc.GetTextAsync().Result; 3379var docText = doc.GetTextAsync().Result; 3525private static ObjectReference<SourceText> GetObservedText(Solution solution, DocumentId documentId, string expectedText = null) 3527var observedText = solution.GetDocument(documentId).GetTextAsync().Result; 3534return new ObjectReference<SourceText>(observedText); 3556private static ObjectReference<SourceText> GetObservedTextAsync(Solution solution, DocumentId documentId, string expectedText = null) 3558var observedText = solution.GetDocument(documentId).GetTextAsync().Result; 3565return new ObjectReference<SourceText>(observedText); 3773.AddDocument(did, "test", SourceText.From(language == LanguageNames.CSharp ? "class C {}" : "Class C : End Class", Encoding.UTF8, SourceHashAlgorithm.Sha256), filePath: "old path"); 3916var text = await doc.GetTextAsync().ConfigureAwait(false); 3978var solution2 = solution.WithDocumentText(did3, SourceText.From(text4)); 3991var doc = ws.AddDocument(proj.Id, "a.cs", SourceText.From("public class c { }", Encoding.UTF32)); 4052workspace.AddDocument(project1.Id, "Broken.cs", SourceText.From("class ")); 4074project = project.AddDocument("Extra.cs", SourceText.From("class Extra { }")).Project; 4076var documentToFreeze = project.AddDocument("DocumentToFreeze.cs", SourceText.From("")); 4099project = project.AddDocument("Extra.cs", SourceText.From("class Extra { }")).Project; 4101var documentToFreeze = project.AddDocument("DocumentToFreeze.cs", SourceText.From("")); 4127project = project.AddDocument("Extra.cs", SourceText.From("class Extra { }")).Project; 4129var documentToFreezeOriginal = project.AddDocument("DocumentToFreeze.cs", SourceText.From("class DocumentToFreeze { void M() { } }")); 4133var solution = project.Solution.WithDocumentText(documentToFreezeOriginal.Id, SourceText.From("class DocumentToFreeze { void M() { /*no top level change*/ } }")); 4172project = project.AddDocument("Extra.cs", SourceText.From("class Extra { }")).Project; 4174var documentToFreezeOriginal = project.AddDocument("DocumentToFreeze.cs", SourceText.From("class DocumentToFreeze { void M() { } }")); 4178var solution = project.Solution.WithDocumentText(documentToFreezeOriginal.Id, SourceText.From("class DocumentToFreeze { void M() { } public void NewMethod() { } }")); 4236var document = workspace.AddDocument(project2.Id, "Test.cs", SourceText.From("")); 4340document = document.WithText(SourceText.From("// Source File with Changes")); 4366.WithDocumentText(documentId1, SourceText.From("// Document 1 Changed")) 4367.WithDocumentText(documentId2, SourceText.From("// Document 2 Changed")) 4368.WithDocumentText(documentId3, SourceText.From("// Document 3 Changed")); 4553var text = SourceText.From("// empty", encoding: null, SourceHashAlgorithms.Default); 4556var sourceText = strongTree.GetText(); 4688loader: TextLoader.From(TextAndVersion.Create(SourceText.From("[*.*]\r\n\r\ndotnet_diagnostic.CA1234.severity = error"), VersionStamp.Default))))); 4721loader: TextLoader.From(TextAndVersion.Create(SourceText.From("[*.*]\r\n\r\ndotnet_diagnostic.CA1234.severity = error"), VersionStamp.Default))))); 4762loader: TextLoader.From(TextAndVersion.Create(SourceText.From("[*.*]\r\n\r\ndotnet_diagnostic.CA1234.severity = error"), VersionStamp.Default))))); 4774TextLoader.From(TextAndVersion.Create(SourceText.From("[*.*]\r\n\r\ndotnet_diagnostic.CA6789.severity = error"), VersionStamp.Default)), 4810loader: TextLoader.From(TextAndVersion.Create(SourceText.From("is_global = true\r\n\r\ndotnet_diagnostic.CA1234.severity = error"), VersionStamp.Default))))); 4856loader: TextLoader.From(TextAndVersion.Create(SourceText.From("[*.*]\r\n\r\ngenerated_code = true"), VersionStamp.Default))))); 5421var text = SourceText.From("public class C { }"); 5442var newDocText = await newDoc.GetTextAsync(); 5443var sameText = await newDoc.GetTextAsync(); 5447var treeText = newDocTree.GetText(); 5469var sourceTextToRelease = ObjectReference.CreateFromFactory(static () => SourceText.From(Guid.NewGuid().ToString())); 5517.AddDocument(documentId, "test.cs", SourceText.From("public class C { }"), filePath: sourcePath) 5518.AddAnalyzerConfigDocument(DocumentId.CreateNewId(projectId), ".editorconfig", SourceText.From($"[{pattern}]\nindent_style = tab"), filePath: configPath); 5578project = project.AddDocument("Extra.cs", SourceText.From("class Extra { }")).Project; 5595project = project.AddDocument("Extra.cs", SourceText.From("class Extra { }")).Project; 5616project1 = project2.Solution.GetProject(project1.Id).AddDocument("Doc1", SourceText.From("class Doc1 { }")).Project; 5617project2 = project1.Solution.GetProject(project2.Id).AddDocument("Doc2", SourceText.From("class Doc2 { }")).Project; 5644project1 = project2.Solution.GetProject(project1.Id).AddDocument("Doc1", SourceText.From("class Doc1 { }")).Project; 5645project2 = project1.Solution.GetProject(project2.Id).AddDocument("Doc2", SourceText.From("class Doc2 { }")).Project; 5674project1 = project2.Solution.GetProject(project1.Id).AddDocument("Doc1", SourceText.From("class Doc1 { }")).Project; 5675project2 = project1.Solution.GetProject(project2.Id).AddDocument("Doc2", SourceText.From("class Doc2 { }")).Project; 5706project1 = project1.AddDocument("Doc1", SourceText.From("class Doc1 { }")).Project; 5715var forkedProject1 = frozenSolution.WithDocumentText(project1.Documents.Single().Id, SourceText.From("class Doc2 { }")).GetProject(project1.Id); 5734project1 = project1.AddDocument("Doc1", SourceText.From("class Doc1 { }")).Project; 5754var forkedProject1 = frozenSolution.WithDocumentText(project1.Documents.Single().Id, SourceText.From("class Doc2 { }")).GetProject(project1.Id); 5783project = project.AddDocument("Extra.ts", SourceText.From("class Extra { }")).Project; 5806.AddDocument($"Document", SourceText.From("class C { }"), filePath: @"c:\test\Document.cs").Project; 5816.AddDocument($"Document", SourceText.From("class C { }"), filePath: @"c:\test\Document.cs").Project; 5827old => old.WithDocumentText(documentId1, SourceText.From(lastContents)),
SolutionTests\SolutionWithSourceGeneratorTests.cs (23)
206project = project.AdditionalDocuments.First().WithAdditionalDocumentText(SourceText.From("Changed text!")).Project; 230project = project.AddDocument("Source.cs", SourceText.From("")).Project; 263project = project.Solution.WithDocumentText(documentId, SourceText.From("// Changed Source File")).Projects.Single(); 306project = project.Solution.WithAdditionalDocumentText(additionalDocumentId, SourceText.From("Hello, everyone!")).Projects.Single(); 311project = project.Solution.WithAdditionalDocumentText(additionalDocumentId, SourceText.From("Good evening, everyone!")).Projects.Single(); 375SourceText.From("Hello, world!!!!")).Projects.Single(); 489project = project.Documents.Single().WithText(SourceText.From("// Change")).Project; 565var existingText = await project.Documents.Single().GetTextAsync(); 566var newText = existingText.WithChanges(new TextChange(new TextSpan(existingText.Length, length: 0), " With Change")); 595var differentOpenTextContainer = SourceText.From("// Open Text").Container; 619var differentOpenTextContainer = SourceText.From("// StaticContent", Encoding.UTF8).Container; 634.AddAdditionalDocument("Test.txt", SourceText.From("")); 639var differentOpenTextContainer = SourceText.From("// Open Text").Container; 670var differentOpenTextContainer = SourceText.From("// Open Text").Container; 697var differentOpenTextContainer = SourceText.From("// Open Text").Container; 734documentToFreeze = documentToFreeze.WithText(SourceText.From("// Changed Source File")); 764document = document.WithText(SourceText.From("// Something else")); 793document = document.WithText(SourceText.From("// Something else")); 827document = document.WithText(SourceText.From("// Something else")); 888identity, DateTime.Now, SourceText.From("// Frozen Document")); 915[(sourceGeneratedDocument1.Identity, DateTime.Now, SourceText.From("// Frozen 1")), (sourceGeneratedDocument2.Identity, DateTime.Now, SourceText.From("// Frozen 2"))]); 935sourceGeneratedDocumentIdentity, sourceGeneratedDocument.GenerationDateTime, SourceText.From("// Hello, World"));
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)
862var sourceText = SourceText.From(text); 874var updated = sourceText.WithChanges(new TextChange(new TextSpan(position, 0), "insertion")); 909var sourceText = SourceText.From(text); 921var updated = sourceText.WithChanges(new TextChange(new TextSpan(position, 0), "insertion")); 1416var 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)
32.AddDocument(did, "Test.cs", SourceText.From(source)); 42.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 (9)
38var text = SourceText.From(new string(' ', 4096) + "public class A {}"); 42text = SourceText.From(string.Empty); 46text = SourceText.From(new string(' ', 1024 * 1024) + "public class A {}"); 74private static void TestTemporaryStorage(ITemporaryStorageServiceInternal temporaryStorageService, SourceText text) 280var text = SourceText.From(new string(' ', 4096) + "public class A {}", Encoding.ASCII); 284text = SourceText.From(string.Empty); 288text = SourceText.From(new string(' ', 1024 * 1024) + "public class A {}");
WorkspaceTests\AdhocWorkspaceTests.cs (22)
73var doc = ws.AddDocument(project.Id, name, SourceText.From(source)); 155loader: TextLoader.From(TextAndVersion.Create(SourceText.From(""), VersionStamp.Create()))); 213var text = SourceText.From("public class C { }"); 227Assert.False(doc.TryGetText(out var currentText)); 247var text = SourceText.From("public class C { }"); 261Assert.False(doc.TryGetText(out var currentText)); 281var text = SourceText.From("public class C { }"); 300Assert.False(doc.TryGetText(out var currentText)); 320var text = SourceText.From("public class C { }"); 334Assert.False(doc.TryGetText(out var currentText)); 366var actualText = await newDoc.GetTextAsync(); 378var docid1 = ws.AddDocument(projid, "A.cs", SourceText.From("public class A { }")).Id; 379var docid2 = ws.AddDocument(projid, "B.cs", SourceText.From("public class B { }")).Id; 415var originalDoc = ws.AddDocument(projectId, "TestDocument", SourceText.From("")); 446var originalDoc = ws.AddDocument(projectId, "TestDocument", SourceText.From("")); 482var originalDoc = ws.AddDocument(projectId, "TestDocument", SourceText.From("")); 514var originalDoc = ws.AddDocument(projectId, "TestDocument", SourceText.From("")); 545var originalDoc = ws.AddDocument(projectId, "TestDocument", SourceText.From(""));
WorkspaceTests\WorkspaceTests.cs (7)
25var originalDoc = ws.AddDocument(projectId, "TestDocument", SourceText.From("")); 27var changedDoc = originalDoc.WithText(SourceText.From("new")); 38var originalDoc = ws.AddDocument(projectId, "TestDocument", SourceText.From("")); 54var originalDoc = ws.AddDocument(projectId, "TestDocument", SourceText.From("")); 73var originalDoc = ws.AddDocument(projectId, "TestDocument", SourceText.From("")); 90var originalDoc = ws.AddDocument(projectId, "TestDocument", SourceText.From("")); 147public Document AddDocument(ProjectId projectId, string name, SourceText text)
Microsoft.DotNet.CodeAnalysis (2)
Analyzers\MembersMustExistAnalyzer.cs (1)
71SourceText fileContents = additionalFile.GetText();
Analyzers\PinvokeAnalyzer.cs (1)
76SourceText fileContents = additionalFile.GetText();
Microsoft.Extensions.Logging.Generators (1)
LoggerMessageGenerator.Roslyn3.11.cs (1)
39context.AddSource("LoggerMessage.g.cs", SourceText.From(result, Encoding.UTF8));
Microsoft.Extensions.Options.SourceGeneration (1)
Generator.cs (1)
56context.AddSource("Validators.g.cs", SourceText.From(result, Encoding.UTF8));
Microsoft.Gen.ComplianceReports.Unit.Tests (5)
test\Generators\Shared\RoslynTestUtils.cs (5)
512var s = await proj.FindDocument(l[i]).GetTextAsync().ConfigureAwait(false); 520var s = await proj.FindDocument($"src-{i}.cs").GetTextAsync().ConfigureAwait(false); 527var s = await proj.FindDocument(extraFile).GetTextAsync().ConfigureAwait(false); 548var newText = await document.GetTextAsync().ConfigureAwait(false); 549return document.WithText(SourceText.From(newText.ToString(), newText.Encoding, newText.ChecksumAlgorithm));
Microsoft.Gen.ContextualOptions.Unit.Tests (5)
test\Generators\Shared\RoslynTestUtils.cs (5)
512var s = await proj.FindDocument(l[i]).GetTextAsync().ConfigureAwait(false); 520var s = await proj.FindDocument($"src-{i}.cs").GetTextAsync().ConfigureAwait(false); 527var s = await proj.FindDocument(extraFile).GetTextAsync().ConfigureAwait(false); 548var newText = await document.GetTextAsync().ConfigureAwait(false); 549return document.WithText(SourceText.From(newText.ToString(), newText.Encoding, newText.ChecksumAlgorithm));
Microsoft.Gen.Logging (1)
LoggingGenerator.cs (1)
49context.AddSource("Logging.g.cs", SourceText.From(result, Encoding.UTF8));
Microsoft.Gen.Logging.Unit.Tests (5)
test\Generators\Shared\RoslynTestUtils.cs (5)
512var s = await proj.FindDocument(l[i]).GetTextAsync().ConfigureAwait(false); 520var s = await proj.FindDocument($"src-{i}.cs").GetTextAsync().ConfigureAwait(false); 527var s = await proj.FindDocument(extraFile).GetTextAsync().ConfigureAwait(false); 548var newText = await document.GetTextAsync().ConfigureAwait(false); 549return document.WithText(SourceText.From(newText.ToString(), newText.Encoding, newText.ChecksumAlgorithm));
Microsoft.Gen.Metrics (2)
MetricsGenerator.cs (2)
40context.AddSource("Factory.g.cs", SourceText.From(factory, Encoding.UTF8)); 44context.AddSource("Metrics.g.cs", SourceText.From(metrics, Encoding.UTF8));
Microsoft.Gen.Metrics.Unit.Tests (5)
test\Generators\Shared\RoslynTestUtils.cs (5)
512var s = await proj.FindDocument(l[i]).GetTextAsync().ConfigureAwait(false); 520var s = await proj.FindDocument($"src-{i}.cs").GetTextAsync().ConfigureAwait(false); 527var s = await proj.FindDocument(extraFile).GetTextAsync().ConfigureAwait(false); 548var newText = await document.GetTextAsync().ConfigureAwait(false); 549return document.WithText(SourceText.From(newText.ToString(), newText.Encoding, newText.ChecksumAlgorithm));
Microsoft.Gen.MetricsReports.Unit.Tests (5)
test\Generators\Shared\RoslynTestUtils.cs (5)
512var s = await proj.FindDocument(l[i]).GetTextAsync().ConfigureAwait(false); 520var s = await proj.FindDocument($"src-{i}.cs").GetTextAsync().ConfigureAwait(false); 527var s = await proj.FindDocument(extraFile).GetTextAsync().ConfigureAwait(false); 548var newText = await document.GetTextAsync().ConfigureAwait(false); 549return document.WithText(SourceText.From(newText.ToString(), newText.Encoding, newText.ChecksumAlgorithm));
Microsoft.ML.AutoML.SourceGenerator (3)
EstimatorTypeGenerator.cs (1)
53context.AddSource(className + ".cs", SourceText.From(code.TransformText(), Encoding.UTF8));
SweepableEstimatorFactoryGenerator.cs (1)
48context.AddSource(className + ".cs", SourceText.From(code.TransformText(), Encoding.UTF8));
SweepableEstimatorGenerator.cs (1)
73context.AddSource(c.Item1 + ".cs", SourceText.From(c.Item2, Encoding.UTF8));
Microsoft.VisualStudio.LanguageServices (91)
EditorConfigSettings\Analyzers\View\AnalyzerSettingsView.xaml.cs (2)
29public Task<SourceText> UpdateEditorConfigAsync(SourceText sourceText) => _viewModel.UpdateEditorConfigAsync(sourceText);
EditorConfigSettings\CodeStyle\View\CodeStyleSettingsView.xaml.cs (2)
30public 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\Whitespace\View\WhitespaceSettingsView.xaml.cs (2)
29public Task<SourceText> UpdateEditorConfigAsync(SourceText sourceText) => _viewModel.UpdateEditorConfigAsync(sourceText);
Extensions\DocumentExtensions.cs (1)
24var 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 (2)
467private async Task<(ExcerptResult, SourceText)> ExcerptAsync( 468SourceText sourceText, DocumentSpan documentSpan, ClassifiedSpansAndHighlightSpan? classifiedSpans, CancellationToken cancellationToken)
FindReferences\Entries\AbstractDocumentSpanEntry.cs (4)
33SourceText lineText, 81public static async Task<MappedSpanResult?> TryMapAndGetFirstAsync(DocumentSpan documentSpan, SourceText sourceText, CancellationToken cancellationToken) 102public static SourceText GetLineContainingPosition(SourceText text, int position)
FindReferences\Entries\DefinitionItemEntry.cs (1)
26SourceText lineText,
FindReferences\Entries\DocumentSpanEntry.cs (4)
53SourceText lineText, 81SourceText lineText, 184var sourceText = document.GetTextSynchronously(CancellationToken.None); 230private static Span GetRegionSpanForReference(SourceText sourceText, TextSpan sourceSpan)
Implementation\AbstractEditorFactory.cs (3)
353var formattedText = formattedRoot.GetText(unformattedText.Encoding, unformattedText.ChecksumAlgorithm); 358var originalText = formattedText; 406return SourceText.From(stream);
LanguageService\AbstractLanguageService`2.IVsLanguageTextOps.cs (1)
57var text = documentSyntax.Text;
Preview\FileChange.cs (7)
81var oldText = left.GetTextSynchronously(cancellationToken); 82var newText = right.GetTextSynchronously(cancellationToken); 100private ChangeList GetChangeList(IHierarchicalDifferenceCollection diff, DocumentId id, SourceText oldText, SourceText newText) 188private SourceText UpdateBufferText() 244var oldText = left.GetTextSynchronously(cancellationToken); 245var newText = right.GetTextSynchronously(cancellationToken);
Preview\PreviewUpdater.PreviewDialogWorkspace.cs (3)
25public void CloseDocument(TextDocument document, SourceText text) 48private readonly SourceText _text; 50internal PreviewTextLoader(SourceText documentText)
Preview\TopLevelChange.cs (2)
114SourceText updateDocumentTextOpt, 161solution = solution.AddAnalyzerConfigDocument(oldDocument.Id, oldDocument.Name, SourceText.From(oldText), oldDocument.Folders, oldDocument.FilePath);
ProjectSystem\MiscellaneousFilesWorkspace.cs (1)
321protected override void ApplyDocumentTextChanged(DocumentId documentId, SourceText newText)
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)
758protected override void ApplyDocumentAdded(DocumentInfo info, SourceText text) 761protected override void ApplyAdditionalDocumentAdded(DocumentInfo info, SourceText text) 764protected override void ApplyAnalyzerConfigDocumentAdded(DocumentInfo info, SourceText text) 770private void AddDocumentCore(DocumentInfo info, SourceText initialText, TextDocumentKind documentKind) 876SourceText? initialText = null, 895SourceText? initialText = null, 912SourceText text) 977SourceText? initialText, 1184protected override void ApplyDocumentTextChanged(DocumentId documentId, SourceText newText) 1187protected override void ApplyAdditionalDocumentTextChanged(DocumentId documentId, SourceText newText) 1190protected override void ApplyAnalyzerConfigDocumentTextChanged(DocumentId documentId, SourceText newText) 1193private void ApplyTextDocumentChange(DocumentId documentId, SourceText newText)
Snippets\AbstractSnippetCommandHandler.cs (1)
262var currentText = subjectBuffer.AsTextContainer().CurrentText;
TaskList\ProjectExternalErrorReporter.cs (1)
322var text = tree.GetText();
Utilities\IVsEditorAdaptersFactoryServiceExtensions.cs (1)
42var text = document.GetTextSynchronously(cancellationToken);
ValueTracking\TreeItemViewModel.cs (2)
21private readonly SourceText _sourceText; 46SourceText sourceText,
Venus\ContainedDocument.cs (13)
208public void UpdateText(SourceText newText) 210var originalText = SubjectBuffer.CurrentSnapshot.AsText(); 233private ITextSnapshot ApplyChanges(SourceText originalText, IEnumerable<TextChange> changes) 261private IEnumerable<TextChange> FilterTextChanges(SourceText originalText, List<TextSpan> editorVisibleSpansInOriginal, IEnumerable<TextChange> changes) 348private IEnumerable<TextChange> GetSubTextChanges(SourceText originalText, TextChange changeInOriginalText, TextSpan visibleSpanInOriginalText) 365SourceText originalText, TextSpan visibleSpanInOriginalText, string leftText, string rightText, int offsetInOriginalText, List<TextChange> changes) 399SourceText originalText, TextSpan visibleSpanInOriginalText, string leftText, string rightText, int offsetInOriginalText) 503SourceText originalText, TextSpan visibleSpanInOriginalText, 824public BaseIndentationFormattingRule GetBaseIndentationRule(SyntaxNode root, SourceText text, List<TextSpan> spans, int spanIndex) 872private static void GetVisibleAndTextSpan(SourceText text, List<TextSpan> spans, int spanIndex, out TextSpan visibleSpan, out TextSpan visibleTextSpan) 884private int GetBaseIndentation(SyntaxNode root, SourceText text, TextSpan span) 911private static TextSpan GetVisibleTextSpan(SourceText text, TextSpan visibleSpan, bool uptoFirstAndLastLine = false) 949private int GetAdditionalIndentation(SyntaxNode root, SourceText text, TextSpan span, int hostIndentationSize)
Venus\ContainedDocument.DocumentServiceProvider.cs (2)
57private static ITextSnapshot GetRoslynSnapshot(SourceText sourceText) 276private static (SourceText, TextSpan) GetContentAndMappedSpan(ExcerptMode mode, SnapshotSpan primarySpan, SnapshotSpan contentSpan)
Workspace\SourceGeneratedFileManager.cs (2)
333SourceText? generatedSource = null; 529var sourceText = _textBuffer.CurrentSnapshot.AsText();
Workspace\VisualStudioDocumentNavigationService.cs (7)
138static VsTextSpan GetVsTextSpanFromPosition(SourceText text, int position, int virtualSpace) 160Func<SourceText, VsTextSpan> getVsTextSpan, 161Func<SourceText, TextSpan, VsTextSpan> getVsTextSpanForMapping, 184Func<SourceText, VsTextSpan> getVsTextSpan, 185Func<SourceText, TextSpan, VsTextSpan> getVsTextSpanForMapping, 250Func<SourceText, VsTextSpan> getVsTextSpan) 351private static VsTextSpan GetVsTextSpan(SourceText text, TextSpan textSpan, bool allowInvalidSpan)
Workspace\VisualStudioFormattingRuleFactoryServiceFactory.cs (1)
56var text = document.Text;
Microsoft.VisualStudio.LanguageServices.CSharp (41)
CodeModel\CSharpCodeModelService.cs (6)
41private static readonly SyntaxTree s_emptyTree = SyntaxFactory.ParseSyntaxTree(SourceText.From("", encoding: null, SourceHashAlgorithms.Default)); 1274var text = memberDeclaration.SyntaxTree.GetText(CancellationToken.None); 1354var text = memberDeclaration.SyntaxTree.GetText(CancellationToken.None); 1412var text = memberDeclaration.SyntaxTree.GetText(CancellationToken.None); 2796var text = document.GetTextSynchronously(CancellationToken.None); 2837var text = document.GetTextSynchronously(CancellationToken.None);
CodeModel\CSharpCodeModelService.NodeLocator.cs (31)
33protected override VirtualTreePoint? GetStartPoint(SourceText text, LineFormattingOptions options, SyntaxNode node, EnvDTE.vsCMPart part) 84protected override VirtualTreePoint? GetEndPoint(SourceText text, LineFormattingOptions options, SyntaxNode node, EnvDTE.vsCMPart part) 135private static VirtualTreePoint GetBodyStartPoint(SourceText text, SyntaxToken openBrace) 147private static VirtualTreePoint GetBodyStartPoint(SourceText text, LineFormattingOptions options, SyntaxToken openBrace, SyntaxToken closeBrace, int memberStartColumn) 211private static VirtualTreePoint GetBodyEndPoint(SourceText text, SyntaxToken closeBrace) 221private static VirtualTreePoint GetStartPoint(SourceText text, ArrowExpressionClauseSyntax node, EnvDTE.vsCMPart part) 242private static VirtualTreePoint GetStartPoint(SourceText text, AttributeSyntax node, EnvDTE.vsCMPart part) 275private static VirtualTreePoint GetStartPoint(SourceText text, AttributeArgumentSyntax node, EnvDTE.vsCMPart part) 305private static VirtualTreePoint GetStartPoint(SourceText text, BaseTypeDeclarationSyntax node, EnvDTE.vsCMPart part) 353private static VirtualTreePoint GetStartPoint(SourceText text, LineFormattingOptions options, BaseMethodDeclarationSyntax node, EnvDTE.vsCMPart part) 442private static VirtualTreePoint GetStartPoint(SourceText text, LineFormattingOptions options, BasePropertyDeclarationSyntax node, EnvDTE.vsCMPart part) 507private static VirtualTreePoint GetStartPoint(SourceText text, LineFormattingOptions options, AccessorDeclarationSyntax node, EnvDTE.vsCMPart part) 556private static VirtualTreePoint GetStartPoint(SourceText text, BaseNamespaceDeclarationSyntax node, EnvDTE.vsCMPart part) 605private static VirtualTreePoint GetStartPoint(SourceText text, DelegateDeclarationSyntax node, EnvDTE.vsCMPart part) 645private static VirtualTreePoint GetStartPoint(SourceText text, UsingDirectiveSyntax node, EnvDTE.vsCMPart part) 678private static VirtualTreePoint GetStartPoint(SourceText text, VariableDeclaratorSyntax node, EnvDTE.vsCMPart part) 719private static VirtualTreePoint GetStartPoint(SourceText text, EnumMemberDeclarationSyntax node, EnvDTE.vsCMPart part) 759private static VirtualTreePoint GetStartPoint(SourceText text, ParameterSyntax node, EnvDTE.vsCMPart part) 799private static VirtualTreePoint GetEndPoint(SourceText text, ArrowExpressionClauseSyntax node, EnvDTE.vsCMPart part) 817private static VirtualTreePoint GetEndPoint(SourceText text, AttributeSyntax node, EnvDTE.vsCMPart part) 850private static VirtualTreePoint GetEndPoint(SourceText text, AttributeArgumentSyntax node, EnvDTE.vsCMPart part) 880private static VirtualTreePoint GetEndPoint(SourceText text, BaseTypeDeclarationSyntax node, EnvDTE.vsCMPart part) 921private static VirtualTreePoint GetEndPoint(SourceText text, BaseMethodDeclarationSyntax node, EnvDTE.vsCMPart part) 995private static VirtualTreePoint GetEndPoint(SourceText text, BasePropertyDeclarationSyntax node, EnvDTE.vsCMPart part) 1055private static VirtualTreePoint GetEndPoint(SourceText text, AccessorDeclarationSyntax node, EnvDTE.vsCMPart part) 1094private static VirtualTreePoint GetEndPoint(SourceText text, DelegateDeclarationSyntax node, EnvDTE.vsCMPart part) 1135private static VirtualTreePoint GetEndPoint(SourceText text, BaseNamespaceDeclarationSyntax node, EnvDTE.vsCMPart part) 1184private static VirtualTreePoint GetEndPoint(SourceText text, UsingDirectiveSyntax node, EnvDTE.vsCMPart part) 1217private static VirtualTreePoint GetEndPoint(SourceText text, EnumMemberDeclarationSyntax node, EnvDTE.vsCMPart part) 1258private static VirtualTreePoint GetEndPoint(SourceText text, VariableDeclaratorSyntax node, EnvDTE.vsCMPart part) 1300private static VirtualTreePoint GetEndPoint(SourceText text, ParameterSyntax node, EnvDTE.vsCMPart part)
Interactive\CSharpInteractiveWindowCommandCompletionProvider.cs (1)
42public override bool IsInsertionTrigger(SourceText text, int characterPosition, CompletionOptions options)
ProjectSystemShim\TempPECompilerService.cs (2)
45var sourceText = SourceText.From(fileContents[i], parsedArguments.Encoding, parsedArguments.ChecksumAlgorithm);
SemanticSearch\SemanticSearchToolWindowImpl.cs (1)
372var query = await queryDocument.GetTextAsync(cancellationToken).ConfigureAwait(false);
Microsoft.VisualStudio.LanguageServices.CSharp.UnitTests (7)
CodeModel\FileCodeFunctionTests.cs (2)
495var text = await (GetCurrentDocument()).GetTextAsync(); 508var text = await (GetCurrentDocument()).GetTextAsync();
DocumentOutline\DocumentOutlineTestsBase.cs (1)
109solution = solution.WithDocumentText(document.Id, SourceText.From(documentText.ToString(), System.Text.Encoding.UTF8));
EditorConfigSettings\Aggregator\SettingsAggregatorTests.cs (1)
32.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)
17Task<SourceText> ISettingsEditorViewModel.UpdateEditorConfigAsync(SourceText sourceText)
Microsoft.VisualStudio.LanguageServices.LiveShare (6)
Client\Projects\WorkspaceFileTextLoaderNoException.cs (1)
32return Task.FromResult(TextAndVersion.Create(SourceText.From("", encoding: null, options.ChecksumAlgorithm), VersionStamp.Create()));
Client\RemoteLanguageServiceWorkspace.cs (5)
302text = SourceText.From(File.ReadAllText(document.FilePath)); 474protected override void ApplyDocumentTextChanged(DocumentId documentId, SourceText text) 481var sourceText = document.GetTextSynchronously(CancellationToken.None); 505private static void UpdateText(ITextBuffer textBuffer, SourceText text) 509var oldText = oldSnapshot.AsText();
Microsoft.VisualStudio.LanguageServices.Test.Utilities2 (1)
CodeModel\Mocks\MockVisualStudioWorkspace.vb (1)
49Protected Overrides Sub ApplyDocumentTextChanged(documentId As DocumentId, newText As SourceText)
Microsoft.VisualStudio.LanguageServices.UnitTests (4)
Completion\MockCompletionProvider.vb (1)
22Public Overrides Function IsInsertionTrigger(text As SourceText, characterPosition As Integer, options As CompletionOptions) As Boolean
ProjectSystemShim\VisualStudioProjectTests\WorkspaceChangedEventTests.vb (1)
130project.AddSourceTextContainer(SourceText.From("// Test").Container, "Z:\Test.cs")
SolutionExplorer\SourceGeneratorItemTests.vb (1)
256SourceText.From("Changed"),
Venus\DocumentService_IntegrationTests.vb (1)
186Dim 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)
90Public Overrides Function IsInsertionTrigger(text As SourceText, characterPosition As Integer, options As CompletionOptions) As Boolean
Microsoft.VisualStudio.LanguageServices.Xaml (4)
Implementation\LanguageServer\Handler\Completion\CompletionHandler.cs (1)
82private 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)
132var sourceText = SourceText.From(fileStream);
Implementation\LanguageServer\Handler\Diagnostics\AbstractPullDiagnosticHandler.cs (1)
120private static VSDiagnostic[]? ConvertToVSDiagnostics(ImmutableArray<XamlDiagnostic>? xamlDiagnostics, Document document, SourceText text)
Roslyn.VisualStudio.DiagnosticsWindow (2)
Panels\WorkspacePanel.xaml.cs (2)
95var fileText = SourceText.From(fileStream, snapshotText.Encoding, snapshotText.ChecksumAlgorithm);
Roslyn.VisualStudio.Next.UnitTests (83)
Remote\RemoteHostClientServiceFactoryTests.cs (2)
48var document = workspace.AddDocument(project.Id, "doc.cs", SourceText.From("code")); 50var oldText = document.GetTextSynchronously(CancellationToken.None);
Remote\SnapshotSerializationTests.cs (10)
50var document1 = project1.AddDocument("Document1", SourceText.From(csCode)); 54var document2 = project2.AddDocument("Document2", SourceText.From(vbCode)); 60.AddAdditionalDocument("Additional", SourceText.From("hello"), ["test"], @".\Add").Project.Solution; 67loader: TextLoader.From(TextAndVersion.Create(SourceText.From("root = true"), VersionStamp.Create())))]); 153var document = workspace.CurrentSolution.AddProject("Project", "Project.dll", LanguageNames.CSharp).AddDocument("Document", SourceText.From(code)); 173var document = solution.AddProject("Project", "Project.dll", LanguageNames.CSharp).AddDocument("Document", SourceText.From(code)); 532var document = CreateWorkspace().CurrentSolution.AddProject("empty", "empty", LanguageNames.CSharp).AddDocument("empty", SourceText.From("")); 607var sourceText = SourceText.From("Hello", Encoding.UTF8); 625sourceText = SourceText.From("Hello", new NotSerializableEncoding());
Services\ServiceHubServicesTests.cs (53)
87var oldText = await oldDocument.GetTextAsync(); 90var newText = oldText.WithChanges(new TextChange(TextSpan.FromBounds(0, 0), "/* test */")); 399params ImmutableArray<(string hintName, SourceText text)>[] values) 407ImmutableArray<ImmutableArray<(string hintName, SourceText text)>> values) 410ImmutableArray<(string hintName, SourceText text)> sourceTexts = default; 436var tempDoc = project.AddDocument("X.cs", SourceText.From("// ")); 451Assert.True(localWorkspace.SetCurrentSolution(s => s.WithDocumentText(tempDocId, SourceText.From("// " + i)), WorkspaceChangeKind.SolutionChanged)); 487var localText = await localDoc.GetTextAsync(); 488var remoteText = await localDoc.GetTextAsync(); 496private static SourceText CreateText(string content, Encoding encoding = null, SourceHashAlgorithm checksumAlgorithm = SourceHashAlgorithm.Sha1) 497=> SourceText.From(content, encoding ?? Encoding.UTF8, checksumAlgorithm); 499private static SourceText CreateStreamText(string content, bool useBOM, bool useMemoryStream) 506return SourceText.From(stream, encoding, SourceHashAlgorithm.Sha1, throwIfBinaryDetected: true); 510return SourceText.From(bytes, bytes.Length, encoding, SourceHashAlgorithm.Sha1, throwIfBinaryDetected: true); 524var sourceText = CreateText(Guid.NewGuid().ToString()); 558var sourceText = CreateText(Guid.NewGuid().ToString()); 602ImmutableArray<(string, SourceText)>.Empty); 609ImmutableArray<(string, SourceText)>.Empty, 656ImmutableArray<(string, SourceText)>.Empty); 662var contents = CreateText(Guid.NewGuid().ToString()); 670var contents = CreateText(Guid.NewGuid().ToString()); 720return ImmutableArray.Create(("hint", SourceText.From($"// generated document {callCount}", Encoding.UTF8))); 742solution = solution.WithTextDocumentText(tempDocId, SourceText.From("// new contents")); 775var tempDoc = project.AddDocument("X.cs", SourceText.From("// ")); 804return ImmutableArray.Create(("hint", SourceText.From($"// generated document {callCount}", Encoding.UTF8))); 859return ImmutableArray.Create(("hint", SourceText.From($"// generated document {callCount}", Encoding.UTF8))); 913var tempDoc = project1.AddDocument("X.cs", SourceText.From("// ")); 922var tempDoc = project2.AddDocument("X.cs", SourceText.From("// ")); 964var tempDoc = project1.AddDocument("X.cs", SourceText.From("// ")); 973var tempDoc = project2.AddDocument("X.cs", SourceText.From("// ")); 1005var tempDoc = project1.AddDocument("X.cs", SourceText.From("// ")); 1014var tempDoc = project2.AddDocument("X.cs", SourceText.From("// ")); 1048var tempDoc = project1.AddDocument("X.cs", SourceText.From("// ")); 1057var tempDoc = project2.AddDocument("X.cs", SourceText.From("// ")); 1100var tempDoc = project1.AddDocument("X.cs", SourceText.From("// ")); 1110var tempDoc = project2.AddDocument("X.cs", SourceText.From("// ")); 1153var tempDoc = project1.AddDocument("X.cs", SourceText.From("// ")); 1163var tempDoc = project2.AddDocument("X.cs", SourceText.From("// ")); 1206var tempDoc = project1.AddDocument("X.cs", SourceText.From("// ")); 1216var tempDoc = project2.AddDocument("X.cs", SourceText.From("// ")); 1251var tempDoc = project1.AddDocument("X.cs", SourceText.From("// ")); 1261var tempDoc = project2.AddDocument("X.cs", SourceText.From("// ")); 1296var tempDoc = project1.AddDocument("X.cs", SourceText.From("// ")); 1305var tempDoc = project2.AddDocument("X.cs", SourceText.From("// ")); 1339var tempDoc = project1.AddDocument("X.cs", SourceText.From("// ")); 1348var tempDoc = project2.AddDocument("X.cs", SourceText.From("// ")); 1431Contract.ThrowIfFalse(workspace.TryApplyChanges(workspace.CurrentSolution.WithDocumentText(normalDocId, SourceText.From("// new text")))); 1545var tempDoc = project1.AddDocument("X.cs", SourceText.From("// ")); 1624private static SourceText GetNewText(Document document, string csAddition, string vbAddition) 1628return SourceText.From(document.State.GetTextSynchronously(CancellationToken.None).ToString() + csAddition); 1631return SourceText.From(document.State.GetTextSynchronously(CancellationToken.None).ToString() + vbAddition); 1737solution = current.AddDocument($"Document{i}", SourceText.From(documents[i])).Project.Solution; 1743solution = current.AddAdditionalDocument($"AdditionalDocument{i}", SourceText.From(additionalDocuments[i])).Project.Solution;
Services\SolutionServiceTests.cs (18)
160await VerifySolutionUpdate(code, s => s.WithDocumentText(s.Projects.First().DocumentIds.First(), SourceText.From(code + " "))); 315project = project.AddDocument("newDocument", SourceText.From("// new text")).Project; 335loader: TextLoader.From(TextAndVersion.Create(SourceText.From("test"), VersionStamp.Create()))); 346return s.WithAdditionalDocumentText(additionalDocumentId, SourceText.From("changed")); 367loader: TextLoader.From(TextAndVersion.Create(SourceText.From("root = true"), VersionStamp.Create(), filePath: configPath)), 379return s.WithAnalyzerConfigDocumentText(analyzerConfigDocumentId, SourceText.From("root = false")); 399loader: TextLoader.From(TextAndVersion.Create(SourceText.From("class A { }"), VersionStamp.Create()))); 410return s.WithDocumentText(documentId, SourceText.From("class Changed { }")); 437var currentSolution = remoteSolution1.WithDocumentText(remoteSolution1.Projects.First().Documents.First().Id, SourceText.From(code + " class Test2 { }")); 446currentSolution = oopSolution2.WithDocumentText(oopSolution2.Projects.First().Documents.First().Id, SourceText.From(code + " class Test3 { }")); 522var frozenText1 = SourceText.From("// Hello, World!"); 531var frozenText2 = SourceText.From("// Hello, World! A second time!"); 835solution = solution.GetProject(project1.Id).AddDocument("X.cs", SourceText.From("// X")).Project.Solution; 836solution = solution.GetProject(project2.Id).AddDocument("Y.vb", SourceText.From("' Y")).Project.Solution; 890solution = solution.GetProject(project1.Id).AddDocument("X.cs", SourceText.From("// X")).Project.Solution; 891solution = solution.GetProject(project2.Id).AddDocument("Y.cs", SourceText.From("// Y")).Project.Solution;
StackDepthTest (1)
Program.cs (1)
79var tree = SyntaxFactory.ParseSyntaxTree(SourceText.From(stringText, encoding: null, SourceHashAlgorithm.Sha256), parseOptions);
System.Private.CoreLib.Generators (1)
EventSourceGenerator.Emitter.cs (1)
27context.AddSource($"{ec.ClassName}.g.cs", SourceText.From(sb.ToString(), Encoding.UTF8));
System.Text.Json.SourceGeneration (17)
JsonSourceGenerator.Emitter.cs (14)
98private partial void AddSource(string hintName, SourceText sourceText); 113SourceText? sourceText = GenerateTypeInfo(contextGenerationSpec, typeGenerationSpec); 183private static SourceText CompleteSourceFileAndReturnText(SourceWriter writer) 194private SourceText? GenerateTypeInfo(ContextGenerationSpec contextSpec, TypeGenerationSpec typeGenerationSpec) 229private static SourceText GenerateForTypeWithBuiltInConverter(ContextGenerationSpec contextSpec, TypeGenerationSpec typeMetadata) 246private static SourceText GenerateForTypeWithCustomConverter(ContextGenerationSpec contextSpec, TypeGenerationSpec typeMetadata) 267private static SourceText GenerateForNullable(ContextGenerationSpec contextSpec, TypeGenerationSpec typeMetadata) 288private static SourceText GenerateForUnsupportedType(ContextGenerationSpec contextSpec, TypeGenerationSpec typeMetadata) 304private static SourceText GenerateForEnum(ContextGenerationSpec contextSpec, TypeGenerationSpec typeMetadata) 320private SourceText GenerateForCollection(ContextGenerationSpec contextSpec, TypeGenerationSpec typeGenerationSpec) 494private SourceText GenerateForObject(ContextGenerationSpec contextSpec, TypeGenerationSpec typeMetadata) 1111private static SourceText GetRootJsonContextImplementation(ContextGenerationSpec contextSpec, bool emitGetConverterForNullablePropertyMethod) 1379private static SourceText GetGetTypeInfoImplementation(ContextGenerationSpec contextSpec) 1421private SourceText GetPropertyNameInitialization(ContextGenerationSpec contextSpec)
JsonSourceGenerator.Roslyn3.11.cs (1)
155private partial void AddSource(string hintName, SourceText sourceText)
src\libraries\Common\src\SourceGenerators\SourceWriter.cs (2)
64public SourceText ToSourceText() 67return SourceText.From(_sb.ToString(), Encoding.UTF8);
System.Windows.Forms.Analyzers (1)
System\Windows\Forms\Analyzers\AppManifestAnalyzer.cs (1)
38SourceText? appManifestXml = appManifest.GetText(context.CancellationToken);
System.Windows.Forms.Analyzers.CSharp.Tests (11)
Generators\ApplicationConfigurationGeneratorTests.cs (7)
85SourceText generatedCode = LoadFileContent("GenerateInitialize_default_boilerplate"); 106SourceText generatedCode = LoadFileContent("GenerateInitialize_default_boilerplate"); 127SourceText generatedCode = LoadFileContent("GenerateInitialize_user_settings_boilerplate"); 165SourceText generatedCode = LoadFileContent("GenerateInitialize_default_top_level"); 191SourceText generatedCode = LoadFileContent("GenerateInitialize_user_top_level"); 221private SourceText LoadFileContent(string testName) => 222SourceText.From(
TestAdditionalText.cs (4)
18private readonly SourceText _text; 20public TestAdditionalText(string path, SourceText text) 27: this(path, SourceText.From(text, encoding)) 33public override SourceText GetText(CancellationToken cancellationToken = default) => _text;
System.Windows.Forms.Analyzers.Tests (12)
System\Windows\Forms\Analyzers\AppManifestAnalyzerTests.cs (12)
47SourceText manifestFile = SourceText.From( 63SourceText manifestFile = SourceText.From( 81SourceText manifestFile = SourceText.From( 104SourceText manifestFile = SourceText.From( 127SourceText manifestFile = SourceText.From( 146SourceText manifestFile = SourceText.From(