Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move open/closed document checks under the _serializationLock #33435

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions src/Workspaces/Core/Portable/Workspace/Workspace_Editor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -372,11 +372,11 @@ protected internal void OnDocumentOpened(
DocumentId documentId, SourceTextContainer textContainer,
bool isCurrentContext = true)
{
CheckDocumentIsInCurrentSolution(documentId);
CheckDocumentIsClosed(documentId);

using (_serializationLock.DisposableWait())
{
CheckDocumentIsInCurrentSolution(documentId);
CheckDocumentIsClosed(documentId);

var oldSolution = this.CurrentSolution;
var oldDocument = oldSolution.GetDocument(documentId);
var oldDocumentState = oldDocument.State;
Expand Down Expand Up @@ -487,11 +487,11 @@ private void AddToOpenDocumentMap(DocumentId documentId)

protected internal void OnAdditionalDocumentOpened(DocumentId documentId, SourceTextContainer textContainer, bool isCurrentContext = true)
{
CheckAdditionalDocumentIsInCurrentSolution(documentId);
CheckDocumentIsClosed(documentId);

using (_serializationLock.DisposableWait())
{
CheckAdditionalDocumentIsInCurrentSolution(documentId);
CheckDocumentIsClosed(documentId);

var oldSolution = this.CurrentSolution;
var oldDocument = oldSolution.GetAdditionalDocument(documentId);
var oldText = oldDocument.GetTextSynchronously(CancellationToken.None);
Expand Down Expand Up @@ -527,11 +527,11 @@ protected internal void OnAdditionalDocumentOpened(DocumentId documentId, Source

protected internal void OnDocumentClosed(DocumentId documentId, TextLoader reloader, bool updateActiveContext = false)
{
this.CheckDocumentIsInCurrentSolution(documentId);
this.CheckDocumentIsOpen(documentId);

using (_serializationLock.DisposableWait())
{
this.CheckDocumentIsInCurrentSolution(documentId);
this.CheckDocumentIsOpen(documentId);

// forget any open document info
ClearOpenDocument(documentId);

Expand All @@ -553,10 +553,11 @@ protected internal void OnDocumentClosed(DocumentId documentId, TextLoader reloa

protected internal void OnAdditionalDocumentClosed(DocumentId documentId, TextLoader reloader)
{
this.CheckAdditionalDocumentIsInCurrentSolution(documentId);

using (_serializationLock.DisposableWait())
{
this.CheckAdditionalDocumentIsInCurrentSolution(documentId);
this.CheckDocumentIsOpen(documentId);

// forget any open document info
ClearOpenDocument(documentId);

Expand Down