Skip to content

TaskAnalyzer: lower non-MT rule severity and recognize directly declared IMultiThreadableTask #14993

Closed

Description

@VolPlita

Context

The next TaskAnalyzer follow-up should prioritize reducing noise for task authors who are not doing MT migration, then refine how MT migration intent is detected.

Changes

Implement these changes in the following order. The severity change is the first and highest-priority part of the follow-up.

  1. First: lower non-MT analyzer defaults to Suggestion/Info.

    Change MSBuildTask0001 from Error to Info and MSBuildTask0009 and MSBuildTask0010 from Warning to Info. MSBuildTask0006–MSBuildTask0008 and MSBuildTask0011 are already Info. MSBuildTask0001 continues to diagnose APIs that are never safe in any MSBuild task, but defaults to Info to avoid breaking builds that consume a newer analyzer package.

  2. Then: accept a directly declared IMultiThreadableTask interface as MT analyzer intent.

    MSBuildTask0002, MSBuildTask0003, and their related MSBuildTask0005 findings should run by default when the task class itself declares IMultiThreadableTask.

    A task that only inherits the interface from a base class must not become MT-scoped for analyzer purposes. Detection must inspect the interfaces declared directly on the task (INamedTypeSymbol.Interfaces), not all inherited interfaces (AllInterfaces).

This analyzer signal represents migration intent only. It does not change runtime routing: [MSBuildMultiThreadableTask] remains the attribute that routes a task to the MT environment.

Acceptance criteria

  • MSBuildTask0001, MSBuildTask0009, and MSBuildTask0010 default to Info.
  • Existing explicit dotnet_diagnostic.<ID>.severity configuration continues to override their defaults.
  • A task that directly declares IMultiThreadableTask receives default MSBuildTask0002/0003 diagnostics and related transitive MSBuildTask0005 diagnostics.
  • A task that only inherits IMultiThreadableTask does not become MT-scoped.
  • Existing attribute-based task and helper opt-ins continue to work.
  • Tests cover direct declaration, inherited interface, direct diagnostics, transitive diagnostics, and configured severity overrides.
  • Documentation clearly distinguishes analyzer migration intent from runtime MT routing.

Compatibility

Lowering MSBuildTask0001, MSBuildTask0009, and MSBuildTask0010 to Info is a compatibility relaxation. Recognizing a directly declared IMultiThreadableTask can surface MT migration warnings, but only for task authors who explicitly declare the migration interface.

Related: #14775, #14990

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions