From 7ec901207e9bfe5bef4089bfa262a81051d5dc10 Mon Sep 17 00:00:00 2001 From: Bert Date: Wed, 3 Jun 2026 14:58:17 +0200 Subject: [PATCH] Add ReportGenerator to baseline exclude filters Update CoverageConfiguration to always exclude "[ReportGenerator.*]*" assemblies. Adjust related tests in CoverageConfigurationDynamicExcludeTests to reflect the new baseline filter and remove dynamic exclusion expectations for ReportGenerator. --- src/coverlet.MTP/Configuration/CoverageConfiguration.cs | 2 +- .../CoverageConfigurationDynamicExcludeTests.cs | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/coverlet.MTP/Configuration/CoverageConfiguration.cs b/src/coverlet.MTP/Configuration/CoverageConfiguration.cs index 8ae0271a2..c75d0363a 100644 --- a/src/coverlet.MTP/Configuration/CoverageConfiguration.cs +++ b/src/coverlet.MTP/Configuration/CoverageConfiguration.cs @@ -18,7 +18,7 @@ internal sealed class CoverageConfiguration // Permanent baseline: coverlet assemblies must always be excluded regardless of source. // All other test-framework assemblies are discovered dynamically at runtime via IProcessAssemblyHelper. - private static readonly string[] s_baselineExcludeFilters = ["[coverlet.*]*", "[Microsoft.VisualStudio.TestPlatform.*]*", "[testhost*]*"]; + private static readonly string[] s_baselineExcludeFilters = ["[coverlet.*]*", "[Microsoft.VisualStudio.TestPlatform.*]*", "[testhost*]*", "[ReportGenerator.*]*"]; private static readonly string[] s_defaultExcludeByAttributes = [ diff --git a/test/coverlet.MTP.tests/Configuration/CoverageConfigurationDynamicExcludeTests.cs b/test/coverlet.MTP.tests/Configuration/CoverageConfigurationDynamicExcludeTests.cs index 1188542f3..aa4a1e163 100644 --- a/test/coverlet.MTP.tests/Configuration/CoverageConfigurationDynamicExcludeTests.cs +++ b/test/coverlet.MTP.tests/Configuration/CoverageConfigurationDynamicExcludeTests.cs @@ -47,7 +47,7 @@ public void WhenNoConfigFileThenDepsJsonFiltersApplied() { _mockProcessAssemblyHelper .Setup(x => x.GetDepsJsonAssemblyNames(s_fakeModuleDir, TestAssemblyName)) - .Returns(["xunit.core", "ReportGenerator.Mtp"]); + .Returns(["xunit.core"]); _mockProcessAssemblyHelper .Setup(x => x.GetLoadedAssemblyNames(TestAssemblyName)) .Returns([]); @@ -62,7 +62,6 @@ public void WhenNoConfigFileThenDepsJsonFiltersApplied() string[] result = config.GetExcludeFilters(); Assert.Contains("[xunit.core]*", result); - Assert.Contains("[ReportGenerator.Mtp]*", result); } [Fact] @@ -106,7 +105,7 @@ public void WhenDepsJsonHelperReturnsEmptyListThenBaselineFallbackUsed() string[] result = config.GetExcludeFilters(); - Assert.Equal(["[coverlet.*]*", "[Microsoft.VisualStudio.TestPlatform.*]*", "[testhost*]*"], result); + Assert.Equal(["[coverlet.*]*", "[Microsoft.VisualStudio.TestPlatform.*]*", "[testhost*]*", "[ReportGenerator.*]*"], result); } [Fact] @@ -127,7 +126,7 @@ public void WhenDepsJsonHelperThrowsThenBaselineFallbackUsed() string[] result = config.GetExcludeFilters(); - Assert.Equal(["[coverlet.*]*", "[Microsoft.VisualStudio.TestPlatform.*]*", "[testhost*]*"], result); + Assert.Equal(["[coverlet.*]*", "[Microsoft.VisualStudio.TestPlatform.*]*", "[testhost*]*", "[ReportGenerator.*]*"], result); } [Fact] @@ -166,7 +165,7 @@ public void WhenNullTestModulePathThenBaselineOnlyReturned() string[] result = config.GetExcludeFilters(); - Assert.Equal(["[coverlet.*]*", "[Microsoft.VisualStudio.TestPlatform.*]*", "[testhost*]*"], result); + Assert.Equal(["[coverlet.*]*", "[Microsoft.VisualStudio.TestPlatform.*]*", "[testhost*]*", "[ReportGenerator.*]*"], result); _mockProcessAssemblyHelper.Verify( x => x.GetDepsJsonAssemblyNames(It.IsAny(), It.IsAny()), Times.Never);