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

Fix errors when using multiple referenced libraries. #14

Merged
merged 2 commits into from Mar 24, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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);
}
}
}
}