Skip to content

Commit 6874e1a

Browse files
committed
docs: fix DI attribute example
1 parent a2cff69 commit 6874e1a

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

docs/docs/test-lifecycle/property-injection.md

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ The required keyword keeps your code clean and correct. If a property isn't pass
88
## AOT-Compatible Property Attributes
99

1010
Supported attributes for properties in AOT mode:
11-
- **Argument** - Compile-time constant values
12-
- **MethodDataSource** - Static method data sources
13-
- **ClassDataSource** - Static class-based data sources
11+
- **MethodDataSource** - Data sources via calling a method
12+
- **ClassDataSource<T>** - A data source that injects in T
1413
- **DataSourceGeneratorAttribute** - Source-generated data (first item only)
15-
- **ClassDataSource** - Dependency injection with service provider
14+
15+
For dependency injection with service providers, inherit from `DependencyInjectionDataSourceAttribute<TScope>` to create custom attributes. See [Dependency Injection](./dependency-injection.md) documentation for details.
1616

1717
The AOT system generates strongly-typed property setters at compile time, eliminating reflection overhead and ensuring Native AOT compatibility.
1818

@@ -55,10 +55,6 @@ namespace MyTestProject;
5555

5656
public class PropertySetterTests
5757
{
58-
// Compile-time constant injection
59-
[Arguments("1")]
60-
public required string Property1 { get; init; }
61-
6258
// Static method data source injection
6359
[MethodDataSource(nameof(GetMethodData))]
6460
public required string Property2 { get; init; }
@@ -83,15 +79,14 @@ public class PropertySetterTests
8379
[DataSourceGeneratorTests.AutoFixtureGenerator<string>]
8480
public required string Property7 { get; init; }
8581

86-
// Service provider dependency injection
82+
// Async initialization example (IAsyncInitializer)
8783
[ClassDataSource<AsyncPropertyExample>]
8884
public required AsyncPropertyExample AsyncService { get; init; }
8985

9086
[Test]
9187
public async Task Test()
9288
{
9389
// All properties are automatically initialized before this test runs
94-
await Assert.That(Property1).IsEqualTo("1");
9590
await Assert.That(Property2).IsNotNull();
9691
await Assert.That(Property3).IsNotNull();
9792
await Assert.That(AsyncService.IsInitialized).IsTrue();

0 commit comments

Comments
 (0)