Scope MT-specific TaskAnalyzer diagnostics to MT tasks by default - #14775
Scope MT-specific TaskAnalyzer diagnostics to MT tasks by default#14775VolPlita wants to merge 6 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Adjusts TaskAnalyzer’s default analysis behavior so multi-threading (MT) diagnostics don’t introduce new warnings for “regular” tasks when the analyzer ships broadly (e.g., with Microsoft.Build.Framework), while still allowing an explicit migration mode to analyze all tasks.
Changes:
- Changed the default scope behavior to analyze MT-specific rules only for MT-opted-in tasks, with
scope=allenabling migration-mode analysis for all tasks. - Applied scope gating to MSBuildTask0002/MSBuildTask0003 and to task-root selection for MSBuildTask0005, with new/updated tests covering default/all/invalid values.
- Updated analyzer documentation/comments to reflect the new default behavior (with a remaining config-mechanism doc mismatch noted in PR comments).
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/TaskAnalyzer/SharedAnalyzerHelpers.cs | Changes scope option parsing to default to MT-only and only enable all-tasks when explicitly set to all. |
| src/TaskAnalyzer/MultiThreadableTaskAnalyzer.cs | Updates scope documentation/comments to match new default behavior. |
| src/TaskAnalyzer/README.md | Updates public documentation for new default scope and migration-mode behavior. |
| src/TaskAnalyzer.Tests/TestHelpers.cs | Refactors helpers to make “all” explicit and adds helpers for default-scope runs. |
| src/TaskAnalyzer.Tests/MultiThreadableTaskAnalyzerTests.cs | Adds tests validating default vs all scope behavior and invalid values. |
| src/TaskAnalyzer.Tests/TransitiveCallChainAnalyzerTests.cs | Adds tests validating MSBuildTask0005 behavior under default vs all scope. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
| @@ -17,8 +17,8 @@ namespace Microsoft.Build.TaskAuthoring.Analyzer | |||
| /// Roslyn analyzer that detects unsafe API usage in MSBuild task implementations. | |||
| /// | |||
| /// Scope (controlled by .editorconfig option "msbuild_task_analyzer.scope"): | |||
| @@ -18,25 +18,25 @@ internal static class SharedAnalyzerHelpers | |||
| { | |||
| /// <summary> | |||
| /// The .editorconfig key controlling analysis scope. | |||
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
@VolPlita please resolve the conflict and give this PR a more meaningful title |
|
expert review AI report: Blocking
Major • Config path (your question #2): ship + build/*.props . Avoid per-tree .editorconfig — MSBuildTask0005 filters at CompilationEnd and has no syntax tree, so scopes would disagree. Moderate • Transitive analyzer builds the full compilation call graph, then discards it at CompilationEnd under the new default — pure cost for the common case. Nits: title typo ("nt" → "mt"), missing newline at EOF, ImplementsInterface helper open-coded. |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…askItem<T> (#14811) Part of #14078. ### Summary Aligns TaskAnalyzer descriptor severities with the documented intent and prevents an unsupported-type false positive when a task uses an open generic `ITaskItem<T>` property. This PR intentionally does **not** change `msbuild_task_analyzer.scope`. The scope-policy implementation and tests belong to #14775 and are excluded from this PR. ### Changes - Changes MSBuildTask0006, MSBuildTask0007, and MSBuildTask0008 from **Warning** to **Info**. These rules provide modernization suggestions with code fixes; they do not report invalid task definitions. - Changes MSBuildTask0010 from **Error** to **Warning**. `Convert.ChangeType` binding succeeds, but its invariant-culture behavior may not match the task's intended parsing semantics. - Keeps MSBuildTask0009 as **Warning**, avoiding a new unconditional build break for existing analyzer consumers. - Skips MSBuildTask0009 for open generic `ITaskItem<T>` properties because an unresolved type parameter does not provide enough information to determine whether the closed task parameter will be supported. - Updates `DiagnosticDescriptors.cs`, `AnalyzerReleases.Unshipped.md`, the README, and analyzer tests so all severity declarations agree. - Adds coverage showing typed task-item diagnostics apply to regular tasks independently of MT opt-in and that open generic task-item properties do not produce a diagnostic. ### Compatibility The severity changes only reduce diagnostics from Warning/Error to Info/Warning. No new warning or error is introduced, and analyzer scope behavior is unchanged. ### Testing - `.dotnet\dotnet.exe test src\TaskAnalyzer.Tests\TaskAnalyzer.Tests.csproj -c Release`: 250 passed, 0 failed, 0 skipped. - `.\build.cmd -v quiet`: succeeded with 0 warnings and 0 errors. ### Related - #14775 owns the analyzer scope-policy change and is not reimplemented here. - MSBuildTask0005 redesign remains follow-up work in #14777. --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
/azp run |
|
Azure Pipelines will not run the associated pipelines, because the pull request was updated after the run command was issued. Review the pull request again and issue a new run command. |
|
@copilot resolve the merge conflicts in this pull request |
Part of #14078
Context
This is a narrow, incremental scope change for MT-specific migration diagnostics. It does not define TaskAnalyzer's complete shipping policy.
MSBuildTask0002, MSBuildTask0003, and related MSBuildTask0005 findings describe MT migration work. Reporting them on every regular task by default can add warnings when customers only update the analyzer package. Always-applicable MSBuildTask0001 and MSBuildTask0004 findings remain active for regular tasks, including through MSBuildTask0005 call chains.
Changes Made
multithreadable_onlyas the default scope for MSBuildTask0002, MSBuildTask0003, and their transitive MSBuildTask0005 findings.allas an explicit migration mode.IMultiThreadableTask,[MSBuildMultiThreadableTask], and[MSBuildMultiThreadableTaskAnalyzed]as MT opt-ins.msbuild_task_analyzer.scopeglobal option and removes the unreachable dottedbuild_propertylookup..globalconfigtests for direct and transitive analysis. A section-based.editorconfigintentionally does not set this compilation-wide option.IMultiThreadableTask,[MSBuildMultiThreadableTask], and[MSBuildMultiThreadableTaskAnalyzed].Microsoft.Build.Taskswithscope = allonly whenBuildAnalyzer=true, preserving repository migration coverage.Testing
TaskAnalyzer.Tests: 282 passed, 0 failed, 0 skipped.TaskAnalyzer.globalconfigis included only whenBuildAnalyzer=true.Scope Relative to Follow-up PRs
The direct migration configuration supported by this PR is: