Skip to content

Commit

Permalink
Fixed code coverage compatibility issue (#2527)
Browse files Browse the repository at this point in the history
Fixed code coverage compatibility issue
  • Loading branch information
cvpoienaru committed Aug 19, 2020
1 parent c1b6b2c commit 1d30394
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
2 changes: 1 addition & 1 deletion scripts/build/TestPlatform.Dependencies.props
Expand Up @@ -11,7 +11,7 @@
<!-- this version also needs to be "statically" readable because the test fixture will inspect this file for the version
and because during the test `dotnet test` will run and re-build some of the test projects and at that time the version
from a build parameter would not be available, so I am writing this version from the build.ps1 script to keep it in sync -->
<NETTestSdkVersion>16.7.0-dev</NETTestSdkVersion>
<NETTestSdkVersion>16.7.1-dev</NETTestSdkVersion>

<MSTestFrameworkVersion>2.1.0</MSTestFrameworkVersion>
<MSTestAdapterVersion>2.1.0</MSTestAdapterVersion>
Expand Down
2 changes: 1 addition & 1 deletion scripts/build/TestPlatform.Settings.targets
Expand Up @@ -5,7 +5,7 @@
<!-- This version is read by vsts-prebuild.ps1 and is a base for the current version, this should be updated
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
readable when we read the file as xml, don't move it to a .props file, unless you change the build server process -->
<TPVersionPrefix>16.7.0</TPVersionPrefix>
<TPVersionPrefix>16.7.1</TPVersionPrefix>
</PropertyGroup>
<PropertyGroup>
<!-- Versioning is defined from the build script. Use a default dev build if it's not defined.
Expand Down
Expand Up @@ -112,8 +112,14 @@ public string GetSessionName()

try
{
var processor = new CodeCoverageRunSettingsProcessor(defaultConfigurationElement);
configurationElement = (XmlElement)processor.Process(configurationElement);
// WARNING: Do NOT remove this function call !!!
//
// Due to a dependency we took on Microsoft.TestPlatform.Utilities.dll, an
// exception may be thrown if we cannot resolve CodeCoverageRunSettingsProcessor.
// If such an exception is thrown we cannot catch it in this try-catch block
// because all method dependencies must be resolved before the method call, thus
// we introduced an additional layer of indirection.
configurationElement = this.AddDefaultExclusions(configurationElement, defaultConfigurationElement);
}
catch (Exception ex)
{
Expand Down Expand Up @@ -326,5 +332,17 @@ private void CreateDirectory(DataCollectionContext context, string path)
throw;
}
}

/// <summary>
/// Adding default exclusions to the configuration element.
/// </summary>
/// <param name="configurationElement">The configuration element.</param>
/// <param name="defaultConfigurationElement">The default configuration element.</param>
/// <returns>The original configuration element with additional default exclusions.</returns>
private XmlElement AddDefaultExclusions(XmlElement configurationElement, XmlElement defaultConfigurationElement)
{
var processor = new CodeCoverageRunSettingsProcessor(defaultConfigurationElement);
return (XmlElement)processor.Process(configurationElement);
}
}
}

0 comments on commit 1d30394

Please sign in to comment.