diff --git a/TUnit.Analyzers/AnalyzerReleases.Shipped.md b/TUnit.Analyzers/AnalyzerReleases.Shipped.md index 3985959552..7438273863 100644 --- a/TUnit.Analyzers/AnalyzerReleases.Shipped.md +++ b/TUnit.Analyzers/AnalyzerReleases.Shipped.md @@ -28,7 +28,7 @@ TUnit0038 | Usage | Error | Property with data attribute must have a data source TUnit0043 | Usage | Error | Properties with data attributes must use 'required' keyword TUnit0044 | Usage | Error | Properties with data attributes must have a setter TUnit0045 | Usage | Error | Property has multiple data source attributes - use only one -TUnit0046 | Usage | Warning | Data source should return Func for lazy evaluation instead of T +TUnit0046 | Usage | Warning | Data source should return Func for reference types to ensure test isolation TUnit0049 | Usage | Error | [Matrix] parameters require [MatrixDataSource] attribute on the test method TUnit0050 | Usage | Error | Too many test arguments provided TUnit0056 | Usage | Error | Instance data source methods must use [InstanceMethodDataSource] attribute diff --git a/TUnit.Analyzers/Resources.resx b/TUnit.Analyzers/Resources.resx index b68d6eadff..4482dd6a1e 100644 --- a/TUnit.Analyzers/Resources.resx +++ b/TUnit.Analyzers/Resources.resx @@ -328,13 +328,13 @@ Too many data attributes - Return a `Func<T>` rather than a `<T>`. + When a data source method provides reference types (other than string) as test parameters, it should return Func<T> to defer object creation until the test runs. This prevents shared state between tests and ensures proper test isolation. - Return a `Func<T>` rather than a `<T>`. + Data source method should return Func<T> for reference type parameters (other than string) to ensure proper test isolation - Return a `Func<T>` rather than a `<T>` + Data source should return Func<T> for reference types For AsyncLocal values set in before hooks, you must call `context.AddAsyncLocalValues` to access them within tests.