Skip to content

Narrow Dynamic Exclude Filters for Loaded Assemblies - #2069

Merged
Bertk merged 2 commits into
coverlet-coverage:masterfrom
Bertk:narrow-dynamic-exclude-filters
Nov 3, 2026
Merged

Bertk merged 2 commits into
coverlet-coverage:masterfrom
Bertk:narrow-dynamic-exclude-filters

Conversation

@Bertk

@Bertk Bertk commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator

This pull request refines the logic for generating dynamic exclude filters in Coverlet.MTP, making the exclusion of assemblies more precise and reducing the risk of unintentionally excluding assemblies that share common prefixes with the system under test (SUT). The update distinguishes between exclusions derived from deps.json (which remain wildcarded) and those from loaded assemblies (which are now exact matches), and updates documentation and tests accordingly.

Dynamic Exclude Filter Precision Improvements:

  • Updated dynamic exclude filter generation so that assemblies discovered via deps.json continue to use wildcard filters, while assemblies already loaded in the controller process now use exact-name filters for exclusion. This prevents overly broad exclusions that could unintentionally exclude SUT assemblies with similar prefixes.

Documentation Updates:

  • Revised the documentation in Coverlet.MTP.Integration.md to clarify the new behavior of dynamic exclude filters, explaining the distinction between runtime discovery sources and the improved exclusion precision for loaded assemblies.

Test Enhancements:

  • Added and updated tests in CoverageConfigurationDynamicExcludeTests.cs to verify that loaded assemblies are excluded using exact-name filters and that wildcard filters are not erroneously applied to SUTs with shared prefixes.
  • Added tests in ProcessAssemblyHelperTests.cs to ensure the new ToExactExcludeFilter method generates the correct filter patterns.

@Bertk Bertk linked an issue Nov 3, 2026 that may be closed by this pull request
@Bertk Bertk added driver-MTP Issue related to Microsoft Testing Platform driver coverlet-core enhancement General enhancement request labels Nov 3, 2026
@Bertk
Bertk requested a balanced review from Copilot November 3, 2026 10:20

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Generated exclusion filters for hyphenated assembly names fail validation, so intended assembly exclusions can be silently dropped.

1 open issue
What changed in this PR

This PR narrows Coverlet.MTP’s dynamic exclusions for loaded assemblies to avoid excluding system-under-test assemblies that share a prefix.

Changes:

  • Uses exact-name filters for loaded assemblies while preserving wildcard normalization for deps.json entries.
  • Adds tests for exact filter generation and shared-prefix scenarios.
  • Documents the two discovery sources and their filtering behavior.
File Description
test/​coverlet.MTP.tests/​Configuration/​CoverageConfigurationDynamicExcludeTests.cs Updates expectations and adds shared-prefix regression coverage.
test/​coverlet.core.tests/​Helpers/​ProcessAssemblyHelperTests.cs Tests exact-name filter generation.
src/​coverlet.MTP/​Configuration/​CoverageConfiguration.cs Applies separate filter transformations to each discovery source.
src/​coverlet.core/​Helpers/​ProcessAssemblyHelper.cs Adds the exact-name filter helper.
Documentation/​Coverlet.MTP.Integration.md Explains runtime discovery and exclusion precision.

Review effort: Balanced

@Bertk
Bertk merged commit f37bf3d into coverlet-coverage:master Nov 3, 2026
10 checks passed
@Bertk
Bertk deleted the narrow-dynamic-exclude-filters branch November 3, 2026 11:38
This was referenced Nov 15, 2026
This was referenced Dec 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

coverlet-core driver-MTP Issue related to Microsoft Testing Platform driver enhancement General enhancement request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Coverlet.MTP 10.1.0 isn’t covering the project being tested

2 participants