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 #2514

Merged
3 commits merged into from
Aug 10, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,14 @@ public virtual void Initialize(

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);
}
}
}