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
Generated property injection assigns dependencies to a copy of struct arguments #7609
Struct arguments with [ClassDataSource<T>] properties receive a null dependency when generated property metadata is used. The generated setter casts the boxed argument into a local struct copy and assigns the property on that copy, so tests never receive the injected value.
Reproduction
usingTUnit.Core;publicclassStructInjectionTests{publicstaticFunc<Fixture>Row()=>()=>newFixture();[Test,MethodDataSource(nameof(Row))]publicvoidTest(Fixturefixture){if(fixture.Dependencyisnull)thrownewInvalidOperationException("Dependency was not injected");}publicstructFixture{[ClassDataSource<Dependency>]publicDependency?Dependency{get;set;}}publicsealedclassDependency;}
Expected and actual
The test should receive a fixture with a non-null dependency. PropertyInjectionSourceGenerator.GeneratePropertyMetadata emits var typedInstance = (Fixture)instance; typedInstance.Dependency = ..., leaving the original box unchanged. See the generated setter emission.
Environment
SDK 10.0.403, net10.0, macOS arm64. Observed while testing #7608: async initializer and event-receiver mutations on the retained box survive, while the generated property assignment does not. The existing MutableTuplePropertyInjectionTests explicitly replaces generated property metadata to exercise the reflection setter, so it does not cover this case.
Please make generated property setters mutate the original boxed struct and cover ordinary struct arguments as well as tuple elements.
Activity
Fix legacy injection lookup for internal struct properties (#7609)
Fix generated property injection into boxed structs (#7612)