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

Fixed code coverage compatibility issue #2527

Merged
merged 2 commits into from Aug 19, 2020
Merged
Show file tree
Hide file tree
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
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);
}
}
}