Skip to content

TaskAnalyzer: report MT diagnostics as suggestions for non-MT tasks #14991

Description

@VolPlita

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:

  1. Behavior: report selected MT-related diagnostics as Suggestion/Info for non-MT tasks while retaining Warning/Error enforcement for MT-scoped tasks.
  2. 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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions