Skip to content

Fix record EqualityContract, GeneratedRegex, field-like-event, and Warning-severity doc-coverage issues - #50

Merged
Malcolmnixon merged 3 commits into
mainfrom
fix/record-equalitycontract-doc-coverage-false-positives
Oct 7, 2026
Merged

Malcolmnixon merged 3 commits into
mainfrom
fix/record-equalitycontract-doc-coverage-false-positives

Conversation

@Malcolmnixon

Copy link
Copy Markdown
Member

Summary

Fixes four related --enforce-docs / Markdown-emission false positives, all
stemming from compiler-generated members that have no source location to
attach documentation to, plus one build-visibility issue:

  1. Record EqualityContract property reported as undocumented and given
    its own Markdown page/table row, for every C# record type (sealed,
    non-sealed, and derived). Fixed by excluding compiler-generated properties
    from both DocumentationCoverageChecker and DotNetEmitter, the same way
    compiler-generated methods were already excluded. A hand-written property
    named EqualityContract on a normal class is still reported/emitted.
  2. [GeneratedRegex] methods losing their <summary> to the regex
    source generator's own <remarks> in the compiled XML doc, making them
    permanently fail --enforce-docs. Fixed by accepting a non-empty
    <remarks> as documentation for members carrying [GeneratedCodeAttribute]
    — coverage-checking only; Markdown emission is unchanged.
  3. Field-like events' backing field reported as undocumented even though
    the event itself is documented. Fixed by also excluding fields carrying
    [CompilerGeneratedAttribute] (the backing field shares the event's exact
    name, so the existing angle-bracket name check didn't catch it).
  4. Warning-severity --enforce-docs findings invisible in normal MSBuild
    output — they were logged as plain messages, so builds reported
    "0 Warning(s)" and findings only appeared at -v n. Fixed by elevating
    [Undocumented] finding lines to real Log.LogWarning/Log.LogError
    calls based on ApiMarkEnforceDocsSeverity.

Testing

  • Added fixtures (RecordClass.cs, FieldLikeEventClass.cs,
    GeneratedRegexClass.cs) and unit tests covering all four scenarios across
    DotNetEmitterTests, DocumentationCoverageCheckerTests, and
    ApiMarkTaskTests.
  • Full solution build: 0 errors/warnings.
  • Updated design, reqstream, and verification documentation for the
    affected units (DotNetEmitter, DocumentationCoverageChecker,
    ApiMarkTask).
  • Passed code-review and formal-review for all three affected review-sets
    (ApiMark-MSBuild-Task, ApiMark-DotNet-DotNetEmitter,
    ApiMark-DotNet-DocumentationCoverageChecker).
  • fix.ps1/lint.ps1 run clean.

Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com

… members

- Exclude a record's compiler-generated EqualityContract property from both
  --enforce-docs coverage checking and Markdown emission (sealed, non-sealed,
  and derived records), while still reporting a hand-written property of the
  same name.
- Accept a <remarks> as documentation (in addition to <summary>) for members
  carrying [GeneratedCodeAttribute], so [GeneratedRegex] partial methods whose
  XML doc summary is overwritten by the source generator no longer fail
  --enforce-docs.
- Exclude a field-like event's compiler-generated backing field (detected via
  CompilerGeneratedAttribute, since it shares the event's exact name) from
  both coverage checking and emission, when the event itself is documented.
- Elevate --enforce-docs findings logged by ApiMarkTask to real MSBuild
  warnings/errors (via the new LogToolOutputLine), based on
  ApiMarkEnforceDocsSeverity, instead of only low-visibility informational
  messages invisible at normal build verbosity.

Adds fixtures and tests for all four scenarios, and updates the design,
reqstream, and verification documentation for the affected units
(DotNetEmitter, DocumentationCoverageChecker, ApiMarkTask) accordingly.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings October 7, 2026 10:46

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

🟡 Changes recommended

Address the generated-type documentation fallback and make the backing-field regression test exercise the intended code path.

Review effort: Lite
Findings: 2 Medium severity

Open (2)
What changed in this PR

This PR fixes documentation false positives for compiler-generated .NET members and improves MSBuild enforcement visibility.

Changes:

  • Filters generated record properties and event backing fields.
  • Accepts generated-code remarks during coverage checks.
  • Elevates enforcement findings to configured MSBuild warning/error severity.
  • Adds fixtures, tests, and documentation updates.
File Summary
test/​ApiMark.MSBuild.Tests/​ApiMarkTaskTests.cs Tests MSBuild severity logging.
test/​ApiMark.DotNet.Tests/​DotNetEmitterTests.cs Tests generated-member filtering.
test/​ApiMark.DotNet.Tests/​DocumentationCoverageCheckerTests.cs Tests coverage behavior.
test/​ApiMark.DotNet.Fixtures/​RecordClass.cs Adds record fixtures.
test/​ApiMark.DotNet.Fixtures/​GeneratedRegexClass.cs Adds generated-regex fixture.
test/​ApiMark.DotNet.Fixtures/​FieldLikeEventClass.cs Adds field-like event fixture.
src/​ApiMark.MSBuild/​ApiMarkTask.cs Elevates enforcement findings.
src/​ApiMark.DotNet/​DotNetEmitter.cs Filters generated properties and fields.
src/​ApiMark.DotNet/​DocumentationCoverageChecker.cs Updates coverage rules.
docs/​verification/​api-mark-msbuild/​api-mark-task.md Documents MSBuild verification.
docs/​verification/​api-mark-dot-net/​dot-net-emitter.md Documents emitter verification.
docs/​verification/​api-mark-dot-net/​documentation-coverage-checker.md Documents coverage verification.
docs/​reqstream/​api-mark-msbuild/​api-mark-task.yaml Updates MSBuild requirements.
docs/​reqstream/​api-mark-dot-net/​documentation-coverage-checker.yaml Updates coverage requirements.
docs/​design/​api-mark-msbuild/​api-mark-task.md Documents logging behavior.
docs/​design/​api-mark-dot-net/​dot-net-emitter.md Documents generated-member filtering.
docs/​design/​api-mark-dot-net/​documentation-coverage-checker.md Documents coverage rules.

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

Comment thread src/ApiMark.DotNet/DocumentationCoverageChecker.cs
Comment thread test/ApiMark.DotNet.Tests/DocumentationCoverageCheckerTests.cs Outdated
- Restrict the GeneratedCodeAttribute <remarks> documentation fallback to
  members only, not types: HasDocumentation now explicitly excludes
  TypeDefinition from the fallback, so a generated public type with no
  <summary> is still reported as undocumented, matching the intent that
  the fallback is for generated members (e.g. [GeneratedRegex] methods),
  not generated types.
- Fix Check_DocumentedFieldLikeEvent_DoesNotReportBackingField to check at
  ApiVisibility.All instead of Public, since the private backing field was
  previously filtered out by visibility before IsCompilerGeneratedField
  was ever consulted, making the regression test a false pass.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings October 7, 2026 10:57

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 only remaining finding is a non-blocking documentation-contract nit; the implementation and tests cover the reviewed changes.

Review effort: Lite
Findings: None

Resolved since last review (2)

Three requirements added during formal-review remediation were not linked
into the system-level requirement tree, making them orphaned (unreachable
from any requirement tagged quality/system):

- ApiMarkDotNet-DocumentationCoverageChecker-ExcludeCompilerGeneratedMembers
- ApiMarkDotNet-DocumentationCoverageChecker-AcceptRemarksForGeneratedCodeMembers
- ApiMarkMsbuild-ApiMarkTask-ElevateUndocumentedFindings

Added them as children of their respective parent system requirements
(ApiMarkDotNet-EnforceDocumentationCoverage and
ApiMarkMsbuild-ApiMarkTask-IntegrateWithMsbuild). `dotnet reqstream --lint`
and the full `lint.ps1` pass now run clean.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings October 7, 2026 11:28

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 changes are covered by tests, and the remaining review note is a non-blocking rationale nit.

Review effort: Lite
Findings: None

@Malcolmnixon
Malcolmnixon merged commit ecfd72e into main Oct 7, 2026
16 checks passed
@Malcolmnixon
Malcolmnixon deleted the fix/record-equalitycontract-doc-coverage-false-positives branch October 7, 2026 11:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants