diff --git a/Directory.Packages.props b/Directory.Packages.props
index 8e4f8b1cd3..1f65e9f665 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -55,6 +55,7 @@
+
diff --git a/TUnit.Assertions.Analyzers/TUnit.Assertions.Analyzers.csproj b/TUnit.Assertions.Analyzers/TUnit.Assertions.Analyzers.csproj
index 8e4b5c4dbd..b519447b98 100644
--- a/TUnit.Assertions.Analyzers/TUnit.Assertions.Analyzers.csproj
+++ b/TUnit.Assertions.Analyzers/TUnit.Assertions.Analyzers.csproj
@@ -42,7 +42,4 @@
Resources.resx
-
-
-
\ No newline at end of file
diff --git a/TUnit.Core.SourceGenerator.Tests/AbstractTests.AbstractClass.verified.txt b/TUnit.Core.SourceGenerator.Tests/AbstractTests.AbstractClass.verified.txt
new file mode 100644
index 0000000000..ad47dbb93f
--- /dev/null
+++ b/TUnit.Core.SourceGenerator.Tests/AbstractTests.AbstractClass.verified.txt
@@ -0,0 +1 @@
+[]
\ No newline at end of file
diff --git a/TUnit.Core.SourceGenerator.Tests/AbstractTests.Concrete1.verified.txt b/TUnit.Core.SourceGenerator.Tests/AbstractTests.Concrete1.verified.txt
new file mode 100644
index 0000000000..49bf2db425
--- /dev/null
+++ b/TUnit.Core.SourceGenerator.Tests/AbstractTests.Concrete1.verified.txt
@@ -0,0 +1,90 @@
+[
+//
+#pragma warning disable
+using global::System.Linq;
+using global::System.Reflection;
+using global::TUnit.Core;
+using global::TUnit.Core.Extensions;
+
+namespace TUnit.SourceGenerated;
+
+[global::System.Diagnostics.StackTraceHidden]
+[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
+file partial class Inherited_ConcreteClass1 : TUnit.Core.Interfaces.SourceGenerator.ITestSource
+{
+ [global::System.Runtime.CompilerServices.ModuleInitializer]
+ public static void Initialise()
+ {
+ SourceRegistrar.Register(new Inherited_ConcreteClass1());
+ }
+ public global::System.Collections.Generic.IReadOnlyList CollectTests(string sessionId)
+ {
+ return Tests0(sessionId);
+ }
+ private global::System.Collections.Generic.List Tests0(string sessionId)
+ {
+ global::System.Collections.Generic.List nodes = [];
+ var classDataIndex = 0;
+ var testMethodDataIndex = 0;
+ try
+ {
+ var testClassType = typeof(global::TUnit.TestProject.AbstractTests.ConcreteClass1);
+ var methodInfo = typeof(global::TUnit.TestProject.AbstractTests.ConcreteClass1).GetMethod("AssertClassName", 0, []);
+
+ var testBuilderContext = new global::TUnit.Core.TestBuilderContext();
+ var testBuilderContextAccessor = new global::TUnit.Core.TestBuilderContextAccessor(testBuilderContext);
+
+ var resettableClassFactoryDelegate = () => new ResettableLazy(() =>
+ new global::TUnit.TestProject.AbstractTests.ConcreteClass1()
+ , sessionId, testBuilderContext);
+
+ var resettableClassFactory = resettableClassFactoryDelegate();
+
+ nodes.Add(new TestMetadata
+ {
+ TestId = $"TUnit.TestProject.AbstractTests.ConcreteClass1.AssertClassName:0",
+ TestClassArguments = [],
+ TestMethodArguments = [],
+ TestClassProperties = [],
+ CurrentRepeatAttempt = 0,
+ RepeatLimit = 0,
+ MethodInfo = methodInfo,
+ ResettableClassFactory = resettableClassFactory,
+ TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.AssertClassName()),
+ TestFilePath = @"",
+ TestLineNumber = 8,
+ TestAttributes = [ new global::TUnit.Core.TestAttribute()
+{
+
+} ],
+ ClassAttributes = [ new global::TUnit.Core.InheritsTestsAttribute()
+{
+
+} ],
+ AssemblyAttributes = [ ],
+ DataAttributes = [ ],
+ TestBuilderContext = testBuilderContext,
+ });
+ resettableClassFactory = resettableClassFactoryDelegate();
+ testBuilderContext = new();
+ testBuilderContextAccessor.Current = testBuilderContext;
+ }
+ catch (global::System.Exception exception)
+ {
+ nodes.Add(new FailedInitializationTest
+ {
+ TestId = $"TUnit.TestProject.AbstractTests.ConcreteClass1.AssertClassName:0",
+ TestClass = typeof(global::TUnit.TestProject.AbstractTests.ConcreteClass1),
+ ReturnType = typeof(global::TUnit.TestProject.AbstractTests.ConcreteClass1).GetMethod("AssertClassName", 0, []).ReturnType,
+ ParameterTypeFullNames = [],
+ TestName = "AssertClassName",
+ TestFilePath = @"",
+ TestLineNumber = 8,
+ Exception = exception,
+ });
+ }
+ return nodes;
+ }
+}
+
+]
\ No newline at end of file
diff --git a/TUnit.Core.SourceGenerator.Tests/AbstractTests.Concrete2.verified.txt b/TUnit.Core.SourceGenerator.Tests/AbstractTests.Concrete2.verified.txt
new file mode 100644
index 0000000000..d85e2235e4
--- /dev/null
+++ b/TUnit.Core.SourceGenerator.Tests/AbstractTests.Concrete2.verified.txt
@@ -0,0 +1,274 @@
+[
+//
+#pragma warning disable
+using global::System.Linq;
+using global::System.Reflection;
+using global::TUnit.Core;
+using global::TUnit.Core.Extensions;
+
+namespace TUnit.SourceGenerated;
+
+[global::System.Diagnostics.StackTraceHidden]
+[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
+file partial class ConcreteClass2 : TUnit.Core.Interfaces.SourceGenerator.ITestSource
+{
+ [global::System.Runtime.CompilerServices.ModuleInitializer]
+ public static void Initialise()
+ {
+ SourceRegistrar.Register(new ConcreteClass2());
+ }
+ public global::System.Collections.Generic.IReadOnlyList CollectTests(string sessionId)
+ {
+ return Tests0(sessionId);
+ }
+ private global::System.Collections.Generic.List Tests0(string sessionId)
+ {
+ global::System.Collections.Generic.List nodes = [];
+ var classDataIndex = 0;
+ var testMethodDataIndex = 0;
+ try
+ {
+ var testClassType = typeof(global::TUnit.TestProject.AbstractTests.ConcreteClass2);
+ var methodInfo = typeof(global::TUnit.TestProject.AbstractTests.ConcreteClass2).GetMethod("SecondTest", 0, []);
+
+ var testBuilderContext = new global::TUnit.Core.TestBuilderContext();
+ var testBuilderContextAccessor = new global::TUnit.Core.TestBuilderContextAccessor(testBuilderContext);
+
+ var resettableClassFactoryDelegate = () => new ResettableLazy(() =>
+ new global::TUnit.TestProject.AbstractTests.ConcreteClass2()
+ , sessionId, testBuilderContext);
+
+ var resettableClassFactory = resettableClassFactoryDelegate();
+
+ nodes.Add(new TestMetadata
+ {
+ TestId = $"TUnit.TestProject.AbstractTests.ConcreteClass2.SecondTest:0",
+ TestClassArguments = [],
+ TestMethodArguments = [],
+ TestClassProperties = [],
+ CurrentRepeatAttempt = 0,
+ RepeatLimit = 0,
+ MethodInfo = methodInfo,
+ ResettableClassFactory = resettableClassFactory,
+ TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.SecondTest()),
+ TestFilePath = @"",
+ TestLineNumber = 11,
+ TestAttributes = [ new global::TUnit.Core.TestAttribute()
+{
+
+} ],
+ ClassAttributes = [ new global::TUnit.Core.InheritsTestsAttribute()
+{
+
+}, new global::TUnit.Core.InheritsTestsAttribute()
+{
+
+} ],
+ AssemblyAttributes = [ ],
+ DataAttributes = [ ],
+ TestBuilderContext = testBuilderContext,
+ });
+ resettableClassFactory = resettableClassFactoryDelegate();
+ testBuilderContext = new();
+ testBuilderContextAccessor.Current = testBuilderContext;
+ }
+ catch (global::System.Exception exception)
+ {
+ nodes.Add(new FailedInitializationTest
+ {
+ TestId = $"TUnit.TestProject.AbstractTests.ConcreteClass2.SecondTest:0",
+ TestClass = typeof(global::TUnit.TestProject.AbstractTests.ConcreteClass2),
+ ReturnType = typeof(global::TUnit.TestProject.AbstractTests.ConcreteClass2).GetMethod("SecondTest", 0, []).ReturnType,
+ ParameterTypeFullNames = [],
+ TestName = "SecondTest",
+ TestFilePath = @"",
+ TestLineNumber = 11,
+ Exception = exception,
+ });
+ }
+ return nodes;
+ }
+}
+
+
+//
+#pragma warning disable
+using global::System.Linq;
+using global::System.Reflection;
+using global::TUnit.Core;
+using global::TUnit.Core.Extensions;
+
+namespace TUnit.SourceGenerated;
+
+[global::System.Diagnostics.StackTraceHidden]
+[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
+file partial class Inherited_ConcreteClass2 : TUnit.Core.Interfaces.SourceGenerator.ITestSource
+{
+ [global::System.Runtime.CompilerServices.ModuleInitializer]
+ public static void Initialise()
+ {
+ SourceRegistrar.Register(new Inherited_ConcreteClass2());
+ }
+ public global::System.Collections.Generic.IReadOnlyList CollectTests(string sessionId)
+ {
+ return Tests0(sessionId);
+ }
+ private global::System.Collections.Generic.List Tests0(string sessionId)
+ {
+ global::System.Collections.Generic.List nodes = [];
+ var classDataIndex = 0;
+ var testMethodDataIndex = 0;
+ try
+ {
+ var testClassType = typeof(global::TUnit.TestProject.AbstractTests.ConcreteClass2);
+ var methodInfo = typeof(global::TUnit.TestProject.AbstractTests.ConcreteClass2).GetMethod("AssertClassName", 0, []);
+
+ var testBuilderContext = new global::TUnit.Core.TestBuilderContext();
+ var testBuilderContextAccessor = new global::TUnit.Core.TestBuilderContextAccessor(testBuilderContext);
+
+ var resettableClassFactoryDelegate = () => new ResettableLazy(() =>
+ new global::TUnit.TestProject.AbstractTests.ConcreteClass2()
+ , sessionId, testBuilderContext);
+
+ var resettableClassFactory = resettableClassFactoryDelegate();
+
+ nodes.Add(new TestMetadata
+ {
+ TestId = $"TUnit.TestProject.AbstractTests.ConcreteClass2.AssertClassName:0",
+ TestClassArguments = [],
+ TestMethodArguments = [],
+ TestClassProperties = [],
+ CurrentRepeatAttempt = 0,
+ RepeatLimit = 0,
+ MethodInfo = methodInfo,
+ ResettableClassFactory = resettableClassFactory,
+ TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.AssertClassName()),
+ TestFilePath = @"",
+ TestLineNumber = 8,
+ TestAttributes = [ new global::TUnit.Core.TestAttribute()
+{
+
+} ],
+ ClassAttributes = [ new global::TUnit.Core.InheritsTestsAttribute()
+{
+
+}, new global::TUnit.Core.InheritsTestsAttribute()
+{
+
+} ],
+ AssemblyAttributes = [ ],
+ DataAttributes = [ ],
+ TestBuilderContext = testBuilderContext,
+ });
+ resettableClassFactory = resettableClassFactoryDelegate();
+ testBuilderContext = new();
+ testBuilderContextAccessor.Current = testBuilderContext;
+ }
+ catch (global::System.Exception exception)
+ {
+ nodes.Add(new FailedInitializationTest
+ {
+ TestId = $"TUnit.TestProject.AbstractTests.ConcreteClass2.AssertClassName:0",
+ TestClass = typeof(global::TUnit.TestProject.AbstractTests.ConcreteClass2),
+ ReturnType = typeof(global::TUnit.TestProject.AbstractTests.ConcreteClass2).GetMethod("AssertClassName", 0, []).ReturnType,
+ ParameterTypeFullNames = [],
+ TestName = "AssertClassName",
+ TestFilePath = @"",
+ TestLineNumber = 8,
+ Exception = exception,
+ });
+ }
+ return nodes;
+ }
+}
+
+
+//
+#pragma warning disable
+using global::System.Linq;
+using global::System.Reflection;
+using global::TUnit.Core;
+using global::TUnit.Core.Extensions;
+
+namespace TUnit.SourceGenerated;
+
+[global::System.Diagnostics.StackTraceHidden]
+[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
+file partial class Inherited_ConcreteClass1 : TUnit.Core.Interfaces.SourceGenerator.ITestSource
+{
+ [global::System.Runtime.CompilerServices.ModuleInitializer]
+ public static void Initialise()
+ {
+ SourceRegistrar.Register(new Inherited_ConcreteClass1());
+ }
+ public global::System.Collections.Generic.IReadOnlyList CollectTests(string sessionId)
+ {
+ return Tests0(sessionId);
+ }
+ private global::System.Collections.Generic.List Tests0(string sessionId)
+ {
+ global::System.Collections.Generic.List nodes = [];
+ var classDataIndex = 0;
+ var testMethodDataIndex = 0;
+ try
+ {
+ var testClassType = typeof(global::TUnit.TestProject.AbstractTests.ConcreteClass1);
+ var methodInfo = typeof(global::TUnit.TestProject.AbstractTests.ConcreteClass1).GetMethod("AssertClassName", 0, []);
+
+ var testBuilderContext = new global::TUnit.Core.TestBuilderContext();
+ var testBuilderContextAccessor = new global::TUnit.Core.TestBuilderContextAccessor(testBuilderContext);
+
+ var resettableClassFactoryDelegate = () => new ResettableLazy(() =>
+ new global::TUnit.TestProject.AbstractTests.ConcreteClass1()
+ , sessionId, testBuilderContext);
+
+ var resettableClassFactory = resettableClassFactoryDelegate();
+
+ nodes.Add(new TestMetadata
+ {
+ TestId = $"TUnit.TestProject.AbstractTests.ConcreteClass1.AssertClassName:0",
+ TestClassArguments = [],
+ TestMethodArguments = [],
+ TestClassProperties = [],
+ CurrentRepeatAttempt = 0,
+ RepeatLimit = 0,
+ MethodInfo = methodInfo,
+ ResettableClassFactory = resettableClassFactory,
+ TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.AssertClassName()),
+ TestFilePath = @"",
+ TestLineNumber = 8,
+ TestAttributes = [ new global::TUnit.Core.TestAttribute()
+{
+
+} ],
+ ClassAttributes = [ new global::TUnit.Core.InheritsTestsAttribute()
+{
+
+} ],
+ AssemblyAttributes = [ ],
+ DataAttributes = [ ],
+ TestBuilderContext = testBuilderContext,
+ });
+ resettableClassFactory = resettableClassFactoryDelegate();
+ testBuilderContext = new();
+ testBuilderContextAccessor.Current = testBuilderContext;
+ }
+ catch (global::System.Exception exception)
+ {
+ nodes.Add(new FailedInitializationTest
+ {
+ TestId = $"TUnit.TestProject.AbstractTests.ConcreteClass1.AssertClassName:0",
+ TestClass = typeof(global::TUnit.TestProject.AbstractTests.ConcreteClass1),
+ ReturnType = typeof(global::TUnit.TestProject.AbstractTests.ConcreteClass1).GetMethod("AssertClassName", 0, []).ReturnType,
+ ParameterTypeFullNames = [],
+ TestName = "AssertClassName",
+ TestFilePath = @"",
+ TestLineNumber = 8,
+ Exception = exception,
+ });
+ }
+ return nodes;
+ }
+}
+
+]
\ No newline at end of file
diff --git a/TUnit.Core.SourceGenerator.Tests/AfterAllTests.Test.verified.txt b/TUnit.Core.SourceGenerator.Tests/AfterAllTests.Test.verified.txt
new file mode 100644
index 0000000000..ef56fb2924
--- /dev/null
+++ b/TUnit.Core.SourceGenerator.Tests/AfterAllTests.Test.verified.txt
@@ -0,0 +1,785 @@
+[
+//
+#pragma warning disable
+using global::System.Linq;
+using global::System.Reflection;
+using global::System.Runtime.CompilerServices;
+using global::TUnit.Core;
+using global::TUnit.Core.Hooks;
+using global::TUnit.Core.Interfaces;
+
+namespace TUnit.SourceGenerated;
+
+[global::System.Diagnostics.StackTraceHidden]
+[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
+file partial class Hooks_Base1 : TUnit.Core.Interfaces.SourceGenerator.IClassHookSource
+{
+ [global::System.Runtime.CompilerServices.ModuleInitializer]
+ public static void Initialise()
+ {
+ var instance = new Hooks_Base1();
+ SourceRegistrar.RegisterClassHookSource(instance);
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectBeforeEveryClassHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectAfterEveryClassHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectBeforeClassHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectAfterClassHooks(string sessionId)
+ {
+ return
+ [
+ new AfterClassHookMethod
+ {
+ MethodInfo = typeof(global::TUnit.TestProject.AfterTests.Base1).GetMethod("AfterAll1", 0, []),
+ AsyncBody = (context, cancellationToken) => AsyncConvert.Convert(() => global::TUnit.TestProject.AfterTests.Base1.AfterAll1()),
+ HookExecutor = DefaultExecutor.Instance,
+ Order = 0,
+ FilePath = @"",
+ LineNumber = 5,
+ },
+ ];
+}
+}
+
+
+//
+#pragma warning disable
+using global::System.Linq;
+using global::System.Reflection;
+using global::System.Runtime.CompilerServices;
+using global::TUnit.Core;
+using global::TUnit.Core.Hooks;
+using global::TUnit.Core.Interfaces;
+
+namespace TUnit.SourceGenerated;
+
+[global::System.Diagnostics.StackTraceHidden]
+[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
+file partial class Hooks_Base1 : TUnit.Core.Interfaces.SourceGenerator.ITestHookSource
+{
+ [global::System.Runtime.CompilerServices.ModuleInitializer]
+ public static void Initialise()
+ {
+ var instance = new Hooks_Base1();
+ SourceRegistrar.RegisterTestHookSource(instance);
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectBeforeEveryTestHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectAfterEveryTestHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList CollectBeforeTestHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList CollectAfterTestHooks(string sessionId)
+ {
+ return
+ [
+ new InstanceHookMethod
+ {
+ MethodInfo = typeof(global::TUnit.TestProject.AfterTests.Base1).GetMethod("AfterEach1", 0, []),
+ AsyncBody = (classInstance, context, cancellationToken) => AsyncConvert.Convert(() => classInstance.AfterEach1()),
+ HookExecutor = DefaultExecutor.Instance,
+ Order = 0,
+ },
+ ];
+ }
+}
+
+
+//
+#pragma warning disable
+using global::System.Linq;
+using global::System.Reflection;
+using global::System.Runtime.CompilerServices;
+using global::TUnit.Core;
+using global::TUnit.Core.Hooks;
+using global::TUnit.Core.Interfaces;
+
+namespace TUnit.SourceGenerated;
+
+[global::System.Diagnostics.StackTraceHidden]
+[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
+file partial class Hooks_Base2 : TUnit.Core.Interfaces.SourceGenerator.IClassHookSource
+{
+ [global::System.Runtime.CompilerServices.ModuleInitializer]
+ public static void Initialise()
+ {
+ var instance = new Hooks_Base2();
+ SourceRegistrar.RegisterClassHookSource(instance);
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectBeforeEveryClassHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectAfterEveryClassHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectBeforeClassHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectAfterClassHooks(string sessionId)
+ {
+ return
+ [
+ new AfterClassHookMethod
+ {
+ MethodInfo = typeof(global::TUnit.TestProject.AfterTests.Base2).GetMethod("AfterAll2", 0, []),
+ AsyncBody = (context, cancellationToken) => AsyncConvert.Convert(() => global::TUnit.TestProject.AfterTests.Base2.AfterAll2()),
+ HookExecutor = DefaultExecutor.Instance,
+ Order = 0,
+ FilePath = @"",
+ LineNumber = 20,
+ },
+ ];
+}
+}
+
+
+//
+#pragma warning disable
+using global::System.Linq;
+using global::System.Reflection;
+using global::System.Runtime.CompilerServices;
+using global::TUnit.Core;
+using global::TUnit.Core.Hooks;
+using global::TUnit.Core.Interfaces;
+
+namespace TUnit.SourceGenerated;
+
+[global::System.Diagnostics.StackTraceHidden]
+[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
+file partial class Hooks_Base2 : TUnit.Core.Interfaces.SourceGenerator.ITestHookSource
+{
+ [global::System.Runtime.CompilerServices.ModuleInitializer]
+ public static void Initialise()
+ {
+ var instance = new Hooks_Base2();
+ SourceRegistrar.RegisterTestHookSource(instance);
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectBeforeEveryTestHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectAfterEveryTestHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList CollectBeforeTestHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList CollectAfterTestHooks(string sessionId)
+ {
+ return
+ [
+ new InstanceHookMethod
+ {
+ MethodInfo = typeof(global::TUnit.TestProject.AfterTests.Base2).GetMethod("AfterEach2", 0, []),
+ AsyncBody = (classInstance, context, cancellationToken) => AsyncConvert.Convert(() => classInstance.AfterEach2()),
+ HookExecutor = DefaultExecutor.Instance,
+ Order = 0,
+ },
+ ];
+ }
+}
+
+
+//
+#pragma warning disable
+using global::System.Linq;
+using global::System.Reflection;
+using global::System.Runtime.CompilerServices;
+using global::TUnit.Core;
+using global::TUnit.Core.Hooks;
+using global::TUnit.Core.Interfaces;
+
+namespace TUnit.SourceGenerated;
+
+[global::System.Diagnostics.StackTraceHidden]
+[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
+file partial class Hooks_Base3 : TUnit.Core.Interfaces.SourceGenerator.IClassHookSource
+{
+ [global::System.Runtime.CompilerServices.ModuleInitializer]
+ public static void Initialise()
+ {
+ var instance = new Hooks_Base3();
+ SourceRegistrar.RegisterClassHookSource(instance);
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectBeforeEveryClassHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectAfterEveryClassHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectBeforeClassHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectAfterClassHooks(string sessionId)
+ {
+ return
+ [
+ new AfterClassHookMethod
+ {
+ MethodInfo = typeof(global::TUnit.TestProject.AfterTests.Base3).GetMethod("AfterAll3", 0, []),
+ AsyncBody = (context, cancellationToken) => AsyncConvert.Convert(() => global::TUnit.TestProject.AfterTests.Base3.AfterAll3()),
+ HookExecutor = DefaultExecutor.Instance,
+ Order = 0,
+ FilePath = @"",
+ LineNumber = 35,
+ },
+ ];
+}
+}
+
+
+//
+#pragma warning disable
+using global::System.Linq;
+using global::System.Reflection;
+using global::System.Runtime.CompilerServices;
+using global::TUnit.Core;
+using global::TUnit.Core.Hooks;
+using global::TUnit.Core.Interfaces;
+
+namespace TUnit.SourceGenerated;
+
+[global::System.Diagnostics.StackTraceHidden]
+[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
+file partial class Hooks_Base3 : TUnit.Core.Interfaces.SourceGenerator.ITestHookSource
+{
+ [global::System.Runtime.CompilerServices.ModuleInitializer]
+ public static void Initialise()
+ {
+ var instance = new Hooks_Base3();
+ SourceRegistrar.RegisterTestHookSource(instance);
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectBeforeEveryTestHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectAfterEveryTestHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList CollectBeforeTestHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList CollectAfterTestHooks(string sessionId)
+ {
+ return
+ [
+ new InstanceHookMethod
+ {
+ MethodInfo = typeof(global::TUnit.TestProject.AfterTests.Base3).GetMethod("AfterEach3", 0, []),
+ AsyncBody = (classInstance, context, cancellationToken) => AsyncConvert.Convert(() => classInstance.AfterEach3()),
+ HookExecutor = DefaultExecutor.Instance,
+ Order = 0,
+ },
+ ];
+ }
+}
+
+
+//
+#pragma warning disable
+using global::System.Linq;
+using global::System.Reflection;
+using global::System.Runtime.CompilerServices;
+using global::TUnit.Core;
+using global::TUnit.Core.Hooks;
+using global::TUnit.Core.Interfaces;
+
+namespace TUnit.SourceGenerated;
+
+[global::System.Diagnostics.StackTraceHidden]
+[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
+file partial class Hooks_CleanupTests : TUnit.Core.Interfaces.SourceGenerator.IClassHookSource
+{
+ [global::System.Runtime.CompilerServices.ModuleInitializer]
+ public static void Initialise()
+ {
+ var instance = new Hooks_CleanupTests();
+ SourceRegistrar.RegisterClassHookSource(instance);
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectBeforeEveryClassHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectAfterEveryClassHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectBeforeClassHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectAfterClassHooks(string sessionId)
+ {
+ return
+ [
+ new AfterClassHookMethod
+ {
+ MethodInfo = typeof(global::TUnit.TestProject.AfterTests.CleanupTests).GetMethod("AfterAllCleanUp", 0, []),
+ AsyncBody = (context, cancellationToken) => AsyncConvert.Convert(() => global::TUnit.TestProject.AfterTests.CleanupTests.AfterAllCleanUp()),
+ HookExecutor = DefaultExecutor.Instance,
+ Order = 0,
+ FilePath = @"",
+ LineNumber = 50,
+ },
+ ];
+}
+}
+
+
+//
+#pragma warning disable
+using global::System.Linq;
+using global::System.Reflection;
+using global::System.Runtime.CompilerServices;
+using global::TUnit.Core;
+using global::TUnit.Core.Hooks;
+using global::TUnit.Core.Interfaces;
+
+namespace TUnit.SourceGenerated;
+
+[global::System.Diagnostics.StackTraceHidden]
+[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
+file partial class Hooks_CleanupTests : TUnit.Core.Interfaces.SourceGenerator.IClassHookSource
+{
+ [global::System.Runtime.CompilerServices.ModuleInitializer]
+ public static void Initialise()
+ {
+ var instance = new Hooks_CleanupTests();
+ SourceRegistrar.RegisterClassHookSource(instance);
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectBeforeEveryClassHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectAfterEveryClassHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectBeforeClassHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectAfterClassHooks(string sessionId)
+ {
+ return
+ [
+ new AfterClassHookMethod
+ {
+ MethodInfo = typeof(global::TUnit.TestProject.AfterTests.CleanupTests).GetMethod("AfterAllCleanUpWithContext", 0, [typeof(global::TUnit.Core.ClassHookContext)]),
+ AsyncBody = (context, cancellationToken) => AsyncConvert.Convert(() => global::TUnit.TestProject.AfterTests.CleanupTests.AfterAllCleanUpWithContext(context)),
+ HookExecutor = DefaultExecutor.Instance,
+ Order = 0,
+ FilePath = @"",
+ LineNumber = 56,
+ },
+ ];
+}
+}
+
+
+//
+#pragma warning disable
+using global::System.Linq;
+using global::System.Reflection;
+using global::System.Runtime.CompilerServices;
+using global::TUnit.Core;
+using global::TUnit.Core.Hooks;
+using global::TUnit.Core.Interfaces;
+
+namespace TUnit.SourceGenerated;
+
+[global::System.Diagnostics.StackTraceHidden]
+[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
+file partial class Hooks_CleanupTests : TUnit.Core.Interfaces.SourceGenerator.IClassHookSource
+{
+ [global::System.Runtime.CompilerServices.ModuleInitializer]
+ public static void Initialise()
+ {
+ var instance = new Hooks_CleanupTests();
+ SourceRegistrar.RegisterClassHookSource(instance);
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectBeforeEveryClassHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectAfterEveryClassHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectBeforeClassHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectAfterClassHooks(string sessionId)
+ {
+ return
+ [
+ new AfterClassHookMethod
+ {
+ MethodInfo = typeof(global::TUnit.TestProject.AfterTests.CleanupTests).GetMethod("AfterAllCleanUp", 0, [typeof(global::System.Threading.CancellationToken)]),
+ AsyncBody = (context, cancellationToken) => AsyncConvert.Convert(() => global::TUnit.TestProject.AfterTests.CleanupTests.AfterAllCleanUp(cancellationToken)),
+ HookExecutor = DefaultExecutor.Instance,
+ Order = 0,
+ FilePath = @"",
+ LineNumber = 62,
+ },
+ ];
+}
+}
+
+
+//
+#pragma warning disable
+using global::System.Linq;
+using global::System.Reflection;
+using global::System.Runtime.CompilerServices;
+using global::TUnit.Core;
+using global::TUnit.Core.Hooks;
+using global::TUnit.Core.Interfaces;
+
+namespace TUnit.SourceGenerated;
+
+[global::System.Diagnostics.StackTraceHidden]
+[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
+file partial class Hooks_CleanupTests : TUnit.Core.Interfaces.SourceGenerator.IClassHookSource
+{
+ [global::System.Runtime.CompilerServices.ModuleInitializer]
+ public static void Initialise()
+ {
+ var instance = new Hooks_CleanupTests();
+ SourceRegistrar.RegisterClassHookSource(instance);
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectBeforeEveryClassHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectAfterEveryClassHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectBeforeClassHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectAfterClassHooks(string sessionId)
+ {
+ return
+ [
+ new AfterClassHookMethod
+ {
+ MethodInfo = typeof(global::TUnit.TestProject.AfterTests.CleanupTests).GetMethod("AfterAllCleanUpWithContext", 0, [typeof(global::TUnit.Core.ClassHookContext), typeof(global::System.Threading.CancellationToken)]),
+ AsyncBody = (context, cancellationToken) => AsyncConvert.Convert(() => global::TUnit.TestProject.AfterTests.CleanupTests.AfterAllCleanUpWithContext(context, cancellationToken)),
+ HookExecutor = DefaultExecutor.Instance,
+ Order = 0,
+ FilePath = @"",
+ LineNumber = 68,
+ },
+ ];
+}
+}
+
+
+//
+#pragma warning disable
+using global::System.Linq;
+using global::System.Reflection;
+using global::System.Runtime.CompilerServices;
+using global::TUnit.Core;
+using global::TUnit.Core.Hooks;
+using global::TUnit.Core.Interfaces;
+
+namespace TUnit.SourceGenerated;
+
+[global::System.Diagnostics.StackTraceHidden]
+[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
+file partial class Hooks_CleanupTests : TUnit.Core.Interfaces.SourceGenerator.ITestHookSource
+{
+ [global::System.Runtime.CompilerServices.ModuleInitializer]
+ public static void Initialise()
+ {
+ var instance = new Hooks_CleanupTests();
+ SourceRegistrar.RegisterTestHookSource(instance);
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectBeforeEveryTestHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectAfterEveryTestHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList CollectBeforeTestHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList CollectAfterTestHooks(string sessionId)
+ {
+ return
+ [
+ new InstanceHookMethod
+ {
+ MethodInfo = typeof(global::TUnit.TestProject.AfterTests.CleanupTests).GetMethod("Cleanup", 0, []),
+ AsyncBody = (classInstance, context, cancellationToken) => AsyncConvert.Convert(() => classInstance.Cleanup()),
+ HookExecutor = DefaultExecutor.Instance,
+ Order = 0,
+ },
+ ];
+ }
+}
+
+
+//
+#pragma warning disable
+using global::System.Linq;
+using global::System.Reflection;
+using global::System.Runtime.CompilerServices;
+using global::TUnit.Core;
+using global::TUnit.Core.Hooks;
+using global::TUnit.Core.Interfaces;
+
+namespace TUnit.SourceGenerated;
+
+[global::System.Diagnostics.StackTraceHidden]
+[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
+file partial class Hooks_CleanupTests : TUnit.Core.Interfaces.SourceGenerator.ITestHookSource
+{
+ [global::System.Runtime.CompilerServices.ModuleInitializer]
+ public static void Initialise()
+ {
+ var instance = new Hooks_CleanupTests();
+ SourceRegistrar.RegisterTestHookSource(instance);
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectBeforeEveryTestHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectAfterEveryTestHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList CollectBeforeTestHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList CollectAfterTestHooks(string sessionId)
+ {
+ return
+ [
+ new InstanceHookMethod
+ {
+ MethodInfo = typeof(global::TUnit.TestProject.AfterTests.CleanupTests).GetMethod("Cleanup", 0, [typeof(global::System.Threading.CancellationToken)]),
+ AsyncBody = (classInstance, context, cancellationToken) => AsyncConvert.Convert(() => classInstance.Cleanup(cancellationToken)),
+ HookExecutor = DefaultExecutor.Instance,
+ Order = 0,
+ },
+ ];
+ }
+}
+
+
+//
+#pragma warning disable
+using global::System.Linq;
+using global::System.Reflection;
+using global::System.Runtime.CompilerServices;
+using global::TUnit.Core;
+using global::TUnit.Core.Hooks;
+using global::TUnit.Core.Interfaces;
+
+namespace TUnit.SourceGenerated;
+
+[global::System.Diagnostics.StackTraceHidden]
+[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
+file partial class Hooks_CleanupTests : TUnit.Core.Interfaces.SourceGenerator.ITestHookSource
+{
+ [global::System.Runtime.CompilerServices.ModuleInitializer]
+ public static void Initialise()
+ {
+ var instance = new Hooks_CleanupTests();
+ SourceRegistrar.RegisterTestHookSource(instance);
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectBeforeEveryTestHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectAfterEveryTestHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList CollectBeforeTestHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList CollectAfterTestHooks(string sessionId)
+ {
+ return
+ [
+ new InstanceHookMethod
+ {
+ MethodInfo = typeof(global::TUnit.TestProject.AfterTests.CleanupTests).GetMethod("CleanupWithContext", 0, [typeof(global::TUnit.Core.TestContext)]),
+ AsyncBody = (classInstance, context, cancellationToken) => AsyncConvert.Convert(() => classInstance.CleanupWithContext(context)),
+ HookExecutor = DefaultExecutor.Instance,
+ Order = 0,
+ },
+ ];
+ }
+}
+
+
+//
+#pragma warning disable
+using global::System.Linq;
+using global::System.Reflection;
+using global::System.Runtime.CompilerServices;
+using global::TUnit.Core;
+using global::TUnit.Core.Hooks;
+using global::TUnit.Core.Interfaces;
+
+namespace TUnit.SourceGenerated;
+
+[global::System.Diagnostics.StackTraceHidden]
+[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
+file partial class Hooks_CleanupTests : TUnit.Core.Interfaces.SourceGenerator.ITestHookSource
+{
+ [global::System.Runtime.CompilerServices.ModuleInitializer]
+ public static void Initialise()
+ {
+ var instance = new Hooks_CleanupTests();
+ SourceRegistrar.RegisterTestHookSource(instance);
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectBeforeEveryTestHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectAfterEveryTestHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList CollectBeforeTestHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList CollectAfterTestHooks(string sessionId)
+ {
+ return
+ [
+ new InstanceHookMethod
+ {
+ MethodInfo = typeof(global::TUnit.TestProject.AfterTests.CleanupTests).GetMethod("CleanupWithContext", 0, [typeof(global::TUnit.Core.TestContext), typeof(global::System.Threading.CancellationToken)]),
+ AsyncBody = (classInstance, context, cancellationToken) => AsyncConvert.Convert(() => classInstance.CleanupWithContext(context, cancellationToken)),
+ HookExecutor = DefaultExecutor.Instance,
+ Order = 0,
+ },
+ ];
+ }
+}
+
+]
\ No newline at end of file
diff --git a/TUnit.Core.SourceGenerator.Tests/AfterAllTests.cs b/TUnit.Core.SourceGenerator.Tests/AfterAllTests.cs
index 298413e51b..4901d67714 100644
--- a/TUnit.Core.SourceGenerator.Tests/AfterAllTests.cs
+++ b/TUnit.Core.SourceGenerator.Tests/AfterAllTests.cs
@@ -13,96 +13,5 @@ public Task Test() => RunTest(Path.Combine(Git.RootDirectory.FullName,
async generatedFiles =>
{
await Assert.That(generatedFiles.Length).IsEqualTo(14);
-
- await AssertFileContains(generatedFiles[0],
- """
- new AfterClassHookMethod
- {
- MethodInfo = typeof(global::TUnit.TestProject.AfterTests.Base1).GetMethod("AfterAll1", 0, []),
- AsyncBody = (context, cancellationToken) => AsyncConvert.Convert(() => global::TUnit.TestProject.AfterTests.Base1.AfterAll1()),
- HookExecutor = DefaultExecutor.Instance,
- Order = 0,
- FilePath = @"",
- LineNumber = 5,
- },
- """);
-
- await AssertFileContains(generatedFiles[2],
- """
- new AfterClassHookMethod
- {
- MethodInfo = typeof(global::TUnit.TestProject.AfterTests.Base2).GetMethod("AfterAll2", 0, []),
- AsyncBody = (context, cancellationToken) => AsyncConvert.Convert(() => global::TUnit.TestProject.AfterTests.Base2.AfterAll2()),
- HookExecutor = DefaultExecutor.Instance,
- Order = 0,
- FilePath = @"",
- LineNumber = 20,
- },
- """);
-
- await AssertFileContains(generatedFiles[4],
- """
- new AfterClassHookMethod
- {
- MethodInfo = typeof(global::TUnit.TestProject.AfterTests.Base3).GetMethod("AfterAll3", 0, []),
- AsyncBody = (context, cancellationToken) => AsyncConvert.Convert(() => global::TUnit.TestProject.AfterTests.Base3.AfterAll3()),
- HookExecutor = DefaultExecutor.Instance,
- Order = 0,
- FilePath = @"",
- LineNumber = 35,
- },
- """);
-
- await AssertFileContains(generatedFiles[6],
- """
- new AfterClassHookMethod
- {
- MethodInfo = typeof(global::TUnit.TestProject.AfterTests.CleanupTests).GetMethod("AfterAllCleanUp", 0, []),
- AsyncBody = (context, cancellationToken) => AsyncConvert.Convert(() => global::TUnit.TestProject.AfterTests.CleanupTests.AfterAllCleanUp()),
- HookExecutor = DefaultExecutor.Instance,
- Order = 0,
- FilePath = @"",
- LineNumber = 50,
- },
- """);
-
- await AssertFileContains(generatedFiles[7],
- """
- new AfterClassHookMethod
- {
- MethodInfo = typeof(global::TUnit.TestProject.AfterTests.CleanupTests).GetMethod("AfterAllCleanUpWithContext", 0, [typeof(global::TUnit.Core.ClassHookContext)]),
- AsyncBody = (context, cancellationToken) => AsyncConvert.Convert(() => global::TUnit.TestProject.AfterTests.CleanupTests.AfterAllCleanUpWithContext(context)),
- HookExecutor = DefaultExecutor.Instance,
- Order = 0,
- FilePath = @"",
- LineNumber = 56,
- },
- """);
-
- await AssertFileContains(generatedFiles[8],
- """
- new AfterClassHookMethod
- {
- MethodInfo = typeof(global::TUnit.TestProject.AfterTests.CleanupTests).GetMethod("AfterAllCleanUp", 0, [typeof(global::System.Threading.CancellationToken)]),
- AsyncBody = (context, cancellationToken) => AsyncConvert.Convert(() => global::TUnit.TestProject.AfterTests.CleanupTests.AfterAllCleanUp(cancellationToken)),
- HookExecutor = DefaultExecutor.Instance,
- Order = 0,
- FilePath = @"",
- LineNumber = 62,
- },
- """);
-
- await AssertFileContains(generatedFiles[9],
- """
- new AfterClassHookMethod
- {
- MethodInfo = typeof(global::TUnit.TestProject.AfterTests.CleanupTests).GetMethod("AfterAllCleanUpWithContext", 0, [typeof(global::TUnit.Core.ClassHookContext), typeof(global::System.Threading.CancellationToken)]),
- AsyncBody = (context, cancellationToken) => AsyncConvert.Convert(() => global::TUnit.TestProject.AfterTests.CleanupTests.AfterAllCleanUpWithContext(context, cancellationToken)),
- HookExecutor = DefaultExecutor.Instance,
- Order = 0,
- FilePath = @"",
- LineNumber = 68,
- },
- """);
});
}
\ No newline at end of file
diff --git a/TUnit.Core.SourceGenerator.Tests/AfterEachTests.cs b/TUnit.Core.SourceGenerator.Tests/AfterEachTests.cs
index 599e7b9b2d..85401a8866 100644
--- a/TUnit.Core.SourceGenerator.Tests/AfterEachTests.cs
+++ b/TUnit.Core.SourceGenerator.Tests/AfterEachTests.cs
@@ -13,82 +13,5 @@ public Task Test() => RunTest(Path.Combine(Git.RootDirectory.FullName,
async generatedFiles =>
{
await Assert.That(generatedFiles.Length).IsEqualTo(14);
-
- await AssertFileContains(generatedFiles[1],
- """
- new InstanceHookMethod
- {
- MethodInfo = typeof(global::TUnit.TestProject.AfterTests.Base1).GetMethod("AfterEach1", 0, []),
- AsyncBody = (classInstance, context, cancellationToken) => AsyncConvert.Convert(() => classInstance.AfterEach1()),
- HookExecutor = DefaultExecutor.Instance,
- Order = 0,
- },
- """);
-
- await AssertFileContains(generatedFiles[3],
- """
- new InstanceHookMethod
- {
- MethodInfo = typeof(global::TUnit.TestProject.AfterTests.Base2).GetMethod("AfterEach2", 0, []),
- AsyncBody = (classInstance, context, cancellationToken) => AsyncConvert.Convert(() => classInstance.AfterEach2()),
- HookExecutor = DefaultExecutor.Instance,
- Order = 0,
- },
- """);
-
- await AssertFileContains(generatedFiles[5],
- """
- new InstanceHookMethod
- {
- MethodInfo = typeof(global::TUnit.TestProject.AfterTests.Base3).GetMethod("AfterEach3", 0, []),
- AsyncBody = (classInstance, context, cancellationToken) => AsyncConvert.Convert(() => classInstance.AfterEach3()),
- HookExecutor = DefaultExecutor.Instance,
- Order = 0,
- },
- """);
-
- await AssertFileContains(generatedFiles[10],
- """
- new InstanceHookMethod
- {
- MethodInfo = typeof(global::TUnit.TestProject.AfterTests.CleanupTests).GetMethod("Cleanup", 0, []),
- AsyncBody = (classInstance, context, cancellationToken) => AsyncConvert.Convert(() => classInstance.Cleanup()),
- HookExecutor = DefaultExecutor.Instance,
- Order = 0,
- },
- """);
-
- await AssertFileContains(generatedFiles[11],
- """
- new InstanceHookMethod
- {
- MethodInfo = typeof(global::TUnit.TestProject.AfterTests.CleanupTests).GetMethod("Cleanup", 0, [typeof(global::System.Threading.CancellationToken)]),
- AsyncBody = (classInstance, context, cancellationToken) => AsyncConvert.Convert(() => classInstance.Cleanup(cancellationToken)),
- HookExecutor = DefaultExecutor.Instance,
- Order = 0,
- },
- """);
-
- await AssertFileContains(generatedFiles[12],
- """
- new InstanceHookMethod
- {
- MethodInfo = typeof(global::TUnit.TestProject.AfterTests.CleanupTests).GetMethod("CleanupWithContext", 0, [typeof(global::TUnit.Core.TestContext)]),
- AsyncBody = (classInstance, context, cancellationToken) => AsyncConvert.Convert(() => classInstance.CleanupWithContext(context)),
- HookExecutor = DefaultExecutor.Instance,
- Order = 0,
- },
- """);
-
- await AssertFileContains(generatedFiles[13],
- """
- new InstanceHookMethod
- {
- MethodInfo = typeof(global::TUnit.TestProject.AfterTests.CleanupTests).GetMethod("CleanupWithContext", 0, [typeof(global::TUnit.Core.TestContext), typeof(global::System.Threading.CancellationToken)]),
- AsyncBody = (classInstance, context, cancellationToken) => AsyncConvert.Convert(() => classInstance.CleanupWithContext(context, cancellationToken)),
- HookExecutor = DefaultExecutor.Instance,
- Order = 0,
- },
- """);
});
}
\ No newline at end of file
diff --git a/TUnit.Core.SourceGenerator.Tests/AfterTests.Test.verified.txt b/TUnit.Core.SourceGenerator.Tests/AfterTests.Test.verified.txt
new file mode 100644
index 0000000000..ef56fb2924
--- /dev/null
+++ b/TUnit.Core.SourceGenerator.Tests/AfterTests.Test.verified.txt
@@ -0,0 +1,785 @@
+[
+//
+#pragma warning disable
+using global::System.Linq;
+using global::System.Reflection;
+using global::System.Runtime.CompilerServices;
+using global::TUnit.Core;
+using global::TUnit.Core.Hooks;
+using global::TUnit.Core.Interfaces;
+
+namespace TUnit.SourceGenerated;
+
+[global::System.Diagnostics.StackTraceHidden]
+[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
+file partial class Hooks_Base1 : TUnit.Core.Interfaces.SourceGenerator.IClassHookSource
+{
+ [global::System.Runtime.CompilerServices.ModuleInitializer]
+ public static void Initialise()
+ {
+ var instance = new Hooks_Base1();
+ SourceRegistrar.RegisterClassHookSource(instance);
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectBeforeEveryClassHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectAfterEveryClassHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectBeforeClassHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectAfterClassHooks(string sessionId)
+ {
+ return
+ [
+ new AfterClassHookMethod
+ {
+ MethodInfo = typeof(global::TUnit.TestProject.AfterTests.Base1).GetMethod("AfterAll1", 0, []),
+ AsyncBody = (context, cancellationToken) => AsyncConvert.Convert(() => global::TUnit.TestProject.AfterTests.Base1.AfterAll1()),
+ HookExecutor = DefaultExecutor.Instance,
+ Order = 0,
+ FilePath = @"",
+ LineNumber = 5,
+ },
+ ];
+}
+}
+
+
+//
+#pragma warning disable
+using global::System.Linq;
+using global::System.Reflection;
+using global::System.Runtime.CompilerServices;
+using global::TUnit.Core;
+using global::TUnit.Core.Hooks;
+using global::TUnit.Core.Interfaces;
+
+namespace TUnit.SourceGenerated;
+
+[global::System.Diagnostics.StackTraceHidden]
+[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
+file partial class Hooks_Base1 : TUnit.Core.Interfaces.SourceGenerator.ITestHookSource
+{
+ [global::System.Runtime.CompilerServices.ModuleInitializer]
+ public static void Initialise()
+ {
+ var instance = new Hooks_Base1();
+ SourceRegistrar.RegisterTestHookSource(instance);
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectBeforeEveryTestHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectAfterEveryTestHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList CollectBeforeTestHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList CollectAfterTestHooks(string sessionId)
+ {
+ return
+ [
+ new InstanceHookMethod
+ {
+ MethodInfo = typeof(global::TUnit.TestProject.AfterTests.Base1).GetMethod("AfterEach1", 0, []),
+ AsyncBody = (classInstance, context, cancellationToken) => AsyncConvert.Convert(() => classInstance.AfterEach1()),
+ HookExecutor = DefaultExecutor.Instance,
+ Order = 0,
+ },
+ ];
+ }
+}
+
+
+//
+#pragma warning disable
+using global::System.Linq;
+using global::System.Reflection;
+using global::System.Runtime.CompilerServices;
+using global::TUnit.Core;
+using global::TUnit.Core.Hooks;
+using global::TUnit.Core.Interfaces;
+
+namespace TUnit.SourceGenerated;
+
+[global::System.Diagnostics.StackTraceHidden]
+[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
+file partial class Hooks_Base2 : TUnit.Core.Interfaces.SourceGenerator.IClassHookSource
+{
+ [global::System.Runtime.CompilerServices.ModuleInitializer]
+ public static void Initialise()
+ {
+ var instance = new Hooks_Base2();
+ SourceRegistrar.RegisterClassHookSource(instance);
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectBeforeEveryClassHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectAfterEveryClassHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectBeforeClassHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectAfterClassHooks(string sessionId)
+ {
+ return
+ [
+ new AfterClassHookMethod
+ {
+ MethodInfo = typeof(global::TUnit.TestProject.AfterTests.Base2).GetMethod("AfterAll2", 0, []),
+ AsyncBody = (context, cancellationToken) => AsyncConvert.Convert(() => global::TUnit.TestProject.AfterTests.Base2.AfterAll2()),
+ HookExecutor = DefaultExecutor.Instance,
+ Order = 0,
+ FilePath = @"",
+ LineNumber = 20,
+ },
+ ];
+}
+}
+
+
+//
+#pragma warning disable
+using global::System.Linq;
+using global::System.Reflection;
+using global::System.Runtime.CompilerServices;
+using global::TUnit.Core;
+using global::TUnit.Core.Hooks;
+using global::TUnit.Core.Interfaces;
+
+namespace TUnit.SourceGenerated;
+
+[global::System.Diagnostics.StackTraceHidden]
+[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
+file partial class Hooks_Base2 : TUnit.Core.Interfaces.SourceGenerator.ITestHookSource
+{
+ [global::System.Runtime.CompilerServices.ModuleInitializer]
+ public static void Initialise()
+ {
+ var instance = new Hooks_Base2();
+ SourceRegistrar.RegisterTestHookSource(instance);
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectBeforeEveryTestHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectAfterEveryTestHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList CollectBeforeTestHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList CollectAfterTestHooks(string sessionId)
+ {
+ return
+ [
+ new InstanceHookMethod
+ {
+ MethodInfo = typeof(global::TUnit.TestProject.AfterTests.Base2).GetMethod("AfterEach2", 0, []),
+ AsyncBody = (classInstance, context, cancellationToken) => AsyncConvert.Convert(() => classInstance.AfterEach2()),
+ HookExecutor = DefaultExecutor.Instance,
+ Order = 0,
+ },
+ ];
+ }
+}
+
+
+//
+#pragma warning disable
+using global::System.Linq;
+using global::System.Reflection;
+using global::System.Runtime.CompilerServices;
+using global::TUnit.Core;
+using global::TUnit.Core.Hooks;
+using global::TUnit.Core.Interfaces;
+
+namespace TUnit.SourceGenerated;
+
+[global::System.Diagnostics.StackTraceHidden]
+[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
+file partial class Hooks_Base3 : TUnit.Core.Interfaces.SourceGenerator.IClassHookSource
+{
+ [global::System.Runtime.CompilerServices.ModuleInitializer]
+ public static void Initialise()
+ {
+ var instance = new Hooks_Base3();
+ SourceRegistrar.RegisterClassHookSource(instance);
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectBeforeEveryClassHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectAfterEveryClassHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectBeforeClassHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectAfterClassHooks(string sessionId)
+ {
+ return
+ [
+ new AfterClassHookMethod
+ {
+ MethodInfo = typeof(global::TUnit.TestProject.AfterTests.Base3).GetMethod("AfterAll3", 0, []),
+ AsyncBody = (context, cancellationToken) => AsyncConvert.Convert(() => global::TUnit.TestProject.AfterTests.Base3.AfterAll3()),
+ HookExecutor = DefaultExecutor.Instance,
+ Order = 0,
+ FilePath = @"",
+ LineNumber = 35,
+ },
+ ];
+}
+}
+
+
+//
+#pragma warning disable
+using global::System.Linq;
+using global::System.Reflection;
+using global::System.Runtime.CompilerServices;
+using global::TUnit.Core;
+using global::TUnit.Core.Hooks;
+using global::TUnit.Core.Interfaces;
+
+namespace TUnit.SourceGenerated;
+
+[global::System.Diagnostics.StackTraceHidden]
+[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
+file partial class Hooks_Base3 : TUnit.Core.Interfaces.SourceGenerator.ITestHookSource
+{
+ [global::System.Runtime.CompilerServices.ModuleInitializer]
+ public static void Initialise()
+ {
+ var instance = new Hooks_Base3();
+ SourceRegistrar.RegisterTestHookSource(instance);
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectBeforeEveryTestHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectAfterEveryTestHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList CollectBeforeTestHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList CollectAfterTestHooks(string sessionId)
+ {
+ return
+ [
+ new InstanceHookMethod
+ {
+ MethodInfo = typeof(global::TUnit.TestProject.AfterTests.Base3).GetMethod("AfterEach3", 0, []),
+ AsyncBody = (classInstance, context, cancellationToken) => AsyncConvert.Convert(() => classInstance.AfterEach3()),
+ HookExecutor = DefaultExecutor.Instance,
+ Order = 0,
+ },
+ ];
+ }
+}
+
+
+//
+#pragma warning disable
+using global::System.Linq;
+using global::System.Reflection;
+using global::System.Runtime.CompilerServices;
+using global::TUnit.Core;
+using global::TUnit.Core.Hooks;
+using global::TUnit.Core.Interfaces;
+
+namespace TUnit.SourceGenerated;
+
+[global::System.Diagnostics.StackTraceHidden]
+[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
+file partial class Hooks_CleanupTests : TUnit.Core.Interfaces.SourceGenerator.IClassHookSource
+{
+ [global::System.Runtime.CompilerServices.ModuleInitializer]
+ public static void Initialise()
+ {
+ var instance = new Hooks_CleanupTests();
+ SourceRegistrar.RegisterClassHookSource(instance);
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectBeforeEveryClassHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectAfterEveryClassHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectBeforeClassHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectAfterClassHooks(string sessionId)
+ {
+ return
+ [
+ new AfterClassHookMethod
+ {
+ MethodInfo = typeof(global::TUnit.TestProject.AfterTests.CleanupTests).GetMethod("AfterAllCleanUp", 0, []),
+ AsyncBody = (context, cancellationToken) => AsyncConvert.Convert(() => global::TUnit.TestProject.AfterTests.CleanupTests.AfterAllCleanUp()),
+ HookExecutor = DefaultExecutor.Instance,
+ Order = 0,
+ FilePath = @"",
+ LineNumber = 50,
+ },
+ ];
+}
+}
+
+
+//
+#pragma warning disable
+using global::System.Linq;
+using global::System.Reflection;
+using global::System.Runtime.CompilerServices;
+using global::TUnit.Core;
+using global::TUnit.Core.Hooks;
+using global::TUnit.Core.Interfaces;
+
+namespace TUnit.SourceGenerated;
+
+[global::System.Diagnostics.StackTraceHidden]
+[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
+file partial class Hooks_CleanupTests : TUnit.Core.Interfaces.SourceGenerator.IClassHookSource
+{
+ [global::System.Runtime.CompilerServices.ModuleInitializer]
+ public static void Initialise()
+ {
+ var instance = new Hooks_CleanupTests();
+ SourceRegistrar.RegisterClassHookSource(instance);
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectBeforeEveryClassHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectAfterEveryClassHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectBeforeClassHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectAfterClassHooks(string sessionId)
+ {
+ return
+ [
+ new AfterClassHookMethod
+ {
+ MethodInfo = typeof(global::TUnit.TestProject.AfterTests.CleanupTests).GetMethod("AfterAllCleanUpWithContext", 0, [typeof(global::TUnit.Core.ClassHookContext)]),
+ AsyncBody = (context, cancellationToken) => AsyncConvert.Convert(() => global::TUnit.TestProject.AfterTests.CleanupTests.AfterAllCleanUpWithContext(context)),
+ HookExecutor = DefaultExecutor.Instance,
+ Order = 0,
+ FilePath = @"",
+ LineNumber = 56,
+ },
+ ];
+}
+}
+
+
+//
+#pragma warning disable
+using global::System.Linq;
+using global::System.Reflection;
+using global::System.Runtime.CompilerServices;
+using global::TUnit.Core;
+using global::TUnit.Core.Hooks;
+using global::TUnit.Core.Interfaces;
+
+namespace TUnit.SourceGenerated;
+
+[global::System.Diagnostics.StackTraceHidden]
+[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
+file partial class Hooks_CleanupTests : TUnit.Core.Interfaces.SourceGenerator.IClassHookSource
+{
+ [global::System.Runtime.CompilerServices.ModuleInitializer]
+ public static void Initialise()
+ {
+ var instance = new Hooks_CleanupTests();
+ SourceRegistrar.RegisterClassHookSource(instance);
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectBeforeEveryClassHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectAfterEveryClassHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectBeforeClassHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectAfterClassHooks(string sessionId)
+ {
+ return
+ [
+ new AfterClassHookMethod
+ {
+ MethodInfo = typeof(global::TUnit.TestProject.AfterTests.CleanupTests).GetMethod("AfterAllCleanUp", 0, [typeof(global::System.Threading.CancellationToken)]),
+ AsyncBody = (context, cancellationToken) => AsyncConvert.Convert(() => global::TUnit.TestProject.AfterTests.CleanupTests.AfterAllCleanUp(cancellationToken)),
+ HookExecutor = DefaultExecutor.Instance,
+ Order = 0,
+ FilePath = @"",
+ LineNumber = 62,
+ },
+ ];
+}
+}
+
+
+//
+#pragma warning disable
+using global::System.Linq;
+using global::System.Reflection;
+using global::System.Runtime.CompilerServices;
+using global::TUnit.Core;
+using global::TUnit.Core.Hooks;
+using global::TUnit.Core.Interfaces;
+
+namespace TUnit.SourceGenerated;
+
+[global::System.Diagnostics.StackTraceHidden]
+[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
+file partial class Hooks_CleanupTests : TUnit.Core.Interfaces.SourceGenerator.IClassHookSource
+{
+ [global::System.Runtime.CompilerServices.ModuleInitializer]
+ public static void Initialise()
+ {
+ var instance = new Hooks_CleanupTests();
+ SourceRegistrar.RegisterClassHookSource(instance);
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectBeforeEveryClassHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectAfterEveryClassHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectBeforeClassHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectAfterClassHooks(string sessionId)
+ {
+ return
+ [
+ new AfterClassHookMethod
+ {
+ MethodInfo = typeof(global::TUnit.TestProject.AfterTests.CleanupTests).GetMethod("AfterAllCleanUpWithContext", 0, [typeof(global::TUnit.Core.ClassHookContext), typeof(global::System.Threading.CancellationToken)]),
+ AsyncBody = (context, cancellationToken) => AsyncConvert.Convert(() => global::TUnit.TestProject.AfterTests.CleanupTests.AfterAllCleanUpWithContext(context, cancellationToken)),
+ HookExecutor = DefaultExecutor.Instance,
+ Order = 0,
+ FilePath = @"",
+ LineNumber = 68,
+ },
+ ];
+}
+}
+
+
+//
+#pragma warning disable
+using global::System.Linq;
+using global::System.Reflection;
+using global::System.Runtime.CompilerServices;
+using global::TUnit.Core;
+using global::TUnit.Core.Hooks;
+using global::TUnit.Core.Interfaces;
+
+namespace TUnit.SourceGenerated;
+
+[global::System.Diagnostics.StackTraceHidden]
+[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
+file partial class Hooks_CleanupTests : TUnit.Core.Interfaces.SourceGenerator.ITestHookSource
+{
+ [global::System.Runtime.CompilerServices.ModuleInitializer]
+ public static void Initialise()
+ {
+ var instance = new Hooks_CleanupTests();
+ SourceRegistrar.RegisterTestHookSource(instance);
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectBeforeEveryTestHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectAfterEveryTestHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList CollectBeforeTestHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList CollectAfterTestHooks(string sessionId)
+ {
+ return
+ [
+ new InstanceHookMethod
+ {
+ MethodInfo = typeof(global::TUnit.TestProject.AfterTests.CleanupTests).GetMethod("Cleanup", 0, []),
+ AsyncBody = (classInstance, context, cancellationToken) => AsyncConvert.Convert(() => classInstance.Cleanup()),
+ HookExecutor = DefaultExecutor.Instance,
+ Order = 0,
+ },
+ ];
+ }
+}
+
+
+//
+#pragma warning disable
+using global::System.Linq;
+using global::System.Reflection;
+using global::System.Runtime.CompilerServices;
+using global::TUnit.Core;
+using global::TUnit.Core.Hooks;
+using global::TUnit.Core.Interfaces;
+
+namespace TUnit.SourceGenerated;
+
+[global::System.Diagnostics.StackTraceHidden]
+[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
+file partial class Hooks_CleanupTests : TUnit.Core.Interfaces.SourceGenerator.ITestHookSource
+{
+ [global::System.Runtime.CompilerServices.ModuleInitializer]
+ public static void Initialise()
+ {
+ var instance = new Hooks_CleanupTests();
+ SourceRegistrar.RegisterTestHookSource(instance);
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectBeforeEveryTestHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectAfterEveryTestHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList CollectBeforeTestHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList CollectAfterTestHooks(string sessionId)
+ {
+ return
+ [
+ new InstanceHookMethod
+ {
+ MethodInfo = typeof(global::TUnit.TestProject.AfterTests.CleanupTests).GetMethod("Cleanup", 0, [typeof(global::System.Threading.CancellationToken)]),
+ AsyncBody = (classInstance, context, cancellationToken) => AsyncConvert.Convert(() => classInstance.Cleanup(cancellationToken)),
+ HookExecutor = DefaultExecutor.Instance,
+ Order = 0,
+ },
+ ];
+ }
+}
+
+
+//
+#pragma warning disable
+using global::System.Linq;
+using global::System.Reflection;
+using global::System.Runtime.CompilerServices;
+using global::TUnit.Core;
+using global::TUnit.Core.Hooks;
+using global::TUnit.Core.Interfaces;
+
+namespace TUnit.SourceGenerated;
+
+[global::System.Diagnostics.StackTraceHidden]
+[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
+file partial class Hooks_CleanupTests : TUnit.Core.Interfaces.SourceGenerator.ITestHookSource
+{
+ [global::System.Runtime.CompilerServices.ModuleInitializer]
+ public static void Initialise()
+ {
+ var instance = new Hooks_CleanupTests();
+ SourceRegistrar.RegisterTestHookSource(instance);
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectBeforeEveryTestHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectAfterEveryTestHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList CollectBeforeTestHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList CollectAfterTestHooks(string sessionId)
+ {
+ return
+ [
+ new InstanceHookMethod
+ {
+ MethodInfo = typeof(global::TUnit.TestProject.AfterTests.CleanupTests).GetMethod("CleanupWithContext", 0, [typeof(global::TUnit.Core.TestContext)]),
+ AsyncBody = (classInstance, context, cancellationToken) => AsyncConvert.Convert(() => classInstance.CleanupWithContext(context)),
+ HookExecutor = DefaultExecutor.Instance,
+ Order = 0,
+ },
+ ];
+ }
+}
+
+
+//
+#pragma warning disable
+using global::System.Linq;
+using global::System.Reflection;
+using global::System.Runtime.CompilerServices;
+using global::TUnit.Core;
+using global::TUnit.Core.Hooks;
+using global::TUnit.Core.Interfaces;
+
+namespace TUnit.SourceGenerated;
+
+[global::System.Diagnostics.StackTraceHidden]
+[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
+file partial class Hooks_CleanupTests : TUnit.Core.Interfaces.SourceGenerator.ITestHookSource
+{
+ [global::System.Runtime.CompilerServices.ModuleInitializer]
+ public static void Initialise()
+ {
+ var instance = new Hooks_CleanupTests();
+ SourceRegistrar.RegisterTestHookSource(instance);
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectBeforeEveryTestHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectAfterEveryTestHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList CollectBeforeTestHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList CollectAfterTestHooks(string sessionId)
+ {
+ return
+ [
+ new InstanceHookMethod
+ {
+ MethodInfo = typeof(global::TUnit.TestProject.AfterTests.CleanupTests).GetMethod("CleanupWithContext", 0, [typeof(global::TUnit.Core.TestContext), typeof(global::System.Threading.CancellationToken)]),
+ AsyncBody = (classInstance, context, cancellationToken) => AsyncConvert.Convert(() => classInstance.CleanupWithContext(context, cancellationToken)),
+ HookExecutor = DefaultExecutor.Instance,
+ Order = 0,
+ },
+ ];
+ }
+}
+
+]
\ No newline at end of file
diff --git a/TUnit.Core.SourceGenerator.Tests/AssemblyAfterTests.Test.verified.txt b/TUnit.Core.SourceGenerator.Tests/AssemblyAfterTests.Test.verified.txt
new file mode 100644
index 0000000000..356e64ab79
--- /dev/null
+++ b/TUnit.Core.SourceGenerator.Tests/AssemblyAfterTests.Test.verified.txt
@@ -0,0 +1,785 @@
+[
+//
+#pragma warning disable
+using global::System.Linq;
+using global::System.Reflection;
+using global::System.Runtime.CompilerServices;
+using global::TUnit.Core;
+using global::TUnit.Core.Hooks;
+using global::TUnit.Core.Interfaces;
+
+namespace TUnit.SourceGenerated;
+
+[global::System.Diagnostics.StackTraceHidden]
+[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
+file partial class Hooks_AssemblyBase1 : TUnit.Core.Interfaces.SourceGenerator.IAssemblyHookSource
+{
+ [global::System.Runtime.CompilerServices.ModuleInitializer]
+ public static void Initialise()
+ {
+ var instance = new Hooks_AssemblyBase1();
+ SourceRegistrar.RegisterAssemblyHookSource(instance);
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectBeforeEveryAssemblyHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectAfterEveryAssemblyHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectBeforeAssemblyHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectAfterAssemblyHooks(string sessionId)
+ {
+ return
+ [
+ new AfterAssemblyHookMethod
+ {
+ MethodInfo = typeof(global::TUnit.TestProject.AfterTests.AssemblyBase1).GetMethod("AfterAll1", 0, []),
+ AsyncBody = (context, cancellationToken) => AsyncConvert.Convert(() => global::TUnit.TestProject.AfterTests.AssemblyBase1.AfterAll1()),
+ HookExecutor = DefaultExecutor.Instance,
+ Order = 0,
+ FilePath = @"",
+ LineNumber = 5,
+ },
+ ];
+}
+}
+
+
+//
+#pragma warning disable
+using global::System.Linq;
+using global::System.Reflection;
+using global::System.Runtime.CompilerServices;
+using global::TUnit.Core;
+using global::TUnit.Core.Hooks;
+using global::TUnit.Core.Interfaces;
+
+namespace TUnit.SourceGenerated;
+
+[global::System.Diagnostics.StackTraceHidden]
+[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
+file partial class Hooks_AssemblyBase1 : TUnit.Core.Interfaces.SourceGenerator.ITestHookSource
+{
+ [global::System.Runtime.CompilerServices.ModuleInitializer]
+ public static void Initialise()
+ {
+ var instance = new Hooks_AssemblyBase1();
+ SourceRegistrar.RegisterTestHookSource(instance);
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectBeforeEveryTestHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectAfterEveryTestHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList CollectBeforeTestHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList CollectAfterTestHooks(string sessionId)
+ {
+ return
+ [
+ new InstanceHookMethod
+ {
+ MethodInfo = typeof(global::TUnit.TestProject.AfterTests.AssemblyBase1).GetMethod("AfterEach1", 0, []),
+ AsyncBody = (classInstance, context, cancellationToken) => AsyncConvert.Convert(() => classInstance.AfterEach1()),
+ HookExecutor = DefaultExecutor.Instance,
+ Order = 0,
+ },
+ ];
+ }
+}
+
+
+//
+#pragma warning disable
+using global::System.Linq;
+using global::System.Reflection;
+using global::System.Runtime.CompilerServices;
+using global::TUnit.Core;
+using global::TUnit.Core.Hooks;
+using global::TUnit.Core.Interfaces;
+
+namespace TUnit.SourceGenerated;
+
+[global::System.Diagnostics.StackTraceHidden]
+[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
+file partial class Hooks_AssemblyBase2 : TUnit.Core.Interfaces.SourceGenerator.IAssemblyHookSource
+{
+ [global::System.Runtime.CompilerServices.ModuleInitializer]
+ public static void Initialise()
+ {
+ var instance = new Hooks_AssemblyBase2();
+ SourceRegistrar.RegisterAssemblyHookSource(instance);
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectBeforeEveryAssemblyHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectAfterEveryAssemblyHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectBeforeAssemblyHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectAfterAssemblyHooks(string sessionId)
+ {
+ return
+ [
+ new AfterAssemblyHookMethod
+ {
+ MethodInfo = typeof(global::TUnit.TestProject.AfterTests.AssemblyBase2).GetMethod("AfterAll2", 0, []),
+ AsyncBody = (context, cancellationToken) => AsyncConvert.Convert(() => global::TUnit.TestProject.AfterTests.AssemblyBase2.AfterAll2()),
+ HookExecutor = DefaultExecutor.Instance,
+ Order = 0,
+ FilePath = @"",
+ LineNumber = 20,
+ },
+ ];
+}
+}
+
+
+//
+#pragma warning disable
+using global::System.Linq;
+using global::System.Reflection;
+using global::System.Runtime.CompilerServices;
+using global::TUnit.Core;
+using global::TUnit.Core.Hooks;
+using global::TUnit.Core.Interfaces;
+
+namespace TUnit.SourceGenerated;
+
+[global::System.Diagnostics.StackTraceHidden]
+[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
+file partial class Hooks_AssemblyBase2 : TUnit.Core.Interfaces.SourceGenerator.ITestHookSource
+{
+ [global::System.Runtime.CompilerServices.ModuleInitializer]
+ public static void Initialise()
+ {
+ var instance = new Hooks_AssemblyBase2();
+ SourceRegistrar.RegisterTestHookSource(instance);
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectBeforeEveryTestHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectAfterEveryTestHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList CollectBeforeTestHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList CollectAfterTestHooks(string sessionId)
+ {
+ return
+ [
+ new InstanceHookMethod
+ {
+ MethodInfo = typeof(global::TUnit.TestProject.AfterTests.AssemblyBase2).GetMethod("AfterEach2", 0, []),
+ AsyncBody = (classInstance, context, cancellationToken) => AsyncConvert.Convert(() => classInstance.AfterEach2()),
+ HookExecutor = DefaultExecutor.Instance,
+ Order = 0,
+ },
+ ];
+ }
+}
+
+
+//
+#pragma warning disable
+using global::System.Linq;
+using global::System.Reflection;
+using global::System.Runtime.CompilerServices;
+using global::TUnit.Core;
+using global::TUnit.Core.Hooks;
+using global::TUnit.Core.Interfaces;
+
+namespace TUnit.SourceGenerated;
+
+[global::System.Diagnostics.StackTraceHidden]
+[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
+file partial class Hooks_AssemblyBase3 : TUnit.Core.Interfaces.SourceGenerator.IAssemblyHookSource
+{
+ [global::System.Runtime.CompilerServices.ModuleInitializer]
+ public static void Initialise()
+ {
+ var instance = new Hooks_AssemblyBase3();
+ SourceRegistrar.RegisterAssemblyHookSource(instance);
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectBeforeEveryAssemblyHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectAfterEveryAssemblyHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectBeforeAssemblyHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectAfterAssemblyHooks(string sessionId)
+ {
+ return
+ [
+ new AfterAssemblyHookMethod
+ {
+ MethodInfo = typeof(global::TUnit.TestProject.AfterTests.AssemblyBase3).GetMethod("AfterAll3", 0, []),
+ AsyncBody = (context, cancellationToken) => AsyncConvert.Convert(() => global::TUnit.TestProject.AfterTests.AssemblyBase3.AfterAll3()),
+ HookExecutor = DefaultExecutor.Instance,
+ Order = 0,
+ FilePath = @"",
+ LineNumber = 35,
+ },
+ ];
+}
+}
+
+
+//
+#pragma warning disable
+using global::System.Linq;
+using global::System.Reflection;
+using global::System.Runtime.CompilerServices;
+using global::TUnit.Core;
+using global::TUnit.Core.Hooks;
+using global::TUnit.Core.Interfaces;
+
+namespace TUnit.SourceGenerated;
+
+[global::System.Diagnostics.StackTraceHidden]
+[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
+file partial class Hooks_AssemblyBase3 : TUnit.Core.Interfaces.SourceGenerator.ITestHookSource
+{
+ [global::System.Runtime.CompilerServices.ModuleInitializer]
+ public static void Initialise()
+ {
+ var instance = new Hooks_AssemblyBase3();
+ SourceRegistrar.RegisterTestHookSource(instance);
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectBeforeEveryTestHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectAfterEveryTestHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList CollectBeforeTestHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList CollectAfterTestHooks(string sessionId)
+ {
+ return
+ [
+ new InstanceHookMethod
+ {
+ MethodInfo = typeof(global::TUnit.TestProject.AfterTests.AssemblyBase3).GetMethod("AfterEach3", 0, []),
+ AsyncBody = (classInstance, context, cancellationToken) => AsyncConvert.Convert(() => classInstance.AfterEach3()),
+ HookExecutor = DefaultExecutor.Instance,
+ Order = 0,
+ },
+ ];
+ }
+}
+
+
+//
+#pragma warning disable
+using global::System.Linq;
+using global::System.Reflection;
+using global::System.Runtime.CompilerServices;
+using global::TUnit.Core;
+using global::TUnit.Core.Hooks;
+using global::TUnit.Core.Interfaces;
+
+namespace TUnit.SourceGenerated;
+
+[global::System.Diagnostics.StackTraceHidden]
+[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
+file partial class Hooks_AssemblyCleanupTests : TUnit.Core.Interfaces.SourceGenerator.IAssemblyHookSource
+{
+ [global::System.Runtime.CompilerServices.ModuleInitializer]
+ public static void Initialise()
+ {
+ var instance = new Hooks_AssemblyCleanupTests();
+ SourceRegistrar.RegisterAssemblyHookSource(instance);
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectBeforeEveryAssemblyHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectAfterEveryAssemblyHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectBeforeAssemblyHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectAfterAssemblyHooks(string sessionId)
+ {
+ return
+ [
+ new AfterAssemblyHookMethod
+ {
+ MethodInfo = typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests).GetMethod("AfterAllCleanUp", 0, []),
+ AsyncBody = (context, cancellationToken) => AsyncConvert.Convert(() => global::TUnit.TestProject.AfterTests.AssemblyCleanupTests.AfterAllCleanUp()),
+ HookExecutor = DefaultExecutor.Instance,
+ Order = 0,
+ FilePath = @"",
+ LineNumber = 50,
+ },
+ ];
+}
+}
+
+
+//
+#pragma warning disable
+using global::System.Linq;
+using global::System.Reflection;
+using global::System.Runtime.CompilerServices;
+using global::TUnit.Core;
+using global::TUnit.Core.Hooks;
+using global::TUnit.Core.Interfaces;
+
+namespace TUnit.SourceGenerated;
+
+[global::System.Diagnostics.StackTraceHidden]
+[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
+file partial class Hooks_AssemblyCleanupTests : TUnit.Core.Interfaces.SourceGenerator.IAssemblyHookSource
+{
+ [global::System.Runtime.CompilerServices.ModuleInitializer]
+ public static void Initialise()
+ {
+ var instance = new Hooks_AssemblyCleanupTests();
+ SourceRegistrar.RegisterAssemblyHookSource(instance);
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectBeforeEveryAssemblyHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectAfterEveryAssemblyHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectBeforeAssemblyHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectAfterAssemblyHooks(string sessionId)
+ {
+ return
+ [
+ new AfterAssemblyHookMethod
+ {
+ MethodInfo = typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests).GetMethod("AfterAllCleanUpWithContext", 0, [typeof(global::TUnit.Core.AssemblyHookContext)]),
+ AsyncBody = (context, cancellationToken) => AsyncConvert.Convert(() => global::TUnit.TestProject.AfterTests.AssemblyCleanupTests.AfterAllCleanUpWithContext(context)),
+ HookExecutor = DefaultExecutor.Instance,
+ Order = 0,
+ FilePath = @"",
+ LineNumber = 56,
+ },
+ ];
+}
+}
+
+
+//
+#pragma warning disable
+using global::System.Linq;
+using global::System.Reflection;
+using global::System.Runtime.CompilerServices;
+using global::TUnit.Core;
+using global::TUnit.Core.Hooks;
+using global::TUnit.Core.Interfaces;
+
+namespace TUnit.SourceGenerated;
+
+[global::System.Diagnostics.StackTraceHidden]
+[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
+file partial class Hooks_AssemblyCleanupTests : TUnit.Core.Interfaces.SourceGenerator.IAssemblyHookSource
+{
+ [global::System.Runtime.CompilerServices.ModuleInitializer]
+ public static void Initialise()
+ {
+ var instance = new Hooks_AssemblyCleanupTests();
+ SourceRegistrar.RegisterAssemblyHookSource(instance);
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectBeforeEveryAssemblyHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectAfterEveryAssemblyHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectBeforeAssemblyHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectAfterAssemblyHooks(string sessionId)
+ {
+ return
+ [
+ new AfterAssemblyHookMethod
+ {
+ MethodInfo = typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests).GetMethod("AfterAllCleanUp", 0, [typeof(global::System.Threading.CancellationToken)]),
+ AsyncBody = (context, cancellationToken) => AsyncConvert.Convert(() => global::TUnit.TestProject.AfterTests.AssemblyCleanupTests.AfterAllCleanUp(cancellationToken)),
+ HookExecutor = DefaultExecutor.Instance,
+ Order = 0,
+ FilePath = @"",
+ LineNumber = 62,
+ },
+ ];
+}
+}
+
+
+//
+#pragma warning disable
+using global::System.Linq;
+using global::System.Reflection;
+using global::System.Runtime.CompilerServices;
+using global::TUnit.Core;
+using global::TUnit.Core.Hooks;
+using global::TUnit.Core.Interfaces;
+
+namespace TUnit.SourceGenerated;
+
+[global::System.Diagnostics.StackTraceHidden]
+[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
+file partial class Hooks_AssemblyCleanupTests : TUnit.Core.Interfaces.SourceGenerator.IAssemblyHookSource
+{
+ [global::System.Runtime.CompilerServices.ModuleInitializer]
+ public static void Initialise()
+ {
+ var instance = new Hooks_AssemblyCleanupTests();
+ SourceRegistrar.RegisterAssemblyHookSource(instance);
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectBeforeEveryAssemblyHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectAfterEveryAssemblyHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectBeforeAssemblyHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectAfterAssemblyHooks(string sessionId)
+ {
+ return
+ [
+ new AfterAssemblyHookMethod
+ {
+ MethodInfo = typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests).GetMethod("AfterAllCleanUpWithContext", 0, [typeof(global::TUnit.Core.AssemblyHookContext), typeof(global::System.Threading.CancellationToken)]),
+ AsyncBody = (context, cancellationToken) => AsyncConvert.Convert(() => global::TUnit.TestProject.AfterTests.AssemblyCleanupTests.AfterAllCleanUpWithContext(context, cancellationToken)),
+ HookExecutor = DefaultExecutor.Instance,
+ Order = 0,
+ FilePath = @"",
+ LineNumber = 68,
+ },
+ ];
+}
+}
+
+
+//
+#pragma warning disable
+using global::System.Linq;
+using global::System.Reflection;
+using global::System.Runtime.CompilerServices;
+using global::TUnit.Core;
+using global::TUnit.Core.Hooks;
+using global::TUnit.Core.Interfaces;
+
+namespace TUnit.SourceGenerated;
+
+[global::System.Diagnostics.StackTraceHidden]
+[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
+file partial class Hooks_AssemblyCleanupTests : TUnit.Core.Interfaces.SourceGenerator.ITestHookSource
+{
+ [global::System.Runtime.CompilerServices.ModuleInitializer]
+ public static void Initialise()
+ {
+ var instance = new Hooks_AssemblyCleanupTests();
+ SourceRegistrar.RegisterTestHookSource(instance);
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectBeforeEveryTestHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectAfterEveryTestHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList CollectBeforeTestHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList CollectAfterTestHooks(string sessionId)
+ {
+ return
+ [
+ new InstanceHookMethod
+ {
+ MethodInfo = typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests).GetMethod("Cleanup", 0, []),
+ AsyncBody = (classInstance, context, cancellationToken) => AsyncConvert.Convert(() => classInstance.Cleanup()),
+ HookExecutor = DefaultExecutor.Instance,
+ Order = 0,
+ },
+ ];
+ }
+}
+
+
+//
+#pragma warning disable
+using global::System.Linq;
+using global::System.Reflection;
+using global::System.Runtime.CompilerServices;
+using global::TUnit.Core;
+using global::TUnit.Core.Hooks;
+using global::TUnit.Core.Interfaces;
+
+namespace TUnit.SourceGenerated;
+
+[global::System.Diagnostics.StackTraceHidden]
+[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
+file partial class Hooks_AssemblyCleanupTests : TUnit.Core.Interfaces.SourceGenerator.ITestHookSource
+{
+ [global::System.Runtime.CompilerServices.ModuleInitializer]
+ public static void Initialise()
+ {
+ var instance = new Hooks_AssemblyCleanupTests();
+ SourceRegistrar.RegisterTestHookSource(instance);
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectBeforeEveryTestHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectAfterEveryTestHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList CollectBeforeTestHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList CollectAfterTestHooks(string sessionId)
+ {
+ return
+ [
+ new InstanceHookMethod
+ {
+ MethodInfo = typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests).GetMethod("Cleanup", 0, [typeof(global::System.Threading.CancellationToken)]),
+ AsyncBody = (classInstance, context, cancellationToken) => AsyncConvert.Convert(() => classInstance.Cleanup(cancellationToken)),
+ HookExecutor = DefaultExecutor.Instance,
+ Order = 0,
+ },
+ ];
+ }
+}
+
+
+//
+#pragma warning disable
+using global::System.Linq;
+using global::System.Reflection;
+using global::System.Runtime.CompilerServices;
+using global::TUnit.Core;
+using global::TUnit.Core.Hooks;
+using global::TUnit.Core.Interfaces;
+
+namespace TUnit.SourceGenerated;
+
+[global::System.Diagnostics.StackTraceHidden]
+[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
+file partial class Hooks_AssemblyCleanupTests : TUnit.Core.Interfaces.SourceGenerator.ITestHookSource
+{
+ [global::System.Runtime.CompilerServices.ModuleInitializer]
+ public static void Initialise()
+ {
+ var instance = new Hooks_AssemblyCleanupTests();
+ SourceRegistrar.RegisterTestHookSource(instance);
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectBeforeEveryTestHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectAfterEveryTestHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList CollectBeforeTestHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList CollectAfterTestHooks(string sessionId)
+ {
+ return
+ [
+ new InstanceHookMethod
+ {
+ MethodInfo = typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests).GetMethod("CleanupWithContext", 0, [typeof(global::TUnit.Core.TestContext)]),
+ AsyncBody = (classInstance, context, cancellationToken) => AsyncConvert.Convert(() => classInstance.CleanupWithContext(context)),
+ HookExecutor = DefaultExecutor.Instance,
+ Order = 0,
+ },
+ ];
+ }
+}
+
+
+//
+#pragma warning disable
+using global::System.Linq;
+using global::System.Reflection;
+using global::System.Runtime.CompilerServices;
+using global::TUnit.Core;
+using global::TUnit.Core.Hooks;
+using global::TUnit.Core.Interfaces;
+
+namespace TUnit.SourceGenerated;
+
+[global::System.Diagnostics.StackTraceHidden]
+[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
+file partial class Hooks_AssemblyCleanupTests : TUnit.Core.Interfaces.SourceGenerator.ITestHookSource
+{
+ [global::System.Runtime.CompilerServices.ModuleInitializer]
+ public static void Initialise()
+ {
+ var instance = new Hooks_AssemblyCleanupTests();
+ SourceRegistrar.RegisterTestHookSource(instance);
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectBeforeEveryTestHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectAfterEveryTestHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList CollectBeforeTestHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList CollectAfterTestHooks(string sessionId)
+ {
+ return
+ [
+ new InstanceHookMethod
+ {
+ MethodInfo = typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests).GetMethod("CleanupWithContext", 0, [typeof(global::TUnit.Core.TestContext), typeof(global::System.Threading.CancellationToken)]),
+ AsyncBody = (classInstance, context, cancellationToken) => AsyncConvert.Convert(() => classInstance.CleanupWithContext(context, cancellationToken)),
+ HookExecutor = DefaultExecutor.Instance,
+ Order = 0,
+ },
+ ];
+ }
+}
+
+]
\ No newline at end of file
diff --git a/TUnit.Core.SourceGenerator.Tests/AssemblyAfterTests.cs b/TUnit.Core.SourceGenerator.Tests/AssemblyAfterTests.cs
index 4049d8f87a..7ce8f8779b 100644
--- a/TUnit.Core.SourceGenerator.Tests/AssemblyAfterTests.cs
+++ b/TUnit.Core.SourceGenerator.Tests/AssemblyAfterTests.cs
@@ -13,96 +13,5 @@ public Task Test() => RunTest(Path.Combine(Git.RootDirectory.FullName,
async generatedFiles =>
{
await Assert.That(generatedFiles.Length).IsEqualTo(14);
-
- await AssertFileContains(generatedFiles[0],
- """
- new AfterAssemblyHookMethod
- {
- MethodInfo = typeof(global::TUnit.TestProject.AfterTests.AssemblyBase1).GetMethod("AfterAll1", 0, []),
- AsyncBody = (context, cancellationToken) => AsyncConvert.Convert(() => global::TUnit.TestProject.AfterTests.AssemblyBase1.AfterAll1()),
- HookExecutor = DefaultExecutor.Instance,
- Order = 0,
- FilePath = @"",
- LineNumber = 5,
- },
- """);
-
- await AssertFileContains(generatedFiles[2],
- """
- new AfterAssemblyHookMethod
- {
- MethodInfo = typeof(global::TUnit.TestProject.AfterTests.AssemblyBase2).GetMethod("AfterAll2", 0, []),
- AsyncBody = (context, cancellationToken) => AsyncConvert.Convert(() => global::TUnit.TestProject.AfterTests.AssemblyBase2.AfterAll2()),
- HookExecutor = DefaultExecutor.Instance,
- Order = 0,
- FilePath = @"",
- LineNumber = 20,
- },
- """);
-
- await AssertFileContains(generatedFiles[4],
- """
- new AfterAssemblyHookMethod
- {
- MethodInfo = typeof(global::TUnit.TestProject.AfterTests.AssemblyBase3).GetMethod("AfterAll3", 0, []),
- AsyncBody = (context, cancellationToken) => AsyncConvert.Convert(() => global::TUnit.TestProject.AfterTests.AssemblyBase3.AfterAll3()),
- HookExecutor = DefaultExecutor.Instance,
- Order = 0,
- FilePath = @"",
- LineNumber = 35,
- },
- """);
-
- await AssertFileContains(generatedFiles[6],
- """
- new AfterAssemblyHookMethod
- {
- MethodInfo = typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests).GetMethod("AfterAllCleanUp", 0, []),
- AsyncBody = (context, cancellationToken) => AsyncConvert.Convert(() => global::TUnit.TestProject.AfterTests.AssemblyCleanupTests.AfterAllCleanUp()),
- HookExecutor = DefaultExecutor.Instance,
- Order = 0,
- FilePath = @"",
- LineNumber = 50,
- },
- """);
-
- await AssertFileContains(generatedFiles[7],
- """
- new AfterAssemblyHookMethod
- {
- MethodInfo = typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests).GetMethod("AfterAllCleanUpWithContext", 0, [typeof(global::TUnit.Core.AssemblyHookContext)]),
- AsyncBody = (context, cancellationToken) => AsyncConvert.Convert(() => global::TUnit.TestProject.AfterTests.AssemblyCleanupTests.AfterAllCleanUpWithContext(context)),
- HookExecutor = DefaultExecutor.Instance,
- Order = 0,
- FilePath = @"",
- LineNumber = 56,
- },
- """);
-
- await AssertFileContains(generatedFiles[8],
- """
- new AfterAssemblyHookMethod
- {
- MethodInfo = typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests).GetMethod("AfterAllCleanUp", 0, [typeof(global::System.Threading.CancellationToken)]),
- AsyncBody = (context, cancellationToken) => AsyncConvert.Convert(() => global::TUnit.TestProject.AfterTests.AssemblyCleanupTests.AfterAllCleanUp(cancellationToken)),
- HookExecutor = DefaultExecutor.Instance,
- Order = 0,
- FilePath = @"",
- LineNumber = 62,
- },
- """);
-
- await AssertFileContains(generatedFiles[9],
- """
- new AfterAssemblyHookMethod
- {
- MethodInfo = typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests).GetMethod("AfterAllCleanUpWithContext", 0, [typeof(global::TUnit.Core.AssemblyHookContext), typeof(global::System.Threading.CancellationToken)]),
- AsyncBody = (context, cancellationToken) => AsyncConvert.Convert(() => global::TUnit.TestProject.AfterTests.AssemblyCleanupTests.AfterAllCleanUpWithContext(context, cancellationToken)),
- HookExecutor = DefaultExecutor.Instance,
- Order = 0,
- FilePath = @"",
- LineNumber = 68,
- },
- """);
});
}
\ No newline at end of file
diff --git a/TUnit.Core.SourceGenerator.Tests/AssemblyBeforeTests.Test.verified.txt b/TUnit.Core.SourceGenerator.Tests/AssemblyBeforeTests.Test.verified.txt
new file mode 100644
index 0000000000..2352bcfd24
--- /dev/null
+++ b/TUnit.Core.SourceGenerator.Tests/AssemblyBeforeTests.Test.verified.txt
@@ -0,0 +1,785 @@
+[
+//
+#pragma warning disable
+using global::System.Linq;
+using global::System.Reflection;
+using global::System.Runtime.CompilerServices;
+using global::TUnit.Core;
+using global::TUnit.Core.Hooks;
+using global::TUnit.Core.Interfaces;
+
+namespace TUnit.SourceGenerated;
+
+[global::System.Diagnostics.StackTraceHidden]
+[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
+file partial class Hooks_AssemblyBase1 : TUnit.Core.Interfaces.SourceGenerator.IAssemblyHookSource
+{
+ [global::System.Runtime.CompilerServices.ModuleInitializer]
+ public static void Initialise()
+ {
+ var instance = new Hooks_AssemblyBase1();
+ SourceRegistrar.RegisterAssemblyHookSource(instance);
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectBeforeEveryAssemblyHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectAfterEveryAssemblyHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectBeforeAssemblyHooks(string sessionId)
+ {
+ return
+ [
+ new BeforeAssemblyHookMethod
+ {
+ MethodInfo = typeof(global::TUnit.TestProject.BeforeTests.AssemblyBase1).GetMethod("BeforeAll1", 0, []),
+ AsyncBody = (context, cancellationToken) => AsyncConvert.Convert(() => global::TUnit.TestProject.BeforeTests.AssemblyBase1.BeforeAll1()),
+ HookExecutor = DefaultExecutor.Instance,
+ Order = 0,
+ FilePath = @"",
+ LineNumber = 5,
+ },
+ ];
+}
+public global::System.Collections.Generic.IReadOnlyList> CollectAfterAssemblyHooks(string sessionId)
+{
+ return
+ [
+ ];
+}
+}
+
+
+//
+#pragma warning disable
+using global::System.Linq;
+using global::System.Reflection;
+using global::System.Runtime.CompilerServices;
+using global::TUnit.Core;
+using global::TUnit.Core.Hooks;
+using global::TUnit.Core.Interfaces;
+
+namespace TUnit.SourceGenerated;
+
+[global::System.Diagnostics.StackTraceHidden]
+[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
+file partial class Hooks_AssemblyBase1 : TUnit.Core.Interfaces.SourceGenerator.ITestHookSource
+{
+ [global::System.Runtime.CompilerServices.ModuleInitializer]
+ public static void Initialise()
+ {
+ var instance = new Hooks_AssemblyBase1();
+ SourceRegistrar.RegisterTestHookSource(instance);
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectBeforeEveryTestHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectAfterEveryTestHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList CollectBeforeTestHooks(string sessionId)
+ {
+ return
+ [
+ new InstanceHookMethod
+ {
+ MethodInfo = typeof(global::TUnit.TestProject.BeforeTests.AssemblyBase1).GetMethod("BeforeEach1", 0, []),
+ AsyncBody = (classInstance, context, cancellationToken) => AsyncConvert.Convert(() => classInstance.BeforeEach1()),
+ HookExecutor = DefaultExecutor.Instance,
+ Order = 0,
+ },
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList CollectAfterTestHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+}
+
+
+//
+#pragma warning disable
+using global::System.Linq;
+using global::System.Reflection;
+using global::System.Runtime.CompilerServices;
+using global::TUnit.Core;
+using global::TUnit.Core.Hooks;
+using global::TUnit.Core.Interfaces;
+
+namespace TUnit.SourceGenerated;
+
+[global::System.Diagnostics.StackTraceHidden]
+[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
+file partial class Hooks_AssemblyBase2 : TUnit.Core.Interfaces.SourceGenerator.IAssemblyHookSource
+{
+ [global::System.Runtime.CompilerServices.ModuleInitializer]
+ public static void Initialise()
+ {
+ var instance = new Hooks_AssemblyBase2();
+ SourceRegistrar.RegisterAssemblyHookSource(instance);
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectBeforeEveryAssemblyHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectAfterEveryAssemblyHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectBeforeAssemblyHooks(string sessionId)
+ {
+ return
+ [
+ new BeforeAssemblyHookMethod
+ {
+ MethodInfo = typeof(global::TUnit.TestProject.BeforeTests.AssemblyBase2).GetMethod("BeforeAll2", 0, []),
+ AsyncBody = (context, cancellationToken) => AsyncConvert.Convert(() => global::TUnit.TestProject.BeforeTests.AssemblyBase2.BeforeAll2()),
+ HookExecutor = DefaultExecutor.Instance,
+ Order = 0,
+ FilePath = @"",
+ LineNumber = 20,
+ },
+ ];
+}
+public global::System.Collections.Generic.IReadOnlyList> CollectAfterAssemblyHooks(string sessionId)
+{
+ return
+ [
+ ];
+}
+}
+
+
+//
+#pragma warning disable
+using global::System.Linq;
+using global::System.Reflection;
+using global::System.Runtime.CompilerServices;
+using global::TUnit.Core;
+using global::TUnit.Core.Hooks;
+using global::TUnit.Core.Interfaces;
+
+namespace TUnit.SourceGenerated;
+
+[global::System.Diagnostics.StackTraceHidden]
+[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
+file partial class Hooks_AssemblyBase2 : TUnit.Core.Interfaces.SourceGenerator.ITestHookSource
+{
+ [global::System.Runtime.CompilerServices.ModuleInitializer]
+ public static void Initialise()
+ {
+ var instance = new Hooks_AssemblyBase2();
+ SourceRegistrar.RegisterTestHookSource(instance);
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectBeforeEveryTestHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectAfterEveryTestHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList CollectBeforeTestHooks(string sessionId)
+ {
+ return
+ [
+ new InstanceHookMethod
+ {
+ MethodInfo = typeof(global::TUnit.TestProject.BeforeTests.AssemblyBase2).GetMethod("BeforeEach2", 0, []),
+ AsyncBody = (classInstance, context, cancellationToken) => AsyncConvert.Convert(() => classInstance.BeforeEach2()),
+ HookExecutor = DefaultExecutor.Instance,
+ Order = 0,
+ },
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList CollectAfterTestHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+}
+
+
+//
+#pragma warning disable
+using global::System.Linq;
+using global::System.Reflection;
+using global::System.Runtime.CompilerServices;
+using global::TUnit.Core;
+using global::TUnit.Core.Hooks;
+using global::TUnit.Core.Interfaces;
+
+namespace TUnit.SourceGenerated;
+
+[global::System.Diagnostics.StackTraceHidden]
+[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
+file partial class Hooks_AssemblyBase3 : TUnit.Core.Interfaces.SourceGenerator.IAssemblyHookSource
+{
+ [global::System.Runtime.CompilerServices.ModuleInitializer]
+ public static void Initialise()
+ {
+ var instance = new Hooks_AssemblyBase3();
+ SourceRegistrar.RegisterAssemblyHookSource(instance);
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectBeforeEveryAssemblyHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectAfterEveryAssemblyHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectBeforeAssemblyHooks(string sessionId)
+ {
+ return
+ [
+ new BeforeAssemblyHookMethod
+ {
+ MethodInfo = typeof(global::TUnit.TestProject.BeforeTests.AssemblyBase3).GetMethod("BeforeAll3", 0, []),
+ AsyncBody = (context, cancellationToken) => AsyncConvert.Convert(() => global::TUnit.TestProject.BeforeTests.AssemblyBase3.BeforeAll3()),
+ HookExecutor = DefaultExecutor.Instance,
+ Order = 0,
+ FilePath = @"",
+ LineNumber = 35,
+ },
+ ];
+}
+public global::System.Collections.Generic.IReadOnlyList> CollectAfterAssemblyHooks(string sessionId)
+{
+ return
+ [
+ ];
+}
+}
+
+
+//
+#pragma warning disable
+using global::System.Linq;
+using global::System.Reflection;
+using global::System.Runtime.CompilerServices;
+using global::TUnit.Core;
+using global::TUnit.Core.Hooks;
+using global::TUnit.Core.Interfaces;
+
+namespace TUnit.SourceGenerated;
+
+[global::System.Diagnostics.StackTraceHidden]
+[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
+file partial class Hooks_AssemblyBase3 : TUnit.Core.Interfaces.SourceGenerator.ITestHookSource
+{
+ [global::System.Runtime.CompilerServices.ModuleInitializer]
+ public static void Initialise()
+ {
+ var instance = new Hooks_AssemblyBase3();
+ SourceRegistrar.RegisterTestHookSource(instance);
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectBeforeEveryTestHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectAfterEveryTestHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList CollectBeforeTestHooks(string sessionId)
+ {
+ return
+ [
+ new InstanceHookMethod
+ {
+ MethodInfo = typeof(global::TUnit.TestProject.BeforeTests.AssemblyBase3).GetMethod("BeforeEach3", 0, []),
+ AsyncBody = (classInstance, context, cancellationToken) => AsyncConvert.Convert(() => classInstance.BeforeEach3()),
+ HookExecutor = DefaultExecutor.Instance,
+ Order = 0,
+ },
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList CollectAfterTestHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+}
+
+
+//
+#pragma warning disable
+using global::System.Linq;
+using global::System.Reflection;
+using global::System.Runtime.CompilerServices;
+using global::TUnit.Core;
+using global::TUnit.Core.Hooks;
+using global::TUnit.Core.Interfaces;
+
+namespace TUnit.SourceGenerated;
+
+[global::System.Diagnostics.StackTraceHidden]
+[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
+file partial class Hooks_AssemblySetupTests : TUnit.Core.Interfaces.SourceGenerator.IAssemblyHookSource
+{
+ [global::System.Runtime.CompilerServices.ModuleInitializer]
+ public static void Initialise()
+ {
+ var instance = new Hooks_AssemblySetupTests();
+ SourceRegistrar.RegisterAssemblyHookSource(instance);
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectBeforeEveryAssemblyHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectAfterEveryAssemblyHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectBeforeAssemblyHooks(string sessionId)
+ {
+ return
+ [
+ new BeforeAssemblyHookMethod
+ {
+ MethodInfo = typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests).GetMethod("BeforeAllSetUp", 0, []),
+ AsyncBody = (context, cancellationToken) => AsyncConvert.Convert(() => global::TUnit.TestProject.BeforeTests.AssemblySetupTests.BeforeAllSetUp()),
+ HookExecutor = DefaultExecutor.Instance,
+ Order = 0,
+ FilePath = @"",
+ LineNumber = 50,
+ },
+ ];
+}
+public global::System.Collections.Generic.IReadOnlyList> CollectAfterAssemblyHooks(string sessionId)
+{
+ return
+ [
+ ];
+}
+}
+
+
+//
+#pragma warning disable
+using global::System.Linq;
+using global::System.Reflection;
+using global::System.Runtime.CompilerServices;
+using global::TUnit.Core;
+using global::TUnit.Core.Hooks;
+using global::TUnit.Core.Interfaces;
+
+namespace TUnit.SourceGenerated;
+
+[global::System.Diagnostics.StackTraceHidden]
+[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
+file partial class Hooks_AssemblySetupTests : TUnit.Core.Interfaces.SourceGenerator.IAssemblyHookSource
+{
+ [global::System.Runtime.CompilerServices.ModuleInitializer]
+ public static void Initialise()
+ {
+ var instance = new Hooks_AssemblySetupTests();
+ SourceRegistrar.RegisterAssemblyHookSource(instance);
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectBeforeEveryAssemblyHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectAfterEveryAssemblyHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectBeforeAssemblyHooks(string sessionId)
+ {
+ return
+ [
+ new BeforeAssemblyHookMethod
+ {
+ MethodInfo = typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests).GetMethod("BeforeAllSetUpWithContext", 0, [typeof(global::TUnit.Core.AssemblyHookContext)]),
+ AsyncBody = (context, cancellationToken) => AsyncConvert.Convert(() => global::TUnit.TestProject.BeforeTests.AssemblySetupTests.BeforeAllSetUpWithContext(context)),
+ HookExecutor = DefaultExecutor.Instance,
+ Order = 0,
+ FilePath = @"",
+ LineNumber = 56,
+ },
+ ];
+}
+public global::System.Collections.Generic.IReadOnlyList> CollectAfterAssemblyHooks(string sessionId)
+{
+ return
+ [
+ ];
+}
+}
+
+
+//
+#pragma warning disable
+using global::System.Linq;
+using global::System.Reflection;
+using global::System.Runtime.CompilerServices;
+using global::TUnit.Core;
+using global::TUnit.Core.Hooks;
+using global::TUnit.Core.Interfaces;
+
+namespace TUnit.SourceGenerated;
+
+[global::System.Diagnostics.StackTraceHidden]
+[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
+file partial class Hooks_AssemblySetupTests : TUnit.Core.Interfaces.SourceGenerator.IAssemblyHookSource
+{
+ [global::System.Runtime.CompilerServices.ModuleInitializer]
+ public static void Initialise()
+ {
+ var instance = new Hooks_AssemblySetupTests();
+ SourceRegistrar.RegisterAssemblyHookSource(instance);
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectBeforeEveryAssemblyHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectAfterEveryAssemblyHooks(string sessionId)
+ {
+ return
+ [
+ ];
+ }
+ public global::System.Collections.Generic.IReadOnlyList> CollectBeforeAssemblyHooks(string sessionId)
+ {
+ return
+ [
+ new BeforeAssemblyHookMethod
+ {
+ MethodInfo = typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests).GetMethod("BeforeAllSetUp", 0, [typeof(global::System.Threading.CancellationToken)]),
+ AsyncBody = (context, cancellationToken) => AsyncConvert.Convert(() => global::TUnit.TestProject.BeforeTests.AssemblySetupTests.BeforeAllSetUp(cancellationToken)),
+ HookExecutor = DefaultExecutor.Instance,
+ Order = 0,
+ FilePath = @"",
+ LineNumber = 62,
+ },
+ ];
+}
+public global::System.Collections.Generic.IReadOnlyList