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

Do not throw ObjectDisposedException in OnWorkspaceUpdateAsync #8892

Closed
Closed
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,11 @@ public void ChainDisposal(IDisposable disposable)
/// <returns>A task that completes when the update has been integrated.</returns>
internal async Task OnWorkspaceUpdateAsync(IProjectVersionedValue<WorkspaceUpdate> update)
{
Verify.NotDisposed(this);

if (IsDisposed || IsDisposing)
{
return;
}

await InitializeAsync(_unloadCancellationToken);

Assumes.True(_state is WorkspaceState.Uninitialized or WorkspaceState.Initialized);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,21 @@ public async Task Dispose_TriggersObjectDisposedExceptionsOnPublicMembers()

await Assert.ThrowsAsync<ObjectDisposedException>(() => workspace.WriteAsync(w => Task.CompletedTask, CancellationToken.None));
await Assert.ThrowsAsync<ObjectDisposedException>(() => workspace.WriteAsync(w => TaskResult.EmptyString, CancellationToken.None));
await Assert.ThrowsAsync<ObjectDisposedException>(() => workspace.OnWorkspaceUpdateAsync(null!));
//await Assert.ThrowsAsync<ObjectDisposedException>(() => workspace.OnWorkspaceUpdateAsync(null!));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Is this commented code intended to remain since this solution may not be a complete fix?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, no; I meant to delete that.


Assert.Throws<ObjectDisposedException>(() => workspace.ChainDisposal(null!));
}

[Fact]
public async Task Dispose_DoesNotTriggerObjectDisposedExceptionsOnUpdate()
{
var workspace = await CreateInstanceAsync();

await workspace.DisposeAsync();

await workspace.OnWorkspaceUpdateAsync(null!);
}

[Theory]
[CombinatorialData]
public async Task WriteAsync_ThrowsIfNullAction(bool isGeneric)
Expand Down