Problem
MT-related TaskAnalyzer diagnostics can also provide useful migration guidance for non-MT tasks. However, reporting them as warnings or errors for those tasks can disrupt builds that are not adopting multithreaded task execution.
Non-MT tasks should still receive the selected diagnostics, but only as suggestions or informational messages. MT-scoped tasks need stronger enforcement because unsafe behavior can affect other tasks running in the shared process.
Proposed behavior
For selected MT-related diagnostics:
- Report them as Suggestion/Info for non-MT tasks, so migration guidance remains visible in the IDE without normally affecting command-line builds.
- Report the same diagnostic IDs at their intended Warning or Error severity for MT-scoped tasks.
- Always let an explicit
dotnet_diagnostic.<ID>.severity setting in .editorconfig or .globalconfig override the analyzer's contextual default.
This should apply only to diagnostics that the team wants to enforce strongly for MT tasks. Disabled and advisory rules must retain their intended defaults.
Scope and implementation
This issue covers two parts of the same change:
- Behavior: report selected MT-related diagnostics as Suggestion/Info for non-MT tasks while retaining Warning/Error enforcement for MT-scoped tasks.
- Implementation: add contextual severity to TaskAnalyzer so it can select the appropriate default severity from the task context while preserving the same diagnostic ID and standard analyzer configuration.
Contextual severity is the mechanism required to implement the behavior, not a separate independent feature. The implementation must verify that an explicit dotnet_diagnostic.<ID>.severity setting overrides the contextual default for both MT and non-MT tasks.
Design questions
Related: #14775, #14990
Problem
MT-related TaskAnalyzer diagnostics can also provide useful migration guidance for non-MT tasks. However, reporting them as warnings or errors for those tasks can disrupt builds that are not adopting multithreaded task execution.
Non-MT tasks should still receive the selected diagnostics, but only as suggestions or informational messages. MT-scoped tasks need stronger enforcement because unsafe behavior can affect other tasks running in the shared process.
Proposed behavior
For selected MT-related diagnostics:
dotnet_diagnostic.<ID>.severitysetting in.editorconfigor.globalconfigoverride the analyzer's contextual default.This should apply only to diagnostics that the team wants to enforce strongly for MT tasks. Disabled and advisory rules must retain their intended defaults.
Scope and implementation
This issue covers two parts of the same change:
Contextual severity is the mechanism required to implement the behavior, not a separate independent feature. The implementation must verify that an explicit
dotnet_diagnostic.<ID>.severitysetting overrides the contextual default for both MT and non-MT tasks.Design questions
msbuild_task_analyzer.run_mt_analyzers_on_all_tasksfrom Scope MT-specific TaskAnalyzer diagnostics and support .editorconfig #14775?Related: #14775, #14990