未验证 提交 490904b1 编写于 作者: T Tomáš Matoušek 提交者: GitHub

EnC: Compare document content before performing IO while stepping (#39341)

* EnC: Compare document content before performing IO while stepping

* Feedback
上级 acfc61d0
......@@ -314,7 +314,7 @@ internal async Task<ImmutableArray<ActiveStatementExceptionRegions>> GetBaseActi
var outOfSyncDiagnostics = ArrayBuilder<Diagnostic>.GetInstance();
var changes = project.GetChanges(baseProject);
foreach (var documentId in changes.GetChangedDocuments())
foreach (var documentId in changes.GetChangedDocuments(onlyGetDocumentsWithTextChanges: true))
{
var document = project.GetDocument(documentId)!;
if (EditAndContinueWorkspaceService.IsDesignTimeOnlyDocument(document))
......@@ -322,6 +322,22 @@ internal async Task<ImmutableArray<ActiveStatementExceptionRegions>> GetBaseActi
continue;
}
// Check if the currently observed document content has changed compared to the base document content.
// This is an important optimization that aims to avoid IO while stepping in sources that have not changed.
//
// We may be comparing out-of-date committed document content but we only make a decision based on that content
// if it matches the current content. If the current content is equal to baseline content that does not match
// the debuggee then the workspace has not observed the change made to the file on disk since baseline was captured
// (there had to be one as the content doesn't match). When we are about to apply changes it is ok to ignore this
// document because the user does not see the change yet in the buffer (if the doc is open) and won't be confused
// if it is not applied yet. The change will be applied later after it's observed by the workspace.
var baseSource = await baseProject.GetDocument(documentId)!.GetTextAsync(cancellationToken).ConfigureAwait(false);
var source = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
if (baseSource.ContentEquals(source))
{
continue;
}
var (oldDocument, oldDocumentState) = await DebuggingSession.LastCommittedSolution.GetDocumentAndStateAsync(documentId, cancellationToken, reloadOutOfSyncDocument: true).ConfigureAwait(false);
switch (oldDocumentState)
{
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册