2 instantiations of TextAndVersion
Microsoft.CodeAnalysis.Workspaces (2)
Workspace\Solution\TextAndVersion.cs (2)
54
=>
new
(text ?? throw new ArgumentNullException(nameof(text)), version, filePath, exceptionMessage: null);
62
=>
new
(text, version, filePath, exceptionMessage);
141 references to TextAndVersion
Microsoft.CodeAnalysis.Features (3)
EditAndContinue\CommittedSolution.cs (1)
291
loader: TextLoader.From(
TextAndVersion
.Create(sourceText, sourceTextVersion, document.Name)),
PdbSourceDocument\PdbSourceDocumentLoaderService.cs (2)
196
var
textAndVersion =
TextAndVersion
.Create(sourceText, VersionStamp.Default, filePath);
Microsoft.CodeAnalysis.Workspaces (138)
Serialization\SerializableSourceText.cs (4)
234
public override async Task<
TextAndVersion
> LoadTextAndVersionAsync(LoadTextOptions options, CancellationToken cancellationToken)
235
=>
TextAndVersion
.Create(await this.SerializableSourceText.GetTextAsync(cancellationToken).ConfigureAwait(false), _version);
237
internal override
TextAndVersion
LoadTextAndVersionSynchronously(LoadTextOptions options, CancellationToken cancellationToken)
238
=>
TextAndVersion
.Create(this.SerializableSourceText.GetText(cancellationToken), _version);
Workspace\AdhocWorkspace.cs (4)
126
var loader = TextLoader.From(
TextAndVersion
.Create(text, VersionStamp.Create()));
169
var loader = TextLoader.From(
TextAndVersion
.Create(text, version, doc.FilePath));
197
var loader = TextLoader.From(
TextAndVersion
.Create(text, version, doc.FilePath));
225
var loader = TextLoader.From(
TextAndVersion
.Create(text, version, doc.FilePath));
Workspace\ProjectSystem\ProjectSystemProject.BatchingDocumentCollection.cs (2)
499
public override async Task<
TextAndVersion
> LoadTextAndVersionAsync(LoadTextOptions options, CancellationToken cancellationToken)
500
=>
TextAndVersion
.Create(_textContainer.CurrentText, VersionStamp.Create(), _filePath);
Workspace\Solution\AdditionalDocumentState.cs (1)
56
public new AdditionalDocumentState UpdateText(
TextAndVersion
newTextAndVersion, PreservationMode mode)
Workspace\Solution\AnalyzerConfigDocumentState.cs (1)
66
public new AnalyzerConfigDocumentState UpdateText(
TextAndVersion
newTextAndVersion, PreservationMode mode)
Workspace\Solution\ConstantTextAndVersionSource.cs (5)
14
internal sealed class ConstantTextAndVersionSource(
TextAndVersion
value) : ITextAndVersionSource
16
private readonly
TextAndVersion
_value = value;
27
public
TextAndVersion
GetValue(LoadTextOptions options, CancellationToken cancellationToken)
30
public async Task<
TextAndVersion
> GetValueAsync(LoadTextOptions options, CancellationToken cancellationToken)
33
public bool TryGetValue(LoadTextOptions options, [MaybeNullWhen(false)] out
TextAndVersion
value)
Workspace\Solution\DocumentState.cs (8)
138
var
textAndVersion = await newTextSource.GetValueAsync(loadTextOptions, cancellationToken).ConfigureAwait(false);
154
var
textAndVersion = newTextSource.GetValue(loadTextOptions, cancellationToken);
163
TextAndVersion
textAndVersion,
200
var
newTextAndVersion = await newTextSource.GetValueAsync(loadTextOptions, cancellationToken).ConfigureAwait(false);
222
var
newTextAndVersion = newTextSource.GetValue(loadTextOptions, cancellationToken);
235
TextAndVersion
newTextAndVersion,
447
public new DocumentState UpdateText(
TextAndVersion
newTextAndVersion, PreservationMode mode)
571
if (TextAndVersionSource.TryGetValue(LoadTextOptions, out
var
textAndVersion))
Workspace\Solution\DocumentState_TreeTextSource.cs (7)
14
/// A source for <see cref="
TextAndVersion
"/> constructed from an syntax tree.
29
public async Task<
TextAndVersion
> GetValueAsync(LoadTextOptions options, CancellationToken cancellationToken)
32
return
TextAndVersion
.Create(text, _version);
35
public
TextAndVersion
GetValue(LoadTextOptions options, CancellationToken cancellationToken)
38
return
TextAndVersion
.Create(text, _version);
41
public bool TryGetValue(LoadTextOptions options, [NotNullWhen(true)] out
TextAndVersion
? value)
45
value =
TextAndVersion
.Create(text, _version);
Workspace\Solution\FileTextLoader.cs (9)
90
public override Task<
TextAndVersion
> LoadTextAndVersionAsync(Workspace? workspace, DocumentId? documentId, CancellationToken cancellationToken)
101
public override async Task<
TextAndVersion
> LoadTextAndVersionAsync(LoadTextOptions options, CancellationToken cancellationToken)
174
var
textAndVersion = await FileUtilities.RethrowExceptionsAsIOExceptionAsync(
184
return
TextAndVersion
.Create(text, version, t.self.Path);
195
internal override
TextAndVersion
LoadTextAndVersionSynchronously(LoadTextOptions options, CancellationToken cancellationToken)
201
var
textAndVersion = FileUtilities.RethrowExceptionsAsIOException(
208
return
TextAndVersion
.Create(text, version, t.self.Path);
214
private
TextAndVersion
CheckForConcurrentFileWrites(DateTime prevLastWriteTime,
TextAndVersion
textAndVersion)
Workspace\Solution\Solution.cs (5)
1040
loader: TextLoader.From(
TextAndVersion
.Create(text, VersionStamp.Create(), name)),
1154
var loader = TextLoader.From(
TextAndVersion
.Create(text, version, name));
1353
public Solution WithDocumentText(DocumentId documentId,
TextAndVersion
textAndVersion, PreservationMode mode = PreservationMode.PreserveValue)
1374
public Solution WithAdditionalDocumentText(DocumentId documentId,
TextAndVersion
textAndVersion, PreservationMode mode = PreservationMode.PreserveValue)
1395
public Solution WithAnalyzerConfigDocumentText(DocumentId documentId,
TextAndVersion
textAndVersion, PreservationMode mode = PreservationMode.PreserveValue)
Workspace\Solution\SolutionCompilationState.cs (6)
981
/// <inheritdoc cref="SolutionState.WithDocumentText(DocumentId,
TextAndVersion
, PreservationMode)"/>
983
DocumentId documentId,
TextAndVersion
textAndVersion, PreservationMode mode)
989
/// <inheritdoc cref="SolutionState.WithAdditionalDocumentText(DocumentId,
TextAndVersion
, PreservationMode)"/>
991
DocumentId documentId,
TextAndVersion
textAndVersion, PreservationMode mode)
997
/// <inheritdoc cref="SolutionState.WithAnalyzerConfigDocumentText(DocumentId,
TextAndVersion
, PreservationMode)"/>
999
DocumentId documentId,
TextAndVersion
textAndVersion, PreservationMode mode)
Workspace\Solution\SolutionState.cs (6)
1051
public StateChange WithDocumentText(DocumentId documentId,
TextAndVersion
textAndVersion, PreservationMode mode = PreservationMode.PreserveValue)
1054
if (oldDocument.TryGetTextAndVersion(out
var
oldTextAndVersion) && textAndVersion == oldTextAndVersion)
1067
public StateChange WithAdditionalDocumentText(DocumentId documentId,
TextAndVersion
textAndVersion, PreservationMode mode = PreservationMode.PreserveValue)
1070
if (oldDocument.TryGetTextAndVersion(out
var
oldTextAndVersion) && textAndVersion == oldTextAndVersion)
1083
public StateChange WithAnalyzerConfigDocumentText(DocumentId documentId,
TextAndVersion
textAndVersion, PreservationMode mode = PreservationMode.PreserveValue)
1086
if (oldDocument.TryGetTextAndVersion(out
var
oldTextAndVersion) && textAndVersion == oldTextAndVersion)
Workspace\Solution\SourceGeneratedDocumentState.cs (4)
91
var
textAndVersion =
TextAndVersion
.Create(generatedSourceText, VersionStamp.Create());
242
var
textAndVersion =
TextAndVersion
.Create(sourceText, VersionStamp.Create());
Workspace\Solution\TextAndVersion.cs (4)
48
/// Create a new <see cref="
TextAndVersion
"/> instance.
53
public static
TextAndVersion
Create(SourceText text, VersionStamp version, string? filePath = null)
57
/// Create a new <see cref="
TextAndVersion
"/> instance.
61
internal static
TextAndVersion
Create(SourceText text, VersionStamp version, string? filePath, string? exceptionMessage)
Workspace\Solution\TextDocumentState.cs (16)
71
private static ConstantTextAndVersionSource CreateStrongText(
TextAndVersion
text)
74
private static RecoverableTextAndVersion CreateRecoverableText(
TextAndVersion
text, SolutionServices services)
82
if (this.TextAndVersionSource.TryGetValue(LoadTextOptions, out
var
textAndVersion))
97
public bool TryGetTextAndVersion([NotNullWhen(true)] out
TextAndVersion
? textAndVersion)
105
var
textAndVersion = await GetTextAndVersionAsync(cancellationToken).ConfigureAwait(false);
111
var
textAndVersion = this.TextAndVersionSource.GetValue(LoadTextOptions, cancellationToken);
117
var
textAndVersion = this.TextAndVersionSource.GetValue(LoadTextOptions, cancellationToken);
129
var
textAndVersion = await GetTextAndVersionAsync(cancellationToken).ConfigureAwait(false);
133
public TextDocumentState UpdateText(
TextAndVersion
newTextAndVersion, PreservationMode mode)
143
var
newTextAndVersion =
TextAndVersion
.Create(newText, newVersion, FilePath);
159
: CreateStrongText(
TextAndVersion
.Create(SourceText.From(string.Empty, encoding: null, loadTextOptions.ChecksumAlgorithm), VersionStamp.Default, filePath));
181
private async ValueTask<
TextAndVersion
> GetTextAndVersionAsync(CancellationToken cancellationToken)
183
if (this.TextAndVersionSource.TryGetValue(LoadTextOptions, out
var
textAndVersion))
198
var
textAndVersion = await GetTextAndVersionAsync(cancellationToken).ConfigureAwait(false);
204
if (this.TextAndVersionSource.TryGetValue(LoadTextOptions, out
var
textAndVersion))
Workspace\Solution\TextLoader.cs (16)
60
public 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)
83
public virtual Task<
TextAndVersion
> LoadTextAndVersionAsync(Workspace? workspace, DocumentId? documentId, CancellationToken cancellationToken)
92
internal virtual
TextAndVersion
LoadTextAndVersionSynchronously(LoadTextOptions options, CancellationToken cancellationToken)
98
internal async Task<
TextAndVersion
> LoadTextAsync(LoadTextOptions options, CancellationToken cancellationToken)
127
internal
TextAndVersion
LoadTextSynchronously(LoadTextOptions options, CancellationToken cancellationToken)
158
private
TextAndVersion
CreateFailedText(string message)
160
return
TextAndVersion
.Create(
170
public static TextLoader From(
TextAndVersion
textAndVersion)
198
private readonly
TextAndVersion
_textAndVersion;
200
internal TextDocumentLoader(
TextAndVersion
textAndVersion)
203
public override async Task<
TextAndVersion
> LoadTextAndVersionAsync(LoadTextOptions options, CancellationToken cancellationToken)
206
internal override
TextAndVersion
LoadTextAndVersionSynchronously(LoadTextOptions options, CancellationToken cancellationToken)
226
public override async Task<
TextAndVersion
> LoadTextAndVersionAsync(LoadTextOptions options, CancellationToken cancellationToken)
229
internal override
TextAndVersion
LoadTextAndVersionSynchronously(LoadTextOptions options, CancellationToken cancellationToken)
230
=>
TextAndVersion
.Create(_container.CurrentText, _version, _filePath);
Workspace\Solution\VersionSource\ITextAndVersionSource.cs (3)
25
bool TryGetValue(LoadTextOptions options, [MaybeNullWhen(false)] out
TextAndVersion
value);
26
TextAndVersion
GetValue(LoadTextOptions options, CancellationToken cancellationToken);
27
Task<
TextAndVersion
> GetValueAsync(LoadTextOptions options, CancellationToken cancellationToken);
Workspace\Solution\VersionSource\LoadableTextAndVersionSource.cs (16)
28
private
TextAndVersion
? _instance;
35
private WeakReference<
TextAndVersion
>? _weakInstance;
37
private Task<
TextAndVersion
> LoadAsync(CancellationToken cancellationToken)
40
private
TextAndVersion
LoadSynchronously(CancellationToken cancellationToken)
43
public bool TryGetValue([MaybeNullWhen(false)] out
TextAndVersion
value)
52
public
TextAndVersion
GetValue(CancellationToken cancellationToken)
54
if (!TryGetValue(out
var
textAndVersion))
69
public async Task<
TextAndVersion
> GetValueAsync(CancellationToken cancellationToken)
71
if (!TryGetValue(out
var
textAndVersion))
86
private void UpdateWeakAndStrongReferences_NoLock(
TextAndVersion
textAndVersion)
99
_weakInstance ??= new WeakReference<
TextAndVersion
>(textAndVersion);
126
public
TextAndVersion
GetValue(LoadTextOptions options, CancellationToken cancellationToken)
129
public bool TryGetValue(LoadTextOptions options, [MaybeNullWhen(false)] out
TextAndVersion
value)
132
public Task<
TextAndVersion
> GetValueAsync(LoadTextOptions options, CancellationToken cancellationToken)
137
if (!TryGetValue(options, out
var
value))
149
var
value = await GetValueAsync(options, cancellationToken).ConfigureAwait(false);
Workspace\Solution\VersionSource\RecoverableTextAndVersion.cs (9)
54
public bool TryGetValue(LoadTextOptions options, [MaybeNullWhen(false)] out
TextAndVersion
value)
61
value =
TextAndVersion
.Create(text, recoverableText.Version, filePath: null, recoverableText.ExceptionMessage);
90
var
textAndVersion = useAsync
105
var
textAndVersion = useAsync
116
public
TextAndVersion
GetValue(LoadTextOptions options, CancellationToken cancellationToken)
126
public async Task<
TextAndVersion
> GetValueAsync(LoadTextOptions options, CancellationToken cancellationToken)
148
public RecoverableText(ITextAndVersionSource source,
TextAndVersion
textAndVersion, LoadTextOptions options, SolutionServices services)
166
public
TextAndVersion
ToTextAndVersion(SourceText text)
167
=>
TextAndVersion
.Create(text, Version, filePath: null, ExceptionMessage);
Workspace\Workspace.cs (5)
2038
=> CreateDocumentInfoWithoutText(doc).WithTextLoader(TextLoader.From(
TextAndVersion
.Create(doc.GetTextSynchronously(CancellationToken.None), VersionStamp.Create(), doc.FilePath)));
2205
this.OnDocumentAdded(info.WithTextLoader(TextLoader.From(
TextAndVersion
.Create(text, VersionStamp.Create()))));
2249
this.OnAdditionalDocumentAdded(info.WithTextLoader(TextLoader.From(
TextAndVersion
.Create(text, VersionStamp.Create()))));
2282
this.OnAnalyzerConfigDocumentAdded(info.WithTextLoader(TextLoader.From(
TextAndVersion
.Create(text, VersionStamp.Create()))));
2304
this.OnAnalyzerConfigDocumentTextLoaderChanged(id, TextLoader.From(
TextAndVersion
.Create(text, VersionStamp.Create())));
Workspace\Workspace_Editor.cs (7)
401
var
newTextAndVersion = GetProperTextAndVersion(oldText, newText, version, oldDocumentState.FilePath);
486
private static
TextAndVersion
GetProperTextAndVersion(SourceText oldText, SourceText newText, VersionStamp version, string? filePath)
491
?
TextAndVersion
.Create(newText, version, filePath)
492
:
TextAndVersion
.Create(newText, version.GetNewerVersion(), filePath);
557
Func<Solution, DocumentId,
TextAndVersion
, PreservationMode, Solution> withDocumentTextAndVersion,
597
var
newTextAndVersion =
TextAndVersion
.Create(newText, version, oldDocument.FilePath);