Skip to content

Treat CS1591 as a build error in MTP and TestFramework (#9060) - #9073

Merged
Amaury Levé (Evangelink) merged 1 commit into
mainfrom
dev/amauryleve/issue-9060-cs1591-error
Jun 12, 2026
Merged

Amaury Levé (Evangelink) merged 1 commit into
mainfrom
dev/amauryleve/issue-9060-cs1591-error

Conversation

@Evangelink

Copy link
Copy Markdown
Member

Addresses task 5 of #9060: enforce CS1591 (missing XML doc comment on publicly visible type or member) as a build error for the two main public-API projects.

Changes

Adds <WarningsAsErrors>$(WarningsAsErrors);CS1591</WarningsAsErrors> to:

  • src/Platform/Microsoft.Testing.Platform/Microsoft.Testing.Platform.csproj
  • src/TestFramework/TestFramework/TestFramework.csproj

Why this is safe today

Both projects already build with 0 CS1591 warnings on main:

  • MTP has no #pragma warning disable CS1591 anywhere in the project.
  • TestFramework has a handful of #pragma warning disable CS1591 blocks around [EditorBrowsable(EditorBrowsableState.Never)] InterpolatedStringHandler structs; those pragmas continue to suppress the warning even when CS1591 is treated as an error. (Document Assert interpolated-string-handler structs (#9060) #9072 documents those handlers and removes the pragmas so they can't be re-applied silently.)

What this prevents going forward

Any new public type or member added to these two projects without an XML /// summary will now fail the build instead of producing a warning that is easy to miss. The repo already has <GenerateDocumentationFile>true</GenerateDocumentationFile> globally and <SkipArcadeNoWarnCS1591>true</SkipArcadeNoWarnCS1591> for src/, so this is purely a tightening of the existing policy.

Verification

  • dotnet build src/TestFramework/TestFramework/TestFramework.csproj → 0 warnings / 0 errors (4 TFMs)
  • dotnet build src/Platform/Microsoft.Testing.Platform/Microsoft.Testing.Platform.csproj → 0 warnings / 0 errors (3 TFMs)

Part of #9060.

Adds `<WarningsAsErrors>$(WarningsAsErrors);CS1591</WarningsAsErrors>`
to `src/Platform/Microsoft.Testing.Platform/Microsoft.Testing.Platform.csproj`
and `src/TestFramework/TestFramework/TestFramework.csproj`.

Both projects already build cleanly with 0 CS1591 warnings (any
remaining gaps are wrapped by `#pragma` blocks that suppress the warning
at source), so this change just prevents regressions: any new public API
without an XML doc comment will now break the build instead of being
silently undocumented.

Closes the last task of #9060.

Co-authored-by: Copilot <[email protected]>
Copilot AI review requested due to automatic review settings June 12, 2026 12:12

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.

Pull request overview

This pull request tightens the documentation policy for the two primary public-API projects (Microsoft.Testing.Platform and MSTest TestFramework) by promoting compiler warning CS1591 (missing XML doc comments on publicly visible members) to a build error.

Changes:

  • Add CS1591 to WarningsAsErrors in Microsoft.Testing.Platform.csproj.
  • Add CS1591 to WarningsAsErrors in TestFramework.csproj.
Show a summary per file
File Description
src/Platform/Microsoft.Testing.Platform/Microsoft.Testing.Platform.csproj Enforces CS1591 as an error so new undocumented public APIs fail the build.
src/TestFramework/TestFramework/TestFramework.csproj Enforces CS1591 as an error for MSTest’s core public API assembly to prevent undocumented additions.

Copilot's findings

  • Files reviewed: 2/2 changed files
  • Comments generated: 0

@Evangelink Amaury Levé (Evangelink) left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Note

🤖 Automated review by GitHub Copilot. Posted via a maintainer's GitHub token, so it appears under their account — the account owner did not write or approve this content personally. Generated by the Expert Code Review workflow. To request a follow-up action, reply by tagging @copilot directly.

✅ 22/22 dimensions clean — no findings.


MSBuild Authoring (supplemental) — LGTM

The <WarningsAsErrors>$(WarningsAsErrors);CS1591</WarningsAsErrors> pattern correctly accumulates on top of any globally established value without overwriting it — consistent with how <NoWarn>$(NoWarn);... is used throughout the repo. Placement within a <PropertyGroup> in the individual .csproj is correct. The evaluation order is sound:

  1. src/Directory.Build.props sets <SkipArcadeNoWarnCS1591>true</SkipArcadeNoWarnCS1591> before Arcade props are imported → Arcade does not add CS1591 to $(NoWarn).
  2. The individual project file then appends CS1591 to $(WarningsAsErrors).

No interference with CI's /p:TreatWarningsAsErrors=true flag — both accumulate independently.


One observation (not a blocker for this PR):

TestFramework.Extensions.csproj is the project that actually ships the MSTest.TestFramework NuGet package (<PackageId>MSTest.TestFramework</PackageId>, <IsPackable>true</IsPackable>). It references TestFramework.csproj via <ProjectReference>. CS1591 is enforced per compilation unit, so any new public members declared directly in Extensions source files (rather than in the referenced assembly) would not be caught by this PR's change. In practice, Extensions appears to be primarily a packaging wrapper, so the gap is narrow. If future tasks in #9060 add enforcement to additional projects, TestFramework.Extensions.csproj would be worth including in that pass.

🤖 Automated content by GitHub Copilot. Posted via a maintainer's GitHub token, so it appears under their account — the account owner did not write or approve this content personally. Generated by the Expert Code Review (on PR ready) workflow. · 313.8 AIC · ⌖ 13.2 AIC · ◷

@Evangelink
Amaury Levé (Evangelink) merged commit 29dd790 into main Jun 12, 2026
33 of 36 checks passed
@Evangelink
Amaury Levé (Evangelink) deleted the dev/amauryleve/issue-9060-cs1591-error branch June 12, 2026 12:41
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