Skip to content

Code fix snapshots render only the first fix when one document has several diagnostics of the same rule #359

Description

@RLittlesII

GeneratorTestContextBuilder renders every ResolvedFixes entry's TextChanges from the first applied fix when a single document carries more than one diagnostic of the same rule. Each entry gets the correct CodeAction.Title, but they all report the same edit.

Two tests work around this today rather than asserting through it:

  • test/CodeFixes.Tests/Usages/Rsa3002FixTests.cs — GivenSource_WhenCodeFix_ThenVerify is [Theory(Skip = "Verify output seems odd.")]
  • test/CodeFixes.Tests/Design/Rsa2011FixTests.cs — GivenTypeAndMember_WhenCodeFix_ThenEachDeclaresItsOwnDefault asserts only the action titles, with a comment pointing at this limitation

The RSA2011 case is the clearer illustration. A type in a namespace defaults to internal and a member of a type to private, so one document with both produces two fixes inserting different text. The titles come back correct (Declare 'internal' explicitly, Declare 'private' explicitly) but both entries report internal as the inserted text. The fix itself is correct — single-diagnostic snapshots confirm internal class and private void respectively — so this is a harness reporting problem, not a product bug.

Worth either fixing in Rocket.Surgery.Extensions.Testing.SourceGenerators or documenting as intended, so these two tests can assert the real output and the skip can come off.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    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