Skip to content
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
18 changes: 12 additions & 6 deletions src/coverlet.core/CoverageTracker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ static CoverageTracker()
_markers = new Dictionary<string, List<string>>();
_markerFileCount = new Dictionary<string, int>();
AppDomain.CurrentDomain.ProcessExit += new EventHandler(CurrentDomain_ProcessExit);
AppDomain.CurrentDomain.DomainUnload += new EventHandler(CurrentDomain_ProcessExit);
}

[ExcludeFromCoverage]
Expand Down Expand Up @@ -48,17 +49,22 @@ public static void MarkExecuted(string path, string marker)
[ExcludeFromCoverage]
public static void CurrentDomain_ProcessExit(object sender, EventArgs e)
{
foreach (var kvp in _markers)
lock (_markers)
{
using (var fs = new FileStream($"{kvp.Key}_compressed_{_markerFileCount[kvp.Key]}", FileMode.OpenOrCreate))
using (var gz = new GZipStream(fs, CompressionMode.Compress))
using (var sw = new StreamWriter(gz))
foreach (var kvp in _markers)
{
foreach(var line in kvp.Value)
using (var fs = new FileStream($"{kvp.Key}_compressed_{_markerFileCount[kvp.Key]}", FileMode.OpenOrCreate))
using (var gz = new GZipStream(fs, CompressionMode.Compress))
using (var sw = new StreamWriter(gz))
{
sw.WriteLine(line);
foreach(var line in kvp.Value)
{
sw.WriteLine(line);
}
}
}

_markers.Clear();
}
}
}
Expand Down