Skip to content

fix regression issue 2045 - #2046

Merged
Bertk merged 1 commit into
coverlet-coverage:masterfrom
Bertk:2045-bug-instrument-local-functions
Oct 3, 2026
Merged

Bertk merged 1 commit into
coverlet-coverage:masterfrom
Bertk:2045-bug-instrument-local-functions

Conversation

@Bertk

@Bertk Bertk commented Oct 3, 2026

Copy link
Copy Markdown
Collaborator

InstrumentType now detects local functions via IInstrumentationHelper.IsLocalMethod, and for those methods ignores CompilerGeneratedAttribute/GeneratedCodeAttribute when deciding exclusion (reusing the existing IsCompilerGeneratedOrGeneratedCodeAttribute helper), while still honoring any other user-configured exclude attribute (e.g. ExcludeFromCodeCoverage) applied directly to a local function.

InstrumentType now detects local functions via IInstrumentationHelper.IsLocalMethod, and for those methods ignores CompilerGeneratedAttribute/GeneratedCodeAttribute when deciding exclusion (reusing the existing IsCompilerGeneratedOrGeneratedCodeAttribute helper), while still honoring any other user-configured exclude attribute (e.g. ExcludeFromCodeCoverage) applied directly to a local function.

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.

Copilot review overview

🟢 Approval recommended

The focused implementation matches the reported regression and is adequately covered by the added test.

Review effort: Balanced
Findings: None

What changed in this PR

Fixes issue #2045 by ensuring local functions remain instrumented when compiler-generated attributes are excluded.

Changes:

  • Detects local functions before applying attribute exclusions.
  • Preserves other explicit exclusion attributes.
  • Adds a regression sample and unit test.
File Description
src/​coverlet.core/​Instrumentation/​Instrumenter.cs Adjusts local-function exclusion logic.
test/​coverlet.core.tests/​Instrumentation/​InstrumenterTests.cs Adds regression coverage.
test/​coverlet.core.tests/​Samples/​Samples.cs Adds a representative local-function sample.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@Bertk
Bertk merged commit ecd6fd5 into coverlet-coverage:master Oct 3, 2026
10 checks passed
@Bertk
Bertk deleted the 2045-bug-instrument-local-functions branch October 3, 2026 14:37
Bertk added a commit to Bertk/coverlet that referenced this pull request Oct 14, 2026
InstrumentType now detects local functions via IInstrumentationHelper.IsLocalMethod, and for those methods ignores CompilerGeneratedAttribute/GeneratedCodeAttribute when deciding exclusion (reusing the existing IsCompilerGeneratedOrGeneratedCodeAttribute helper), while still honoring any other user-configured exclude attribute (e.g. ExcludeFromCodeCoverage) applied directly to a local function.
@Bertk Bertk added the bug Something isn't working label Oct 17, 2026
This was referenced Nov 15, 2026
This was referenced Dec 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working coverlet-core regression software bug of before working feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

coverlet.MTP does not instrument local functions; [DoesNotReturn] leaves unreachable sequence point uncovered

2 participants