Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Aug 16, 2025

The documentation referenced [DataSourceGeneratorProperty<T>] attribute for nested data source initialization, but this attribute doesn't exist in the codebase. Users trying to follow the documentation examples would encounter compilation errors.

Problem

The issue was reported in the nested data sources documentation at https://tunit.dev/docs/test-authoring/nested-data-sources where examples showed:

[DataSourceGeneratorProperty<RedisTestContainer>]
public required RedisTestContainer Redis { get; init; }

However, DataSourceGeneratorProperty is not implemented in TUnit.Core, causing compilation failures for users following the documentation.

Solution

Updated all documentation to use [ClassDataSource<T>] which is a real attribute that implements IDataSourceAttribute and supports property injection. The corrected pattern is:

[ClassDataSource<RedisTestContainer>]
public required RedisTestContainer Redis { get; init; }

Changes Made

  • docs/docs/test-authoring/nested-data-sources.md: Replaced all instances of [DataSourceGeneratorProperty<T>] with [ClassDataSource<T>]
  • docs/examples/nested-data-sources-example.md: Updated examples to use the correct attribute
  • docs/examples/nested-data-sources-quickstart.md: Updated examples to use the correct attribute
  • Updated explanatory text to mention "any attribute implementing IDataSourceAttribute" for broader applicability

Verification

  • Build succeeds with no compilation errors
  • Existing tests in PropertyDataSourceInjectionTests.cs confirm [ClassDataSource<T>] works correctly for property injection
  • No remaining references to the non-existent attribute in the documentation

Users can now successfully follow the documentation examples for nested data source initialization.

Fixes #2928.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

…ith ClassDataSource<T>

Co-authored-by: thomhurst <30480171+thomhurst@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] DataSourceGeneratorProperty Not Found Fix documentation: Replace non-existent DataSourceGeneratorProperty with ClassDataSource<T> Aug 16, 2025
@Copilot Copilot AI requested a review from thomhurst August 16, 2025 15:16
Copilot finished work on behalf of thomhurst August 16, 2025 15:16
@thomhurst thomhurst marked this pull request as ready for review August 16, 2025 15:21
@thomhurst thomhurst merged commit c2a89c6 into main Aug 16, 2025
4 checks passed
@thomhurst thomhurst deleted the copilot/fix-2928 branch August 16, 2025 15:21
This was referenced Aug 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DataSourceGeneratorProperty Not Found
2 participants