Skip to content

TUnit0004 rejects inherited property sources supplied by the derived test class #7551

Open

Description

@thomhurst

An inherited property decorated with MethodDataSource("Rows") can resolve Rows on the derived test class during generated and reflection execution, but the analyzer reports TUnit0004 on the base property. This prevents compiling an otherwise supported data source.

Reproduction

In a TUnit test project:

public abstract class Base
{
    [TUnit.Core.MethodDataSource("Rows")]
    public int Value { get; set; }
}
public class Tests : Base
{
    public static int Rows() => 49;
    [TUnit.Core.Test]
    public void Test() { }
}

Expected and actual

Allow the derived test class to supply the property source, matching TestMetadataGenerator.GeneratePropertyDataSources and reflection execution. Currently TUnit0004 reports that the source method is missing at the base property.

Environment

Repository head a8babf9, SDK 10.0.403, macOS arm64. Found while validating #7547; its regression narrowly suppresses this diagnostic.

Acceptance criteria

  • The reproduction compiles without suppressing TUnit0004 when the inherited property source is supplied by the concrete derived test class.
  • Add analyzer regression coverage for this inherited-property case and retain diagnostics for genuinely missing data-source members.
  • Verify the inherited property receives the derived source value in generated and reflection execution.

Activity

  1. added
    bugSomething isn't working
    P2Medium: edge case, mode divergence, flaky test, or workaround exists
    on Nov 4, 2026
  2. thomhurst commented on Nov 4, 2026

    @thomhurst
    OwnerAuthor

    Audited against main at 10a0af7. TestDataAnalyzer.AnalyzeProperty still passes propertySymbol.ContainingType (lines 86–87), and CheckMethodDataSource searches only that type and its bases before reporting TUnit0004 (lines 437–469). TestMetadataGenerator.GeneratePropertyDataSources instead passes the concrete test type when generating inherited property sources.

    #7547 changes generator/converter discovery, not this analyzer, so it does not supersede or block this fix. Added acceptance criteria; this issue remains open and available for implementation.

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

    P2Medium: edge case, mode divergence, flaky test, or workaround existsbugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions