Commit 88e6508
* fix: add support for [GenerateGenericTest] on generic classes (#4431)
## Summary
- Fix generic class handling in reflection mode by supporting [GenerateGenericTest] attribute
- Fix init-only property setters for generic types (UnsafeAccessor doesn't work with open generics)
## Changes
- **ReflectionTestDataCollector.cs**: Handle [GenerateGenericTest] attributes that explicitly specify type arguments for generic test classes
- **TestMetadataGenerator.cs**: Use reflection-based setter for init-only properties on generic types instead of UnsafeAccessor
## Test cases
Added test files in TUnit.TestProject/Bugs/4431/ demonstrating:
- Generic class with [GenerateGenericTest] attribute
- Generic class with [ClassDataSource] property injection
- Various combinations of generic classes/methods with data sources
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* fix: address review feedback - AOT compatibility and snapshot tests
- Replace reflection-based setter for init-only properties on generic types
with NotSupportedException (AOT-compatible)
- Add missing verified files for GenericPropertyInjection tests
- Add source generator test for generic method with data source
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 82d75ff commit 88e6508
11 files changed
Lines changed: 6439 additions & 88 deletions
File tree
- TUnit.Core.SourceGenerator.Tests
- TUnit.Core.SourceGenerator/Generators
- TUnit.Engine/Discovery
- TUnit.TestProject/Bugs/4431
Lines changed: 3257 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 81 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
0 commit comments