Skip to content

Source generators reuse diagnostic IDs for unrelated rules #7504

Closed

Description

@thomhurst

Summary

Source generators assign the same diagnostic IDs to unrelated errors. Suppressing or configuring one rule can therefore affect another rule, and users cannot reliably identify the failure from its ID. Generator IDs should identify a single rule across the packages.

Reproduction

On current main, compare src/TUnit.Core.SourceGenerator/Generators/AotConverterGenerator.cs (lines 73 and 543) with src/TUnit.Assertions.SourceGenerator/Generators/MethodAssertionGenerator.cs (lines 26 and 35). Both declare TUNITGEN001 and TUNITGEN002 for different rules.

Expected and actual

Expected: each generator rule has a unique, documented ID. Actual: IDs collide across the core and assertions generators; there is no shared registry preventing reuse. PR #7503 adds a distinct TUNITGEN005 and surfaced this existing issue during review.

Environment

Repository main at 9d6a435. Please establish unique generator diagnostic IDs with a shared registry or validation and document their meanings.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Medium: edge case, mode divergence, flaky test, or workaround existsbugSomething isn't workingin-progressWork is in progress

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions