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
3747 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( 1560var 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 (6)
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);
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); 305var project = _baseProject.AddDocument("TestMapActions.cs", SourceText.From(source, Encoding.UTF8)).Project; 360var generatedCode = await generatedSyntaxTree.GetTextAsync(); 381private 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); 305var project = _baseProject.AddDocument("TestMapActions.cs", SourceText.From(source, Encoding.UTF8)).Project; 360var generatedCode = await generatedSyntaxTree.GetTextAsync(); 381private 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)
255internal SourceText? TryReadFileContent(CommandLineSourceFile file, IList<DiagnosticInfo> diagnostics) 267internal SourceText? TryReadFileContent(CommandLineSourceFile file, IList<DiagnosticInfo> diagnostics, out string? normalizedFilePath) 1159var 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)
33/// 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 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)
142var 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 (49)
CommandLine\CSharpCompiler.cs (1)
204SourceText content,
Compilation\CSharpCompilation.cs (1)
1101var text = tree.GetText();
Compilation\CSharpSemanticModel.cs (1)
5217var 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); 373using var tempLexer = new Lexer(SourceText.From(expressionText), options, allowPreprocessorDirectives: false, interpolationFollowedByColon: interpolation.HasColon); 463using var tempLexer = new Lexer(SourceText.From(fakeString), this.Options, allowPreprocessorDirectives: false);
Parser\Lexer.cs (2)
113public Lexer(SourceText text, CSharpParseOptions options, bool allowPreprocessorDirectives = true, bool interpolationFollowedByColon = false) 2045var 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)
104var sourceText = semanticModel.SyntaxTree.GetText(cancellationToken); 126SourceText text, 151SourceText text,
src\Analyzers\CSharp\Analyzers\UseCollectionExpression\UseCollectionExpressionHelpers.cs (2)
737SourceText sourceText, 759SourceText sourceText,
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\EmbeddedLanguages\VirtualChars\CSharpVirtualCharService.cs (3)
186var parentSourceText = parentExpression.SyntaxTree.GetText(); 191var 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(); 268SourceText 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)
57var 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); 147var 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)
2493SourceText embeddedSource = mdReader.GetEmbeddedSource(handle); 14004context.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)
98void AddSpanOfInterest(SourceText documentText, TextSpan fallbackSpan, TextSpan? surroundingSpanOfInterest, ArrayBuilder<string> 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)
814project = project.AddAnalyzerConfigDocument(".editorconfig", SourceText.From(editorconfigText), filePath: @"z:\\.editorconfig").Project; 910project = 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)
46var tree3 = SyntaxFactory.ParseSyntaxTree(SourceText.From("class C { }", encoding: null), path: "Bar.cs"); 67var tree4 = SyntaxFactory.ParseSyntaxTree(SourceText.From("class D { public void F() { } }", new UTF8Encoding(false, false)), path: "Baz.cs"); 103context.AddSource("hint2", SourceText.From("class G2 { void F() {} }", Encoding.UTF8, checksumAlgorithm: SourceHashAlgorithm.Sha256)); 105Assert.Throws<ArgumentException>(() => context.AddSource("hint3", SourceText.From("class G3 { void F() {} }", encoding: null, checksumAlgorithm: SourceHashAlgorithm.Sha256)));
Microsoft.CodeAnalysis.CSharp.Features (118)
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)
70protected 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)
104var sourceText = semanticModel.SyntaxTree.GetText(cancellationToken); 126SourceText text, 151SourceText text,
src\Analyzers\CSharp\Analyzers\UseCollectionExpression\UseCollectionExpressionHelpers.cs (2)
737SourceText sourceText, 759SourceText 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(); 268SourceText 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)
57var 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); 147var 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)
44var sourceText = node.SyntaxTree.GetText(cancellationToken);
UseExpressionBody\UseExpressionBodyCodeRefactoringProvider.cs (1)
98UseExpressionBodyHelper 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)
1159compilation.SyntaxTrees.Last().WithChangedText(SourceText.From(""" 1209compilation.SyntaxTrees.Last().WithChangedText(SourceText.From(""" 1265compilation.SyntaxTrees.First().WithChangedText(SourceText.From(""" 1422compilation.SyntaxTrees.First().WithChangedText(SourceText.From(""" 1467compilation.SyntaxTrees.First().WithChangedText(SourceText.From(""" 1519compilation.SyntaxTrees.First().WithChangedText(SourceText.From(""" 1570compilation.SyntaxTrees.First().WithChangedText(SourceText.From(""" 1632compilation.SyntaxTrees.Last().WithChangedText(SourceText.From("""
SourceGeneration\SyntaxAwareGeneratorTests.cs (3)
419onExecute: (e) => { e.AddSource("test", SourceText.From("public class D{}", Encoding.UTF8)); } 509onExecute: (e) => { receiver = e.SyntaxReceiver; e.AddSource("test", SourceText.From("public class D{}", Encoding.UTF8)); } 2047onExecute: (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 (331)
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 (224)
28var itext = SourceText.From(text); 35var itext = SourceText.From(text); 494var text = tree.GetText(); 526var text = tree.GetText(); 567var text = tree.GetText(); 699var text = SourceText.From(@"partial class C{}"); 703var newText = text.WithChanges(new TextChange(new TextSpan(0, 8), "")); 713var text = SourceText.From(@"partial class C{}"); 717var newText = text.WithChanges(new TextChange(new TextSpan(0, 8), "")); 727SourceText oldText = SourceText.From(@" 743SourceText oldText = SourceText.From(@" 759SourceText oldText = SourceText.From(@" 776SourceText oldText = SourceText.From(@" 792SourceText oldText = SourceText.From(@" 805SourceText oldText = SourceText.From(@" 821SourceText oldText = SourceText.From(@" 833SourceText oldText = SourceText.From(@" 845SourceText oldText = SourceText.From(@" class A 861SourceText oldText = SourceText.From(@"public class TestClass 874SourceText oldText = SourceText.From(@"using System; 889SourceText oldText = SourceText.From(@"public class MyClass { 901SourceText oldText = SourceText.From(@" 915SourceText startingText = SourceText.From(@" 936SourceText startingText = SourceText.From(@" 955SourceText startingText = SourceText.From(@" 975SourceText oldText = SourceText.From(@"class MyClass 995SourceText oldText = SourceText.From(@" 1019SourceText oldText = SourceText.From(@" 1043SourceText oldText = SourceText.From(@"interface IGoo 1067SourceText oldText = SourceText.From(@"interface IGoo 1091SourceText oldText = SourceText.From(@"using System.Runtime.CompilerServices; 1113SourceText oldText = SourceText.From(@"class A 1137SourceText oldText = SourceText.From(@"public class MyClass { 1159SourceText oldText = SourceText.From(@"public class MyClass { 1250SourceText oldText = SourceText.From(@"class filesystem{ 1269SourceText oldText = SourceText.From(@"class CSTR020mod{ public static void CSTR020() { ON ERROR GOTO ErrorTrap; } }"); 1285SourceText oldText = SourceText.From(@"class A 1305SourceText oldText = SourceText.From(@"public class DynClassDrived 1327SourceText oldText = SourceText.From(@"public class MemberClass 1347SourceText oldText = SourceText.From(@"public class MemberClass 1366SourceText oldText = SourceText.From(@"class Test 1388SourceText oldText = SourceText.From( 1415SourceText oldText = SourceText.From( 1441SourceText oldText = SourceText.From( 1466SourceText oldText = SourceText.From( 1488SourceText oldText = SourceText.From( 1543SourceText oldText = SourceText.From( 1565SourceText oldText = SourceText.From( 1586SourceText oldText = SourceText.From( 1607SourceText oldText = SourceText.From( 1630SourceText oldText = SourceText.From( 1651SourceText oldText = SourceText.From( 1671SourceText oldText = SourceText.From( 1689SourceText oldText = SourceText.From( 1710SourceText oldText = SourceText.From( 1733SourceText oldText = SourceText.From( 1750SourceText oldText = SourceText.From( 1768SourceText oldText = SourceText.From( 1786SourceText oldText = SourceText.From( 1807SourceText oldText = SourceText.From( 1842SourceText oldText = SourceText.From( 1866SourceText oldText = SourceText.From( 1884SourceText oldText = SourceText.From( 1902SourceText oldText = SourceText.From( 1921SourceText oldText = SourceText.From( 1952SourceText oldText = SourceText.From( 1977SourceText oldText = SourceText.From( 1996SourceText oldText = SourceText.From( 2014SourceText oldText = SourceText.From( 2033SourceText oldText = SourceText.From( 2052SourceText oldText = SourceText.From( 2073SourceText oldText = SourceText.From( 2092SourceText oldText = SourceText.From( 2119SourceText oldText = SourceText.From( 2147SourceText oldText = SourceText.From( 2169SourceText oldText = SourceText.From( 2188SourceText oldText = SourceText.From( 2220SourceText oldText = SourceText.From( 2253SourceText oldText = SourceText.From( 2279SourceText oldText = SourceText.From( 2304SourceText oldText = SourceText.From( 2334SourceText oldText = SourceText.From( 2363SourceText oldText = SourceText.From( 2384SourceText oldText = SourceText.From( 2416SourceText oldText = SourceText.From( 2444SourceText oldText = SourceText.From( 2482var text = SourceText.From(str); 2485var text2 = text.WithChanges( 2500SourceText oldText = SourceText.From(@" 2508var newText = oldText.WithChanges(new TextChange(new TextSpan(0, 0), "{")); 2518SourceText oldText = SourceText.From(@"System.Console.WriteLine(true) 2524var newText = oldText.WithChanges(new TextChange(new TextSpan(0, 0), @"System.Console.WriteLine(false) 2547SourceText oldText = SourceText.From(@"System.Console.WriteLine(true) 2553var newText = oldText.WithInsertAt( 2577SourceText oldText = SourceText.From(@"System.Console.WriteLine(true) 2583var newText = oldText.WithChanges(new TextChange(new TextSpan(0, 0), @"if (false) 2637var oldIText = oldTree.GetText(); 2641var newIText = oldIText.WithChanges(change); 2715var currIText = currTree.GetText(); 2755var currIText = currTree.GetText(); 2835var oldText = SourceText.From(items[0]); 2839var newText = oldText.WithChanges(change); // f is a method decl parameter 2866var oldText = SourceText.From(@" 2892var newText = SourceText.From(@" 2935var text = tree.GetText(); 2956var text = tree.GetText(); 2977var text = tree.GetText(); 2998var text = tree.GetText(); 3019var text = tree.GetText(); 3040var text = tree.GetText(); 3064var text = tree.GetText(); 3088var text = tree.GetText(); 3112var text = tree.GetText(); 3136var text = tree.GetText(); 3160var text = tree.GetText(); 3186var text = tree.GetText(); 3212var text = tree.GetText(); 3237var text = tree.GetText(); 3263var text = tree.GetText(); 3281var text = tree.GetText(); 3299var text = tree.GetText(); 3317var text = tree.GetText(); 3332var text = tree.GetText(); 3346var text = tree.GetText(); 3360var text = tree.GetText(); 3398var text = tree.GetText(); 3425private static void CommentOutText(SourceText oldText, int locationOfChange, int widthOfChange, out SyntaxTree incrementalTree, out SyntaxTree parsedTree) 3427var newText = oldText.WithChanges( 3437private static void RemoveText(SourceText oldText, int locationOfChange, int widthOfChange, out SyntaxTree incrementalTree, out SyntaxTree parsedTree) 3439var newText = oldText.WithChanges(new TextChange(new TextSpan(locationOfChange, widthOfChange), "")); 3459private static void CharByCharIncrementalParse(SourceText oldText, char newChar, out SyntaxTree incrementalTree, out SyntaxTree parsedTree) 3465var newText = oldText.WithChanges(new TextChange(new TextSpan(oldText.Length, 0), newChar.ToString())); 3470private static void TokenByTokenBottomUp(SourceText oldText, string token, out SyntaxTree incrementalTree, out SyntaxTree parsedTree) 3473SourceText 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)
367var lexer = new Syntax.InternalSyntax.Lexer(Text.SourceText.From(text), CSharpParseOptions.Default);
Parsing\RoundTrippingTests.cs (4)
28var tree = SyntaxFactory.ParseSyntaxTree(SourceText.From(text), options); 103var tree = SyntaxFactory.ParseSyntaxTree(SourceText.From(text), path: ""); 1581var itext = SourceText.From(text);
Syntax\Mocks\MockCSharpSyntaxTree.cs (5)
16private readonly SourceText _sourceText; 24SourceText? source = null, 29_sourceText = source ?? SourceText.From("", Encoding.UTF8, SourceHashAlgorithm.Sha256); 34public override SourceText GetText(CancellationToken cancellationToken) 37public override bool TryGetText(out SourceText text)
Syntax\SyntaxFactoryTests.cs (2)
45var text = SyntaxFactory.SyntaxTree(SyntaxFactory.CompilationUnit(), encoding: null).GetText(); 53var text = SyntaxFactory.CompilationUnit().SyntaxTree.GetText();
Syntax\SyntaxNodeTests.cs (1)
3565SourceText 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)
501internal static void AddLexicalClassifications(SourceText text, TextSpan textSpan, SegmentedList<ClassifiedSpan> result, CancellationToken cancellationToken) 509internal 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)
186var parentSourceText = parentExpression.SyntaxTree.GetText(); 191var 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 (114)
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();
DocumentationComments\AbstractDocumentationCommentCommandHandler.cs (4)
60private static DocumentationCommentSnippet? InsertOnCharacterTyped(IDocumentationCommentSnippetService service, SyntaxTree syntaxTree, SourceText text, int position, DocumentationCommentOptions options, CancellationToken cancellationToken) 63private static DocumentationCommentSnippet? InsertOnEnterTyped(IDocumentationCommentSnippetService service, SyntaxTree syntaxTree, SourceText text, int position, DocumentationCommentOptions options, CancellationToken cancellationToken) 66private static DocumentationCommentSnippet? InsertOnCommandInvoke(IDocumentationCommentSnippetService service, SyntaxTree syntaxTree, SourceText text, int position, DocumentationCommentOptions options, CancellationToken cancellationToken) 79Func<IDocumentationCommentSnippetService, SyntaxTree, SourceText, int, DocumentationCommentOptions, CancellationToken, DocumentationCommentSnippet?> getSnippetAction,
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; 896async Task<ImmutableArray<(DocumentId documentId, string newName, SyntaxNode newRoot, SourceText newText)>> CalculateFinalDocumentChangesAsync( 902using var _ = PooledObjects.ArrayBuilder<(DocumentId documentId, string newName, SyntaxNode newRoot, SourceText newText)>.GetInstance(out var result); 923ImmutableArray<(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)
135var sourceText = document.GetTextSynchronously(cancellationToken); 154SourceText sourceText, 175ITextBuffer buffer, int caretPoint, SourceText text, LanguageServices services, CompletionRules rules) 600SourceText 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;
LanguageServer\EditorLspCompletionResultCreationService.cs (2)
34SourceText documentText, 112var sourceText = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
Navigation\IDocumentNavigationServiceExtensions.cs (1)
79var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
Preview\AbstractPreviewFactoryService.cs (2)
782var oldText = oldDocument.GetTextSynchronously(cancellationToken); 783var newText = newDocument.GetTextSynchronously(cancellationToken);
Remote\SolutionChecksumUpdater.cs (2)
229if (!oldDocument.TryGetText(out var oldText) || 230!newDocument.TryGetText(out var newText))
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 (25)
BracePairs\AbstractBracePairsTests.cs (1)
33var text = await document.GetTextAsync();
Completion\AbstractCompletionProviderTests.cs (4)
511var text = await document.GetTextAsync(); 512var newText = text.WithChanges(commit.TextChange); 599var text = await document.GetTextAsync(); 1046var text = hostDocument.GetTextBuffer().CurrentSnapshot.AsText();
LanguageServer\AbstractLanguageServerProtocolTests.cs (6)
165private protected static string ApplyTextEdits(LSP.TextEdit[] edits, SourceText originalMarkup) 167var text = originalMarkup; 341solution = 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)); 452static LSP.Location ConvertTextSpanWithTextToLocation(TextSpan span, SourceText text, Uri documentUri) 750internal 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)
920var text = context.AdditionalFile.GetText(context.CancellationToken); 946var text = await document.GetTextAsync(ct).ConfigureAwait(false); 947var newText = SourceText.From(text.ToString() + Title); 1067sourceDocument = sourceDocument.WithText(SourceText.From(code)); 1153var 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")); 260var document1 = await solution.GetDocument(documentId).GetTextAsync(); 268Text = 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)
4208Public Overrides Function IsInsertionTrigger(text As SourceText, characterPosition As Integer, options As CompletionOptions) As Boolean 8226Public Overrides Function ShouldTriggerCompletion(text As SourceText, caretPosition As Integer, trigger As CompletionTrigger, options As OptionSet) As Boolean 8271Public Overrides Function ShouldTriggerCompletion(text As SourceText, caretPosition As Integer, trigger As CompletionTrigger, options As OptionSet) As Boolean 9613Public Overrides Function ShouldTriggerCompletion(text As SourceText, caretPosition As Integer, trigger As CompletionTrigger, options As OptionSet) As Boolean 10274Public Overrides Function IsInsertionTrigger(text As SourceText, characterPosition As Integer, options As CompletionOptions) As Boolean 10347Public Overrides Function IsInsertionTrigger(text As SourceText, characterPosition As Integer, options As CompletionOptions) As Boolean 10640Public Overrides Function IsInsertionTrigger(text As SourceText, characterPosition As Integer, options As CompletionOptions) As Boolean 10776Public 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)
18SourceText text, 30SourceText text,
Microsoft.CodeAnalysis.ExternalAccess.Razor (2)
RazorExcerptResult.cs (2)
13public readonly SourceText Content; 23public RazorExcerptResult(SourceText content, TextSpan mappedSpan, ImmutableArray<ClassifiedSpan> classifiedSpans, Document document, TextSpan span)
Microsoft.CodeAnalysis.Features (150)
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)
129Document document, ConcatImmutableArray<CompletionProvider> providers, int caretPosition, CompletionOptions options, CompletionTrigger trigger, ImmutableHashSet<string>? roles, SourceText text) 191Document 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)
168var 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 (10)
43SourceText text, 84private List<string>? GetDocumentationCommentLines(SyntaxToken token, SourceText text, in DocumentationCommentOptions options, out string? indentText, out int caretOffset, out int spanToReplaceLength) 115private List<string>? GetDocumentationCommentLinesNoIndentation(SyntaxToken token, SourceText text, in DocumentationCommentOptions options, out int caretOffset, out int spanToReplaceLength) 131private List<string>? GetDocumentationStubLines(SyntaxToken token, SourceText text, in DocumentationCommentOptions options, out int caretOffset, out int spanToReplaceLength, out string? existingCommentText) 169public bool IsValidTargetMember(SyntaxTree syntaxTree, SourceText text, int position, CancellationToken cancellationToken) 172private TMemberNode? GetTargetMember(SyntaxTree syntaxTree, SourceText text, int position, CancellationToken cancellationToken) 229public DocumentationCommentSnippet? GetDocumentationCommentSnippetOnEnterTyped(SyntaxTree syntaxTree, SourceText text, int position, in DocumentationCommentOptions options, CancellationToken cancellationToken) 247private DocumentationCommentSnippet? GenerateDocumentationCommentAfterEnter(SyntaxTree syntaxTree, SourceText text, int position, in DocumentationCommentOptions options, CancellationToken cancellationToken) 289public DocumentationCommentSnippet? GetDocumentationCommentSnippetOnCommandInvoke(SyntaxTree syntaxTree, SourceText text, int position, in DocumentationCommentOptions options, CancellationToken cancellationToken) 326private DocumentationCommentSnippet? GenerateExteriorTriviaAfterEnter(SyntaxTree syntaxTree, SourceText text, int position, in DocumentationCommentOptions options, CancellationToken cancellationToken)
DocumentationComments\IDocumentationCommentSnippetService.cs (4)
20SourceText text, 28SourceText text, 35SourceText text, 45bool IsValidTargetMember(SyntaxTree syntaxTree, SourceText text, int caretPosition, CancellationToken cancellationToken);
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, 85SourceText 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; 67SourceText originalSourceText, 91var newSourceText = OriginalSourceText.WithChanges(
Wrapping\BinaryExpression\BinaryExpressionCodeActionComputer.cs (1)
48SourceText originalSourceText,
Wrapping\ChainedExpression\ChainedExpressionCodeActionComputer.cs (1)
70SourceText originalSourceText,
Wrapping\SeparatedSyntaxList\SeparatedSyntaxListCodeActionComputer.cs (1)
77SourceText sourceText,
Microsoft.CodeAnalysis.Features.Test.Utilities (20)
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); 470var text = tree.GetText();
EditAndContinue\EditAndContinueWorkspaceTestBase.cs (8)
66internal static SourceText GetAnalyzerConfigText((string key, string value)[] analyzerConfig) 256var sourceText = SourceText.From(new MemoryStream(encoding.GetBytesWithPreamble(source.content)), encoding, checksumAlgorithm); 305internal static SourceText CreateText(string source) 306=> SourceText.From(source, Encoding.UTF8, SourceHashAlgorithms.Default); 308internal static SourceText CreateTextFromFile(string path) 311return SourceText.From(stream, Encoding.UTF8, SourceHashAlgorithms.Default); 337var sourceText = CreateText("class DTO {}");
EditAndContinue\Extensions.cs (1)
25public static IEnumerable<RudeEditDiagnosticDescription> ToDescription(this IEnumerable<RudeEditDiagnostic> diagnostics, SourceText newSource, bool includeFirstLines)
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)
45AddAdditionalDocument(additionalDocumentId, "additional", SourceText.From(""), filePath: additionalFilePath). 46AddAnalyzerConfigDocument(analyzerConfigId, "config", SourceText.From(""), filePath: "RazorSourceGenerator.razorencconfig"). 99context.AddSource("hint", SourceText.From(s)); 111AddAdditionalDocument(additionalDocumentId, "additional", SourceText.From(""), filePath: "additional.razor"). 112AddAnalyzerConfigDocument(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); 304var sourceText = CreateText("class D {}"); 368solution = solution.AddDocument(designTimeOnlyDocumentId, designTimeOnlyFileName, SourceText.From(sourceDesignTimeOnly, Encoding.UTF8), filePath: designTimeOnlyFilePath); 388solution = solution.AddDocument(designTimeOnlyDocumentId, designTimeOnlyFileName, SourceText.From(sourceDesignTimeOnly, Encoding.UTF8), filePath: designTimeOnlyFilePath); 583AddDocument("a.cs", SourceText.From(source1, Encoding.UTF8, SourceHashAlgorithm.Sha1), filePath: sourceFile.Path); 883AddDocument(documentId, "test.cs", SourceText.From(source1, encoding, SourceHashAlgorithm.Sha1), filePath: sourceFile.Path); 1636context.AddSource("generated.cs", SourceText.From("generated: " + additionalText, Encoding.UTF8, SourceHashAlgorithm.Sha256)); 1985solution = solution.WithDocumentText(document1.Id, SourceText.From("class C1 { void M() { System.Console.WriteLine(2); } }", encoding: null, SourceHashAlgorithms.Default)); 3441DocumentId 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)
71AddDocument(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 (83)
Extensions\ProtocolConversions.cs (7)
303public static LSP.TextDocumentPositionParams PositionToTextDocumentPositionParams(int position, SourceText text, Document document) 324public static TextSpan RangeToTextSpan(LSP.Range range, SourceText text) 353public static LSP.TextEdit TextChangeToTextEdit(TextChange textChange, SourceText oldText) 363public static TextChange TextEditToTextChange(LSP.TextEdit edit, SourceText oldText) 366public static TextChange ContentChangeEventToTextChange(LSP.TextDocumentContentChangeEvent changeEvent, SourceText text) 375public static LSP.Range TextSpanToRange(TextSpan textSpan, SourceText text) 538static 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)
47var originalSourceText = await originalDocument.GetTextAsync(cancellationToken).ConfigureAwait(false); 49var 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; 156SourceText 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\AbstractLspCompletionResultCreationService.cs (5)
28protected abstract Task<LSP.CompletionItem> CreateItemAndPopulateTextEditAsync(Document document, SourceText documentText, bool snippetsSupported, bool itemDefaultsSupported, TextSpan defaultSpan, string typedText, CompletionItem item, CompletionService completionService, CancellationToken cancellationToken); 372SourceText documentText, 394SourceText documentText, 423var sourceText = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); 468var documentText = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
Handler\Completion\CompletionHandler.cs (2)
84SourceText sourceText, 162SourceText sourceText)
Handler\Completion\DefaultLspCompletionResultCreationService.cs (1)
33SourceText documentText,
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)
108var oldText = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); 120var focusText = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
Handler\OnAutoInsert\OnAutoInsertHandler.cs (5)
175var indentedText = GetIndentedText(newSourceText, caretLine, desiredCaretLinePosition, options); 207static SourceText GetIndentedText( 208SourceText textToIndent, 218var indentedText = textToIndent.WithChanges(new TextChange(new TextSpan(lineToIndent.End, 0), indentText)); 229static string GetTextChangeTextWithCaretAtLocation(SourceText sourceText, TextChange textChange, LinePosition desiredCaretLinePosition)
Handler\References\FindUsagesLSPContext.cs (1)
282SourceText 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\Symbols\DocumentSymbolsHandler.cs (3)
87RoslynNavigationBarItem item, Document document, SourceText text, string? containerName, ILspSymbolInformationCreationService symbolInformationCreationService) 108RoslynNavigationBarItem item, SourceText text, CancellationToken cancellationToken) 135ImmutableArray<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) 74/// Calls to this method and <see cref="AddMiscellaneousDocument(Uri, SourceText, string, ILspLogger)"/> are made 105public ValueTask UpdateTextIfPresentAsync(DocumentId documentId, SourceText sourceText, CancellationToken cancellationToken) 111private class StaticSourceTextContainer(SourceText text) : SourceTextContainer 113public override SourceText CurrentText => text;
Workspaces\LspWorkspaceManager.cs (6)
114private ImmutableDictionary<Uri, (SourceText Text, string LanguageId)> _trackedDocuments = ImmutableDictionary<Uri, (SourceText, string)>.Empty.WithComparers(LspUriComparer.Instance); 155public async ValueTask StartTrackingAsync(Uri uri, SourceText documentText, string languageId, CancellationToken cancellationToken) 224public void UpdateTrackedDocument(Uri uri, SourceText newSourceText) 237public ImmutableDictionary<Uri, (SourceText Text, string LanguageId)> GetTrackedLspText() => _trackedDocuments; 454private 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 (35)
Completion\CompletionFeaturesTests.cs (4)
583Project project, LanguageServices languageServices, SourceText text, int caretPosition, CompletionTrigger trigger, 597var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); 824Project project, LanguageServices languageServices, SourceText text, int caretPosition, CompletionTrigger trigger, 838var 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)
206var sourceText = SourceText.From(markup); 219var sourceText = SourceText.From(markup); 233var sourceText = SourceText.From(markup); 252var sourceText = SourceText.From(markup); 266var sourceText = SourceText.From(markup); 276var sourceText = SourceText.From(markup);
SemanticTokens\AbstractSemanticTokensTests.cs (1)
65var text = await document.GetTextAsync().ConfigureAwait(false);
SpellCheck\SpellCheckTests.cs (1)
651var sourceText = await document.GetTextAsync();
Workspaces\LspWorkspaceManagerTests.cs (5)
86await testLspServer.TestWorkspace.ChangeDocumentAsync(firstDocument.Id, SourceText.From($"Some more text{markupOne}", System.Text.Encoding.UTF8, SourceHashAlgorithms.Default)); 120await testLspServer.TestWorkspace.ChangeDocumentAsync(secondDocument.Id, SourceText.From("Two is now three!", System.Text.Encoding.UTF8, SourceHashAlgorithms.Default)); 222var newSolution = testLspServer.TestWorkspace.CurrentSolution.AddDocument(newDocumentId, "NewDoc.cs", SourceText.From("New Doc", System.Text.Encoding.UTF8, SourceHashAlgorithms.Default), filePath: @"C:\NewDoc.cs"); 560.AddDocument(filePath, SourceText.From("ProjectSystemText"), filePath: filePath) 617testLspServer.TestWorkspace.CurrentSolution.WithDocumentText(document.Id, SourceText.From("New Disk Contents")));
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)
91var frozenDocuments = new FixedSizeArrayBuilder<(SourceGeneratedDocumentIdentity identity, DateTime generationDateTime, SourceText text)>(count);
Services\AssetSynchronization\RemoteAssetSynchronizationService.cs (1)
79async 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)
103SourceText code = null; 190private int RunScript(ScriptOptions options, SourceText code, ErrorLogger errorLogger, CancellationToken cancellationToken) 221var script = Script.CreateInitialScript<object>(_scriptCompiler, SourceText.From(initialScriptCodeOpt), options, globals.GetType(), assemblyLoaderOpt: null); 248var tree = _scriptCompiler.ParseSubmission(SourceText.From(input.ToString()), options.ParseOptions, cancellationToken); 273newScript = Script.CreateInitialScript<object>(_scriptCompiler, SourceText.From(code ?? string.Empty), options, globals.GetType(), assemblyLoaderOpt: null);
Script.cs (6)
39internal Script(ScriptCompiler compiler, ScriptBuilder builder, SourceText sourceText, ScriptOptions options, Type globalsTypeOpt, Script previousOpt) 54internal static Script<T> CreateInitialScript<T>(ScriptCompiler compiler, SourceText sourceText, ScriptOptions optionsOpt, Type globalsTypeOpt, InteractiveAssemblyLoader assemblyLoaderOpt) 79internal SourceText SourceText { get; } 117return new Script<TResult>(Compiler, Builder, SourceText.From(code ?? "", options.FileEncoding), options, GlobalsType, this); 130return new Script<TResult>(Compiler, Builder, SourceText.From(code, options.FileEncoding), options, GlobalsType, this); 318internal Script(ScriptCompiler compiler, ScriptBuilder builder, SourceText sourceText, ScriptOptions options, Type globalsTypeOpt, Script previousOpt)
ScriptCompiler.cs (1)
20public abstract SyntaxTree ParseSubmission(SourceText text, ParseOptions parseOptions, CancellationToken cancellationToken);
Microsoft.CodeAnalysis.Scripting.TestUtilities (3)
TestCompilationFactory.cs (3)
24new[] { CSharp.SyntaxFactory.ParseSyntaxTree(SourceText.From(source, encoding: null, SourceHashAlgorithms.Default)) }, 33new[] { VisualBasic.SyntaxFactory.ParseSyntaxTree(SourceText.From(source, encoding: null, SourceHashAlgorithms.Default)) }, 42new[] { CSharp.SyntaxFactory.ParseSyntaxTree(SourceText.From(source, encoding: null, SourceHashAlgorithms.Default)) },
Microsoft.CodeAnalysis.Test.Utilities (31)
AssemblyLoadTestFixture.cs (1)
522syntaxTrees: 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;
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)
25context.AddSource(GeneratedEnglishClassName, SourceText.From($$""" 36context.AddSource(GeneratedSpanishClassName, SourceText.From($$""" 46context.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 (512)
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) 46Return New SyntaxTree() {VisualBasicSyntaxTree.ParseText(SourceText.From(source, encoding:=Nothing, SourceHashAlgorithms.Default), parseOptions)} 51Return sources.Select(Function(s) VisualBasicSyntaxTree.ParseText(SourceText.From(s, encoding:=Nothing, SourceHashAlgorithms.Default), parseOptions)).ToArray()
CompilationTestUtils.vb (4)
22Return source.Select(Function(s) VisualBasicSyntaxTree.ParseText(SourceText.From(s, encoding:=Nothing, SourceHashAlgorithms.Default), parseOptions)) 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, VisualBasicParseOptions.Default), path:=fileName) 220Public Sub IncParseAndVerify(oldIText As SourceText, newIText As SourceText) 254Dim oldText = SourceText.From(node.oldText) 255Dim newText As SourceText = oldText 519Public Overrides Function GetText(Optional cancellationToken As CancellationToken = Nothing) As SourceText 523Public Overrides Function TryGetText(ByRef text As SourceText) As Boolean 545Public Overrides Function WithChangedText(newText As SourceText) As SyntaxTree
VBParser.vb (1)
18Dim tree = VisualBasicSyntaxTree.ParseText(SourceText.From(code, Encoding.UTF8, SourceHashAlgorithms.Default), _options, path:="")
Microsoft.CodeAnalysis.VisualBasic.Workspaces (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 (351)
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 (13)
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) 69private SerializableSourceText(TemporaryStorageTextHandle? storageHandle, SourceText? text, ImmutableArray<byte> contentHash) 88private SourceText? TryGetText() 91public async ValueTask<SourceText> GetTextAsync(CancellationToken cancellationToken) 93var text = TryGetText(); 103public SourceText GetText(CancellationToken cancellationToken) 105var 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 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)
115/// 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)
137siblingTree.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)
697public Document AddDocument(string name, SourceText text, IEnumerable<string>? folders = null, string? filePath = null) 715public TextDocument AddAdditionalDocument(string name, SourceText text, IEnumerable<string>? folders = null, string? filePath = null) 733public TextDocument AddAnalyzerConfigDocument(string name, SourceText text, IEnumerable<string>? folders = null, string? filePath = null)
Workspace\Solution\ProjectState.cs (1)
144var text = await documentState.GetTextAsync(cancellationToken).ConfigureAwait(false);
Workspace\Solution\Solution.cs (17)
917var sourceText = SourceText.From(text, encoding: null, checksumAlgorithm: project.ChecksumAlgorithm); 926public Solution AddDocument(DocumentId documentId, string name, SourceText text, IEnumerable<string>? folders = null, string? filePath = null, bool isGenerated = false) 957var sourceText = SourceText.From(string.Empty, encoding: null, project.ChecksumAlgorithm); 963private Solution AddDocumentImpl(ProjectState project, DocumentId documentId, string name, SourceText text, IReadOnlyList<string>? folders, string? filePath, bool isGenerated) 1018=> this.AddAdditionalDocument(documentId, name, SourceText.From(text), folders, filePath); 1024public Solution AddAdditionalDocument(DocumentId documentId, string name, SourceText text, IEnumerable<string>? folders = null, string? filePath = null) 1055public Solution AddAnalyzerConfigDocument(DocumentId documentId, string name, SourceText text, IEnumerable<string>? folders = null, string? filePath = null) 1079private DocumentInfo CreateDocumentInfo(DocumentId documentId, string name, SourceText text, IEnumerable<string>? folders, string? filePath) 1217public Solution WithDocumentText(DocumentId documentId, SourceText text, PreservationMode mode = PreservationMode.PreserveValue) 1220internal Solution WithDocumentTexts(ImmutableArray<(DocumentId documentId, SourceText text)> texts, PreservationMode mode = PreservationMode.PreserveValue) 1240public Solution WithAdditionalDocumentText(DocumentId documentId, SourceText text, PreservationMode mode = PreservationMode.PreserveValue) 1261public Solution WithAnalyzerConfigDocumentText(DocumentId documentId, SourceText text, PreservationMode mode = PreservationMode.PreserveValue) 1571public Solution WithDocumentText(IEnumerable<DocumentId?> documentIds, SourceText text, PreservationMode mode = PreservationMode.PreserveValue) 1597SourceGeneratedDocumentIdentity documentIdentity, DateTime generationDateTime, SourceText text) 1609internal Solution WithFrozenSourceGeneratedDocuments(ImmutableArray<(SourceGeneratedDocumentIdentity documentIdentity, DateTime generationDateTime, SourceText text)> documents)
Workspace\Solution\SolutionCompilationState.cs (11)
792internal SolutionCompilationState WithDocumentTexts(ImmutableArray<(DocumentId documentId, SourceText text)> texts, PreservationMode mode) 793=> UpdateDocumentsInMultipleProjects<DocumentState, SourceText, PreservationMode>( 799private static bool SourceTextIsUnchanged(DocumentState oldDocument, SourceText text) 800=> oldDocument.TryGetText(out var oldText) && text == oldText; 917/// <inheritdoc cref="SolutionState.WithAdditionalDocumentText(DocumentId, SourceText, PreservationMode)"/> 919DocumentId documentId, SourceText text, PreservationMode mode) 925/// <inheritdoc cref="SolutionState.WithAnalyzerConfigDocumentText(DocumentId, SourceText, PreservationMode)"/> 927DocumentId documentId, SourceText text, PreservationMode mode) 1326ImmutableArray<(SourceGeneratedDocumentIdentity documentIdentity, DateTime generationDateTime, SourceText sourceText)> documents) 1765public SolutionCompilationState WithDocumentText(IEnumerable<DocumentId?> documentIds, SourceText text, PreservationMode mode) 1767using var _ = ArrayBuilder<(DocumentId, SourceText)>.GetInstance(out var changedDocuments);
Workspace\Solution\SolutionCompilationState.RegularCompilationTracker_Generators.cs (2)
190var sourceText = SourceText.From(
Workspace\Solution\SolutionState.cs (6)
968public StateChange WithDocumentText(DocumentId documentId, SourceText text, PreservationMode mode = PreservationMode.PreserveValue) 971if (oldDocument.TryGetText(out var oldText) && text == oldText) 996public StateChange WithAdditionalDocumentText(DocumentId documentId, SourceText text, PreservationMode mode = PreservationMode.PreserveValue) 999if (oldDocument.TryGetText(out var oldText) && text == oldText) 1012public StateChange WithAnalyzerConfigDocumentText(DocumentId documentId, SourceText text, PreservationMode mode = PreservationMode.PreserveValue) 1015if (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) 1898var text = document.GetTextSynchronously(CancellationToken.None); 1907var text = document.GetTextSynchronously(CancellationToken.None); 1916var text = document.GetTextSynchronously(CancellationToken.None); 1933var currentText = newDoc.GetTextSynchronously(CancellationToken.None); // needs wait 1943var currentText = newDoc.GetTextSynchronously(CancellationToken.None); // needs wait 1960if (!oldDoc.TryGetText(out var oldText)) 1965var currentText = newDoc.GetTextSynchronously(CancellationToken.None); // needs wait 1968else if (!newDoc.TryGetText(out var newText)) 2173protected virtual void ApplyDocumentAdded(DocumentInfo info, SourceText text) 2195protected virtual void ApplyDocumentTextChanged(DocumentId id, SourceText text) 2217protected virtual void ApplyAdditionalDocumentAdded(DocumentInfo info, SourceText text) 2239protected virtual void ApplyAdditionalDocumentTextChanged(DocumentId id, SourceText text) 2250protected virtual void ApplyAnalyzerConfigDocumentAdded(DocumentInfo info, SourceText text) 2272protected 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)
53var document = project.AddDocument("Document", SourceText.From(code)); 87private static async Task AssertFormatAsync(SolutionServices services, string expected, SyntaxNode root, ImmutableArray<TextSpan> spans, SyntaxFormattingOptions options, SourceText sourceText) 94var resultText = sourceText.WithChanges(result); 103private static bool TryAdjustSpans(SourceText inputText, IList<TextChange> changes, SourceText outputText, ImmutableArray<TextSpan> inputSpans, out ImmutableArray<TextSpan> outputSpans) 131protected 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)
188=> 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)
788var 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 (291)
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 (127)
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); 832var text = SourceText.From("new text"); 835Assert.True(newSolution1.GetAdditionalDocument(documentId)!.TryGetText(out var actualText)); 841Assert.Throws<ArgumentNullException>(() => solution.WithAdditionalDocumentText(documentId, (SourceText)null!, PreservationMode.PreserveIdentity)); 854var textAndVersion = TextAndVersion.Create(SourceText.From("new text"), VersionStamp.Default); 857Assert.True(newSolution1.GetAdditionalDocument(documentId)!.TryGetText(out var actualText)); 865Assert.Throws<ArgumentNullException>(() => solution.WithAdditionalDocumentText(documentId, (SourceText)null!, PreservationMode.PreserveIdentity)); 878var text = SourceText.From("new text"); 881Assert.True(newSolution1.GetAnalyzerConfigDocument(documentId)!.TryGetText(out var actualText)); 887Assert.Throws<ArgumentNullException>(() => solution.WithAnalyzerConfigDocumentText(documentId, (SourceText)null!, PreservationMode.PreserveIdentity)); 900var textAndVersion = TextAndVersion.Create(SourceText.From("new text"), VersionStamp.Default); 903Assert.True(newSolution1.GetAnalyzerConfigDocument(documentId)!.TryGetText(out var actualText)); 911Assert.Throws<ArgumentNullException>(() => solution.WithAnalyzerConfigDocumentText(documentId, (SourceText)null!, PreservationMode.PreserveIdentity)); 1005.AddDocument(d1, "d1.cs", SourceText.From("class D1;", Encoding.UTF8, SourceHashAlgorithms.Default), filePath: Path.Combine(s_projectDir, "d1.cs")) 1006.AddDocument(d2, "d2.cs", SourceText.From("class D2;", Encoding.UTF8, SourceHashAlgorithms.Default), filePath: Path.Combine(s_projectDir, "d2.cs")) 1007.AddAdditionalDocument(a1, "a1.txt", SourceText.From("text1", Encoding.UTF8, SourceHashAlgorithms.Default)) 1008.AddAdditionalDocument(a2, "a2.txt", SourceText.From("text2", Encoding.UTF8, SourceHashAlgorithms.Default)) 1009.AddAnalyzerConfigDocument(c1, "c1", SourceText.From("#empty1", Encoding.UTF8, SourceHashAlgorithms.Default), filePath: Path.Combine(s_projectDir, "editorcfg")) 1010.AddAnalyzerConfigDocument(c2, "c2", SourceText.From("#empty2", Encoding.UTF8, SourceHashAlgorithms.Default), filePath: Path.Combine(s_projectDir, "editorcfg")); 1020loader: TextLoader.From(TextAndVersion.Create(SourceText.From("class NewD1;", Encoding.UTF32, SourceHashAlgorithm.Sha256), VersionStamp.Create(), filePath: Path.Combine(s_projectDir, "newD1.cs"))), 1029loader: TextLoader.From(TextAndVersion.Create(SourceText.From("class NewD3;", Encoding.UTF8, SourceHashAlgorithms.Default), VersionStamp.Create(), filePath: Path.Combine(s_projectDir, "newD3.cs"))), 1039loader: TextLoader.From(TextAndVersion.Create(SourceText.From("new text1", Encoding.UTF32, SourceHashAlgorithm.Sha256), VersionStamp.Create(), filePath: Path.Combine(s_projectDir, "newD1.cs"))), 1048loader: TextLoader.From(TextAndVersion.Create(SourceText.From("new text3", Encoding.UTF8, SourceHashAlgorithms.Default), VersionStamp.Create(), filePath: Path.Combine(s_projectDir, "newD3.cs"))), 1058loader: TextLoader.From(TextAndVersion.Create(SourceText.From("#new empty1", Encoding.UTF32, SourceHashAlgorithm.Sha256), VersionStamp.Create(), filePath: Path.Combine(s_projectDir, "newD1.cs"))), 1067loader: TextLoader.From(TextAndVersion.Create(SourceText.From("#new empty3", Encoding.UTF8, SourceHashAlgorithms.Default), VersionStamp.Create(), filePath: Path.Combine(s_projectDir, "newD3.cs"))), 1495var textC = SourceText.From("class C {}", encoding: null, checksumAlgorithm: SourceHashAlgorithm.Sha1); 2187var solution4 = solution3.AddAnalyzerConfigDocument(editorConfigId, "editorconfig2", SourceText.From(editorConfigContent), filePath: Path.Combine(s_projectDir, "editorconfig2")); 2279var sourceText = SourceText.From("text", checksumAlgorithm: SourceHashAlgorithms.Default); 2293Assert.Throws<ArgumentNullException>("text", () => solution.AddDocument(documentId, "name", text: (SourceText)null!)); 2340var root = CSharp.SyntaxFactory.ParseSyntaxTree(SourceText.From("class C {}", encoding: null, SourceHashAlgorithm.Sha1)).GetRoot(); 3018.AddDocument(documentId, "DocumentName", SourceText.From("class Class{}")); 3058var text2 = tree2.GetText(); 3171var observedText2 = sol.GetDocument(did).GetTextAsync().Result; 3189var docText = doc.GetTextAsync().Result; 3211var docText = doc.GetTextAsync().Result; 3236var docText = doc.GetTextAsync().Result; 3382private static ObjectReference<SourceText> GetObservedText(Solution solution, DocumentId documentId, string expectedText = null) 3384var observedText = solution.GetDocument(documentId).GetTextAsync().Result; 3391return new ObjectReference<SourceText>(observedText); 3413private static ObjectReference<SourceText> GetObservedTextAsync(Solution solution, DocumentId documentId, string expectedText = null) 3415var observedText = solution.GetDocument(documentId).GetTextAsync().Result; 3422return new ObjectReference<SourceText>(observedText); 3630.AddDocument(did, "test", SourceText.From(language == LanguageNames.CSharp ? "class C {}" : "Class C : End Class", Encoding.UTF8, SourceHashAlgorithm.Sha256), filePath: "old path"); 3773var text = await doc.GetTextAsync().ConfigureAwait(false); 3835var solution2 = solution.WithDocumentText(did3, SourceText.From(text4)); 3848var doc = ws.AddDocument(proj.Id, "a.cs", SourceText.From("public class c { }", Encoding.UTF32)); 3909workspace.AddDocument(project1.Id, "Broken.cs", SourceText.From("class ")); 3931project = project.AddDocument("Extra.cs", SourceText.From("class Extra { }")).Project; 3933var documentToFreeze = project.AddDocument("DocumentToFreeze.cs", SourceText.From("")); 3956project = project.AddDocument("Extra.cs", SourceText.From("class Extra { }")).Project; 3958var documentToFreeze = project.AddDocument("DocumentToFreeze.cs", SourceText.From("")); 3984project = project.AddDocument("Extra.cs", SourceText.From("class Extra { }")).Project; 3986var documentToFreezeOriginal = project.AddDocument("DocumentToFreeze.cs", SourceText.From("class DocumentToFreeze { void M() { } }")); 3990var solution = project.Solution.WithDocumentText(documentToFreezeOriginal.Id, SourceText.From("class DocumentToFreeze { void M() { /*no top level change*/ } }")); 4029project = project.AddDocument("Extra.cs", SourceText.From("class Extra { }")).Project; 4031var documentToFreezeOriginal = project.AddDocument("DocumentToFreeze.cs", SourceText.From("class DocumentToFreeze { void M() { } }")); 4035var solution = project.Solution.WithDocumentText(documentToFreezeOriginal.Id, SourceText.From("class DocumentToFreeze { void M() { } public void NewMethod() { } }")); 4093var document = workspace.AddDocument(project2.Id, "Test.cs", SourceText.From("")); 4197document = document.WithText(SourceText.From("// Source File with Changes")); 4223.WithDocumentText(documentId1, SourceText.From("// Document 1 Changed")) 4224.WithDocumentText(documentId2, SourceText.From("// Document 2 Changed")) 4225.WithDocumentText(documentId3, SourceText.From("// Document 3 Changed")); 4410var text = SourceText.From("// empty", encoding: null, SourceHashAlgorithms.Default); 4413var sourceText = strongTree.GetText(); 4545loader: TextLoader.From(TextAndVersion.Create(SourceText.From("[*.*]\r\n\r\ndotnet_diagnostic.CA1234.severity = error"), VersionStamp.Default))))); 4578loader: TextLoader.From(TextAndVersion.Create(SourceText.From("[*.*]\r\n\r\ndotnet_diagnostic.CA1234.severity = error"), VersionStamp.Default))))); 4619loader: TextLoader.From(TextAndVersion.Create(SourceText.From("[*.*]\r\n\r\ndotnet_diagnostic.CA1234.severity = error"), VersionStamp.Default))))); 4631TextLoader.From(TextAndVersion.Create(SourceText.From("[*.*]\r\n\r\ndotnet_diagnostic.CA6789.severity = error"), VersionStamp.Default)), 4667loader: TextLoader.From(TextAndVersion.Create(SourceText.From("is_global = true\r\n\r\ndotnet_diagnostic.CA1234.severity = error"), VersionStamp.Default))))); 4713loader: TextLoader.From(TextAndVersion.Create(SourceText.From("[*.*]\r\n\r\ngenerated_code = true"), VersionStamp.Default))))); 5278var text = SourceText.From("public class C { }"); 5299var newDocText = await newDoc.GetTextAsync(); 5300var sameText = await newDoc.GetTextAsync(); 5304var treeText = newDocTree.GetText(); 5326var sourceTextToRelease = ObjectReference.CreateFromFactory(static () => SourceText.From(Guid.NewGuid().ToString())); 5374.AddDocument(documentId, "test.cs", SourceText.From("public class C { }"), filePath: sourcePath) 5375.AddAnalyzerConfigDocument(DocumentId.CreateNewId(projectId), ".editorconfig", SourceText.From($"[{pattern}]\nindent_style = tab"), filePath: configPath); 5434project = project.AddDocument("Extra.cs", SourceText.From("class Extra { }")).Project; 5451project = project.AddDocument("Extra.cs", SourceText.From("class Extra { }")).Project; 5472project1 = project2.Solution.GetProject(project1.Id).AddDocument("Doc1", SourceText.From("class Doc1 { }")).Project; 5473project2 = project1.Solution.GetProject(project2.Id).AddDocument("Doc2", SourceText.From("class Doc2 { }")).Project; 5500project1 = project2.Solution.GetProject(project1.Id).AddDocument("Doc1", SourceText.From("class Doc1 { }")).Project; 5501project2 = project1.Solution.GetProject(project2.Id).AddDocument("Doc2", SourceText.From("class Doc2 { }")).Project; 5530project1 = project2.Solution.GetProject(project1.Id).AddDocument("Doc1", SourceText.From("class Doc1 { }")).Project; 5531project2 = project1.Solution.GetProject(project2.Id).AddDocument("Doc2", SourceText.From("class Doc2 { }")).Project; 5562project1 = project1.AddDocument("Doc1", SourceText.From("class Doc1 { }")).Project; 5571var forkedProject1 = frozenSolution.WithDocumentText(project1.Documents.Single().Id, SourceText.From("class Doc2 { }")).GetProject(project1.Id); 5587project1 = project1.AddDocument("Doc1", SourceText.From("class Doc1 { }")).Project; 5607var forkedProject1 = frozenSolution.WithDocumentText(project1.Documents.Single().Id, SourceText.From("class Doc2 { }")).GetProject(project1.Id); 5636project = project.AddDocument("Extra.ts", SourceText.From("class Extra { }")).Project; 5659.AddDocument($"Document", SourceText.From("class C { }"), filePath: @"c:\test\Document.cs").Project; 5669.AddDocument($"Document", SourceText.From("class C { }"), filePath: @"c:\test\Document.cs").Project; 5680old => old.WithDocumentText(documentId1, SourceText.From(lastContents)),
SolutionTests\SolutionWithSourceGeneratorTests.cs (22)
194project = project.AdditionalDocuments.First().WithAdditionalDocumentText(SourceText.From("Changed text!")).Project; 218project = project.AddDocument("Source.cs", SourceText.From("")).Project; 251project = project.Solution.WithDocumentText(documentId, SourceText.From("// Changed Source File")).Projects.Single(); 294project = project.Solution.WithAdditionalDocumentText(additionalDocumentId, SourceText.From("Hello, everyone!")).Projects.Single(); 299project = project.Solution.WithAdditionalDocumentText(additionalDocumentId, SourceText.From("Good evening, everyone!")).Projects.Single(); 355SourceText.From("Hello, world!!!!")).Projects.Single(); 468project = project.Documents.Single().WithText(SourceText.From("// Change")).Project; 544var existingText = await project.Documents.Single().GetTextAsync(); 545var newText = existingText.WithChanges(new TextChange(new TextSpan(existingText.Length, length: 0), " With Change")); 574var differentOpenTextContainer = SourceText.From("// Open Text").Container; 598var differentOpenTextContainer = SourceText.From("// StaticContent", Encoding.UTF8).Container; 613.AddAdditionalDocument("Test.txt", SourceText.From("")); 618var differentOpenTextContainer = SourceText.From("// Open Text").Container; 649var differentOpenTextContainer = SourceText.From("// Open Text").Container; 676var differentOpenTextContainer = SourceText.From("// Open Text").Container; 713documentToFreeze = documentToFreeze.WithText(SourceText.From("// Changed Source File")); 742document = document.WithText(SourceText.From("// Something else")); 776document = document.WithText(SourceText.From("// Something else")); 837identity, DateTime.Now, SourceText.From("// Frozen Document")); 864[(sourceGeneratedDocument1.Identity, DateTime.Now, SourceText.From("// Frozen 1")), (sourceGeneratedDocument2.Identity, DateTime.Now, SourceText.From("// Frozen 2"))]); 884sourceGeneratedDocumentIdentity, 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 (89)
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, 76public static async Task<MappedSpanResult?> TryMapAndGetFirstAsync(DocumentSpan documentSpan, SourceText sourceText, CancellationToken cancellationToken) 97public 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 (5)
135static VsTextSpan GetVsTextSpan(SourceText text, int position, int virtualSpace) 157Func<SourceText, VsTextSpan> getVsTextSpan, 180Func<SourceText, VsTextSpan> getVsTextSpan, 240Func<SourceText, VsTextSpan> getVsTextSpan) 341private 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)
130var 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)
54var document1 = project1.AddDocument("Document1", SourceText.From(csCode)); 58var document2 = project2.AddDocument("Document2", SourceText.From(vbCode)); 64.AddAdditionalDocument("Additional", SourceText.From("hello"), ImmutableArray.Create("test"), @".\Add").Project.Solution; 73loader: TextLoader.From(TextAndVersion.Create(SourceText.From("root = true"), VersionStamp.Create()))))); 159var document = workspace.CurrentSolution.AddProject("Project", "Project.dll", LanguageNames.CSharp).AddDocument("Document", SourceText.From(code)); 179var document = solution.AddProject("Project", "Project.dll", LanguageNames.CSharp).AddDocument("Document", SourceText.From(code)); 538var document = CreateWorkspace().CurrentSolution.AddProject("empty", "empty", LanguageNames.CSharp).AddDocument("empty", SourceText.From("")); 613var sourceText = SourceText.From("Hello", Encoding.UTF8); 631sourceText = 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; 433var tempDoc = project.AddDocument("X.cs", SourceText.From("// ")); 448Assert.True(localWorkspace.SetCurrentSolution(s => s.WithDocumentText(tempDocId, SourceText.From("// " + i)), WorkspaceChangeKind.SolutionChanged)); 484var localText = await localDoc.GetTextAsync(); 485var remoteText = await localDoc.GetTextAsync(); 493private static SourceText CreateText(string content, Encoding encoding = null, SourceHashAlgorithm checksumAlgorithm = SourceHashAlgorithm.Sha1) 494=> SourceText.From(content, encoding ?? Encoding.UTF8, checksumAlgorithm); 496private static SourceText CreateStreamText(string content, bool useBOM, bool useMemoryStream) 503return SourceText.From(stream, encoding, SourceHashAlgorithm.Sha1, throwIfBinaryDetected: true); 507return SourceText.From(bytes, bytes.Length, encoding, SourceHashAlgorithm.Sha1, throwIfBinaryDetected: true); 521var sourceText = CreateText(Guid.NewGuid().ToString()); 555var sourceText = CreateText(Guid.NewGuid().ToString()); 599ImmutableArray<(string, SourceText)>.Empty); 606ImmutableArray<(string, SourceText)>.Empty, 653ImmutableArray<(string, SourceText)>.Empty); 659var contents = CreateText(Guid.NewGuid().ToString()); 667var contents = CreateText(Guid.NewGuid().ToString()); 717return ImmutableArray.Create(("hint", SourceText.From($"// generated document {callCount}", Encoding.UTF8))); 739solution = solution.WithTextDocumentText(tempDocId, SourceText.From("// new contents")); 769var tempDoc = project.AddDocument("X.cs", SourceText.From("// ")); 798return ImmutableArray.Create(("hint", SourceText.From($"// generated document {callCount}", Encoding.UTF8))); 853return ImmutableArray.Create(("hint", SourceText.From($"// generated document {callCount}", Encoding.UTF8))); 907var tempDoc = project1.AddDocument("X.cs", SourceText.From("// ")); 916var tempDoc = project2.AddDocument("X.cs", SourceText.From("// ")); 958var tempDoc = project1.AddDocument("X.cs", SourceText.From("// ")); 967var tempDoc = project2.AddDocument("X.cs", SourceText.From("// ")); 999var tempDoc = project1.AddDocument("X.cs", SourceText.From("// ")); 1008var tempDoc = project2.AddDocument("X.cs", SourceText.From("// ")); 1042var tempDoc = project1.AddDocument("X.cs", SourceText.From("// ")); 1051var tempDoc = project2.AddDocument("X.cs", SourceText.From("// ")); 1094var tempDoc = project1.AddDocument("X.cs", SourceText.From("// ")); 1104var tempDoc = project2.AddDocument("X.cs", SourceText.From("// ")); 1147var tempDoc = project1.AddDocument("X.cs", SourceText.From("// ")); 1157var tempDoc = project2.AddDocument("X.cs", SourceText.From("// ")); 1200var tempDoc = project1.AddDocument("X.cs", SourceText.From("// ")); 1210var tempDoc = project2.AddDocument("X.cs", SourceText.From("// ")); 1245var tempDoc = project1.AddDocument("X.cs", SourceText.From("// ")); 1255var tempDoc = project2.AddDocument("X.cs", SourceText.From("// ")); 1290var tempDoc = project1.AddDocument("X.cs", SourceText.From("// ")); 1299var tempDoc = project2.AddDocument("X.cs", SourceText.From("// ")); 1333var tempDoc = project1.AddDocument("X.cs", SourceText.From("// ")); 1342var tempDoc = project2.AddDocument("X.cs", SourceText.From("// ")); 1425Contract.ThrowIfFalse(workspace.TryApplyChanges(workspace.CurrentSolution.WithDocumentText(normalDocId, SourceText.From("// new text")))); 1539var tempDoc = project1.AddDocument("X.cs", SourceText.From("// ")); 1618private static SourceText GetNewText(Document document, string csAddition, string vbAddition) 1622return SourceText.From(document.State.GetTextSynchronously(CancellationToken.None).ToString() + csAddition); 1625return SourceText.From(document.State.GetTextSynchronously(CancellationToken.None).ToString() + vbAddition); 1731solution = current.AddDocument($"Document{i}", SourceText.From(documents[i])).Project.Solution; 1737solution = current.AddAdditionalDocument($"AdditionalDocument{i}", SourceText.From(additionalDocuments[i])).Project.Solution;
Services\SolutionServiceTests.cs (18)
159await VerifySolutionUpdate(code, s => s.WithDocumentText(s.Projects.First().DocumentIds.First(), SourceText.From(code + " "))); 312project = project.AddDocument("newDocument", SourceText.From("// new text")).Project; 332loader: TextLoader.From(TextAndVersion.Create(SourceText.From("test"), VersionStamp.Create()))); 343return s.WithAdditionalDocumentText(additionalDocumentId, SourceText.From("changed")); 364loader: TextLoader.From(TextAndVersion.Create(SourceText.From("root = true"), VersionStamp.Create(), filePath: configPath)), 376return s.WithAnalyzerConfigDocumentText(analyzerConfigDocumentId, SourceText.From("root = false")); 396loader: TextLoader.From(TextAndVersion.Create(SourceText.From("class A { }"), VersionStamp.Create()))); 407return s.WithDocumentText(documentId, SourceText.From("class Changed { }")); 434var currentSolution = remoteSolution1.WithDocumentText(remoteSolution1.Projects.First().Documents.First().Id, SourceText.From(code + " class Test2 { }")); 443currentSolution = oopSolution2.WithDocumentText(oopSolution2.Projects.First().Documents.First().Id, SourceText.From(code + " class Test3 { }")); 516var frozenText1 = SourceText.From("// Hello, World!"); 525var frozenText2 = SourceText.From("// Hello, World! A second time!"); 829solution = solution.GetProject(project1.Id).AddDocument("X.cs", SourceText.From("// X")).Project.Solution; 830solution = solution.GetProject(project2.Id).AddDocument("Y.vb", SourceText.From("' Y")).Project.Solution; 884solution = solution.GetProject(project1.Id).AddDocument("X.cs", SourceText.From("// X")).Project.Solution; 885solution = 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)
95private partial void AddSource(string hintName, SourceText sourceText); 110SourceText? sourceText = GenerateTypeInfo(contextGenerationSpec, typeGenerationSpec); 180private static SourceText CompleteSourceFileAndReturnText(SourceWriter writer) 191private SourceText? GenerateTypeInfo(ContextGenerationSpec contextSpec, TypeGenerationSpec typeGenerationSpec) 226private static SourceText GenerateForTypeWithBuiltInConverter(ContextGenerationSpec contextSpec, TypeGenerationSpec typeMetadata) 243private static SourceText GenerateForTypeWithCustomConverter(ContextGenerationSpec contextSpec, TypeGenerationSpec typeMetadata) 264private static SourceText GenerateForNullable(ContextGenerationSpec contextSpec, TypeGenerationSpec typeMetadata) 285private static SourceText GenerateForUnsupportedType(ContextGenerationSpec contextSpec, TypeGenerationSpec typeMetadata) 301private static SourceText GenerateForEnum(ContextGenerationSpec contextSpec, TypeGenerationSpec typeMetadata) 317private SourceText GenerateForCollection(ContextGenerationSpec contextSpec, TypeGenerationSpec typeGenerationSpec) 491private SourceText GenerateForObject(ContextGenerationSpec contextSpec, TypeGenerationSpec typeMetadata) 1107private static SourceText GetRootJsonContextImplementation(ContextGenerationSpec contextSpec, bool emitGetConverterForNullablePropertyMethod) 1358private static SourceText GetGetTypeInfoImplementation(ContextGenerationSpec contextSpec) 1400private 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(