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
Instead of using [ModuleInitializer] + RunClassConstructor to register test classes, the source generator could emit per-class assembly attributes:
[assembly:TestClass(typeof(MyClass))]
The engine would discover test classes via assembly.GetCustomAttributes<TestClassAttribute>() — pure metadata enumeration with zero .cctor triggers and zero JIT overhead at startup.
Summary
Suggested by @teo-tsirpanis in dotnet/runtime#126541 (comment)
Instead of using
[ModuleInitializer]+RunClassConstructorto register test classes, the source generator could emit per-class assembly attributes:The engine would discover test classes via
assembly.GetCustomAttributes<TestClassAttribute>()— pure metadata enumeration with zero.cctortriggers and zero JIT overhead at startup.Proposed attribute
Benefits over current approach
TUnitInfrastructure.Initialize()+RunClassConstructorchain entirely[assembly: TestClass(...)], noCollectneededConsiderations
Sources.TestEntries" to "scan assembly attributes then resolve per-class"Context