Skip to content

Migrate ShowPreviewMessage to IMultiThreadableTask - #53956

Merged
OvesN merged 4 commits into
dotnet:mainfrom
SimaTian:migrate-show-preview-message
May 13, 2026
Merged

OvesN merged 4 commits into
dotnet:mainfrom
SimaTian:migrate-show-preview-message

Conversation

@SimaTian

@SimaTian SimaTian commented Apr 17, 2026 •

Copy link
Copy Markdown
Contributor

Context

The ShowPreviewMessage task was migrated to support multithreaded execution
under MSBuild's IMultiThreadableTask model.

Changes Made

ShowPreviewMessage.cs

  • Hardened the "preview SDK" message guard against concurrent execution by
    multiple task instances:
  • Added a fast-path GetRegisteredTaskObject check before taking any lock.
  • Wrapped the registration in a static lock with a double-checked
    GetRegisteredTaskObject call so the message is logged and the marker
    object is registered exactly once per build, even when several
    ShowPreviewMessage instances run in parallel.

Supersedes

Part of the split of stuck merge-group PR #52936. This is the 5-of-5 split for \ShowPreviewMessage.

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

Migrates ShowPreviewMessage to participate in MSBuild’s multithreaded task execution model by marking it as multithreadable and implementing IMultiThreadableTask, with accompanying unit tests validating expected behavior.

Changes:

  • Adds [MSBuildMultiThreadableTask] and implements IMultiThreadableTask on ShowPreviewMessage, including a TaskEnvironment property.
  • Introduces new unit tests covering interface implementation, guard/registration behavior, logging behavior, and per-engine isolation.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/Tasks/Microsoft.NET.Build.Tasks/ShowPreviewMessage.cs Marks the task as multithreadable and adds the IMultiThreadableTask TaskEnvironment property (with NETFRAMEWORK handling).
src/Tasks/Microsoft.NET.Build.Tasks.UnitTests/GivenAShowPreviewMessageMultiThreading.cs Adds unit tests validating multithreadable task requirements and expected logging/guard behavior.

SimaTian and others added 4 commits May 13, 2026 12:16
- Add [MSBuildMultiThreadableTask] attribute to support multi-threaded execution
- Implement IMultiThreadableTask interface with TaskEnvironment property
- Conditional implementation for NETFRAMEWORK vs other targets
- Add comprehensive unit tests for multi-threading scenarios

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@SimaTian
SimaTian force-pushed the migrate-show-preview-message branch from f3ea3ae to 4dd95b7 Compare May 13, 2026 10:24
@OvesN
OvesN merged commit 20d2ea7 into dotnet:main May 13, 2026
24 checks passed
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.

4 participants