Skip to content

Commit

Permalink
Fix race condition in test
Browse files Browse the repository at this point in the history
  • Loading branch information
tmat committed Nov 14, 2024
1 parent 5a52e85 commit 4e801ee
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ public abstract class EditAndContinueWorkspaceTestBase : TestBase, IDisposable
/// <summary>
/// Streams that are verified to be disposed at the end of the debug session (by default).
/// </summary>
public List<(Guid mvid, Stream stream)> DisposalVerifiedStreams = [];
private ImmutableList<Stream> _disposalVerifiedStreams = [];

public override void Dispose()
{
base.Dispose();

foreach (var (_, stream) in DisposalVerifiedStreams)
foreach (var stream in _disposalVerifiedStreams)
{
Assert.False(stream.CanRead);
}
Expand Down Expand Up @@ -314,15 +314,15 @@ 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;
},
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;
Expand Down

0 comments on commit 4e801ee

Please sign in to comment.