зеркало из https://github.com/dotnet/razor.git
Don't expose DocumentSnapshot.State
This commit is contained in:
Родитель
ca3f42bcfa
Коммит
d1d3d48ced
|
@ -270,7 +270,7 @@ internal partial class RazorProjectService : IRazorProjectService, IRazorProject
|
|||
{
|
||||
_logger.LogInformation($"Removing document '{textDocumentPath}' from project '{projectSnapshot.Key}'.");
|
||||
|
||||
updater.DocumentRemoved(projectSnapshot.Key, documentSnapshot.State.HostDocument);
|
||||
updater.DocumentRemoved(projectSnapshot.Key, documentSnapshot.HostDocument);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
@ -445,7 +445,7 @@ internal partial class RazorProjectService : IRazorProjectService, IRazorProject
|
|||
continue;
|
||||
}
|
||||
|
||||
var currentHostDocument = documentSnapshot.State.HostDocument;
|
||||
var currentHostDocument = documentSnapshot.HostDocument;
|
||||
var newFilePath = EnsureFullPath(documentHandle.FilePath, projectDirectory);
|
||||
var newHostDocument = new HostDocument(newFilePath, documentHandle.TargetPath, documentHandle.FileKind);
|
||||
|
||||
|
@ -512,7 +512,7 @@ internal partial class RazorProjectService : IRazorProjectService, IRazorProject
|
|||
return;
|
||||
}
|
||||
|
||||
var currentHostDocument = documentSnapshot.State.HostDocument;
|
||||
var currentHostDocument = documentSnapshot.HostDocument;
|
||||
|
||||
var textLoader = new DocumentSnapshotTextLoader(documentSnapshot);
|
||||
|
||||
|
|
|
@ -13,42 +13,43 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem;
|
|||
|
||||
internal sealed class DocumentSnapshot : IDocumentSnapshot
|
||||
{
|
||||
public string FileKind => State.HostDocument.FileKind;
|
||||
public string FilePath => State.HostDocument.FilePath;
|
||||
public string TargetPath => State.HostDocument.TargetPath;
|
||||
private readonly DocumentState _state;
|
||||
|
||||
public string FileKind => _state.HostDocument.FileKind;
|
||||
public string FilePath => _state.HostDocument.FilePath;
|
||||
public string TargetPath => _state.HostDocument.TargetPath;
|
||||
public IProjectSnapshot Project => ProjectInternal;
|
||||
|
||||
public int Version => State.Version;
|
||||
public int Version => _state.Version;
|
||||
|
||||
public ProjectSnapshot ProjectInternal { get; }
|
||||
public DocumentState State { get; }
|
||||
|
||||
public DocumentSnapshot(ProjectSnapshot project, DocumentState state)
|
||||
{
|
||||
ProjectInternal = project ?? throw new ArgumentNullException(nameof(project));
|
||||
State = state ?? throw new ArgumentNullException(nameof(state));
|
||||
_state = state ?? throw new ArgumentNullException(nameof(state));
|
||||
}
|
||||
|
||||
public HostDocument HostDocument => State.HostDocument;
|
||||
public HostDocument HostDocument => _state.HostDocument;
|
||||
|
||||
public Task<SourceText> GetTextAsync()
|
||||
=> State.GetTextAsync();
|
||||
=> _state.GetTextAsync();
|
||||
|
||||
public Task<VersionStamp> GetTextVersionAsync()
|
||||
=> State.GetTextVersionAsync();
|
||||
=> _state.GetTextVersionAsync();
|
||||
|
||||
public bool TryGetText([NotNullWhen(true)] out SourceText? result)
|
||||
=> State.TryGetText(out result);
|
||||
=> _state.TryGetText(out result);
|
||||
|
||||
public bool TryGetTextVersion(out VersionStamp result)
|
||||
=> State.TryGetTextVersion(out result);
|
||||
=> _state.TryGetTextVersion(out result);
|
||||
|
||||
public bool TryGetGeneratedOutput([NotNullWhen(true)] out RazorCodeDocument? result)
|
||||
{
|
||||
if (State.IsGeneratedOutputResultAvailable)
|
||||
if (_state.IsGeneratedOutputResultAvailable)
|
||||
{
|
||||
#pragma warning disable VSTHRD002 // Avoid problematic synchronous waits
|
||||
result = State.GetGeneratedOutputAndVersionAsync(ProjectInternal, this).Result.output;
|
||||
result = _state.GetGeneratedOutputAndVersionAsync(ProjectInternal, this).Result.output;
|
||||
#pragma warning restore VSTHRD002 // Avoid problematic synchronous waits
|
||||
return true;
|
||||
}
|
||||
|
@ -59,7 +60,7 @@ internal sealed class DocumentSnapshot : IDocumentSnapshot
|
|||
|
||||
public IDocumentSnapshot WithText(SourceText text)
|
||||
{
|
||||
return new DocumentSnapshot(ProjectInternal, State.WithText(text, VersionStamp.Create()));
|
||||
return new DocumentSnapshot(ProjectInternal, _state.WithText(text, VersionStamp.Create()));
|
||||
}
|
||||
|
||||
public async Task<SyntaxTree> GetCSharpSyntaxTreeAsync(CancellationToken cancellationToken)
|
||||
|
@ -76,7 +77,7 @@ internal sealed class DocumentSnapshot : IDocumentSnapshot
|
|||
return await GetDesignTimeGeneratedOutputAsync().ConfigureAwait(false);
|
||||
}
|
||||
|
||||
var (output, _) = await State.GetGeneratedOutputAndVersionAsync(ProjectInternal, this).ConfigureAwait(false);
|
||||
var (output, _) = await _state.GetGeneratedOutputAndVersionAsync(ProjectInternal, this).ConfigureAwait(false);
|
||||
return output;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче