Skip to content

Commit 1d30394

Browse files
authored
Fixed code coverage compatibility issue (#2527)
Fixed code coverage compatibility issue
1 parent c1b6b2c commit 1d30394

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

scripts/build/TestPlatform.Dependencies.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<!-- this version also needs to be "statically" readable because the test fixture will inspect this file for the version
1212
and because during the test `dotnet test` will run and re-build some of the test projects and at that time the version
1313
from a build parameter would not be available, so I am writing this version from the build.ps1 script to keep it in sync -->
14-
<NETTestSdkVersion>16.7.0-dev</NETTestSdkVersion>
14+
<NETTestSdkVersion>16.7.1-dev</NETTestSdkVersion>
1515

1616
<MSTestFrameworkVersion>2.1.0</MSTestFrameworkVersion>
1717
<MSTestAdapterVersion>2.1.0</MSTestAdapterVersion>

scripts/build/TestPlatform.Settings.targets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<!-- This version is read by vsts-prebuild.ps1 and is a base for the current version, this should be updated
66
at the start of new iteration to the goal number. This is also used to version the local packages. This version needs to be statically
77
readable when we read the file as xml, don't move it to a .props file, unless you change the build server process -->
8-
<TPVersionPrefix>16.7.0</TPVersionPrefix>
8+
<TPVersionPrefix>16.7.1</TPVersionPrefix>
99
</PropertyGroup>
1010
<PropertyGroup>
1111
<!-- Versioning is defined from the build script. Use a default dev build if it's not defined.

src/DataCollectors/TraceDataCollector/VanguardCollector/DynamicCoverageDataCollectorImpl.cs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,14 @@ public virtual void Initialize(
112112

113113
try
114114
{
115-
var processor = new CodeCoverageRunSettingsProcessor(defaultConfigurationElement);
116-
configurationElement = (XmlElement)processor.Process(configurationElement);
115+
// WARNING: Do NOT remove this function call !!!
116+
//
117+
// Due to a dependency we took on Microsoft.TestPlatform.Utilities.dll, an
118+
// exception may be thrown if we cannot resolve CodeCoverageRunSettingsProcessor.
119+
// If such an exception is thrown we cannot catch it in this try-catch block
120+
// because all method dependencies must be resolved before the method call, thus
121+
// we introduced an additional layer of indirection.
122+
configurationElement = this.AddDefaultExclusions(configurationElement, defaultConfigurationElement);
117123
}
118124
catch (Exception ex)
119125
{
@@ -326,5 +332,17 @@ private void CreateDirectory(DataCollectionContext context, string path)
326332
throw;
327333
}
328334
}
335+
336+
/// <summary>
337+
/// Adding default exclusions to the configuration element.
338+
/// </summary>
339+
/// <param name="configurationElement">The configuration element.</param>
340+
/// <param name="defaultConfigurationElement">The default configuration element.</param>
341+
/// <returns>The original configuration element with additional default exclusions.</returns>
342+
private XmlElement AddDefaultExclusions(XmlElement configurationElement, XmlElement defaultConfigurationElement)
343+
{
344+
var processor = new CodeCoverageRunSettingsProcessor(defaultConfigurationElement);
345+
return (XmlElement)processor.Process(configurationElement);
346+
}
329347
}
330348
}

0 commit comments

Comments
 (0)