Skip to content

Clarify ClassDataSource constructor requirements - #6716

Merged
thomhurst merged 2 commits into
mainfrom
docs/class-data-source-constructor-requirements
Sep 3, 2026
Merged

thomhurst merged 2 commits into
mainfrom
docs/class-data-source-constructor-requirements

Conversation

@thomhurst

@thomhurst thomhurst commented Sep 3, 2026

Copy link
Copy Markdown
Owner

Summary

  • Document the accessible parameterless constructor requirement for ClassDataSource<T> types.
  • Distinguish supported test-class constructor injection from unsupported constructor injection inside data source types.
  • Add a nested property-injection example and cross-reference the detailed guide.

Validation

  • yarn build from docs

Refs #6694

Summary by CodeRabbit

  • Documentation
    • Clarified that ClassDataSource<T> types require a public parameterless constructor.
    • Recommended property injection for nested dependencies within data sources.
    • Added guidance and an example for asynchronously initializing dependent fixtures.
    • Documented that constructor-injected dependencies inside data source types are not currently supported.
    • Updated shared-fixture guidance to clarify test-class constructor parameter usage.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@greptile-apps

greptile-apps Bot commented Sep 3, 2026

Copy link
Copy Markdown

Greptile Summary

The PR clarifies the construction rules for ClassDataSource<T> and distinguishes test-class constructor injection from nested data-source dependency injection.

  • States consistently that data-source types require a public parameterless constructor.
  • Recommends property injection for nested dependencies.
  • Adds an initialization-order example and links to the detailed nested-property-injection guide.

Confidence Score: 5/5

The documentation-only PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
README.md Clarifies that constructor parameters are supported on test classes while data-source types require public parameterless constructors.
docs/docs/writing-tests/class-data-source.md Documents the public-constructor requirement and adds a nested property-injection example with lifecycle guidance.
docs/docs/writing-tests/nested-data-sources.md Explicitly directs nested data-source dependencies to property injection and accurately states the public-constructor requirement.

Reviews (2): Last reviewed commit: "docs: require public ClassDataSource con..." | Re-trigger Greptile

Comment thread docs/docs/writing-tests/class-data-source.md Outdated
@coderabbitai

coderabbitai Bot commented Sep 3, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: 01526aa2-a1be-41e1-8633-e342a6a85327

📥 Commits

Reviewing files that changed from the base of the PR and between 8685475 and 2d22632.

📒 Files selected for processing (3)
  • README.md
  • docs/docs/writing-tests/class-data-source.md
  • docs/docs/writing-tests/nested-data-sources.md
🚧 Files skipped from review as they are similar to previous changes (3)
  • README.md
  • docs/docs/writing-tests/nested-data-sources.md
  • docs/docs/writing-tests/class-data-source.md

Included review availability: Your plan provides up to 8 included reviews per hour; 2 remain after this review.


📝 Walkthrough

Walkthrough

The documentation states that ClassDataSource<T> requires a public parameterless constructor. It recommends property injection for nested dependencies and documents constructor injection on the receiving test class.

Changes

ClassDataSource documentation

Layer / File(s) Summary
Constructor and nested dependency guidance
docs/docs/writing-tests/class-data-source.md, docs/docs/writing-tests/nested-data-sources.md, README.md
The documentation explains ClassDataSource<T> constructor requirements, distinguishes test-class constructor injection from data-source construction, and provides an IAsyncInitializer example using property injection for nested dependencies.

Estimated code review effort: 1 (Trivial) | ~3 minutes

Merge Risk: ⚪ Minimal · up to 2d226

This documentation update clarifies supported dependency injection patterns for ClassDataSource types, with no identified merge-readiness risk.

Poem

A rabbit reads the fixture guide,
With nested properties safe inside.
A public constructor marks the way,
While async fixtures start the day.
Clear documentation leads the way.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: documenting the constructor requirements for ClassDataSource types.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0 files. (3 skipped: 3 unsupported.)

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch docs/class-data-source-constructor-requirements

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@claude

claude Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Code review

Reviewed the diff (README.md, docs/docs/writing-tests/class-data-source.md, docs/docs/writing-tests/nested-data-sources.md) — this is a documentation-only change with no source-gen or reflection-engine code touched, so the dual-mode requirement in CLAUDE.md doesn't apply here.

Technical accuracy check: I verified the core claim against the implementation rather than taking it on faith. ClassDataSources.Create (src/TUnit.Core/Attributes/TestData/ClassDataSources.cs:92) instantiates data-source types via Activator.CreateInstance(type) with no constructor arguments — which does require a public parameterless constructor. The new docs and example (nested ApplicationFixture/DatabaseFixture using property injection + IAsyncInitializer) accurately reflect this behavior and the initialization order described in nested-data-sources.md.

No issues found. The added example is clear, the distinction between test-class constructor injection (supported) and data-source constructor injection (unsupported) is well explained, and no CLAUDE.md rules are implicated by a docs-only change. Nothing to flag architecturally — this is straightforward prose/example documentation, not a case where alternative designs apply.

🤖 Generated with automated code review

@thomhurst
thomhurst merged commit add2b5a into main Sep 3, 2026
18 checks passed
@thomhurst
thomhurst deleted the docs/class-data-source-constructor-requirements branch September 3, 2026 22:19
intellitect-bot pushed a commit to IntelliTect/EssentialCSharp.Web that referenced this pull request Sep 4, 2026
Updated [TUnit](https://github.com/thomhurst/TUnit) from 1.65.68 to
1.66.0.

<details>
<summary>Release notes</summary>

_Sourced from [TUnit's
releases](https://github.com/thomhurst/TUnit/releases)._

## 1.66.0

<!-- Release notes generated using configuration in .github/release.yml
at v1.66.0 -->

## What's Changed
### Other Changes
* Compile all C# documentation snippets by @​thomhurst in
thomhurst/TUnit#6695
* Fix `Type` assignability assertions to evaluate represented type (not
`RuntimeType`) by @​thomhurst with @​Copilot in
thomhurst/TUnit#6711
* Clarify ClassDataSource constructor requirements by @​thomhurst in
thomhurst/TUnit#6716
* Add programmatic HTML reporting settings by @​thomhurst in
thomhurst/TUnit#6699
* Fix timeout cancellation diagnostics by @​thomhurst in
thomhurst/TUnit#6715
### Dependencies
* chore(deps): update tunit to 1.65.68 by @​thomhurst in
thomhurst/TUnit#6682
* chore(deps): update dependency verify.tool to v0.9.1 by @​thomhurst in
thomhurst/TUnit#6683
* chore(deps): update dependency mockolate to 3.4.1 by @​thomhurst in
thomhurst/TUnit#6685
* chore(deps): update dependency serialize-javascript to v7.1.1 by
@​thomhurst in thomhurst/TUnit#6687
* chore(deps): update dependency qs to v6.16.0 by @​thomhurst in
thomhurst/TUnit#6691
* chore(deps): update dependency system.reactive to v7 by @​thomhurst in
thomhurst/TUnit#6696
* chore(deps): update dependency imposter to 0.1.10 by @​thomhurst in
thomhurst/TUnit#6701
* chore(deps): update dependency microsoft.kiota.abstractions to 2.1.0
by @​thomhurst in thomhurst/TUnit#6704
* chore(deps): update mstest to 4.4.0 by @​thomhurst in
thomhurst/TUnit#6705
* chore(deps): update dependency dotnet-trace to v10 by @​thomhurst in
thomhurst/TUnit#6706
* chore(deps): update microsoft.testing by @​thomhurst in
thomhurst/TUnit#6703
* chore(deps): update microsoft.testing by @​thomhurst in
thomhurst/TUnit#6713
* chore(deps): bump fast-uri from 3.1.5 to 3.1.7 in /docs by
@​dependabot[bot] in thomhurst/TUnit#6707


**Full Changelog**:
thomhurst/TUnit@v1.65.68...v1.66.0

Commits viewable in [compare
view](thomhurst/TUnit@v1.65.68...v1.66.0).
</details>

Updated [TUnit.AspNetCore](https://github.com/thomhurst/TUnit) from
1.65.68 to 1.66.0.

<details>
<summary>Release notes</summary>

_Sourced from [TUnit.AspNetCore's
releases](https://github.com/thomhurst/TUnit/releases)._

## 1.66.0

<!-- Release notes generated using configuration in .github/release.yml
at v1.66.0 -->

## What's Changed
### Other Changes
* Compile all C# documentation snippets by @​thomhurst in
thomhurst/TUnit#6695
* Fix `Type` assignability assertions to evaluate represented type (not
`RuntimeType`) by @​thomhurst with @​Copilot in
thomhurst/TUnit#6711
* Clarify ClassDataSource constructor requirements by @​thomhurst in
thomhurst/TUnit#6716
* Add programmatic HTML reporting settings by @​thomhurst in
thomhurst/TUnit#6699
* Fix timeout cancellation diagnostics by @​thomhurst in
thomhurst/TUnit#6715
### Dependencies
* chore(deps): update tunit to 1.65.68 by @​thomhurst in
thomhurst/TUnit#6682
* chore(deps): update dependency verify.tool to v0.9.1 by @​thomhurst in
thomhurst/TUnit#6683
* chore(deps): update dependency mockolate to 3.4.1 by @​thomhurst in
thomhurst/TUnit#6685
* chore(deps): update dependency serialize-javascript to v7.1.1 by
@​thomhurst in thomhurst/TUnit#6687
* chore(deps): update dependency qs to v6.16.0 by @​thomhurst in
thomhurst/TUnit#6691
* chore(deps): update dependency system.reactive to v7 by @​thomhurst in
thomhurst/TUnit#6696
* chore(deps): update dependency imposter to 0.1.10 by @​thomhurst in
thomhurst/TUnit#6701
* chore(deps): update dependency microsoft.kiota.abstractions to 2.1.0
by @​thomhurst in thomhurst/TUnit#6704
* chore(deps): update mstest to 4.4.0 by @​thomhurst in
thomhurst/TUnit#6705
* chore(deps): update dependency dotnet-trace to v10 by @​thomhurst in
thomhurst/TUnit#6706
* chore(deps): update microsoft.testing by @​thomhurst in
thomhurst/TUnit#6703
* chore(deps): update microsoft.testing by @​thomhurst in
thomhurst/TUnit#6713
* chore(deps): bump fast-uri from 3.1.5 to 3.1.7 in /docs by
@​dependabot[bot] in thomhurst/TUnit#6707


**Full Changelog**:
thomhurst/TUnit@v1.65.68...v1.66.0

Commits viewable in [compare
view](thomhurst/TUnit@v1.65.68...v1.66.0).
</details>

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This was referenced Sep 16, 2026
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.

1 participant