Skip to content

Commit 28aa07f

Browse files
committed
Adding diagnostic logs
1 parent faa5b92 commit 28aa07f

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

src/coverlet.collector/InProcDataCollection/CoverletInProcDataCollector.cs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
using System;
22
using System.Reflection;
3+
using Coverlet.Collector.Utilities;
34
using Coverlet.Core.Instrumentation;
5+
using Microsoft.VisualStudio.TestPlatform.ObjectModel;
46
using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection;
57
using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollector.InProcDataCollector;
68
using Microsoft.VisualStudio.TestPlatform.ObjectModel.InProcDataCollector;
79

8-
namespace Coverlet.Collector.InProcDataCollector
10+
namespace Coverlet.Collector.DataCollection
911
{
1012
public class CoverletInProcDataCollector : InProcDataCollection
1113
{
@@ -37,9 +39,13 @@ public void TestSessionEnd(TestSessionEndArgs testSessionEndArgs)
3739
{
3840
unloadModule.Invoke(null, new[] { null, EventArgs.Empty });
3941
}
40-
catch
42+
catch(Exception ex)
4143
{
4244
// Ignore exceptions and continue with the unload
45+
if (EqtTrace.IsWarningEnabled)
46+
{
47+
EqtTrace.Warning("{0}: Failed to unload module with error: {1}", CoverletConstants.InProcDataCollectorName, ex);
48+
}
4349
}
4450
}
4551
}
@@ -63,9 +69,13 @@ private static Type GetInstrumentationClass(Assembly assembly)
6369

6470
return null;
6571
}
66-
catch
72+
catch(Exception ex)
6773
{
6874
// Avoid crashing if reflection fails.
75+
if (EqtTrace.IsWarningEnabled)
76+
{
77+
EqtTrace.Warning("{0}: Failed to get Instrumentation class with error: {1}", CoverletConstants.InProcDataCollectorName, ex);
78+
}
6979
return null;
7080
}
7181
}

src/coverlet.collector/Utilities/CoverletConstants.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,6 @@ internal static class CoverletConstants
1919
public const string TestSourcesPropertyName = "TestSources";
2020
public const string ReportFormatElementName = "Format";
2121
public const string DefaultExcludeFilter = "[coverlet.*]*";
22+
public const string InProcDataCollectorName = "CoverletInProcDataCollector";
2223
}
2324
}

0 commit comments

Comments
 (0)