Skip to content

Honor warning promotion for BuildCheck infrastructure failures - #15616

Open
MattKotsenas wants to merge 2 commits into
dotnet:mainfrom
MattKotsenas:bugfix/buildcheck-infrastructure-warning-promotion
Open

MattKotsenas wants to merge 2 commits into
dotnet:mainfrom
MattKotsenas:bugfix/buildcheck-infrastructure-warning-promotion

Conversation

@MattKotsenas

@MattKotsenas MattKotsenas commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

Related issue(s): #15575

Context

This PR lets BuildCheck infrastructure warnings honor MSBuild's project-level warning settings, including treating warnings as errors. Failures during configuration, initialization, action registration, or callback execution remain contained warnings by default, and the affected check is disabled.

Changes Made

Project-aware warning handling

Infrastructure warnings retain their originating project context and location. When the project context is not yet available, BuildCheck can hold the warning until the corresponding project starts, allowing MSBuild logging to apply that project's warning settings.

Warnings already covered by /warnaserror are submitted at their original reporting point. Delaying them until project-start processing could allow the submission to finish successfully before logging receives the error. MSBuild logging continues to determine final severity using its existing warning-promotion, exclusion, and message-demotion rules.

Deferred delivery and manager lifetime

The PR also completes deferred reporting before logging shuts down, so pending diagnostics from failed evaluations and graph construction are not lost. The existing FinalizeProcessing operation dispatches remaining diagnostics at coordinator, worker, and replay completion. The coordinator drains incoming events, completes deferred reporting, then drains the emitted diagnostics before calculating its final status. Worker completion preserves diagnostics even when request deactivation fails. Replay dispatches pending warnings before forwarding the recorded build-finished event.

The shared in-process manager remains alive through logging shutdown. Releasing its provider through the component factory lets subsequent builds initialize a fresh manager.

Deferred-warning synchronization

A private DeferredWarnings collection makes appending warnings and taking batches thread-safe. Taking a batch transfers ownership atomically, preventing a concurrent append from losing a warning. Dispatch runs outside the collection lock.

This synchronization work overlaps draft #14686.

Compatibility and scope

Ordinary rule reporting, diagnostic ownership and location, and MSBuild's warning-policy precedence are preserved. Worker tracing remains success-only, and public build-finished callbacks keep their existing timing. No public APIs or binary-log event formats change.

The late-warning limitations discussed in #10670 remain: asynchronous project-only promotion can miss its policy window, and an ordinary finding promoted after submission completion can still leave a successful result. Graph-result reconciliation is tracked separately in #15572.

Copilot AI balanced review requested due to automatic review settings November 19, 2026 16:37

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

Deferred infrastructure warnings can bypass warning-as-error handling, leaving graph results, build-finished status, or out-of-process project results incorrectly successful.

2 open issues
What changed in this PR

Updates BuildCheck infrastructure failure reporting to use MSBuild’s native warning-promotion path while continuing to disable failed checks. It also coordinates deferred diagnostic delivery with build and replay completion.

Changes:

  • Preserve originating project context and synchronize deferred warning batches.
  • Flush pending diagnostics at coordinator, worker, and replay completion, with revised manager lifetime handling.
  • Add regression coverage for promotion, concurrency, diagnostic ordering, and build-manager reuse.
File Description
src/​BuildCheck.UnitTests/​EndToEndTests.cs Adds CLI promotion and worker-failure coverage.
src/​BuildCheck.UnitTests/​BuildCheckReplayModeConnectorTests.cs Tests deferred diagnostic ordering during replay.
src/​BuildCheck.UnitTests/​BuildCheckManagerProviderTests.cs Tests matching, reentrant, and concurrent warning drains.
src/​BuildCheck.UnitTests/​BuildCheckLifecycleTests.cs Covers mixed graph/build sessions and manager reuse.
src/​BuildCheck.UnitTests/​BuildCheckCentralContext_Tests.cs Removes the obsolete warning-dispatch test stub.
src/​Build/​Evaluation/​IntrinsicFunctions.cs Attaches originating context to check acquisition events.
src/​Build/​BuildCheck/​Infrastructure/​NullBuildCheckManager.cs Updates the no-op completion signature.
src/​Build/​BuildCheck/​Infrastructure/​IBuildCheckManager.cs Defines completion through a check context.
src/​Build/​BuildCheck/​Infrastructure/​CheckWrapper.cs Routes infrastructure warnings through the result reporter.
src/​Build/​BuildCheck/​Infrastructure/​CheckContext/​ICheckContext.cs Removes direct text-warning dispatch.
src/​Build/​BuildCheck/​Infrastructure/​CheckContext/​CheckLoggingContext.cs Removes the obsolete logging warning helper.
src/​Build/​BuildCheck/​Infrastructure/​CheckContext/​CheckDispatchingContext.cs Removes the obsolete replay warning helper.
src/​Build/​BuildCheck/​Infrastructure/​BuildCheckReplayModeConnector.cs Flushes pending diagnostics before replayed build completion.
src/​Build/​BuildCheck/​Infrastructure/​BuildCheckManagerProvider.cs Defers infrastructure warnings and synchronizes batch ownership.
src/​Build/​BuildCheck/​Infrastructure/​BuildCheckCentralContext.cs Routes callback failures through the result reporter.
src/​Build/​BackEnd/​Node/​OutOfProcNode.cs Releases the provider through its component factory.
src/​Build/​BackEnd/​Components/​RequestBuilder/​RequestBuilder.cs Supplies originating request identity before evaluation.
src/​Build/​BackEnd/​Components/​BuildRequestEngine/​BuildRequestEngine.cs Flushes worker diagnostics even after deactivation failures.
src/​Build/​BackEnd/​BuildManager/​BuildManager.cs Adds completion drains and retains the manager through logging shutdown.
src/​Build.UnitTests/​BackEnd/​MockHost.cs Allows tests to inject a BuildCheck provider.
src/​Build.UnitTests/​BackEnd/​BuildRequestEngine_Tests.cs Tests worker failure cleanup and shared-manager ownership.

Review effort: Balanced

@OvesN
OvesN requested a review from baronfel November 20, 2026 10:05
Route callback and configuration failures through result reporting so project warning policy is available before ordinary submission completion. Keep checker containment and warnings-by-default behavior. Preserve deferred diagnostics at coordinator, worker and replay completion, including failed worker deactivation, without changing telemetry finalization policy. Add real-checker promotion and diagnostic-preservation regressions.
@MattKotsenas
MattKotsenas force-pushed the bugfix/buildcheck-infrastructure-warning-promotion branch from f62ac6c to d3b252b Compare November 24, 2026 22:52

This branch was previously deployed

1 inactive (outdated) deployment
copilot-pat-pool — f62ac6c2 Deployed Nov 19, 2026 by MattKotsenas via pat_pool #1183
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