You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat: allow class-level [MatrixDataSource] to cascade to methods with [Matrix] parameters #4765
When a class has multiple test methods using `[Matrix]` parameters, `[MatrixDataSource]` must be repeated on every method:
```csharp
[Category("Search")]
public class ProductSearchTests
{
[Test]
[MatrixDataSource] // must repeat
public async Task Search_Returns_Results(
[Matrix("electronics", "clothing", "books")] string category,
[Matrix("price_asc", "price_desc", "name")] string sortBy) { }
[Test]
[MatrixDataSource] // must repeat again
public async Task Pagination_Works(
[Matrix(1, 2, 3)] int page,
[Matrix(2, 5)] int pageSize) { }
}
```
Placing `[MatrixDataSource]` on the class doesn't work - you get TUnit0049 errors on each method.
Proposed Behavior
`[MatrixDataSource]` on the class should cascade to any method that has `[Matrix]` parameters:
```csharp
[MatrixDataSource] // applies to all methods with [Matrix] params
public class ProductSearchTests
{
[Test]
public async Task Search_Returns_Results(
[Matrix("electronics", "clothing", "books")] string category,
[Matrix("price_asc", "price_desc", "name")] string sortBy) { }
[Test]
public async Task Pagination_Works(
[Matrix(1, 2, 3)] int page,
[Matrix(2, 5)] int pageSize) { }
[Test]
public async Task Non_Matrix_Test() { } // no [Matrix] params, unaffected
}
```
Methods without `[Matrix]` parameters would be unaffected. Methods with explicit `[MatrixDataSource]` would override the class-level attribute if needed.
Context
Discovered while building the CloudShop Aspire + TUnit example (#4761). The `ProductSearchTests` class had to repeat the attribute on every method.
Closing - by design, data source attributes on a class apply to constructor parameters, not to individual test methods. [MatrixDataSource] should remain on each test method that uses [Matrix] parameters.
Activity
claude commentedon Feb 13, 2026
Issue Analysis
Type: Feature Request (Enhancement) ✓
Priority: Medium
No Duplicates Found
Searched for similar issues involving:
Current Labels:
Suggested Additional Labels:
help wanted- if open to community contributionsNotes:
[Matrix]parameters[Matrix]params unaffected[MatrixDataSource]can override class-levelThis is a good quality feature request with clear motivation and scope.
thomhurst commentedon Feb 13, 2026
Closing - by design, data source attributes on a class apply to constructor parameters, not to individual test methods.
[MatrixDataSource]should remain on each test method that uses[Matrix]parameters.