Skip to content

Migrate ResolveCodeAnalysisRuleSet to multithreaded execution#13636

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

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.

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 <223556219+Copilot@users.noreply.github.com>
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

1 participant