Skip to content

Fix missing interface XML docs in multi-interface generation#1110

Merged
christianhelle merged 3 commits into
mainfrom
christianhelle/issue-1109-investigation
Jun 7, 2026
Merged

Fix missing interface XML docs in multi-interface generation#1110
christianhelle merged 3 commits into
mainfrom
christianhelle/issue-1109-investigation

Conversation

@christianhelle

@christianhelle christianhelle commented Jun 6, 2026

Copy link
Copy Markdown
Owner

Description:

This change fixes a regression where generated multi-interface clients could fail consumer builds with CS1591 when XML docs are enabled and warnings are treated as errors. The issue happened when OpenAPI metadata did not include tag or endpoint summaries, leaving generated public interfaces undocumented.

The generator now always emits interface-level XML summaries for multi-interface output:

  • ByTag: uses tag description when available, otherwise a stable fallback summary.
  • ByEndpoint: uses endpoint summary when available, otherwise a stable fallback summary.

To prevent regressions, strict warnings-as-errors build coverage was added in tests by introducing strict project-file fixtures and regression scenarios that compile generated code under XML-doc + warnings-as-errors settings. The test build helper now also supports net10.0 target framework alongside the existing net8.0 and net9.0 targets.

Example OpenAPI Specifications:

N/A

Example generated Refit interface

/// <summary>Users</summary>
[System.CodeDom.Compiler.GeneratedCode("Refitter", "1.0.0.0")]
public partial interface IUsersApi
{
    [Get("/users")]
    Task GetUsers();
}

Summary by CodeRabbit

  • New Features

    • Generated client interfaces now include automatic fallback documentation summaries when API specifications lack descriptions.
  • Tests

    • Added regression tests to validate XML documentation generation with stricter compilation settings.
    • Extended build helper to support net10.0 target framework in test project fixtures.

Summary by CodeRabbit

  • New Features

    • Client interfaces now always include fallback XML summary documentation when API specs lack descriptions.
  • Tests

    • Added regression tests verifying fallback summaries and that generated code builds with warnings treated as errors.
  • Chores

    • Build/test helpers and project templates updated to support warnings-as-errors across target frameworks.
    • CI workflow formatting and package dependency versions updated.

@coderabbitai

coderabbitai Bot commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

XmlDocumentationGenerator now always emits interface

documentation using fallback text when descriptions are missing; test build helpers and project templates were added to enable warnings-as-errors compilation checks, and regression tests verify generated summaries and successful compilation.

Changes

XML Documentation Fallback Summaries with Warnings-as-Errors Testing

Layer / File(s) Summary
XML documentation fallback summary generation
src/Refitter.Core/XmlDocumentationGenerator.cs
XmlDocumentationGenerator now computes fallback text and emits interface <summary> via a new AppendInterfaceSummary helper: by-tag falls back to Operations for {tag}; by-endpoint prefers Summary then Operations for {operationId} or Operations for endpoint..
Test infrastructure for warnings-as-errors builds
src/Refitter.Tests/Build/BuildHelper.cs, src/Refitter.Tests/Build/ProjectFileContents.cs
BuildHelper.BuildCSharp gained overloads accepting warningsAsErrors and routes through a core overload; new .csproj templates Net80AppWithWarningsAsErrors, Net90AppWithWarningsAsErrors, and Net100AppWithWarningsAsErrors set <TreatWarningsAsErrors>true for tests and are selected based on the warningsAsErrors flag.
Regression tests for fallback summaries and compilation
src/Refitter.Tests/Regression/MissingInterfaceXmlDocsWarningsAsErrorsTests.cs, src/Refitter.Tests/XmlDocumentationGeneratorTests.cs
Adds MissingInterfaceXmlDocsWarningsAsErrorsTests to assert fallback interface summaries for tag- and endpoint-grouped specs and to verify generated code builds with warningsAsErrors: true; updates an existing test to expect the fallback summary when tags are null.
CI and dependency tweaks
.github/workflows/codecov.yml, test/ConsoleApp/Directory.Build.props
Adjusts Codecov action pin and minor workflow formatting; bumps several Microsoft.Extensions package references in the test ConsoleApp props.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • christianhelle/refitter#709: Both PRs modify src/Refitter.Core/XmlDocumentationGenerator.cs to change how interface XML <summary> comments are emitted (including fallback/default behavior).
  • christianhelle/refitter#887: Both PRs touch src/Refitter.Core/XmlDocumentationGenerator.cs around interface XML summary generation and related refactors.
  • christianhelle/refitter#1111: Related test build plumbing changes for BuildHelper.BuildCSharp/ProjectFileContents and net10.0 handling.

Suggested labels

\.NET, bugfix

Poem

🐰
I hopped through tags and endpoint trails,
Escaped the symbols, filled the missing veils.
When summaries vanished, fallbacks found their place,
Generated code compiled with warnings in embrace.
A tiny rabbit cheers the build's green trace.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and specifically describes the main change: fixing missing interface XML documentation in multi-interface code generation.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch christianhelle/issue-1109-investigation

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@christianhelle christianhelle self-assigned this Jun 6, 2026
@christianhelle christianhelle added the enhancement New feature, bug fix, or request label Jun 6, 2026
@codecov

codecov Bot commented Jun 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.33%. Comparing base (493007e) to head (57ea9d4).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1110      +/-   ##
==========================================
+ Coverage   95.32%   95.33%   +0.01%     
==========================================
  Files          28       28              
  Lines        3013     3021       +8     
==========================================
+ Hits         2872     2880       +8     
  Misses         45       45              
  Partials       96       96              
Flag Coverage Δ
unittests 95.33% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@coderabbitai coderabbitai Bot 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.

🧹 Nitpick comments (1)
src/Refitter.Tests/Regression/MissingInterfaceXmlDocsWarningsAsErrorsTests.cs (1)

70-78: 💤 Low value

Consider a more precise assertion for the endpoint without operationId.

The assertion at Line 77 checks for the prefix "/// <summary>Operations for", but based on the ByEndpointSpec where the /orders endpoint lacks both operationId and summary, the fallback should be the complete string "Operations for endpoint." Test precision would improve by asserting the exact expected fallback.

🔍 Suggested improvement
         generatedCode.Should().Contain("/// <summary>Operations for GetUsers.</summary>");
         generatedCode.Should().Contain("partial interface IOrdersEndpoint");
-        generatedCode.Should().Contain("/// <summary>Operations for");
+        generatedCode.Should().Contain("/// <summary>Operations for endpoint.</summary>");
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@src/Refitter.Tests/Regression/MissingInterfaceXmlDocsWarningsAsErrorsTests.cs`
around lines 70 - 78, The test currently asserts a loose prefix ("///
<summary>Operations for") for the endpoint with no operationId/summary; update
the assertion to check the exact fallback summary string expected for that
endpoint by replacing the loose contains with an assertion that generatedCode
contains "/// <summary>Operations for endpoint.</summary>" (locate the assertion
in MissingInterfaceXmlDocsWarningsAsErrorsTests.cs near the
GenerateCode(ByEndpointSpec, MultipleInterfaces.ByEndpoint) call and update the
third Should().Contain to the precise string).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In
`@src/Refitter.Tests/Regression/MissingInterfaceXmlDocsWarningsAsErrorsTests.cs`:
- Around line 70-78: The test currently asserts a loose prefix ("///
<summary>Operations for") for the endpoint with no operationId/summary; update
the assertion to check the exact fallback summary string expected for that
endpoint by replacing the loose contains with an assertion that generatedCode
contains "/// <summary>Operations for endpoint.</summary>" (locate the assertion
in MissingInterfaceXmlDocsWarningsAsErrorsTests.cs near the
GenerateCode(ByEndpointSpec, MultipleInterfaces.ByEndpoint) call and update the
third Should().Contain to the precise string).

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 48943d87-189b-4dc3-847b-97dd4cfbb7ea

📥 Commits

Reviewing files that changed from the base of the PR and between 919536b and 54367ee.

📒 Files selected for processing (5)
  • src/Refitter.Core/XmlDocumentationGenerator.cs
  • src/Refitter.Tests/Build/BuildHelper.cs
  • src/Refitter.Tests/Build/ProjectFileContents.cs
  • src/Refitter.Tests/Regression/MissingInterfaceXmlDocsWarningsAsErrorsTests.cs
  • src/Refitter.Tests/XmlDocumentationGeneratorTests.cs

@christianhelle christianhelle enabled auto-merge June 6, 2026 17:14
@christianhelle christianhelle disabled auto-merge June 6, 2026 17:20
@christianhelle

Copy link
Copy Markdown
Owner Author

@copilot resolve the merge conflicts in this pull request

Copilot AI commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

@copilot resolve the merge conflicts in this pull request

Merge conflicts resolved in commit 281c8ab. The only conflict was in src/Refitter.Tests/Build/BuildHelper.cs where the PR's warningsAsErrors tuple-switch needed to be combined with the net10.0 support added in main. The resolved switch now handles all combinations:

  • ("net9.0", true)Net90AppWithWarningsAsErrors
  • ("net9.0", false)Net90App
  • ("net10.0", _)Net100App
  • (_, true)Net80AppWithWarningsAsErrors
  • _Net80App

@christianhelle christianhelle force-pushed the christianhelle/issue-1109-investigation branch from 281c8ab to e036d85 Compare June 6, 2026 21:24

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/Refitter.Tests/Build/ProjectFileContents.cs (1)

142-168: net10.0 warnings-as-errors template: package TFMs include net10.0, so mismatch is compatible
The prior concern was that Net100AppWithWarningsAsErrors uses a different aligned package set than the net8.0/net9.0 templates. For the key packages checked in src/Refitter.Tests/Build/ProjectFileContents.cs (lines 142-168), the NuGet packages include lib/net10.0/*:

  • Refit.HttpClientFactory 11.0.1: lib/net10.0/Refit.HttpClientFactory.dll
  • Microsoft.Extensions.DependencyInjection 10.0.8: lib/net10.0/Microsoft.Extensions.DependencyInjection.dll
    So the net10.0 template’s package versions shouldn’t inherently break due to missing net10.0 assemblies; documenting this rationale (or confirming the rest of the packages’ TFMs) would be sufficient rather than changing versions.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/Refitter.Tests/Build/ProjectFileContents.cs` around lines 142 - 168,
Reviewer concern: the Net100AppWithWarningsAsErrors template may mismatch
package TFMs; fix by adding a brief inline comment above the
Net100AppWithWarningsAsErrors constant in ProjectFileContents.cs stating that
the listed package versions provide lib/net10.0 assets (e.g.,
Refit.HttpClientFactory 11.0.1 and Microsoft.Extensions.DependencyInjection
10.0.8) and that you verified the remaining packages expose net10.0; if any
package does not, update that package version to one that provides net10.0 or
replace it, then commit the verification note.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@src/Refitter.Tests/Regression/MissingInterfaceXmlDocsWarningsAsErrorsTests.cs`:
- Around line 75-78: The assertion for the no-operationId fallback is too weak —
change the assertion in MissingInterfaceXmlDocsWarningsAsErrorsTests (the
generatedCode.Should().Contain checks) to assert the exact fallback summary text
produced for the ByEndpoint branch (e.g. require the full string "///
<summary>Operations for endpoint.</summary>" and similarly assert the exact
interface declaration "partial interface IOrdersEndpoint") so the test proves
the concrete fallback is used; after updating these assertions, also add/verify
equivalent tests exercising both multi-interface generation modes (ByEndpoint
and ByTag) to ensure the XML-doc fallback behavior is correct for each mode.

---

Nitpick comments:
In `@src/Refitter.Tests/Build/ProjectFileContents.cs`:
- Around line 142-168: Reviewer concern: the Net100AppWithWarningsAsErrors
template may mismatch package TFMs; fix by adding a brief inline comment above
the Net100AppWithWarningsAsErrors constant in ProjectFileContents.cs stating
that the listed package versions provide lib/net10.0 assets (e.g.,
Refit.HttpClientFactory 11.0.1 and Microsoft.Extensions.DependencyInjection
10.0.8) and that you verified the remaining packages expose net10.0; if any
package does not, update that package version to one that provides net10.0 or
replace it, then commit the verification note.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 3c0f3d9a-3c8c-4939-a895-9aec806794da

📥 Commits

Reviewing files that changed from the base of the PR and between 281c8ab and e036d85.

📒 Files selected for processing (5)
  • src/Refitter.Core/XmlDocumentationGenerator.cs
  • src/Refitter.Tests/Build/BuildHelper.cs
  • src/Refitter.Tests/Build/ProjectFileContents.cs
  • src/Refitter.Tests/Regression/MissingInterfaceXmlDocsWarningsAsErrorsTests.cs
  • src/Refitter.Tests/XmlDocumentationGeneratorTests.cs
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/Refitter.Tests/XmlDocumentationGeneratorTests.cs
  • src/Refitter.Core/XmlDocumentationGenerator.cs

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/codecov.yml:
- Line 58: Replace the moving tag usage of codecov/codecov-action@v5 with a
specific commit SHA (e.g., codecov/codecov-action@<sha>) to pin the action, and
update the workflow comment and the PR description to document why v5 is chosen
over v6 (note v6 Node.js 24 runtime compatibility concerns and runner support)
so reviewers can see the downgrade rationale and the supply-chain hardening
justification.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9747b851-1ad0-42d0-8f18-51f0187b878a

📥 Commits

Reviewing files that changed from the base of the PR and between e036d85 and 3c4ec1c.

📒 Files selected for processing (2)
  • .github/workflows/codecov.yml
  • test/ConsoleApp/Directory.Build.props
✅ Files skipped from review due to trivial changes (1)
  • test/ConsoleApp/Directory.Build.props

Comment thread .github/workflows/codecov.yml Outdated
@christianhelle christianhelle force-pushed the christianhelle/issue-1109-investigation branch from 3c4ec1c to 57ea9d4 Compare June 7, 2026 10:54
@sonarqubecloud

sonarqubecloud Bot commented Jun 7, 2026

Copy link
Copy Markdown

@christianhelle christianhelle enabled auto-merge June 7, 2026 11:23
@christianhelle christianhelle merged commit 7605581 into main Jun 7, 2026
19 of 21 checks passed
@christianhelle christianhelle deleted the christianhelle/issue-1109-investigation branch June 7, 2026 11:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature, bug fix, or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Build Error CS1591 Missing XML comment for publicly visible type or member

2 participants