Capture file content on open instead of save (#54643) #54667
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Port #54643 to Preview 2
EnC analyzer needs to compare the original content of a source file, which the compiler used to emit the baseline dll, with the current snapshot.
To ensure the original content is compared, the EnC analyzer compares the checksum of the document with the checksum stored in PDB. If they don't match the document is "out of sync" and analysis can't be performed until the analyzer gets ahold of the original content.
The solution snapshot captured at the start of debugging or Hot Reload session doesn't necessarily reflect the original content since workspace is updated based on file watcher events and updates in editor buffers.
Previously we attempted to capture the original file content when an editor buffer is saved (looking at the content on disk before the save). However the current implementation is just best effort (race condition) and the editor currently does not provide APIs that would give us a chance to asynchronously read the content of the file before the save operation without blocking UI.
Instead, we check the checksum of the content of a source file on disk when the file is opened.
Fixes https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1348122