2 instantiations of TextAndVersion
Microsoft.CodeAnalysis.Workspaces (2)
241 references to TextAndVersion
Microsoft.CodeAnalysis.CSharp.EditorFeatures.UnitTests (1)
Microsoft.CodeAnalysis.CSharp.Workspaces.UnitTests (1)
Microsoft.CodeAnalysis.EditorFeatures (3)
Microsoft.CodeAnalysis.EditorFeatures.Test.Utilities (1)
Microsoft.CodeAnalysis.EditorFeatures.UnitTests (2)
Microsoft.CodeAnalysis.Features (3)
Microsoft.CodeAnalysis.Features.Test.Utilities (3)
Microsoft.CodeAnalysis.Features.UnitTests (2)
Microsoft.CodeAnalysis.LanguageServer (3)
Microsoft.CodeAnalysis.LanguageServer.Protocol (2)
Microsoft.CodeAnalysis.Workspaces (138)
Workspace\Solution\Solution.cs (5)
1041loader: TextLoader.From(TextAndVersion.Create(text, VersionStamp.Create(), name)),
1155var loader = TextLoader.From(TextAndVersion.Create(text, version, name));
1354public Solution WithDocumentText(DocumentId documentId, TextAndVersion textAndVersion, PreservationMode mode = PreservationMode.PreserveValue)
1375public Solution WithAdditionalDocumentText(DocumentId documentId, TextAndVersion textAndVersion, PreservationMode mode = PreservationMode.PreserveValue)
1396public Solution WithAnalyzerConfigDocumentText(DocumentId documentId, TextAndVersion textAndVersion, PreservationMode mode = PreservationMode.PreserveValue)
Workspace\Solution\SolutionCompilationState.cs (6)
971/// <inheritdoc cref="SolutionState.WithDocumentText(DocumentId, TextAndVersion, PreservationMode)"/>
973DocumentId documentId, TextAndVersion textAndVersion, PreservationMode mode)
979/// <inheritdoc cref="SolutionState.WithAdditionalDocumentText(DocumentId, TextAndVersion, PreservationMode)"/>
981DocumentId documentId, TextAndVersion textAndVersion, PreservationMode mode)
987/// <inheritdoc cref="SolutionState.WithAnalyzerConfigDocumentText(DocumentId, TextAndVersion, PreservationMode)"/>
989DocumentId documentId, TextAndVersion textAndVersion, PreservationMode mode)
Workspace\Solution\TextDocumentState.cs (16)
71private static ConstantTextAndVersionSource CreateStrongText(TextAndVersion text)
74private static RecoverableTextAndVersion CreateRecoverableText(TextAndVersion text, SolutionServices services)
82if (this.TextAndVersionSource.TryGetValue(LoadTextOptions, out var textAndVersion))
97public bool TryGetTextAndVersion([NotNullWhen(true)] out TextAndVersion? textAndVersion)
105var textAndVersion = await GetTextAndVersionAsync(cancellationToken).ConfigureAwait(false);
111var textAndVersion = this.TextAndVersionSource.GetValue(LoadTextOptions, cancellationToken);
117var textAndVersion = this.TextAndVersionSource.GetValue(LoadTextOptions, cancellationToken);
129var textAndVersion = await GetTextAndVersionAsync(cancellationToken).ConfigureAwait(false);
133public TextDocumentState UpdateText(TextAndVersion newTextAndVersion, PreservationMode mode)
143var newTextAndVersion = TextAndVersion.Create(newText, newVersion, FilePath);
159: CreateStrongText(TextAndVersion.Create(SourceText.From(string.Empty, encoding: null, loadTextOptions.ChecksumAlgorithm), VersionStamp.Default, filePath));
181private async ValueTask<TextAndVersion> GetTextAndVersionAsync(CancellationToken cancellationToken)
183if (this.TextAndVersionSource.TryGetValue(LoadTextOptions, out var textAndVersion))
198var textAndVersion = await GetTextAndVersionAsync(cancellationToken).ConfigureAwait(false);
204if (this.TextAndVersionSource.TryGetValue(LoadTextOptions, out var textAndVersion))
Workspace\Solution\TextLoader.cs (16)
60public virtual Task<TextAndVersion> LoadTextAndVersionAsync(LoadTextOptions options, CancellationToken cancellationToken)
65_ => new StrongBox<bool>(new Func<Workspace, DocumentId, CancellationToken, Task<TextAndVersion>>(LoadTextAndVersionAsync).Method.DeclaringType != typeof(TextLoader))).Value)
83public virtual Task<TextAndVersion> LoadTextAndVersionAsync(Workspace? workspace, DocumentId? documentId, CancellationToken cancellationToken)
92internal virtual TextAndVersion LoadTextAndVersionSynchronously(LoadTextOptions options, CancellationToken cancellationToken)
98internal async Task<TextAndVersion> LoadTextAsync(LoadTextOptions options, CancellationToken cancellationToken)
127internal TextAndVersion LoadTextSynchronously(LoadTextOptions options, CancellationToken cancellationToken)
158private TextAndVersion CreateFailedText(string message)
160return TextAndVersion.Create(
170public static TextLoader From(TextAndVersion textAndVersion)
198private readonly TextAndVersion _textAndVersion;
200internal TextDocumentLoader(TextAndVersion textAndVersion)
203public override async Task<TextAndVersion> LoadTextAndVersionAsync(LoadTextOptions options, CancellationToken cancellationToken)
206internal override TextAndVersion LoadTextAndVersionSynchronously(LoadTextOptions options, CancellationToken cancellationToken)
226public override async Task<TextAndVersion> LoadTextAndVersionAsync(LoadTextOptions options, CancellationToken cancellationToken)
229internal override TextAndVersion LoadTextAndVersionSynchronously(LoadTextOptions options, CancellationToken cancellationToken)
230=> TextAndVersion.Create(_container.CurrentText, _version, _filePath);
Workspace\Solution\VersionSource\RecoverableTextAndVersion.cs (9)
54public bool TryGetValue(LoadTextOptions options, [MaybeNullWhen(false)] out TextAndVersion value)
61value = TextAndVersion.Create(text, recoverableText.Version, filePath: null, recoverableText.ExceptionMessage);
90var textAndVersion = useAsync
105var textAndVersion = useAsync
116public TextAndVersion GetValue(LoadTextOptions options, CancellationToken cancellationToken)
126public async Task<TextAndVersion> GetValueAsync(LoadTextOptions options, CancellationToken cancellationToken)
148public RecoverableText(ITextAndVersionSource source, TextAndVersion textAndVersion, LoadTextOptions options, SolutionServices services)
166public TextAndVersion ToTextAndVersion(SourceText text)
167=> TextAndVersion.Create(text, Version, filePath: null, ExceptionMessage);
Workspace\Workspace_Editor.cs (7)
401var newTextAndVersion = GetProperTextAndVersion(oldText, newText, version, oldDocumentState.FilePath);
486private static TextAndVersion GetProperTextAndVersion(SourceText oldText, SourceText newText, VersionStamp version, string? filePath)
491? TextAndVersion.Create(newText, version, filePath)
492: TextAndVersion.Create(newText, version.GetNewerVersion(), filePath);
557Func<Solution, DocumentId, TextAndVersion, PreservationMode, Solution> withDocumentTextAndVersion,
597var newTextAndVersion = TextAndVersion.Create(newText, version, oldDocument.FilePath);
Microsoft.CodeAnalysis.Workspaces.Test.Utilities (5)
Microsoft.CodeAnalysis.Workspaces.UnitTests (68)
SolutionTests\SolutionTests.cs (36)
372var textAndVersion = TextAndVersion.Create(SourceText.From("new text"), VersionStamp.Default);
450var textAndVersion = TextAndVersion.Create(text, VersionStamp.Create());
494private static Solution UpdateSolution(PreservationMode mode, TextUpdateType updateType, Solution solution, DocumentId documentId1, SourceText text, TextAndVersion textAndVersion)
538var textAndVersion = TextAndVersion.Create(text, VersionStamp.Create());
621var textAndVersion = TextAndVersion.Create(text, VersionStamp.Create());
704var textAndVersion = TextAndVersion.Create(text, VersionStamp.Create());
780var textAndVersion = TextAndVersion.Create(text, VersionStamp.Create());
867var textAndVersion = TextAndVersion.Create(text, VersionStamp.Create());
940var textAndVersion = TextAndVersion.Create(SourceText.From("new text"), VersionStamp.Default);
986var textAndVersion = TextAndVersion.Create(SourceText.From("new text"), VersionStamp.Default);
1106loader: TextLoader.From(TextAndVersion.Create(SourceText.From("class NewD1;", Encoding.UTF32, SourceHashAlgorithm.Sha256), VersionStamp.Create(), filePath: Path.Combine(s_projectDir, "newD1.cs"))),
1115loader: TextLoader.From(TextAndVersion.Create(SourceText.From("class NewD3;", Encoding.UTF8, SourceHashAlgorithms.Default), VersionStamp.Create(), filePath: Path.Combine(s_projectDir, "newD3.cs"))),
1125loader: TextLoader.From(TextAndVersion.Create(SourceText.From("new text1", Encoding.UTF32, SourceHashAlgorithm.Sha256), VersionStamp.Create(), filePath: Path.Combine(s_projectDir, "newD1.cs"))),
1134loader: TextLoader.From(TextAndVersion.Create(SourceText.From("new text3", Encoding.UTF8, SourceHashAlgorithms.Default), VersionStamp.Create(), filePath: Path.Combine(s_projectDir, "newD3.cs"))),
1144loader: TextLoader.From(TextAndVersion.Create(SourceText.From("#new empty1", Encoding.UTF32, SourceHashAlgorithm.Sha256), VersionStamp.Create(), filePath: Path.Combine(s_projectDir, "newD1.cs"))),
1153loader: TextLoader.From(TextAndVersion.Create(SourceText.From("#new empty3", Encoding.UTF8, SourceHashAlgorithms.Default), VersionStamp.Create(), filePath: Path.Combine(s_projectDir, "newD3.cs"))),
1315loader: TextLoader.From(TextAndVersion.Create(text, VersionStamp.Create(), filePath: docPath)),
1329var newSolution2 = newSolution.AddDocument(documentId2, "e", TextLoader.From(TextAndVersion.Create(text, VersionStamp.Create(), filePath: docPath)));
4611var unused = await loader.LoadTextAndVersionAsync(new LoadTextOptions(SourceHashAlgorithms.Default), CancellationToken.None);
4625var unused = loader.LoadTextAndVersionSynchronously(new LoadTextOptions(SourceHashAlgorithms.Default), CancellationToken.None);
4762loader: TextLoader.From(TextAndVersion.Create(SourceText.From("[*.*]\r\n\r\ndotnet_diagnostic.CA1234.severity = error"), VersionStamp.Default)))));
4795loader: TextLoader.From(TextAndVersion.Create(SourceText.From("[*.*]\r\n\r\ndotnet_diagnostic.CA1234.severity = error"), VersionStamp.Default)))));
4836loader: TextLoader.From(TextAndVersion.Create(SourceText.From("[*.*]\r\n\r\ndotnet_diagnostic.CA1234.severity = error"), VersionStamp.Default)))));
4848TextLoader.From(TextAndVersion.Create(SourceText.From("[*.*]\r\n\r\ndotnet_diagnostic.CA6789.severity = error"), VersionStamp.Default)),
4884loader: TextLoader.From(TextAndVersion.Create(SourceText.From("is_global = true\r\n\r\ndotnet_diagnostic.CA1234.severity = error"), VersionStamp.Default)))));
4930loader: TextLoader.From(TextAndVersion.Create(SourceText.From("[*.*]\r\n\r\ngenerated_code = true"), VersionStamp.Default)))));
5514var docInfo = DocumentInfo.Create(DocumentId.CreateNewId(pid), "c.cs", loader: TextLoader.From(TextAndVersion.Create(text, version)));
SolutionTests\TextLoaderTests.cs (26)
22public new virtual Task<TextAndVersion> LoadTextAndVersionAsync(Workspace? workspace, DocumentId? documentId, CancellationToken cancellationToken)
23=> Task.FromResult((TextAndVersion?)null!);
29public new virtual Task<TextAndVersion> LoadTextAndVersionAsync(Workspace? workspace, DocumentId? documentId, CancellationToken cancellationToken)
30=> Task.FromResult((TextAndVersion?)null!);
33public virtual Task<TextAndVersion> LoadTextAndVersionAsync(Workspace? workspace, DocumentId? documentId)
34=> Task.FromResult((TextAndVersion?)null!);
37public virtual Task<TextAndVersion> LoadTextAndVersionAsync(Workspace? workspace, ref DocumentId? documentId, CancellationToken cancellationToken)
38=> Task.FromResult((TextAndVersion?)null!);
41public virtual Task<TextAndVersion> LoadTextAndVersionAsync<T>(Workspace? workspace, DocumentId? documentId, CancellationToken cancellationToken)
42=> Task.FromResult((TextAndVersion?)null!);
47public override Task<TextAndVersion> LoadTextAndVersionAsync(Workspace? workspace, DocumentId? documentId, CancellationToken cancellationToken)
48=> Task.FromResult((TextAndVersion?)null!);
53public override Task<TextAndVersion> LoadTextAndVersionAsync(Workspace? workspace, DocumentId? documentId)
59public override Task<TextAndVersion> LoadTextAndVersionAsync(Workspace? workspace, ref DocumentId? documentId, CancellationToken cancellationToken)
60=> Task.FromResult((TextAndVersion?)null!);
65public override Task<TextAndVersion> LoadTextAndVersionAsync<T>(Workspace? workspace, DocumentId? documentId, CancellationToken cancellationToken)
66=> Task.FromResult((TextAndVersion?)null!);
82public static readonly TextAndVersion Value = TextAndVersion.Create(SourceText.From(""), VersionStamp.Default);
85public override Task<TextAndVersion> LoadTextAndVersionAsync(Workspace? workspace, DocumentId? documentId, CancellationToken cancellationToken)
91public static new readonly TextAndVersion Value = TextAndVersion.Create(SourceText.From(""), VersionStamp.Default);
94public override Task<TextAndVersion> LoadTextAndVersionAsync(Workspace? workspace, DocumentId? documentId, CancellationToken cancellationToken)
100public static readonly TextAndVersion Value = TextAndVersion.Create(SourceText.From(""), VersionStamp.Default);
102public override Task<TextAndVersion> LoadTextAndVersionAsync(LoadTextOptions options, CancellationToken cancellationToken)
WorkspaceTests\AdhocWorkspaceTests.cs (5)
155loader: TextLoader.From(TextAndVersion.Create(SourceText.From(""), VersionStamp.Create())));
215var docInfo = DocumentInfo.Create(DocumentId.CreateNewId(pid), "c.cs", loader: TextLoader.From(TextAndVersion.Create(text, version)));
249var docInfo = DocumentInfo.Create(DocumentId.CreateNewId(pid), "c.cs", loader: TextLoader.From(TextAndVersion.Create(text, version)));
287loader: TextLoader.From(TextAndVersion.Create(text, version, analyzerConfigDocFilePath)),
322var docInfo = DocumentInfo.Create(DocumentId.CreateNewId(pid), "c.cs", loader: TextLoader.From(TextAndVersion.Create(text, version)));
Microsoft.VisualStudio.LanguageServices (3)
Microsoft.VisualStudio.LanguageServices.LiveShare (2)
Roslyn.VisualStudio.Next.UnitTests (4)