Skip to content

[skills] Align code-review MSBuild rules with multithreaded tasks - #13756

Merged
jonathanpeppers merged 1 commit into
mainfrom
pureween-ccr-evaluation
Nov 24, 2026
Merged

jonathanpeppers merged 1 commit into
mainfrom
pureween-ccr-evaluation

Conversation

@PureWeen

Copy link
Copy Markdown
Member

Agent assessment

Self-reported assessment, not an independent review.

Assessed revision: 91bc2859d37f59d8648e4084e7e929d62e2e3c3b

Dimension Assessment Rationale
Change confidence 9.5/10 ↑ All referenced task base classes, extension methods, and MSBuildTask0002 analyzer settings verified directly against src/Microsoft.Android.Build.BaseTasks/ and .editorconfig.
↑ Independently reviewed across three model families against 163 audited inline review comments with no conflicting open PRs.
↓ Downstream reviewer behavior in .github/workflows/android-reviewer.md is only exercised on subsequent pull requests.

Context: #13465
Context: #13480
Context: #13504
Context: #13512
Context: #13615

.github/skills/code-review/references/msbuild-rules.md (loaded by .github/workflows/android-reviewer.md during automated pull request reviews) still instructed reviewers to prefer AndroidTask and AsyncTask for MSBuild tasks. That contradicts .github/copilot-instructions.md and Documentation/guides/MSBuildBestPractices.md after #13465 and #13504, where new and migrated tasks must use MultithreadedAndroidTask or MultithreadedAndroidToolTask and declare [MSBuildMultiThreadableTask] directly on each concrete class because AndroidTask, AsyncTask, and AndroidToolTask capture the process working directory in their constructors.

An audit of recent inline review comments surfaced concrete multithreaded-task review gaps in these rules:

  • Task base classes and path canonicalization: flag new tasks on AndroidTask, AsyncTask, or AndroidToolTask, and flag [MSBuildMultiThreadableTask] added to tasks still inheriting those bases ([Xamarin.Android.Build.Tasks] Move library tasks to MABT #13615), while allowing unmigrated legacy tasks to keep their base until all code paths are thread-safe. Document TaskEnvironment.GetAbsolutePath(path).GetCanonicalForm() for collapsing ./.. segments rather than Path.GetFullPath(TaskEnvironment.GetAbsolutePath(...)), which fails MSBuildTask0002 in this repository ([Microsoft.Android.Build.Tasks] Enable multithreaded tasks #13480).
  • Background logging and TaskEnvironment thread safety: migrating an AsyncTask to MultithreadedAndroidTask switches CreateTaskLogger() from the queued AsyncTask overload to MSBuildExtensions.CreateTaskLogger(this Task), which calls task.Log.* directly on background threads ([Xamarin.Android.Build.Tasks] Enable -mt for BootAndroidEmulator #13512). Document keeping background logging marshaled to the executing thread, preserving Yield()/Reacquire() in try/finally, and resolving TaskEnvironment paths and settings before Task.WhenAll fan-out ([Xamarin.Android.Build.Tasks] Move library tasks to MABT #13615).
  • RegisterTaskObject cache keys under -mt: RegisteredTaskObjectLifetime.Build entries are shared across concurrent inner builds of the same project (such as different RIDs or TFMs), and MultithreadedAndroidTask omits ProjectSpecificTaskObjectKey ([Microsoft.Android.Build.Tasks] Enable multithreaded tasks #13480). Require a configuration-specific discriminator such as the resolved absolute intermediate output directory, with matching key type, value, and lifetime across producer and consumer.

Validation: Markdown-only review skill update under .github/skills/; no SDK build or test execution required per .github/skills/tests/SKILL.md. Verified all referenced task types, methods, and analyzer settings against src/Microsoft.Android.Build.BaseTasks/ and .editorconfig.

Context: #13465
Context: #13480
Context: #13504
Context: #13512
Context: #13615

`.github/skills/code-review/references/msbuild-rules.md` (loaded by `.github/workflows/android-reviewer.md` during automated pull request reviews) still instructed reviewers to prefer `AndroidTask` and `AsyncTask` for MSBuild tasks. That contradicts `.github/copilot-instructions.md` and `Documentation/guides/MSBuildBestPractices.md` after `#13465` and `#13504`, where new and migrated tasks must use `MultithreadedAndroidTask` or `MultithreadedAndroidToolTask` and declare `[MSBuildMultiThreadableTask]` directly on each concrete class because `AndroidTask`, `AsyncTask`, and `AndroidToolTask` capture the process working directory in their constructors.

An audit of recent inline review comments surfaced four multithreaded-task review gaps in these rules:

  * Task base classes and path canonicalization: flag new tasks on `AndroidTask`, `AsyncTask`, or `AndroidToolTask`, and flag `[MSBuildMultiThreadableTask]` added to tasks still inheriting those bases (`#13615`), while allowing unmigrated legacy tasks to keep their base until all code paths are thread-safe. Document `TaskEnvironment.GetAbsolutePath(path).GetCanonicalForm()` for collapsing `.`/`..` segments rather than `Path.GetFullPath(TaskEnvironment.GetAbsolutePath(...))`, which fails `MSBuildTask0002` in this repository (`#13480`).
  * Background logging and `TaskEnvironment` thread safety: migrating an `AsyncTask` to `MultithreadedAndroidTask` switches `CreateTaskLogger()` from the queued `AsyncTask` overload to `MSBuildExtensions.CreateTaskLogger(this Task)`, which calls `task.Log.*` directly on background threads (`#13512`). Document keeping background logging marshaled to the executing thread, preserving `Yield()`/`Reacquire()` in `try`/`finally`, and resolving `TaskEnvironment` paths/settings before `Task.WhenAll` fan-out (`#13615`).
  * `RegisterTaskObject` cache keys under `-mt`: `RegisteredTaskObjectLifetime.Build` entries are shared across concurrent inner builds of the same project (such as different RIDs or TFMs), and `MultithreadedAndroidTask` omits `ProjectSpecificTaskObjectKey` (`#13480`). Require a configuration-specific discriminator such as the resolved absolute intermediate output directory, with matching key type, value, and lifetime across producer and consumer.

Validation: Markdown-only review skill update under `.github/skills/`; no SDK build or test execution required per `.github/skills/tests/SKILL.md`. Verified all referenced task types, methods, and analyzer settings against `src/Microsoft.Android.Build.BaseTasks/` and `.editorconfig`.

Co-authored-by: Copilot App <[email protected]>
Copilot AI balanced review requested due to automatic review settings November 24, 2026 18:15

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.

🟢 Approval recommended

No active review issues are recorded for the MSBuild guidance update.

No open issues 🎉

What changed in this PR

Updates the code-review skill’s MSBuild guidance to reflect the repository’s multithreaded task infrastructure. This is a documentation-only change; runtime and build behavior are unchanged.

Changes:

  • Replaces legacy task-base recommendations with multithreaded bases, direct opt-in attributes, and path canonicalization guidance.
  • Clarifies background logging, async lifecycle handling, and safe use of TaskEnvironment during parallel work.
  • Requires configuration-specific cache keys and matching producer/consumer registration contracts.
File Description
.github/​skills/​code-review/​references/​msbuild-rules.md Aligns task, async, path, and cache review rules with multithreaded MSBuild execution.

Review effort: Balanced

@jonathanpeppers
jonathanpeppers merged commit 27e8c39 into main Nov 24, 2026
4 of 8 checks passed
@jonathanpeppers
jonathanpeppers deleted the pureween-ccr-evaluation branch November 24, 2026 18:33
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