diff --git a/src/Features/TestUtilities/EditAndContinue/EditAndContinueWorkspaceTestBase.cs b/src/Features/TestUtilities/EditAndContinue/EditAndContinueWorkspaceTestBase.cs index fc40635903865..eb6e9ac492dc2 100644 --- a/src/Features/TestUtilities/EditAndContinue/EditAndContinueWorkspaceTestBase.cs +++ b/src/Features/TestUtilities/EditAndContinue/EditAndContinueWorkspaceTestBase.cs @@ -54,13 +54,13 @@ public abstract class EditAndContinueWorkspaceTestBase : TestBase, IDisposable /// /// Streams that are verified to be disposed at the end of the debug session (by default). /// - public List<(Guid mvid, Stream stream)> DisposalVerifiedStreams = []; + private ImmutableList _disposalVerifiedStreams = []; public override void Dispose() { base.Dispose(); - foreach (var (_, stream) in DisposalVerifiedStreams) + foreach (var stream in _disposalVerifiedStreams) { Assert.False(stream.CanRead); } @@ -314,7 +314,7 @@ internal Guid EmitLibrary(Compilation compilation, DebugInformationFormat pdbFor OpenAssemblyStreamImpl = () => { var stream = new MemoryStream(); - DisposalVerifiedStreams.Add((moduleId, stream)); + ImmutableInterlocked.Update(ref _disposalVerifiedStreams, s => s.Add(stream)); peImage.WriteToStream(stream); stream.Position = 0; return stream; @@ -322,7 +322,7 @@ internal Guid EmitLibrary(Compilation compilation, DebugInformationFormat pdbFor OpenPdbStreamImpl = () => { var stream = new MemoryStream(); - DisposalVerifiedStreams.Add((moduleId, stream)); + ImmutableInterlocked.Update(ref _disposalVerifiedStreams, s => s.Add(stream)); pdbImage.WriteToStream(stream); stream.Position = 0; return stream;