Skip to content

Migrate ResolveCodeAnalysisRuleSet to multithreaded execution#13636

Open
jankratochvilcz wants to merge 1 commit into
mainfrom
jankratochvilcz/multithreaded/resolve-code-analysis-rule-set
Open

Migrate ResolveCodeAnalysisRuleSet to multithreaded execution#13636
jankratochvilcz wants to merge 1 commit into
mainfrom
jankratochvilcz/multithreaded/resolve-code-analysis-rule-set

Conversation

@jankratochvilcz

Copy link
Copy Markdown
Contributor

Migrates ResolveCodeAnalysisRuleSet to support MSBuild's multithreaded execution model.

Changes

  • [MSBuildMultiThreadableTask] applied; class implements IMultiThreadableTask with TaskEnvironment = TaskEnvironment.Fallback default.
  • Ruleset and include-directory path resolution routed through TaskEnvironment.GetAbsolutePath.

Compatibility audit

Ran the 6-deadly-sins playbook (see .github/skills/multithreaded-task-migration/SKILL.md):

  • Sin 1 ([Output] contamination): ResolvedCodeAnalysisRuleSet is assigned the original CodeAnalysisRuleSet value or the unaltered Path.Combine(directory, CodeAnalysisRuleSet) joined string — no AbsolutePath is ever leaked into the output. Absolutization is used solely for the File.Exists probes.
  • Sin 2 (error message inflation): The Compiler.UnableToFindRuleSet warning continues to be formatted with the original CodeAnalysisRuleSet user input.
  • Sin 3 (?? swallowing exceptions): N/A — no null-coalescing was introduced.
  • Sin 4 (try-catch scope): N/A — no try/catch in this task.
  • Sin 5 (canonicalization): N/A — paths are not used as dictionary/set keys, and the previous code did not call Path.GetFullPath.
  • Sin 6 (empty/null inputs): Empty/null CodeAnalysisRuleSet is short-circuited at the top before any GetAbsolutePath call, preserving the original return null behavior. Empty MSBuildProjectDirectory is still gated by !string.IsNullOrEmpty so we never call GetAbsolutePath with a degenerate combined path.

Validation

  • Microsoft.Build.Tasks.csproj builds clean (0 warnings, 0 errors).
  • ResolveAnalyzerRuleSet_Tests passes on both net10.0 and net472 (12 tests × 2 TFMs = 24 passing).

Part of #11834. Closes #13569.

@jankratochvilcz jankratochvilcz marked this pull request as ready for review July 7, 2026 13:21
Copilot AI review requested due to automatic review settings July 7, 2026 13:22

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 PR migrates the built-in ResolveCodeAnalysisRuleSet task to MSBuild’s multithreaded execution model by adopting IMultiThreadableTask and routing file-probe path resolution through TaskEnvironment so FileExists checks don’t accidentally consume process-wide current-directory state when tasks run concurrently.

Changes:

  • Marked ResolveCodeAnalysisRuleSet as thread-safe ([MSBuildMultiThreadableTask]) and implemented IMultiThreadableTask with a TaskEnvironment property.
  • Updated ruleset probing logic to use TaskEnvironment.GetAbsolutePath(...) for FileExists checks while preserving [Output] ResolvedCodeAnalysisRuleSet string semantics and warning message inputs.

Adds [MSBuildMultiThreadableTask] and IMultiThreadableTask, routing
ruleset and include-directory path resolution through
TaskEnvironment.GetAbsolutePath so the task no longer depends on
process CWD when running under multithreaded mode.

Closes #13569.

Co-authored-by: Copilot <[email protected]>
@jankratochvilcz jankratochvilcz force-pushed the jankratochvilcz/multithreaded/resolve-code-analysis-rule-set branch from a86064a to 0a11cfa Compare July 7, 2026 15:06
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.

Enlighten ResolveCodeAnalysisRuleSet task for multithreaded mode

2 participants