Skip to content

Commit

Permalink
Merge pull request #14 from wlmiller/master
Browse files Browse the repository at this point in the history
Fix errors when using multiple referenced libraries.
  • Loading branch information
tonerdo committed Mar 24, 2018
2 parents 82096ee + 75a567a commit f442e6a
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions src/coverlet.core/CoverageTracker.cs
Expand Up @@ -7,27 +7,37 @@ namespace Coverlet.Core
{
public static class CoverageTracker
{
private static List<string> _markers;
private static string _path;
private static Dictionary<string, List<string>> _markers;
private static bool _registered;

[ExcludeFromCoverage]
public static void MarkExecuted(string path, string marker)
{
if (_markers == null)
_markers = new List<string>();
{
_markers = new Dictionary<string, List<string>>();
}

if (!_markers.ContainsKey(path))
{
_markers.Add(path, new List<string>());
}

if (!_registered)
{
AppDomain.CurrentDomain.ProcessExit += new EventHandler(CurrentDomain_ProcessExit);
_registered = true;
}

_markers.Add(marker);
_path = path;
_markers[path].Add(marker);
}

public static void CurrentDomain_ProcessExit(object sender, EventArgs e)
=> File.WriteAllLines(_path, _markers);
{
foreach (var kvp in _markers)
{
File.WriteAllLines(kvp.Key, kvp.Value);
}
}
}
}

0 comments on commit f442e6a

Please sign in to comment.