From 03c392356f0c954f7237c2e27f040831e3112208 Mon Sep 17 00:00:00 2001 From: Tom Longhurst <30480171+thomhurst@users.noreply.github.com> Date: Tue, 29 Sep 2026 08:42:26 +0100 Subject: [PATCH 1/7] perf(source-gen): emit hooks per class with direct, non-async bodies HookMetadataGenerator emitted one file per hook, each with its own namespace, static class, 12 usings and an async body that went through AsyncConvert.Convert(() => ...). Compiling that shape is a noticeable part of CoreCompile in projects with many hooks. - Group hooks by declaring class (Collect + GroupBy into an equatable HookClassGroup) and emit one file per class. Registration fields and body methods now live directly in the TUnit_HookRegistration partial. - For void, Task/Task and ValueTask hooks, emit a direct non-async body that returns the ValueTask. A try/catch turns synchronous throws into a faulted ValueTask, matching the previous async body. Other return types and open generic hooks keep the existing path. --- .../Generators/HookMetadataGenerator.cs | 340 ++-- .../Models/Extracted/HookClassGroup.cs | 11 + .../AssemblyAfterTests.Test.verified.txt | 1470 +++++++--------- .../AssemblyBeforeTests.Test.verified.txt | 1470 +++++++--------- ...nflictingNamespace.DotNet10_0.verified.txt | 1478 +++++++--------- ...onflictingNamespace.DotNet8_0.verified.txt | 1478 +++++++--------- ...onflictingNamespace.DotNet9_0.verified.txt | 1478 +++++++--------- ...thConflictingNamespace.Net4_7.verified.txt | 1476 +++++++--------- ...obalStaticAfterEachTests.Test.verified.txt | 1520 +++++++---------- ...balStaticBeforeEachTests.Test.verified.txt | 1520 +++++++---------- ...oksTests.DisposableFieldTests.verified.txt | 195 +-- .../HookMetadataGeneratorIncrementalTests.cs | 46 + 12 files changed, 5155 insertions(+), 7327 deletions(-) create mode 100644 src/TUnit.Core.SourceGenerator/Models/Extracted/HookClassGroup.cs diff --git a/src/TUnit.Core.SourceGenerator/Generators/HookMetadataGenerator.cs b/src/TUnit.Core.SourceGenerator/Generators/HookMetadataGenerator.cs index 917e20a3d5d..300a59223ca 100644 --- a/src/TUnit.Core.SourceGenerator/Generators/HookMetadataGenerator.cs +++ b/src/TUnit.Core.SourceGenerator/Generators/HookMetadataGenerator.cs @@ -1,3 +1,4 @@ +using System.Collections.Immutable; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; @@ -20,6 +21,7 @@ public class HookMetadataGenerator : IIncrementalGenerator public const string ExtractAfterHooks = "ExtractAfterHooks"; public const string ExtractBeforeEveryHooks = "ExtractBeforeEveryHooks"; public const string ExtractAfterEveryHooks = "ExtractAfterEveryHooks"; + public const string HookClassGroups = "HookClassGroups"; public void Initialize(IncrementalGeneratorInitializationContext context) { @@ -36,8 +38,7 @@ public void Initialize(IncrementalGeneratorInitializationContext context) predicate: static (node, _) => node is MethodDeclarationSyntax, transform: static (ctx, _) => ExtractHookModel(ctx, "Before")) .Where(static m => m is not null) - .WithTrackingName(ExtractBeforeHooks) - .Combine(enabledProvider); + .WithTrackingName(ExtractBeforeHooks); var afterHooks = context.SyntaxProvider .ForAttributeWithMetadataName( @@ -45,8 +46,7 @@ public void Initialize(IncrementalGeneratorInitializationContext context) predicate: static (node, _) => node is MethodDeclarationSyntax, transform: static (ctx, _) => ExtractHookModel(ctx, "After")) .Where(static m => m is not null) - .WithTrackingName(ExtractAfterHooks) - .Combine(enabledProvider); + .WithTrackingName(ExtractAfterHooks); var beforeEveryHooks = context.SyntaxProvider .ForAttributeWithMetadataName( @@ -54,8 +54,7 @@ public void Initialize(IncrementalGeneratorInitializationContext context) predicate: static (node, _) => node is MethodDeclarationSyntax, transform: static (ctx, _) => ExtractHookModel(ctx, "BeforeEvery")) .Where(static m => m is not null) - .WithTrackingName(ExtractBeforeEveryHooks) - .Combine(enabledProvider); + .WithTrackingName(ExtractBeforeEveryHooks); var afterEveryHooks = context.SyntaxProvider .ForAttributeWithMetadataName( @@ -63,26 +62,61 @@ public void Initialize(IncrementalGeneratorInitializationContext context) predicate: static (node, _) => node is MethodDeclarationSyntax, transform: static (ctx, _) => ExtractHookModel(ctx, "AfterEvery")) .Where(static m => m is not null) - .WithTrackingName(ExtractAfterEveryHooks) - .Combine(enabledProvider); - - context.RegisterSourceOutput(beforeHooks, GenerateHookFile); - context.RegisterSourceOutput(afterHooks, GenerateHookFile); - context.RegisterSourceOutput(beforeEveryHooks, GenerateHookFile); - context.RegisterSourceOutput(afterEveryHooks, GenerateHookFile); + .WithTrackingName(ExtractAfterEveryHooks); + + // Group hooks by declaring class so each class gets one generated file instead of one per hook. + // .Collect() is a fan-in, so grouping re-runs when any hook model changes, but it only arranges + // already-extracted models. HookClassGroup's value equality means only the changed class's file + // is re-emitted. + var hookClassGroups = beforeHooks.Collect() + .Combine(afterHooks.Collect()) + .Combine(beforeEveryHooks.Collect()) + .Combine(afterEveryHooks.Collect()) + .Combine(enabledProvider) + .SelectMany(static (data, _) => + { + var ((((before, after), beforeEvery), afterEvery), isEnabled) = data; + return isEnabled + ? GroupHooksByClass(before, after, beforeEvery, afterEvery) + : []; + }) + .WithTrackingName(HookClassGroups); + + context.RegisterSourceOutput(hookClassGroups, GenerateHookClassFile); } - private static void GenerateHookFile(SourceProductionContext context, (HookModel? Hook, bool IsEnabled) data) + private static IEnumerable GroupHooksByClass(params ImmutableArray[] hookArrays) { - var (hook, isEnabled) = data; - if (!isEnabled || hook == null) - { - return; - } + // A type's fully qualified name identifies it within a compilation, so grouping by it matches + // grouping by symbol while keeping the pipeline free of symbols. + return hookArrays + .SelectMany(static hooks => hooks) + .Where(static hook => hook is not null) + .GroupBy(static hook => hook!.FullyQualifiedTypeName, StringComparer.Ordinal) + .Select(static group => new HookClassGroup + { + FullyQualifiedTypeName = group.Key, + Hooks = group.Select(static hook => hook!).ToEquatableArray() + }); + } + private static void GenerateHookClassFile(SourceProductionContext context, HookClassGroup group) + { + var hook = group.Hooks[0]; try { - GenerateIndividualHookFile(context, hook); + using var writer = new CodeWriter(); + WriteHookClassFileHeader(writer); + + foreach (var current in group.Hooks) + { + hook = current; + GenerateHookMembers(writer, hook); + } + + WriteHookClassFileFooter(writer); + + context.AddSource($"{SanitizeForFileName(group.FullyQualifiedTypeName)}.Hooks.g.cs", writer.ToString()); } catch (Exception ex) { @@ -363,55 +397,49 @@ private static int GetHookOrder(AttributeData attribute) return null; } - private static void GenerateIndividualHookFile(SourceProductionContext context, HookModel hook) + private static void WriteHookClassFileHeader(CodeWriter writer) { - var safeFileName = GetSafeFileName(hook); - using var writer = new CodeWriter(); - writer.AppendLine("#nullable enable"); writer.AppendLine("#pragma warning disable CS9113 // Parameter is unread."); writer.AppendLine(); writer.AppendLine("using System;"); - writer.AppendLine("using System.Collections.Generic;"); - writer.AppendLine("using System.Linq;"); writer.AppendLine("using System.Reflection;"); - writer.AppendLine("using System.Runtime.CompilerServices;"); writer.AppendLine("using System.Threading;"); writer.AppendLine("using System.Threading.Tasks;"); writer.AppendLine("using global::TUnit.Core;"); writer.AppendLine("using global::TUnit.Core.Hooks;"); - writer.AppendLine("using global::TUnit.Core.Interfaces.SourceGenerator;"); - writer.AppendLine("using global::TUnit.Core.Models;"); - writer.AppendLine("using HookType = global::TUnit.Core.HookType;"); writer.AppendLine(); - - // Hook delegate body — kept in its own namespace to avoid name collisions. - writer.AppendLine($"namespace TUnit.Generated.Hooks.{safeFileName}"); + writer.AppendLine("namespace TUnit.Generated"); writer.AppendLine("{"); writer.Indent(); + writer.AppendLine("internal static partial class TUnit_HookRegistration"); + writer.AppendLine("{"); + writer.Indent(); + } - using (writer.BeginBlock($"internal static class {safeFileName}Initializer")) - { - GenerateHookDelegate(writer, hook); - } - + private static void WriteHookClassFileFooter(CodeWriter writer) + { + writer.Unindent(); + writer.AppendLine("}"); writer.Unindent(); writer.AppendLine("}"); + } - // Partial class field — registration is a single expression, so the .cctor contains - // no per-hook method calls. All hook registrations compile into ONE JIT'd method. - writer.AppendLine(); - writer.AppendLine("namespace TUnit.Generated"); - writer.AppendLine("{"); - writer.AppendLine(" internal static partial class TUnit_HookRegistration"); - writer.AppendLine(" {"); - writer.Append($" static readonly int _h_{safeFileName} = "); - GenerateInlineHookRegistration(writer, hook, safeFileName); + /// + /// Emits one hook's registration field and body method as members of the shared + /// TUnit_HookRegistration partial class. The registration is a single field initializer, so the + /// .cctor contains no per-hook method calls: all hook registrations compile into ONE JIT'd method. + /// + private static void GenerateHookMembers(CodeWriter writer, HookModel hook) + { + var safeName = GetSafeFileName(hook); + + writer.Append($"static readonly int _h_{safeName} = "); + GenerateInlineHookRegistration(writer, hook, $"{safeName}_Body"); writer.AppendLine(";"); - writer.AppendLine(" }"); - writer.AppendLine("}"); + writer.AppendLine(); - context.AddSource($"{safeFileName}.Hook.g.cs", writer.ToString()); + GenerateHookDelegate(writer, hook, $"{safeName}_Body"); } private static string GetSafeFileName(HookModel hook) @@ -469,11 +497,10 @@ private static string GetSimpleTypeName(string fullyQualifiedTypeName) /// lambda reference; the heavy MethodMetadata/ClassMetadata graph is constructed lazily /// on first hook execution via LazyHookEntry.Materialize(). /// - private static void GenerateInlineHookRegistration(CodeWriter writer, HookModel hook, string safeFileName) + private static void GenerateInlineHookRegistration(CodeWriter writer, HookModel hook, string bodyName) { var typeDisplay = hook.FullyQualifiedTypeName; var isInstance = hook.HookKind is "Before" or "After" && hook.HookType == "Test"; - var delegatePrefix = $"global::TUnit.Generated.Hooks.{safeFileName}.{safeFileName}Initializer."; // Determine collection name and key expression var (collectionName, keyExpr) = GetHookCollectionAndKey(hook, typeDisplay, isInstance); @@ -490,7 +517,7 @@ private static void GenerateInlineHookRegistration(CodeWriter writer, HookModel writer.Indent(); writer.AppendLine("static __registrationIndex =>"); - GenerateHookObject(writer, hook, isInstance, delegatePrefix); + GenerateHookObject(writer, hook, isInstance, bodyName); writer.Unindent(); writer.Append(")"); } @@ -521,44 +548,138 @@ private static (string collectionName, string? keyExpr) GetHookCollectionAndKey( }; } - private static void GenerateHookDelegate(CodeWriter writer, HookModel hook) + private static void GenerateHookDelegate(CodeWriter writer, HookModel hook, string bodyName) { - var delegateKey = GetDelegateKey(hook); var contextType = GetContextTypeForBody(hook.HookType, hook.HookKind); var isInstanceHook = hook.HookKind is "Before" or "After" && hook.HookType == "Test"; + var parameters = isInstanceHook + ? $"object instance, {contextType} context, CancellationToken cancellationToken" + : $"{contextType} context, CancellationToken cancellationToken"; - if (isInstanceHook) + if (hook.ClassIsOpenGeneric && (isInstanceHook || hook.IsStatic)) { - using (writer.BeginBlock($"internal static async ValueTask {delegateKey}_Body(object instance, {contextType} context, CancellationToken cancellationToken)")) + // Open generic hooks resolve the method through reflection at run time. + using (writer.BeginBlock($"private static async ValueTask {bodyName}({parameters})")) { - if (hook.ClassIsOpenGeneric) + if (isInstanceHook) { GenerateReflectionBasedInvocation(writer, hook); } else { - GenerateDirectInvocation(writer, hook); + GenerateOpenGenericStaticInvocation(writer, hook); } } + + writer.AppendLine(); + return; } - else + + var className = hook.FullyQualifiedTypeName; + var methodCall = (isInstanceHook && !hook.IsStatic ? "typedInstance" : className) + "." + hook.MethodName + GetArgumentList(hook); + var returnShape = GetReturnShape(hook); + + if (returnShape == HookReturnShape.Other) { - using (writer.BeginBlock($"internal static async ValueTask {delegateKey}_Body({contextType} context, CancellationToken cancellationToken)")) + // Unrecognised awaitable: keep the general-purpose conversion. + using (writer.BeginBlock($"private static async ValueTask {bodyName}({parameters})")) { - if (hook is { ClassIsOpenGeneric: true, IsStatic: true }) - { - GenerateOpenGenericStaticInvocation(writer, hook); - } - else + if (isInstanceHook) { - GenerateStaticMethodInvocation(writer, hook); + writer.AppendLine($"var typedInstance = ({className})instance;"); } + + writer.AppendLine($"await AsyncConvert.Convert(() => {methodCall});"); + } + + writer.AppendLine(); + return; + } + + // Direct call with no async state machine. Synchronous exceptions are returned as a faulted + // ValueTask, matching what the previous async body produced. + using (writer.BeginBlock($"private static ValueTask {bodyName}({parameters})")) + { + writer.AppendLine("try"); + writer.AppendLine("{"); + writer.Indent(); + + if (isInstanceHook) + { + writer.AppendLine($"var typedInstance = ({className})instance;"); } + + switch (returnShape) + { + case HookReturnShape.Void: + writer.AppendLine($"{methodCall};"); + writer.AppendLine("return default;"); + break; + case HookReturnShape.Task: + writer.AppendLine($"return new ValueTask({methodCall});"); + break; + case HookReturnShape.ValueTask: + writer.AppendLine($"return {methodCall};"); + break; + } + + writer.Unindent(); + writer.AppendLine("}"); + writer.AppendLine("catch (Exception ex)"); + writer.AppendLine("{"); + writer.Indent(); + writer.AppendLine("return new ValueTask(Task.FromException(ex));"); + writer.Unindent(); + writer.AppendLine("}"); } writer.AppendLine(); } + private enum HookReturnShape + { + Void, + Task, + ValueTask, + Other + } + + private static HookReturnShape GetReturnShape(HookModel hook) + { + if (hook.ReturnsVoid) + { + return HookReturnShape.Void; + } + + return hook.ReturnType switch + { + "global::System.Threading.Tasks.Task" => HookReturnShape.Task, + "global::System.Threading.Tasks.ValueTask" => HookReturnShape.ValueTask, + _ when hook.ReturnType.StartsWith("global::System.Threading.Tasks.Task<", StringComparison.Ordinal) => HookReturnShape.Task, + _ => HookReturnShape.Other + }; + } + + private static string GetArgumentList(HookModel hook) + { + if (hook.HasCancellationTokenOnly) + { + return "(cancellationToken)"; + } + + if (hook.HasContextOnly) + { + return "(context)"; + } + + if (hook.HasContextAndCancellationToken) + { + return "(context, cancellationToken)"; + } + + return "()"; + } + private static void GenerateReflectionBasedInvocation(CodeWriter writer, HookModel hook) { writer.AppendLine("var instanceType = instance.GetType();"); @@ -601,35 +722,6 @@ private static void GenerateReflectionBasedInvocation(CodeWriter writer, HookMod writer.AppendLine("}"); } - private static void GenerateDirectInvocation(CodeWriter writer, HookModel hook) - { - var className = hook.FullyQualifiedTypeName; - writer.AppendLine($"var typedInstance = ({className})instance;"); - - var methodCall = hook.IsStatic - ? $"{className}.{hook.MethodName}" - : $"typedInstance.{hook.MethodName}"; - - if (hook.HasCancellationTokenOnly) - { - methodCall += "(cancellationToken)"; - } - else if (hook.HasContextOnly) - { - methodCall += "(context)"; - } - else if (hook.HasContextAndCancellationToken) - { - methodCall += "(context, cancellationToken)"; - } - else - { - methodCall += "()"; - } - - writer.AppendLine($"await AsyncConvert.Convert(() => {methodCall});"); - } - private static void GenerateOpenGenericStaticInvocation(CodeWriter writer, HookModel hook) { writer.AppendLine($"var openGenericType = typeof({hook.FullyQualifiedTypeName});"); @@ -679,35 +771,9 @@ private static void GenerateOpenGenericStaticInvocation(CodeWriter writer, HookM : "await AsyncConvert.ConvertObject(() => method.Invoke(null, parameters));"); } - private static void GenerateStaticMethodInvocation(CodeWriter writer, HookModel hook) - { - var methodCall = $"{hook.FullyQualifiedTypeName}.{hook.MethodName}"; - - if (hook.HasCancellationTokenOnly) - { - methodCall += "(cancellationToken)"; - } - else if (hook.HasContextOnly) - { - methodCall += "(context)"; - } - else if (hook.HasContextAndCancellationToken) - { - methodCall += "(context, cancellationToken)"; - } - else - { - methodCall += "()"; - } - - writer.AppendLine($"await AsyncConvert.Convert(() => {methodCall});"); - } - - private static void GenerateHookObject(CodeWriter writer, HookModel hook, bool isInstance, string delegatePrefix) + private static void GenerateHookObject(CodeWriter writer, HookModel hook, bool isInstance, string bodyName) { var hookClass = GetHookClass(hook.HookType, hook.HookKind, !isInstance); - var delegateKey = GetDelegateKey(hook); - var bodyRef = $"{delegatePrefix}{delegateKey}_Body"; writer.AppendLine($"new {hookClass}"); writer.AppendLine("{"); @@ -726,7 +792,7 @@ private static void GenerateHookObject(CodeWriter writer, HookModel hook, bool i writer.AppendLine($"HookExecutor = {HookExecutorHelper.GetHookExecutor(hook.HookExecutorTypeName)},"); writer.AppendLine($"Order = {hook.Order},"); writer.AppendLine("RegistrationIndex = __registrationIndex,"); - writer.AppendLine($"Body = {bodyRef}" + (isInstance ? "" : ",")); + writer.AppendLine($"Body = {bodyName}" + (isInstance ? "" : ",")); if (!isInstance) { @@ -741,32 +807,6 @@ private static void GenerateHookObject(CodeWriter writer, HookModel hook, bool i writer.Append("}"); } - private static string GetDelegateKey(HookModel hook) - { - var fullTypeName = hook.FullyQualifiedTypeName; - - if (hook.ClassIsGenericType) - { - var genericIndex = fullTypeName.IndexOf('<'); - if (genericIndex > 0) - { - fullTypeName = fullTypeName.Substring(0, genericIndex); - } - } - - var safeClassName = fullTypeName - .Replace(".", "_") - .Replace("::", "_") - .Replace("<", "_") - .Replace(">", "_") - .Replace(",", "_") - .Replace(" ", "") - .Replace("`", "_") - .Replace("+", "_"); - - return $"{safeClassName}_{hook.MethodName}_{hook.ParameterCount}Params"; - } - private static string GetHookClass(string hookType, string hookKind, bool isStatic) { return (hookType, hookKind) switch diff --git a/src/TUnit.Core.SourceGenerator/Models/Extracted/HookClassGroup.cs b/src/TUnit.Core.SourceGenerator/Models/Extracted/HookClassGroup.cs new file mode 100644 index 00000000000..ce4a53b277e --- /dev/null +++ b/src/TUnit.Core.SourceGenerator/Models/Extracted/HookClassGroup.cs @@ -0,0 +1,11 @@ +namespace TUnit.Core.SourceGenerator.Models.Extracted; + +/// +/// All hooks declared by one class, emitted together into a single generated file. +/// Value equality over the hook models means only the file for a class whose hooks changed is re-emitted. +/// +public sealed record HookClassGroup +{ + public required string FullyQualifiedTypeName { get; init; } + public required EquatableArray Hooks { get; init; } +} diff --git a/tests/TUnit.Core.SourceGenerator.Tests/AssemblyAfterTests.Test.verified.txt b/tests/TUnit.Core.SourceGenerator.Tests/AssemblyAfterTests.Test.verified.txt index c0a158f068d..475f66713fa 100644 --- a/tests/TUnit.Core.SourceGenerator.Tests/AssemblyAfterTests.Test.verified.txt +++ b/tests/TUnit.Core.SourceGenerator.Tests/AssemblyAfterTests.Test.verified.txt @@ -4,134 +4,103 @@ #nullable enable #pragma warning disable CS9113 // Parameter is unread. using System; -using System.Collections.Generic; -using System.Linq; using System.Reflection; -using System.Runtime.CompilerServices; using System.Threading; using System.Threading.Tasks; using global::TUnit.Core; using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_AfterTests_AssemblyBase1_AfterAll1_After_Assembly -{ - internal static class TUnit_TestProject_AfterTests_AssemblyBase1_AfterAll1_After_AssemblyInitializer - { - internal static async ValueTask global_TUnit_TestProject_AfterTests_AssemblyBase1_AfterAll1_0Params_Body(AssemblyHookContext context, CancellationToken cancellationToken) - { - await AsyncConvert.Convert(() => global::TUnit.TestProject.AfterTests.AssemblyBase1.AfterAll1()); - } - } -} namespace TUnit.Generated { internal static partial class TUnit_HookRegistration { static readonly int _h_TUnit_TestProject_AfterTests_AssemblyBase1_AfterAll1_After_Assembly = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterAssemblyHooks, typeof(global::TUnit.TestProject.AfterTests.AssemblyBase1).Assembly, global::TUnit.Core.HookRegistrationIndices.GetNextAfterAssemblyHookIndex(), - static __registrationIndex => - new AfterAssemblyHookMethod - { - MethodInfo = new global::TUnit.Core.MethodMetadata - { - Type = typeof(global::TUnit.TestProject.AfterTests.AssemblyBase1), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.AssemblyBase1)), - Name = "AfterAll1", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = global::System.Array.Empty(), - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.AfterTests.AssemblyBase1", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.AfterTests.AssemblyBase1), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.AssemblyBase1)), - Name = "AssemblyBase1", - Namespace = "TUnit.TestProject.AfterTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_AfterTests_AssemblyBase1_AfterAll1_After_Assembly.TUnit_TestProject_AfterTests_AssemblyBase1_AfterAll1_After_AssemblyInitializer.global_TUnit_TestProject_AfterTests_AssemblyBase1_AfterAll1_0Params_Body, - FilePath = "", - LineNumber = 5 - } -); - } -} - - -// ===== FILE SEPARATOR ===== - -// -#pragma warning disable - -#nullable enable -#pragma warning disable CS9113 // Parameter is unread. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Threading; -using System.Threading.Tasks; -using global::TUnit.Core; -using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_AfterTests_AssemblyBase1_AfterEach1_After_Test -{ - internal static class TUnit_TestProject_AfterTests_AssemblyBase1_AfterEach1_After_TestInitializer - { - internal static async ValueTask global_TUnit_TestProject_AfterTests_AssemblyBase1_AfterEach1_0Params_Body(object instance, TestContext context, CancellationToken cancellationToken) + static __registrationIndex => + new AfterAssemblyHookMethod + { + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.AfterTests.AssemblyBase1), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.AssemblyBase1)), + Name = "AfterAll1", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = global::System.Array.Empty(), + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.AfterTests.AssemblyBase1", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.AfterTests.AssemblyBase1), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.AssemblyBase1)), + Name = "AssemblyBase1", + Namespace = "TUnit.TestProject.AfterTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_AfterTests_AssemblyBase1_AfterAll1_After_Assembly_Body, + FilePath = "", + LineNumber = 5 + } + ); + private static ValueTask TUnit_TestProject_AfterTests_AssemblyBase1_AfterAll1_After_Assembly_Body(AssemblyHookContext context, CancellationToken cancellationToken) { - var typedInstance = (global::TUnit.TestProject.AfterTests.AssemblyBase1)instance; - await AsyncConvert.Convert(() => typedInstance.AfterEach1()); + try + { + return new ValueTask(global::TUnit.TestProject.AfterTests.AssemblyBase1.AfterAll1()); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } } - } -} -namespace TUnit.Generated -{ - internal static partial class TUnit_HookRegistration - { static readonly int _h_TUnit_TestProject_AfterTests_AssemblyBase1_AfterEach1_After_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterTestHooks, typeof(global::TUnit.TestProject.AfterTests.AssemblyBase1), global::TUnit.Core.HookRegistrationIndices.GetNextAfterTestHookIndex(), - static __registrationIndex => - new InstanceHookMethod - { - InitClassType = typeof(global::TUnit.TestProject.AfterTests.AssemblyBase1), - MethodInfo = new global::TUnit.Core.MethodMetadata + static __registrationIndex => + new InstanceHookMethod + { + InitClassType = typeof(global::TUnit.TestProject.AfterTests.AssemblyBase1), + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.AfterTests.AssemblyBase1), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.AssemblyBase1)), + Name = "AfterEach1", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = global::System.Array.Empty(), + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.AfterTests.AssemblyBase1", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.AfterTests.AssemblyBase1), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.AssemblyBase1)), + Name = "AssemblyBase1", + Namespace = "TUnit.TestProject.AfterTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_AfterTests_AssemblyBase1_AfterEach1_After_Test_Body + } + ); + private static ValueTask TUnit_TestProject_AfterTests_AssemblyBase1_AfterEach1_After_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) { - Type = typeof(global::TUnit.TestProject.AfterTests.AssemblyBase1), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.AssemblyBase1)), - Name = "AfterEach1", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = global::System.Array.Empty(), - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.AfterTests.AssemblyBase1", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.AfterTests.AssemblyBase1), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.AssemblyBase1)), - Name = "AssemblyBase1", - Namespace = "TUnit.TestProject.AfterTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_AfterTests_AssemblyBase1_AfterEach1_After_Test.TUnit_TestProject_AfterTests_AssemblyBase1_AfterEach1_After_TestInitializer.global_TUnit_TestProject_AfterTests_AssemblyBase1_AfterEach1_0Params_Body - } -); + try + { + var typedInstance = (global::TUnit.TestProject.AfterTests.AssemblyBase1)instance; + return new ValueTask(typedInstance.AfterEach1()); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } + } } } @@ -144,134 +113,103 @@ namespace TUnit.Generated #nullable enable #pragma warning disable CS9113 // Parameter is unread. using System; -using System.Collections.Generic; -using System.Linq; using System.Reflection; -using System.Runtime.CompilerServices; using System.Threading; using System.Threading.Tasks; using global::TUnit.Core; using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_AfterTests_AssemblyBase2_AfterAll2_After_Assembly -{ - internal static class TUnit_TestProject_AfterTests_AssemblyBase2_AfterAll2_After_AssemblyInitializer - { - internal static async ValueTask global_TUnit_TestProject_AfterTests_AssemblyBase2_AfterAll2_0Params_Body(AssemblyHookContext context, CancellationToken cancellationToken) - { - await AsyncConvert.Convert(() => global::TUnit.TestProject.AfterTests.AssemblyBase2.AfterAll2()); - } - } -} namespace TUnit.Generated { internal static partial class TUnit_HookRegistration { static readonly int _h_TUnit_TestProject_AfterTests_AssemblyBase2_AfterAll2_After_Assembly = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterAssemblyHooks, typeof(global::TUnit.TestProject.AfterTests.AssemblyBase2).Assembly, global::TUnit.Core.HookRegistrationIndices.GetNextAfterAssemblyHookIndex(), - static __registrationIndex => - new AfterAssemblyHookMethod - { - MethodInfo = new global::TUnit.Core.MethodMetadata - { - Type = typeof(global::TUnit.TestProject.AfterTests.AssemblyBase2), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.AssemblyBase2)), - Name = "AfterAll2", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = global::System.Array.Empty(), - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.AfterTests.AssemblyBase2", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.AfterTests.AssemblyBase2), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.AssemblyBase2)), - Name = "AssemblyBase2", - Namespace = "TUnit.TestProject.AfterTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_AfterTests_AssemblyBase2_AfterAll2_After_Assembly.TUnit_TestProject_AfterTests_AssemblyBase2_AfterAll2_After_AssemblyInitializer.global_TUnit_TestProject_AfterTests_AssemblyBase2_AfterAll2_0Params_Body, - FilePath = "", - LineNumber = 20 - } -); - } -} - - -// ===== FILE SEPARATOR ===== - -// -#pragma warning disable - -#nullable enable -#pragma warning disable CS9113 // Parameter is unread. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Threading; -using System.Threading.Tasks; -using global::TUnit.Core; -using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_AfterTests_AssemblyBase2_AfterEach2_After_Test -{ - internal static class TUnit_TestProject_AfterTests_AssemblyBase2_AfterEach2_After_TestInitializer - { - internal static async ValueTask global_TUnit_TestProject_AfterTests_AssemblyBase2_AfterEach2_0Params_Body(object instance, TestContext context, CancellationToken cancellationToken) + static __registrationIndex => + new AfterAssemblyHookMethod + { + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.AfterTests.AssemblyBase2), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.AssemblyBase2)), + Name = "AfterAll2", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = global::System.Array.Empty(), + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.AfterTests.AssemblyBase2", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.AfterTests.AssemblyBase2), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.AssemblyBase2)), + Name = "AssemblyBase2", + Namespace = "TUnit.TestProject.AfterTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_AfterTests_AssemblyBase2_AfterAll2_After_Assembly_Body, + FilePath = "", + LineNumber = 20 + } + ); + private static ValueTask TUnit_TestProject_AfterTests_AssemblyBase2_AfterAll2_After_Assembly_Body(AssemblyHookContext context, CancellationToken cancellationToken) { - var typedInstance = (global::TUnit.TestProject.AfterTests.AssemblyBase2)instance; - await AsyncConvert.Convert(() => typedInstance.AfterEach2()); + try + { + return new ValueTask(global::TUnit.TestProject.AfterTests.AssemblyBase2.AfterAll2()); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } } - } -} -namespace TUnit.Generated -{ - internal static partial class TUnit_HookRegistration - { static readonly int _h_TUnit_TestProject_AfterTests_AssemblyBase2_AfterEach2_After_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterTestHooks, typeof(global::TUnit.TestProject.AfterTests.AssemblyBase2), global::TUnit.Core.HookRegistrationIndices.GetNextAfterTestHookIndex(), - static __registrationIndex => - new InstanceHookMethod - { - InitClassType = typeof(global::TUnit.TestProject.AfterTests.AssemblyBase2), - MethodInfo = new global::TUnit.Core.MethodMetadata + static __registrationIndex => + new InstanceHookMethod + { + InitClassType = typeof(global::TUnit.TestProject.AfterTests.AssemblyBase2), + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.AfterTests.AssemblyBase2), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.AssemblyBase2)), + Name = "AfterEach2", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = global::System.Array.Empty(), + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.AfterTests.AssemblyBase2", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.AfterTests.AssemblyBase2), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.AssemblyBase2)), + Name = "AssemblyBase2", + Namespace = "TUnit.TestProject.AfterTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_AfterTests_AssemblyBase2_AfterEach2_After_Test_Body + } + ); + private static ValueTask TUnit_TestProject_AfterTests_AssemblyBase2_AfterEach2_After_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) { - Type = typeof(global::TUnit.TestProject.AfterTests.AssemblyBase2), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.AssemblyBase2)), - Name = "AfterEach2", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = global::System.Array.Empty(), - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.AfterTests.AssemblyBase2", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.AfterTests.AssemblyBase2), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.AssemblyBase2)), - Name = "AssemblyBase2", - Namespace = "TUnit.TestProject.AfterTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_AfterTests_AssemblyBase2_AfterEach2_After_Test.TUnit_TestProject_AfterTests_AssemblyBase2_AfterEach2_After_TestInitializer.global_TUnit_TestProject_AfterTests_AssemblyBase2_AfterEach2_0Params_Body - } -); + try + { + var typedInstance = (global::TUnit.TestProject.AfterTests.AssemblyBase2)instance; + return new ValueTask(typedInstance.AfterEach2()); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } + } } } @@ -284,134 +222,103 @@ namespace TUnit.Generated #nullable enable #pragma warning disable CS9113 // Parameter is unread. using System; -using System.Collections.Generic; -using System.Linq; using System.Reflection; -using System.Runtime.CompilerServices; using System.Threading; using System.Threading.Tasks; using global::TUnit.Core; using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_AfterTests_AssemblyBase3_AfterAll3_After_Assembly -{ - internal static class TUnit_TestProject_AfterTests_AssemblyBase3_AfterAll3_After_AssemblyInitializer - { - internal static async ValueTask global_TUnit_TestProject_AfterTests_AssemblyBase3_AfterAll3_0Params_Body(AssemblyHookContext context, CancellationToken cancellationToken) - { - await AsyncConvert.Convert(() => global::TUnit.TestProject.AfterTests.AssemblyBase3.AfterAll3()); - } - } -} namespace TUnit.Generated { internal static partial class TUnit_HookRegistration { static readonly int _h_TUnit_TestProject_AfterTests_AssemblyBase3_AfterAll3_After_Assembly = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterAssemblyHooks, typeof(global::TUnit.TestProject.AfterTests.AssemblyBase3).Assembly, global::TUnit.Core.HookRegistrationIndices.GetNextAfterAssemblyHookIndex(), - static __registrationIndex => - new AfterAssemblyHookMethod - { - MethodInfo = new global::TUnit.Core.MethodMetadata - { - Type = typeof(global::TUnit.TestProject.AfterTests.AssemblyBase3), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.AssemblyBase3)), - Name = "AfterAll3", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = global::System.Array.Empty(), - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.AfterTests.AssemblyBase3", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.AfterTests.AssemblyBase3), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.AssemblyBase3)), - Name = "AssemblyBase3", - Namespace = "TUnit.TestProject.AfterTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_AfterTests_AssemblyBase3_AfterAll3_After_Assembly.TUnit_TestProject_AfterTests_AssemblyBase3_AfterAll3_After_AssemblyInitializer.global_TUnit_TestProject_AfterTests_AssemblyBase3_AfterAll3_0Params_Body, - FilePath = "", - LineNumber = 35 - } -); - } -} - - -// ===== FILE SEPARATOR ===== - -// -#pragma warning disable - -#nullable enable -#pragma warning disable CS9113 // Parameter is unread. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Threading; -using System.Threading.Tasks; -using global::TUnit.Core; -using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_AfterTests_AssemblyBase3_AfterEach3_After_Test -{ - internal static class TUnit_TestProject_AfterTests_AssemblyBase3_AfterEach3_After_TestInitializer - { - internal static async ValueTask global_TUnit_TestProject_AfterTests_AssemblyBase3_AfterEach3_0Params_Body(object instance, TestContext context, CancellationToken cancellationToken) + static __registrationIndex => + new AfterAssemblyHookMethod + { + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.AfterTests.AssemblyBase3), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.AssemblyBase3)), + Name = "AfterAll3", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = global::System.Array.Empty(), + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.AfterTests.AssemblyBase3", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.AfterTests.AssemblyBase3), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.AssemblyBase3)), + Name = "AssemblyBase3", + Namespace = "TUnit.TestProject.AfterTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_AfterTests_AssemblyBase3_AfterAll3_After_Assembly_Body, + FilePath = "", + LineNumber = 35 + } + ); + private static ValueTask TUnit_TestProject_AfterTests_AssemblyBase3_AfterAll3_After_Assembly_Body(AssemblyHookContext context, CancellationToken cancellationToken) { - var typedInstance = (global::TUnit.TestProject.AfterTests.AssemblyBase3)instance; - await AsyncConvert.Convert(() => typedInstance.AfterEach3()); + try + { + return new ValueTask(global::TUnit.TestProject.AfterTests.AssemblyBase3.AfterAll3()); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } } - } -} -namespace TUnit.Generated -{ - internal static partial class TUnit_HookRegistration - { static readonly int _h_TUnit_TestProject_AfterTests_AssemblyBase3_AfterEach3_After_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterTestHooks, typeof(global::TUnit.TestProject.AfterTests.AssemblyBase3), global::TUnit.Core.HookRegistrationIndices.GetNextAfterTestHookIndex(), - static __registrationIndex => - new InstanceHookMethod - { - InitClassType = typeof(global::TUnit.TestProject.AfterTests.AssemblyBase3), - MethodInfo = new global::TUnit.Core.MethodMetadata + static __registrationIndex => + new InstanceHookMethod + { + InitClassType = typeof(global::TUnit.TestProject.AfterTests.AssemblyBase3), + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.AfterTests.AssemblyBase3), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.AssemblyBase3)), + Name = "AfterEach3", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = global::System.Array.Empty(), + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.AfterTests.AssemblyBase3", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.AfterTests.AssemblyBase3), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.AssemblyBase3)), + Name = "AssemblyBase3", + Namespace = "TUnit.TestProject.AfterTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_AfterTests_AssemblyBase3_AfterEach3_After_Test_Body + } + ); + private static ValueTask TUnit_TestProject_AfterTests_AssemblyBase3_AfterEach3_After_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) { - Type = typeof(global::TUnit.TestProject.AfterTests.AssemblyBase3), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.AssemblyBase3)), - Name = "AfterEach3", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = global::System.Array.Empty(), - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.AfterTests.AssemblyBase3", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.AfterTests.AssemblyBase3), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.AssemblyBase3)), - Name = "AssemblyBase3", - Namespace = "TUnit.TestProject.AfterTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_AfterTests_AssemblyBase3_AfterEach3_After_Test.TUnit_TestProject_AfterTests_AssemblyBase3_AfterEach3_After_TestInitializer.global_TUnit_TestProject_AfterTests_AssemblyBase3_AfterEach3_0Params_Body - } -); + try + { + var typedInstance = (global::TUnit.TestProject.AfterTests.AssemblyBase3)instance; + return new ValueTask(typedInstance.AfterEach3()); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } + } } } @@ -424,570 +331,383 @@ namespace TUnit.Generated #nullable enable #pragma warning disable CS9113 // Parameter is unread. using System; -using System.Collections.Generic; -using System.Linq; using System.Reflection; -using System.Runtime.CompilerServices; using System.Threading; using System.Threading.Tasks; using global::TUnit.Core; using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_AfterTests_AssemblyCleanupTests_AfterAllCleanUp_After_Assembly -{ - internal static class TUnit_TestProject_AfterTests_AssemblyCleanupTests_AfterAllCleanUp_After_AssemblyInitializer - { - internal static async ValueTask global_TUnit_TestProject_AfterTests_AssemblyCleanupTests_AfterAllCleanUp_0Params_Body(AssemblyHookContext context, CancellationToken cancellationToken) - { - await AsyncConvert.Convert(() => global::TUnit.TestProject.AfterTests.AssemblyCleanupTests.AfterAllCleanUp()); - } - } -} namespace TUnit.Generated { internal static partial class TUnit_HookRegistration { static readonly int _h_TUnit_TestProject_AfterTests_AssemblyCleanupTests_AfterAllCleanUp_After_Assembly = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterAssemblyHooks, typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests).Assembly, global::TUnit.Core.HookRegistrationIndices.GetNextAfterAssemblyHookIndex(), - static __registrationIndex => - new AfterAssemblyHookMethod - { - MethodInfo = new global::TUnit.Core.MethodMetadata - { - Type = typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests)), - Name = "AfterAllCleanUp", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = global::System.Array.Empty(), - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.AfterTests.AssemblyCleanupTests", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests)), - Name = "AssemblyCleanupTests", - Namespace = "TUnit.TestProject.AfterTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_AfterTests_AssemblyCleanupTests_AfterAllCleanUp_After_Assembly.TUnit_TestProject_AfterTests_AssemblyCleanupTests_AfterAllCleanUp_After_AssemblyInitializer.global_TUnit_TestProject_AfterTests_AssemblyCleanupTests_AfterAllCleanUp_0Params_Body, - FilePath = "", - LineNumber = 50 - } -); - } -} - - -// ===== FILE SEPARATOR ===== - -// -#pragma warning disable - -#nullable enable -#pragma warning disable CS9113 // Parameter is unread. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Threading; -using System.Threading.Tasks; -using global::TUnit.Core; -using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_AfterTests_AssemblyCleanupTests_AfterAllCleanUpWithContext__AssemblyHookContext_After_Assembly -{ - internal static class TUnit_TestProject_AfterTests_AssemblyCleanupTests_AfterAllCleanUpWithContext__AssemblyHookContext_After_AssemblyInitializer - { - internal static async ValueTask global_TUnit_TestProject_AfterTests_AssemblyCleanupTests_AfterAllCleanUpWithContext_1Params_Body(AssemblyHookContext context, CancellationToken cancellationToken) + static __registrationIndex => + new AfterAssemblyHookMethod + { + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests)), + Name = "AfterAllCleanUp", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = global::System.Array.Empty(), + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.AfterTests.AssemblyCleanupTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests)), + Name = "AssemblyCleanupTests", + Namespace = "TUnit.TestProject.AfterTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_AfterTests_AssemblyCleanupTests_AfterAllCleanUp_After_Assembly_Body, + FilePath = "", + LineNumber = 50 + } + ); + private static ValueTask TUnit_TestProject_AfterTests_AssemblyCleanupTests_AfterAllCleanUp_After_Assembly_Body(AssemblyHookContext context, CancellationToken cancellationToken) { - await AsyncConvert.Convert(() => global::TUnit.TestProject.AfterTests.AssemblyCleanupTests.AfterAllCleanUpWithContext(context)); + try + { + return new ValueTask(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests.AfterAllCleanUp()); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } } - } -} -namespace TUnit.Generated -{ - internal static partial class TUnit_HookRegistration - { static readonly int _h_TUnit_TestProject_AfterTests_AssemblyCleanupTests_AfterAllCleanUpWithContext__AssemblyHookContext_After_Assembly = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterAssemblyHooks, typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests).Assembly, global::TUnit.Core.HookRegistrationIndices.GetNextAfterAssemblyHookIndex(), - static __registrationIndex => - new AfterAssemblyHookMethod - { - MethodInfo = new global::TUnit.Core.MethodMetadata - { - Type = typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests)), - Name = "AfterAllCleanUpWithContext", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = new global::TUnit.Core.ParameterMetadata[] - { - global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::TUnit.Core.AssemblyHookContext), "context", new global::TUnit.Core.ConcreteType(typeof(global::TUnit.Core.AssemblyHookContext)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests).GetMethod("AfterAllCleanUpWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::TUnit.Core.AssemblyHookContext) }, null)!.GetParameters()[0]) - }, - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.AfterTests.AssemblyCleanupTests", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests)), - Name = "AssemblyCleanupTests", - Namespace = "TUnit.TestProject.AfterTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_AfterTests_AssemblyCleanupTests_AfterAllCleanUpWithContext__AssemblyHookContext_After_Assembly.TUnit_TestProject_AfterTests_AssemblyCleanupTests_AfterAllCleanUpWithContext__AssemblyHookContext_After_AssemblyInitializer.global_TUnit_TestProject_AfterTests_AssemblyCleanupTests_AfterAllCleanUpWithContext_1Params_Body, - FilePath = "", - LineNumber = 56 - } -); - } -} - - -// ===== FILE SEPARATOR ===== - -// -#pragma warning disable - -#nullable enable -#pragma warning disable CS9113 // Parameter is unread. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Threading; -using System.Threading.Tasks; -using global::TUnit.Core; -using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_AfterTests_AssemblyCleanupTests_AfterAllCleanUp2_After_Assembly -{ - internal static class TUnit_TestProject_AfterTests_AssemblyCleanupTests_AfterAllCleanUp2_After_AssemblyInitializer - { - internal static async ValueTask global_TUnit_TestProject_AfterTests_AssemblyCleanupTests_AfterAllCleanUp2_0Params_Body(AssemblyHookContext context, CancellationToken cancellationToken) + static __registrationIndex => + new AfterAssemblyHookMethod + { + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests)), + Name = "AfterAllCleanUpWithContext", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = new global::TUnit.Core.ParameterMetadata[] + { + global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::TUnit.Core.AssemblyHookContext), "context", new global::TUnit.Core.ConcreteType(typeof(global::TUnit.Core.AssemblyHookContext)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests).GetMethod("AfterAllCleanUpWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::TUnit.Core.AssemblyHookContext) }, null)!.GetParameters()[0]) + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.AfterTests.AssemblyCleanupTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests)), + Name = "AssemblyCleanupTests", + Namespace = "TUnit.TestProject.AfterTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_AfterTests_AssemblyCleanupTests_AfterAllCleanUpWithContext__AssemblyHookContext_After_Assembly_Body, + FilePath = "", + LineNumber = 56 + } + ); + private static ValueTask TUnit_TestProject_AfterTests_AssemblyCleanupTests_AfterAllCleanUpWithContext__AssemblyHookContext_After_Assembly_Body(AssemblyHookContext context, CancellationToken cancellationToken) { - await AsyncConvert.Convert(() => global::TUnit.TestProject.AfterTests.AssemblyCleanupTests.AfterAllCleanUp2()); + try + { + return new ValueTask(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests.AfterAllCleanUpWithContext(context)); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } } - } -} -namespace TUnit.Generated -{ - internal static partial class TUnit_HookRegistration - { static readonly int _h_TUnit_TestProject_AfterTests_AssemblyCleanupTests_AfterAllCleanUp2_After_Assembly = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterAssemblyHooks, typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests).Assembly, global::TUnit.Core.HookRegistrationIndices.GetNextAfterAssemblyHookIndex(), - static __registrationIndex => - new AfterAssemblyHookMethod - { - MethodInfo = new global::TUnit.Core.MethodMetadata - { - Type = typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests)), - Name = "AfterAllCleanUp2", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = global::System.Array.Empty(), - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.AfterTests.AssemblyCleanupTests", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests)), - Name = "AssemblyCleanupTests", - Namespace = "TUnit.TestProject.AfterTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_AfterTests_AssemblyCleanupTests_AfterAllCleanUp2_After_Assembly.TUnit_TestProject_AfterTests_AssemblyCleanupTests_AfterAllCleanUp2_After_AssemblyInitializer.global_TUnit_TestProject_AfterTests_AssemblyCleanupTests_AfterAllCleanUp2_0Params_Body, - FilePath = "", - LineNumber = 62 - } -); - } -} - - -// ===== FILE SEPARATOR ===== - -// -#pragma warning disable - -#nullable enable -#pragma warning disable CS9113 // Parameter is unread. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Threading; -using System.Threading.Tasks; -using global::TUnit.Core; -using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_AfterTests_AssemblyCleanupTests_AfterAllCleanUpWithContextAndToken__AssemblyHookContext_CancellationToken_After_Assembly -{ - internal static class TUnit_TestProject_AfterTests_AssemblyCleanupTests_AfterAllCleanUpWithContextAndToken__AssemblyHookContext_CancellationToken_After_AssemblyInitializer - { - internal static async ValueTask global_TUnit_TestProject_AfterTests_AssemblyCleanupTests_AfterAllCleanUpWithContextAndToken_2Params_Body(AssemblyHookContext context, CancellationToken cancellationToken) + static __registrationIndex => + new AfterAssemblyHookMethod + { + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests)), + Name = "AfterAllCleanUp2", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = global::System.Array.Empty(), + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.AfterTests.AssemblyCleanupTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests)), + Name = "AssemblyCleanupTests", + Namespace = "TUnit.TestProject.AfterTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_AfterTests_AssemblyCleanupTests_AfterAllCleanUp2_After_Assembly_Body, + FilePath = "", + LineNumber = 62 + } + ); + private static ValueTask TUnit_TestProject_AfterTests_AssemblyCleanupTests_AfterAllCleanUp2_After_Assembly_Body(AssemblyHookContext context, CancellationToken cancellationToken) { - await AsyncConvert.Convert(() => global::TUnit.TestProject.AfterTests.AssemblyCleanupTests.AfterAllCleanUpWithContextAndToken(context, cancellationToken)); + try + { + return new ValueTask(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests.AfterAllCleanUp2()); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } } - } -} -namespace TUnit.Generated -{ - internal static partial class TUnit_HookRegistration - { static readonly int _h_TUnit_TestProject_AfterTests_AssemblyCleanupTests_AfterAllCleanUpWithContextAndToken__AssemblyHookContext_CancellationToken_After_Assembly = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterAssemblyHooks, typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests).Assembly, global::TUnit.Core.HookRegistrationIndices.GetNextAfterAssemblyHookIndex(), - static __registrationIndex => - new AfterAssemblyHookMethod - { - MethodInfo = new global::TUnit.Core.MethodMetadata - { - Type = typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests)), - Name = "AfterAllCleanUpWithContextAndToken", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = new global::TUnit.Core.ParameterMetadata[] - { - global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::TUnit.Core.AssemblyHookContext), "context", new global::TUnit.Core.ConcreteType(typeof(global::TUnit.Core.AssemblyHookContext)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests).GetMethod("AfterAllCleanUpWithContextAndToken", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::TUnit.Core.AssemblyHookContext), typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[0]), - global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::System.Threading.CancellationToken), "cancellationToken", new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.CancellationToken)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests).GetMethod("AfterAllCleanUpWithContextAndToken", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::TUnit.Core.AssemblyHookContext), typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[1]) - }, - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.AfterTests.AssemblyCleanupTests", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests)), - Name = "AssemblyCleanupTests", - Namespace = "TUnit.TestProject.AfterTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_AfterTests_AssemblyCleanupTests_AfterAllCleanUpWithContextAndToken__AssemblyHookContext_CancellationToken_After_Assembly.TUnit_TestProject_AfterTests_AssemblyCleanupTests_AfterAllCleanUpWithContextAndToken__AssemblyHookContext_CancellationToken_After_AssemblyInitializer.global_TUnit_TestProject_AfterTests_AssemblyCleanupTests_AfterAllCleanUpWithContextAndToken_2Params_Body, - FilePath = "", - LineNumber = 68 - } -); - } -} - - -// ===== FILE SEPARATOR ===== - -// -#pragma warning disable - -#nullable enable -#pragma warning disable CS9113 // Parameter is unread. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Threading; -using System.Threading.Tasks; -using global::TUnit.Core; -using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_AfterTests_AssemblyCleanupTests_Cleanup_After_Test -{ - internal static class TUnit_TestProject_AfterTests_AssemblyCleanupTests_Cleanup_After_TestInitializer - { - internal static async ValueTask global_TUnit_TestProject_AfterTests_AssemblyCleanupTests_Cleanup_0Params_Body(object instance, TestContext context, CancellationToken cancellationToken) + static __registrationIndex => + new AfterAssemblyHookMethod + { + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests)), + Name = "AfterAllCleanUpWithContextAndToken", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = new global::TUnit.Core.ParameterMetadata[] + { + global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::TUnit.Core.AssemblyHookContext), "context", new global::TUnit.Core.ConcreteType(typeof(global::TUnit.Core.AssemblyHookContext)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests).GetMethod("AfterAllCleanUpWithContextAndToken", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::TUnit.Core.AssemblyHookContext), typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[0]), + global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::System.Threading.CancellationToken), "cancellationToken", new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.CancellationToken)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests).GetMethod("AfterAllCleanUpWithContextAndToken", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::TUnit.Core.AssemblyHookContext), typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[1]) + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.AfterTests.AssemblyCleanupTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests)), + Name = "AssemblyCleanupTests", + Namespace = "TUnit.TestProject.AfterTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_AfterTests_AssemblyCleanupTests_AfterAllCleanUpWithContextAndToken__AssemblyHookContext_CancellationToken_After_Assembly_Body, + FilePath = "", + LineNumber = 68 + } + ); + private static ValueTask TUnit_TestProject_AfterTests_AssemblyCleanupTests_AfterAllCleanUpWithContextAndToken__AssemblyHookContext_CancellationToken_After_Assembly_Body(AssemblyHookContext context, CancellationToken cancellationToken) { - var typedInstance = (global::TUnit.TestProject.AfterTests.AssemblyCleanupTests)instance; - await AsyncConvert.Convert(() => typedInstance.Cleanup()); + try + { + return new ValueTask(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests.AfterAllCleanUpWithContextAndToken(context, cancellationToken)); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } } - } -} -namespace TUnit.Generated -{ - internal static partial class TUnit_HookRegistration - { static readonly int _h_TUnit_TestProject_AfterTests_AssemblyCleanupTests_Cleanup_After_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterTestHooks, typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests), global::TUnit.Core.HookRegistrationIndices.GetNextAfterTestHookIndex(), - static __registrationIndex => - new InstanceHookMethod - { - InitClassType = typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests), - MethodInfo = new global::TUnit.Core.MethodMetadata - { - Type = typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests)), - Name = "Cleanup", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = global::System.Array.Empty(), - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.AfterTests.AssemblyCleanupTests", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests)), - Name = "AssemblyCleanupTests", - Namespace = "TUnit.TestProject.AfterTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_AfterTests_AssemblyCleanupTests_Cleanup_After_Test.TUnit_TestProject_AfterTests_AssemblyCleanupTests_Cleanup_After_TestInitializer.global_TUnit_TestProject_AfterTests_AssemblyCleanupTests_Cleanup_0Params_Body - } -); - } -} - - -// ===== FILE SEPARATOR ===== - -// -#pragma warning disable - -#nullable enable -#pragma warning disable CS9113 // Parameter is unread. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Threading; -using System.Threading.Tasks; -using global::TUnit.Core; -using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_AfterTests_AssemblyCleanupTests_Cleanup__CancellationToken_After_Test -{ - internal static class TUnit_TestProject_AfterTests_AssemblyCleanupTests_Cleanup__CancellationToken_After_TestInitializer - { - internal static async ValueTask global_TUnit_TestProject_AfterTests_AssemblyCleanupTests_Cleanup_1Params_Body(object instance, TestContext context, CancellationToken cancellationToken) + static __registrationIndex => + new InstanceHookMethod + { + InitClassType = typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests), + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests)), + Name = "Cleanup", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = global::System.Array.Empty(), + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.AfterTests.AssemblyCleanupTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests)), + Name = "AssemblyCleanupTests", + Namespace = "TUnit.TestProject.AfterTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_AfterTests_AssemblyCleanupTests_Cleanup_After_Test_Body + } + ); + private static ValueTask TUnit_TestProject_AfterTests_AssemblyCleanupTests_Cleanup_After_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) { - var typedInstance = (global::TUnit.TestProject.AfterTests.AssemblyCleanupTests)instance; - await AsyncConvert.Convert(() => typedInstance.Cleanup(cancellationToken)); + try + { + var typedInstance = (global::TUnit.TestProject.AfterTests.AssemblyCleanupTests)instance; + return new ValueTask(typedInstance.Cleanup()); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } } - } -} -namespace TUnit.Generated -{ - internal static partial class TUnit_HookRegistration - { static readonly int _h_TUnit_TestProject_AfterTests_AssemblyCleanupTests_Cleanup__CancellationToken_After_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterTestHooks, typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests), global::TUnit.Core.HookRegistrationIndices.GetNextAfterTestHookIndex(), - static __registrationIndex => - new InstanceHookMethod - { - InitClassType = typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests), - MethodInfo = new global::TUnit.Core.MethodMetadata - { - Type = typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests)), - Name = "Cleanup", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = new global::TUnit.Core.ParameterMetadata[] - { - global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::System.Threading.CancellationToken), "cancellationToken", new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.CancellationToken)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests).GetMethod("Cleanup", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[0]) - }, - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.AfterTests.AssemblyCleanupTests", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests)), - Name = "AssemblyCleanupTests", - Namespace = "TUnit.TestProject.AfterTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_AfterTests_AssemblyCleanupTests_Cleanup__CancellationToken_After_Test.TUnit_TestProject_AfterTests_AssemblyCleanupTests_Cleanup__CancellationToken_After_TestInitializer.global_TUnit_TestProject_AfterTests_AssemblyCleanupTests_Cleanup_1Params_Body - } -); - } -} - - -// ===== FILE SEPARATOR ===== - -// -#pragma warning disable - -#nullable enable -#pragma warning disable CS9113 // Parameter is unread. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Threading; -using System.Threading.Tasks; -using global::TUnit.Core; -using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_AfterTests_AssemblyCleanupTests_CleanupWithContext__TestContext_After_Test -{ - internal static class TUnit_TestProject_AfterTests_AssemblyCleanupTests_CleanupWithContext__TestContext_After_TestInitializer - { - internal static async ValueTask global_TUnit_TestProject_AfterTests_AssemblyCleanupTests_CleanupWithContext_1Params_Body(object instance, TestContext context, CancellationToken cancellationToken) + static __registrationIndex => + new InstanceHookMethod + { + InitClassType = typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests), + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests)), + Name = "Cleanup", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = new global::TUnit.Core.ParameterMetadata[] + { + global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::System.Threading.CancellationToken), "cancellationToken", new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.CancellationToken)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests).GetMethod("Cleanup", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[0]) + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.AfterTests.AssemblyCleanupTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests)), + Name = "AssemblyCleanupTests", + Namespace = "TUnit.TestProject.AfterTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_AfterTests_AssemblyCleanupTests_Cleanup__CancellationToken_After_Test_Body + } + ); + private static ValueTask TUnit_TestProject_AfterTests_AssemblyCleanupTests_Cleanup__CancellationToken_After_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) { - var typedInstance = (global::TUnit.TestProject.AfterTests.AssemblyCleanupTests)instance; - await AsyncConvert.Convert(() => typedInstance.CleanupWithContext(context)); + try + { + var typedInstance = (global::TUnit.TestProject.AfterTests.AssemblyCleanupTests)instance; + return new ValueTask(typedInstance.Cleanup(cancellationToken)); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } } - } -} -namespace TUnit.Generated -{ - internal static partial class TUnit_HookRegistration - { static readonly int _h_TUnit_TestProject_AfterTests_AssemblyCleanupTests_CleanupWithContext__TestContext_After_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterTestHooks, typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests), global::TUnit.Core.HookRegistrationIndices.GetNextAfterTestHookIndex(), - static __registrationIndex => - new InstanceHookMethod - { - InitClassType = typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests), - MethodInfo = new global::TUnit.Core.MethodMetadata - { - Type = typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests)), - Name = "CleanupWithContext", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = new global::TUnit.Core.ParameterMetadata[] - { - global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::TUnit.Core.TestContext), "testContext", new global::TUnit.Core.ConcreteType(typeof(global::TUnit.Core.TestContext)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests).GetMethod("CleanupWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(global::TUnit.Core.TestContext) }, null)!.GetParameters()[0]) - }, - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.AfterTests.AssemblyCleanupTests", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests)), - Name = "AssemblyCleanupTests", - Namespace = "TUnit.TestProject.AfterTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_AfterTests_AssemblyCleanupTests_CleanupWithContext__TestContext_After_Test.TUnit_TestProject_AfterTests_AssemblyCleanupTests_CleanupWithContext__TestContext_After_TestInitializer.global_TUnit_TestProject_AfterTests_AssemblyCleanupTests_CleanupWithContext_1Params_Body - } -); - } -} - - -// ===== FILE SEPARATOR ===== - -// -#pragma warning disable - -#nullable enable -#pragma warning disable CS9113 // Parameter is unread. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Threading; -using System.Threading.Tasks; -using global::TUnit.Core; -using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_AfterTests_AssemblyCleanupTests_CleanupWithContext__TestContext_CancellationToken_After_Test -{ - internal static class TUnit_TestProject_AfterTests_AssemblyCleanupTests_CleanupWithContext__TestContext_CancellationToken_After_TestInitializer - { - internal static async ValueTask global_TUnit_TestProject_AfterTests_AssemblyCleanupTests_CleanupWithContext_2Params_Body(object instance, TestContext context, CancellationToken cancellationToken) + static __registrationIndex => + new InstanceHookMethod + { + InitClassType = typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests), + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests)), + Name = "CleanupWithContext", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = new global::TUnit.Core.ParameterMetadata[] + { + global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::TUnit.Core.TestContext), "testContext", new global::TUnit.Core.ConcreteType(typeof(global::TUnit.Core.TestContext)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests).GetMethod("CleanupWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(global::TUnit.Core.TestContext) }, null)!.GetParameters()[0]) + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.AfterTests.AssemblyCleanupTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests)), + Name = "AssemblyCleanupTests", + Namespace = "TUnit.TestProject.AfterTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_AfterTests_AssemblyCleanupTests_CleanupWithContext__TestContext_After_Test_Body + } + ); + private static ValueTask TUnit_TestProject_AfterTests_AssemblyCleanupTests_CleanupWithContext__TestContext_After_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) { - var typedInstance = (global::TUnit.TestProject.AfterTests.AssemblyCleanupTests)instance; - await AsyncConvert.Convert(() => typedInstance.CleanupWithContext(context, cancellationToken)); + try + { + var typedInstance = (global::TUnit.TestProject.AfterTests.AssemblyCleanupTests)instance; + return new ValueTask(typedInstance.CleanupWithContext(context)); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } } - } -} -namespace TUnit.Generated -{ - internal static partial class TUnit_HookRegistration - { static readonly int _h_TUnit_TestProject_AfterTests_AssemblyCleanupTests_CleanupWithContext__TestContext_CancellationToken_After_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterTestHooks, typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests), global::TUnit.Core.HookRegistrationIndices.GetNextAfterTestHookIndex(), - static __registrationIndex => - new InstanceHookMethod - { - InitClassType = typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests), - MethodInfo = new global::TUnit.Core.MethodMetadata + static __registrationIndex => + new InstanceHookMethod + { + InitClassType = typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests), + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests)), + Name = "CleanupWithContext", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = new global::TUnit.Core.ParameterMetadata[] + { + global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::TUnit.Core.TestContext), "testContext", new global::TUnit.Core.ConcreteType(typeof(global::TUnit.Core.TestContext)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests).GetMethod("CleanupWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(global::TUnit.Core.TestContext), typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[0]), + global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::System.Threading.CancellationToken), "cancellationToken", new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.CancellationToken)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests).GetMethod("CleanupWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(global::TUnit.Core.TestContext), typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[1]) + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.AfterTests.AssemblyCleanupTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests)), + Name = "AssemblyCleanupTests", + Namespace = "TUnit.TestProject.AfterTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_AfterTests_AssemblyCleanupTests_CleanupWithContext__TestContext_CancellationToken_After_Test_Body + } + ); + private static ValueTask TUnit_TestProject_AfterTests_AssemblyCleanupTests_CleanupWithContext__TestContext_CancellationToken_After_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) { - Type = typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests)), - Name = "CleanupWithContext", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = new global::TUnit.Core.ParameterMetadata[] - { - global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::TUnit.Core.TestContext), "testContext", new global::TUnit.Core.ConcreteType(typeof(global::TUnit.Core.TestContext)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests).GetMethod("CleanupWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(global::TUnit.Core.TestContext), typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[0]), - global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::System.Threading.CancellationToken), "cancellationToken", new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.CancellationToken)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests).GetMethod("CleanupWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(global::TUnit.Core.TestContext), typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[1]) - }, - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.AfterTests.AssemblyCleanupTests", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests)), - Name = "AssemblyCleanupTests", - Namespace = "TUnit.TestProject.AfterTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_AfterTests_AssemblyCleanupTests_CleanupWithContext__TestContext_CancellationToken_After_Test.TUnit_TestProject_AfterTests_AssemblyCleanupTests_CleanupWithContext__TestContext_CancellationToken_After_TestInitializer.global_TUnit_TestProject_AfterTests_AssemblyCleanupTests_CleanupWithContext_2Params_Body - } -); + try + { + var typedInstance = (global::TUnit.TestProject.AfterTests.AssemblyCleanupTests)instance; + return new ValueTask(typedInstance.CleanupWithContext(context, cancellationToken)); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } + } } } diff --git a/tests/TUnit.Core.SourceGenerator.Tests/AssemblyBeforeTests.Test.verified.txt b/tests/TUnit.Core.SourceGenerator.Tests/AssemblyBeforeTests.Test.verified.txt index 4bdba963103..92af8766e1e 100644 --- a/tests/TUnit.Core.SourceGenerator.Tests/AssemblyBeforeTests.Test.verified.txt +++ b/tests/TUnit.Core.SourceGenerator.Tests/AssemblyBeforeTests.Test.verified.txt @@ -4,134 +4,103 @@ #nullable enable #pragma warning disable CS9113 // Parameter is unread. using System; -using System.Collections.Generic; -using System.Linq; using System.Reflection; -using System.Runtime.CompilerServices; using System.Threading; using System.Threading.Tasks; using global::TUnit.Core; using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_AssemblyBase1_BeforeAll1_Before_Assembly -{ - internal static class TUnit_TestProject_BeforeTests_AssemblyBase1_BeforeAll1_Before_AssemblyInitializer - { - internal static async ValueTask global_TUnit_TestProject_BeforeTests_AssemblyBase1_BeforeAll1_0Params_Body(AssemblyHookContext context, CancellationToken cancellationToken) - { - await AsyncConvert.Convert(() => global::TUnit.TestProject.BeforeTests.AssemblyBase1.BeforeAll1()); - } - } -} namespace TUnit.Generated { internal static partial class TUnit_HookRegistration { static readonly int _h_TUnit_TestProject_BeforeTests_AssemblyBase1_BeforeAll1_Before_Assembly = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeAssemblyHooks, typeof(global::TUnit.TestProject.BeforeTests.AssemblyBase1).Assembly, global::TUnit.Core.HookRegistrationIndices.GetNextBeforeAssemblyHookIndex(), - static __registrationIndex => - new BeforeAssemblyHookMethod - { - MethodInfo = new global::TUnit.Core.MethodMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.AssemblyBase1), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.AssemblyBase1)), - Name = "BeforeAll1", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = global::System.Array.Empty(), - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.AssemblyBase1", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.AssemblyBase1), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.AssemblyBase1)), - Name = "AssemblyBase1", - Namespace = "TUnit.TestProject.BeforeTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_AssemblyBase1_BeforeAll1_Before_Assembly.TUnit_TestProject_BeforeTests_AssemblyBase1_BeforeAll1_Before_AssemblyInitializer.global_TUnit_TestProject_BeforeTests_AssemblyBase1_BeforeAll1_0Params_Body, - FilePath = "", - LineNumber = 5 - } -); - } -} - - -// ===== FILE SEPARATOR ===== - -// -#pragma warning disable - -#nullable enable -#pragma warning disable CS9113 // Parameter is unread. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Threading; -using System.Threading.Tasks; -using global::TUnit.Core; -using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_AssemblyBase1_BeforeEach1_Before_Test -{ - internal static class TUnit_TestProject_BeforeTests_AssemblyBase1_BeforeEach1_Before_TestInitializer - { - internal static async ValueTask global_TUnit_TestProject_BeforeTests_AssemblyBase1_BeforeEach1_0Params_Body(object instance, TestContext context, CancellationToken cancellationToken) + static __registrationIndex => + new BeforeAssemblyHookMethod + { + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.AssemblyBase1), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.AssemblyBase1)), + Name = "BeforeAll1", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = global::System.Array.Empty(), + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.AssemblyBase1", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.AssemblyBase1), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.AssemblyBase1)), + Name = "AssemblyBase1", + Namespace = "TUnit.TestProject.BeforeTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_BeforeTests_AssemblyBase1_BeforeAll1_Before_Assembly_Body, + FilePath = "", + LineNumber = 5 + } + ); + private static ValueTask TUnit_TestProject_BeforeTests_AssemblyBase1_BeforeAll1_Before_Assembly_Body(AssemblyHookContext context, CancellationToken cancellationToken) { - var typedInstance = (global::TUnit.TestProject.BeforeTests.AssemblyBase1)instance; - await AsyncConvert.Convert(() => typedInstance.BeforeEach1()); + try + { + return new ValueTask(global::TUnit.TestProject.BeforeTests.AssemblyBase1.BeforeAll1()); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } } - } -} -namespace TUnit.Generated -{ - internal static partial class TUnit_HookRegistration - { static readonly int _h_TUnit_TestProject_BeforeTests_AssemblyBase1_BeforeEach1_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.AssemblyBase1), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), - static __registrationIndex => - new InstanceHookMethod - { - InitClassType = typeof(global::TUnit.TestProject.BeforeTests.AssemblyBase1), - MethodInfo = new global::TUnit.Core.MethodMetadata + static __registrationIndex => + new InstanceHookMethod + { + InitClassType = typeof(global::TUnit.TestProject.BeforeTests.AssemblyBase1), + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.AssemblyBase1), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.AssemblyBase1)), + Name = "BeforeEach1", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = global::System.Array.Empty(), + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.AssemblyBase1", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.AssemblyBase1), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.AssemblyBase1)), + Name = "AssemblyBase1", + Namespace = "TUnit.TestProject.BeforeTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_BeforeTests_AssemblyBase1_BeforeEach1_Before_Test_Body + } + ); + private static ValueTask TUnit_TestProject_BeforeTests_AssemblyBase1_BeforeEach1_Before_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) { - Type = typeof(global::TUnit.TestProject.BeforeTests.AssemblyBase1), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.AssemblyBase1)), - Name = "BeforeEach1", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = global::System.Array.Empty(), - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.AssemblyBase1", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.AssemblyBase1), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.AssemblyBase1)), - Name = "AssemblyBase1", - Namespace = "TUnit.TestProject.BeforeTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_AssemblyBase1_BeforeEach1_Before_Test.TUnit_TestProject_BeforeTests_AssemblyBase1_BeforeEach1_Before_TestInitializer.global_TUnit_TestProject_BeforeTests_AssemblyBase1_BeforeEach1_0Params_Body - } -); + try + { + var typedInstance = (global::TUnit.TestProject.BeforeTests.AssemblyBase1)instance; + return new ValueTask(typedInstance.BeforeEach1()); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } + } } } @@ -144,134 +113,103 @@ namespace TUnit.Generated #nullable enable #pragma warning disable CS9113 // Parameter is unread. using System; -using System.Collections.Generic; -using System.Linq; using System.Reflection; -using System.Runtime.CompilerServices; using System.Threading; using System.Threading.Tasks; using global::TUnit.Core; using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_AssemblyBase2_BeforeAll2_Before_Assembly -{ - internal static class TUnit_TestProject_BeforeTests_AssemblyBase2_BeforeAll2_Before_AssemblyInitializer - { - internal static async ValueTask global_TUnit_TestProject_BeforeTests_AssemblyBase2_BeforeAll2_0Params_Body(AssemblyHookContext context, CancellationToken cancellationToken) - { - await AsyncConvert.Convert(() => global::TUnit.TestProject.BeforeTests.AssemblyBase2.BeforeAll2()); - } - } -} namespace TUnit.Generated { internal static partial class TUnit_HookRegistration { static readonly int _h_TUnit_TestProject_BeforeTests_AssemblyBase2_BeforeAll2_Before_Assembly = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeAssemblyHooks, typeof(global::TUnit.TestProject.BeforeTests.AssemblyBase2).Assembly, global::TUnit.Core.HookRegistrationIndices.GetNextBeforeAssemblyHookIndex(), - static __registrationIndex => - new BeforeAssemblyHookMethod - { - MethodInfo = new global::TUnit.Core.MethodMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.AssemblyBase2), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.AssemblyBase2)), - Name = "BeforeAll2", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = global::System.Array.Empty(), - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.AssemblyBase2", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.AssemblyBase2), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.AssemblyBase2)), - Name = "AssemblyBase2", - Namespace = "TUnit.TestProject.BeforeTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_AssemblyBase2_BeforeAll2_Before_Assembly.TUnit_TestProject_BeforeTests_AssemblyBase2_BeforeAll2_Before_AssemblyInitializer.global_TUnit_TestProject_BeforeTests_AssemblyBase2_BeforeAll2_0Params_Body, - FilePath = "", - LineNumber = 20 - } -); - } -} - - -// ===== FILE SEPARATOR ===== - -// -#pragma warning disable - -#nullable enable -#pragma warning disable CS9113 // Parameter is unread. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Threading; -using System.Threading.Tasks; -using global::TUnit.Core; -using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_AssemblyBase2_BeforeEach2_Before_Test -{ - internal static class TUnit_TestProject_BeforeTests_AssemblyBase2_BeforeEach2_Before_TestInitializer - { - internal static async ValueTask global_TUnit_TestProject_BeforeTests_AssemblyBase2_BeforeEach2_0Params_Body(object instance, TestContext context, CancellationToken cancellationToken) + static __registrationIndex => + new BeforeAssemblyHookMethod + { + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.AssemblyBase2), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.AssemblyBase2)), + Name = "BeforeAll2", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = global::System.Array.Empty(), + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.AssemblyBase2", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.AssemblyBase2), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.AssemblyBase2)), + Name = "AssemblyBase2", + Namespace = "TUnit.TestProject.BeforeTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_BeforeTests_AssemblyBase2_BeforeAll2_Before_Assembly_Body, + FilePath = "", + LineNumber = 20 + } + ); + private static ValueTask TUnit_TestProject_BeforeTests_AssemblyBase2_BeforeAll2_Before_Assembly_Body(AssemblyHookContext context, CancellationToken cancellationToken) { - var typedInstance = (global::TUnit.TestProject.BeforeTests.AssemblyBase2)instance; - await AsyncConvert.Convert(() => typedInstance.BeforeEach2()); + try + { + return new ValueTask(global::TUnit.TestProject.BeforeTests.AssemblyBase2.BeforeAll2()); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } } - } -} -namespace TUnit.Generated -{ - internal static partial class TUnit_HookRegistration - { static readonly int _h_TUnit_TestProject_BeforeTests_AssemblyBase2_BeforeEach2_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.AssemblyBase2), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), - static __registrationIndex => - new InstanceHookMethod - { - InitClassType = typeof(global::TUnit.TestProject.BeforeTests.AssemblyBase2), - MethodInfo = new global::TUnit.Core.MethodMetadata + static __registrationIndex => + new InstanceHookMethod + { + InitClassType = typeof(global::TUnit.TestProject.BeforeTests.AssemblyBase2), + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.AssemblyBase2), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.AssemblyBase2)), + Name = "BeforeEach2", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = global::System.Array.Empty(), + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.AssemblyBase2", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.AssemblyBase2), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.AssemblyBase2)), + Name = "AssemblyBase2", + Namespace = "TUnit.TestProject.BeforeTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_BeforeTests_AssemblyBase2_BeforeEach2_Before_Test_Body + } + ); + private static ValueTask TUnit_TestProject_BeforeTests_AssemblyBase2_BeforeEach2_Before_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) { - Type = typeof(global::TUnit.TestProject.BeforeTests.AssemblyBase2), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.AssemblyBase2)), - Name = "BeforeEach2", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = global::System.Array.Empty(), - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.AssemblyBase2", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.AssemblyBase2), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.AssemblyBase2)), - Name = "AssemblyBase2", - Namespace = "TUnit.TestProject.BeforeTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_AssemblyBase2_BeforeEach2_Before_Test.TUnit_TestProject_BeforeTests_AssemblyBase2_BeforeEach2_Before_TestInitializer.global_TUnit_TestProject_BeforeTests_AssemblyBase2_BeforeEach2_0Params_Body - } -); + try + { + var typedInstance = (global::TUnit.TestProject.BeforeTests.AssemblyBase2)instance; + return new ValueTask(typedInstance.BeforeEach2()); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } + } } } @@ -284,134 +222,103 @@ namespace TUnit.Generated #nullable enable #pragma warning disable CS9113 // Parameter is unread. using System; -using System.Collections.Generic; -using System.Linq; using System.Reflection; -using System.Runtime.CompilerServices; using System.Threading; using System.Threading.Tasks; using global::TUnit.Core; using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_AssemblyBase3_BeforeAll3_Before_Assembly -{ - internal static class TUnit_TestProject_BeforeTests_AssemblyBase3_BeforeAll3_Before_AssemblyInitializer - { - internal static async ValueTask global_TUnit_TestProject_BeforeTests_AssemblyBase3_BeforeAll3_0Params_Body(AssemblyHookContext context, CancellationToken cancellationToken) - { - await AsyncConvert.Convert(() => global::TUnit.TestProject.BeforeTests.AssemblyBase3.BeforeAll3()); - } - } -} namespace TUnit.Generated { internal static partial class TUnit_HookRegistration { static readonly int _h_TUnit_TestProject_BeforeTests_AssemblyBase3_BeforeAll3_Before_Assembly = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeAssemblyHooks, typeof(global::TUnit.TestProject.BeforeTests.AssemblyBase3).Assembly, global::TUnit.Core.HookRegistrationIndices.GetNextBeforeAssemblyHookIndex(), - static __registrationIndex => - new BeforeAssemblyHookMethod - { - MethodInfo = new global::TUnit.Core.MethodMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.AssemblyBase3), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.AssemblyBase3)), - Name = "BeforeAll3", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = global::System.Array.Empty(), - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.AssemblyBase3", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.AssemblyBase3), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.AssemblyBase3)), - Name = "AssemblyBase3", - Namespace = "TUnit.TestProject.BeforeTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_AssemblyBase3_BeforeAll3_Before_Assembly.TUnit_TestProject_BeforeTests_AssemblyBase3_BeforeAll3_Before_AssemblyInitializer.global_TUnit_TestProject_BeforeTests_AssemblyBase3_BeforeAll3_0Params_Body, - FilePath = "", - LineNumber = 35 - } -); - } -} - - -// ===== FILE SEPARATOR ===== - -// -#pragma warning disable - -#nullable enable -#pragma warning disable CS9113 // Parameter is unread. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Threading; -using System.Threading.Tasks; -using global::TUnit.Core; -using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_AssemblyBase3_BeforeEach3_Before_Test -{ - internal static class TUnit_TestProject_BeforeTests_AssemblyBase3_BeforeEach3_Before_TestInitializer - { - internal static async ValueTask global_TUnit_TestProject_BeforeTests_AssemblyBase3_BeforeEach3_0Params_Body(object instance, TestContext context, CancellationToken cancellationToken) + static __registrationIndex => + new BeforeAssemblyHookMethod + { + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.AssemblyBase3), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.AssemblyBase3)), + Name = "BeforeAll3", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = global::System.Array.Empty(), + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.AssemblyBase3", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.AssemblyBase3), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.AssemblyBase3)), + Name = "AssemblyBase3", + Namespace = "TUnit.TestProject.BeforeTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_BeforeTests_AssemblyBase3_BeforeAll3_Before_Assembly_Body, + FilePath = "", + LineNumber = 35 + } + ); + private static ValueTask TUnit_TestProject_BeforeTests_AssemblyBase3_BeforeAll3_Before_Assembly_Body(AssemblyHookContext context, CancellationToken cancellationToken) { - var typedInstance = (global::TUnit.TestProject.BeforeTests.AssemblyBase3)instance; - await AsyncConvert.Convert(() => typedInstance.BeforeEach3()); + try + { + return new ValueTask(global::TUnit.TestProject.BeforeTests.AssemblyBase3.BeforeAll3()); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } } - } -} -namespace TUnit.Generated -{ - internal static partial class TUnit_HookRegistration - { static readonly int _h_TUnit_TestProject_BeforeTests_AssemblyBase3_BeforeEach3_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.AssemblyBase3), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), - static __registrationIndex => - new InstanceHookMethod - { - InitClassType = typeof(global::TUnit.TestProject.BeforeTests.AssemblyBase3), - MethodInfo = new global::TUnit.Core.MethodMetadata + static __registrationIndex => + new InstanceHookMethod + { + InitClassType = typeof(global::TUnit.TestProject.BeforeTests.AssemblyBase3), + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.AssemblyBase3), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.AssemblyBase3)), + Name = "BeforeEach3", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = global::System.Array.Empty(), + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.AssemblyBase3", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.AssemblyBase3), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.AssemblyBase3)), + Name = "AssemblyBase3", + Namespace = "TUnit.TestProject.BeforeTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_BeforeTests_AssemblyBase3_BeforeEach3_Before_Test_Body + } + ); + private static ValueTask TUnit_TestProject_BeforeTests_AssemblyBase3_BeforeEach3_Before_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) { - Type = typeof(global::TUnit.TestProject.BeforeTests.AssemblyBase3), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.AssemblyBase3)), - Name = "BeforeEach3", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = global::System.Array.Empty(), - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.AssemblyBase3", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.AssemblyBase3), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.AssemblyBase3)), - Name = "AssemblyBase3", - Namespace = "TUnit.TestProject.BeforeTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_AssemblyBase3_BeforeEach3_Before_Test.TUnit_TestProject_BeforeTests_AssemblyBase3_BeforeEach3_Before_TestInitializer.global_TUnit_TestProject_BeforeTests_AssemblyBase3_BeforeEach3_0Params_Body - } -); + try + { + var typedInstance = (global::TUnit.TestProject.BeforeTests.AssemblyBase3)instance; + return new ValueTask(typedInstance.BeforeEach3()); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } + } } } @@ -424,570 +331,383 @@ namespace TUnit.Generated #nullable enable #pragma warning disable CS9113 // Parameter is unread. using System; -using System.Collections.Generic; -using System.Linq; using System.Reflection; -using System.Runtime.CompilerServices; using System.Threading; using System.Threading.Tasks; using global::TUnit.Core; using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_AssemblySetupTests_BeforeAllSetUp_Before_Assembly -{ - internal static class TUnit_TestProject_BeforeTests_AssemblySetupTests_BeforeAllSetUp_Before_AssemblyInitializer - { - internal static async ValueTask global_TUnit_TestProject_BeforeTests_AssemblySetupTests_BeforeAllSetUp_0Params_Body(AssemblyHookContext context, CancellationToken cancellationToken) - { - await AsyncConvert.Convert(() => global::TUnit.TestProject.BeforeTests.AssemblySetupTests.BeforeAllSetUp()); - } - } -} namespace TUnit.Generated { internal static partial class TUnit_HookRegistration { static readonly int _h_TUnit_TestProject_BeforeTests_AssemblySetupTests_BeforeAllSetUp_Before_Assembly = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeAssemblyHooks, typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests).Assembly, global::TUnit.Core.HookRegistrationIndices.GetNextBeforeAssemblyHookIndex(), - static __registrationIndex => - new BeforeAssemblyHookMethod - { - MethodInfo = new global::TUnit.Core.MethodMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests)), - Name = "BeforeAllSetUp", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = global::System.Array.Empty(), - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.AssemblySetupTests", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests)), - Name = "AssemblySetupTests", - Namespace = "TUnit.TestProject.BeforeTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_AssemblySetupTests_BeforeAllSetUp_Before_Assembly.TUnit_TestProject_BeforeTests_AssemblySetupTests_BeforeAllSetUp_Before_AssemblyInitializer.global_TUnit_TestProject_BeforeTests_AssemblySetupTests_BeforeAllSetUp_0Params_Body, - FilePath = "", - LineNumber = 50 - } -); - } -} - - -// ===== FILE SEPARATOR ===== - -// -#pragma warning disable - -#nullable enable -#pragma warning disable CS9113 // Parameter is unread. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Threading; -using System.Threading.Tasks; -using global::TUnit.Core; -using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_AssemblySetupTests_BeforeAllSetUpWithContext__AssemblyHookContext_Before_Assembly -{ - internal static class TUnit_TestProject_BeforeTests_AssemblySetupTests_BeforeAllSetUpWithContext__AssemblyHookContext_Before_AssemblyInitializer - { - internal static async ValueTask global_TUnit_TestProject_BeforeTests_AssemblySetupTests_BeforeAllSetUpWithContext_1Params_Body(AssemblyHookContext context, CancellationToken cancellationToken) + static __registrationIndex => + new BeforeAssemblyHookMethod + { + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests)), + Name = "BeforeAllSetUp", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = global::System.Array.Empty(), + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.AssemblySetupTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests)), + Name = "AssemblySetupTests", + Namespace = "TUnit.TestProject.BeforeTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_BeforeTests_AssemblySetupTests_BeforeAllSetUp_Before_Assembly_Body, + FilePath = "", + LineNumber = 50 + } + ); + private static ValueTask TUnit_TestProject_BeforeTests_AssemblySetupTests_BeforeAllSetUp_Before_Assembly_Body(AssemblyHookContext context, CancellationToken cancellationToken) { - await AsyncConvert.Convert(() => global::TUnit.TestProject.BeforeTests.AssemblySetupTests.BeforeAllSetUpWithContext(context)); + try + { + return new ValueTask(global::TUnit.TestProject.BeforeTests.AssemblySetupTests.BeforeAllSetUp()); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } } - } -} -namespace TUnit.Generated -{ - internal static partial class TUnit_HookRegistration - { static readonly int _h_TUnit_TestProject_BeforeTests_AssemblySetupTests_BeforeAllSetUpWithContext__AssemblyHookContext_Before_Assembly = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeAssemblyHooks, typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests).Assembly, global::TUnit.Core.HookRegistrationIndices.GetNextBeforeAssemblyHookIndex(), - static __registrationIndex => - new BeforeAssemblyHookMethod - { - MethodInfo = new global::TUnit.Core.MethodMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests)), - Name = "BeforeAllSetUpWithContext", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = new global::TUnit.Core.ParameterMetadata[] - { - global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::TUnit.Core.AssemblyHookContext), "context", new global::TUnit.Core.ConcreteType(typeof(global::TUnit.Core.AssemblyHookContext)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests).GetMethod("BeforeAllSetUpWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::TUnit.Core.AssemblyHookContext) }, null)!.GetParameters()[0]) - }, - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.AssemblySetupTests", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests)), - Name = "AssemblySetupTests", - Namespace = "TUnit.TestProject.BeforeTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_AssemblySetupTests_BeforeAllSetUpWithContext__AssemblyHookContext_Before_Assembly.TUnit_TestProject_BeforeTests_AssemblySetupTests_BeforeAllSetUpWithContext__AssemblyHookContext_Before_AssemblyInitializer.global_TUnit_TestProject_BeforeTests_AssemblySetupTests_BeforeAllSetUpWithContext_1Params_Body, - FilePath = "", - LineNumber = 56 - } -); - } -} - - -// ===== FILE SEPARATOR ===== - -// -#pragma warning disable - -#nullable enable -#pragma warning disable CS9113 // Parameter is unread. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Threading; -using System.Threading.Tasks; -using global::TUnit.Core; -using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_AssemblySetupTests_BeforeAllSetUp2_Before_Assembly -{ - internal static class TUnit_TestProject_BeforeTests_AssemblySetupTests_BeforeAllSetUp2_Before_AssemblyInitializer - { - internal static async ValueTask global_TUnit_TestProject_BeforeTests_AssemblySetupTests_BeforeAllSetUp2_0Params_Body(AssemblyHookContext context, CancellationToken cancellationToken) + static __registrationIndex => + new BeforeAssemblyHookMethod + { + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests)), + Name = "BeforeAllSetUpWithContext", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = new global::TUnit.Core.ParameterMetadata[] + { + global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::TUnit.Core.AssemblyHookContext), "context", new global::TUnit.Core.ConcreteType(typeof(global::TUnit.Core.AssemblyHookContext)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests).GetMethod("BeforeAllSetUpWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::TUnit.Core.AssemblyHookContext) }, null)!.GetParameters()[0]) + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.AssemblySetupTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests)), + Name = "AssemblySetupTests", + Namespace = "TUnit.TestProject.BeforeTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_BeforeTests_AssemblySetupTests_BeforeAllSetUpWithContext__AssemblyHookContext_Before_Assembly_Body, + FilePath = "", + LineNumber = 56 + } + ); + private static ValueTask TUnit_TestProject_BeforeTests_AssemblySetupTests_BeforeAllSetUpWithContext__AssemblyHookContext_Before_Assembly_Body(AssemblyHookContext context, CancellationToken cancellationToken) { - await AsyncConvert.Convert(() => global::TUnit.TestProject.BeforeTests.AssemblySetupTests.BeforeAllSetUp2()); + try + { + return new ValueTask(global::TUnit.TestProject.BeforeTests.AssemblySetupTests.BeforeAllSetUpWithContext(context)); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } } - } -} -namespace TUnit.Generated -{ - internal static partial class TUnit_HookRegistration - { static readonly int _h_TUnit_TestProject_BeforeTests_AssemblySetupTests_BeforeAllSetUp2_Before_Assembly = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeAssemblyHooks, typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests).Assembly, global::TUnit.Core.HookRegistrationIndices.GetNextBeforeAssemblyHookIndex(), - static __registrationIndex => - new BeforeAssemblyHookMethod - { - MethodInfo = new global::TUnit.Core.MethodMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests)), - Name = "BeforeAllSetUp2", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = global::System.Array.Empty(), - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.AssemblySetupTests", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests)), - Name = "AssemblySetupTests", - Namespace = "TUnit.TestProject.BeforeTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_AssemblySetupTests_BeforeAllSetUp2_Before_Assembly.TUnit_TestProject_BeforeTests_AssemblySetupTests_BeforeAllSetUp2_Before_AssemblyInitializer.global_TUnit_TestProject_BeforeTests_AssemblySetupTests_BeforeAllSetUp2_0Params_Body, - FilePath = "", - LineNumber = 62 - } -); - } -} - - -// ===== FILE SEPARATOR ===== - -// -#pragma warning disable - -#nullable enable -#pragma warning disable CS9113 // Parameter is unread. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Threading; -using System.Threading.Tasks; -using global::TUnit.Core; -using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_AssemblySetupTests_BeforeAllSetUpWithContext__AssemblyHookContext_CancellationToken_Before_Assembly -{ - internal static class TUnit_TestProject_BeforeTests_AssemblySetupTests_BeforeAllSetUpWithContext__AssemblyHookContext_CancellationToken_Before_AssemblyInitializer - { - internal static async ValueTask global_TUnit_TestProject_BeforeTests_AssemblySetupTests_BeforeAllSetUpWithContext_2Params_Body(AssemblyHookContext context, CancellationToken cancellationToken) + static __registrationIndex => + new BeforeAssemblyHookMethod + { + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests)), + Name = "BeforeAllSetUp2", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = global::System.Array.Empty(), + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.AssemblySetupTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests)), + Name = "AssemblySetupTests", + Namespace = "TUnit.TestProject.BeforeTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_BeforeTests_AssemblySetupTests_BeforeAllSetUp2_Before_Assembly_Body, + FilePath = "", + LineNumber = 62 + } + ); + private static ValueTask TUnit_TestProject_BeforeTests_AssemblySetupTests_BeforeAllSetUp2_Before_Assembly_Body(AssemblyHookContext context, CancellationToken cancellationToken) { - await AsyncConvert.Convert(() => global::TUnit.TestProject.BeforeTests.AssemblySetupTests.BeforeAllSetUpWithContext(context, cancellationToken)); + try + { + return new ValueTask(global::TUnit.TestProject.BeforeTests.AssemblySetupTests.BeforeAllSetUp2()); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } } - } -} -namespace TUnit.Generated -{ - internal static partial class TUnit_HookRegistration - { static readonly int _h_TUnit_TestProject_BeforeTests_AssemblySetupTests_BeforeAllSetUpWithContext__AssemblyHookContext_CancellationToken_Before_Assembly = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeAssemblyHooks, typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests).Assembly, global::TUnit.Core.HookRegistrationIndices.GetNextBeforeAssemblyHookIndex(), - static __registrationIndex => - new BeforeAssemblyHookMethod - { - MethodInfo = new global::TUnit.Core.MethodMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests)), - Name = "BeforeAllSetUpWithContext", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = new global::TUnit.Core.ParameterMetadata[] - { - global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::TUnit.Core.AssemblyHookContext), "context", new global::TUnit.Core.ConcreteType(typeof(global::TUnit.Core.AssemblyHookContext)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests).GetMethod("BeforeAllSetUpWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::TUnit.Core.AssemblyHookContext), typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[0]), - global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::System.Threading.CancellationToken), "cancellationToken", new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.CancellationToken)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests).GetMethod("BeforeAllSetUpWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::TUnit.Core.AssemblyHookContext), typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[1]) - }, - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.AssemblySetupTests", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests)), - Name = "AssemblySetupTests", - Namespace = "TUnit.TestProject.BeforeTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_AssemblySetupTests_BeforeAllSetUpWithContext__AssemblyHookContext_CancellationToken_Before_Assembly.TUnit_TestProject_BeforeTests_AssemblySetupTests_BeforeAllSetUpWithContext__AssemblyHookContext_CancellationToken_Before_AssemblyInitializer.global_TUnit_TestProject_BeforeTests_AssemblySetupTests_BeforeAllSetUpWithContext_2Params_Body, - FilePath = "", - LineNumber = 68 - } -); - } -} - - -// ===== FILE SEPARATOR ===== - -// -#pragma warning disable - -#nullable enable -#pragma warning disable CS9113 // Parameter is unread. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Threading; -using System.Threading.Tasks; -using global::TUnit.Core; -using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_AssemblySetupTests_Setup_Before_Test -{ - internal static class TUnit_TestProject_BeforeTests_AssemblySetupTests_Setup_Before_TestInitializer - { - internal static async ValueTask global_TUnit_TestProject_BeforeTests_AssemblySetupTests_Setup_0Params_Body(object instance, TestContext context, CancellationToken cancellationToken) + static __registrationIndex => + new BeforeAssemblyHookMethod + { + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests)), + Name = "BeforeAllSetUpWithContext", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = new global::TUnit.Core.ParameterMetadata[] + { + global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::TUnit.Core.AssemblyHookContext), "context", new global::TUnit.Core.ConcreteType(typeof(global::TUnit.Core.AssemblyHookContext)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests).GetMethod("BeforeAllSetUpWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::TUnit.Core.AssemblyHookContext), typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[0]), + global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::System.Threading.CancellationToken), "cancellationToken", new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.CancellationToken)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests).GetMethod("BeforeAllSetUpWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::TUnit.Core.AssemblyHookContext), typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[1]) + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.AssemblySetupTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests)), + Name = "AssemblySetupTests", + Namespace = "TUnit.TestProject.BeforeTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_BeforeTests_AssemblySetupTests_BeforeAllSetUpWithContext__AssemblyHookContext_CancellationToken_Before_Assembly_Body, + FilePath = "", + LineNumber = 68 + } + ); + private static ValueTask TUnit_TestProject_BeforeTests_AssemblySetupTests_BeforeAllSetUpWithContext__AssemblyHookContext_CancellationToken_Before_Assembly_Body(AssemblyHookContext context, CancellationToken cancellationToken) { - var typedInstance = (global::TUnit.TestProject.BeforeTests.AssemblySetupTests)instance; - await AsyncConvert.Convert(() => typedInstance.Setup()); + try + { + return new ValueTask(global::TUnit.TestProject.BeforeTests.AssemblySetupTests.BeforeAllSetUpWithContext(context, cancellationToken)); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } } - } -} -namespace TUnit.Generated -{ - internal static partial class TUnit_HookRegistration - { static readonly int _h_TUnit_TestProject_BeforeTests_AssemblySetupTests_Setup_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), - static __registrationIndex => - new InstanceHookMethod - { - InitClassType = typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests), - MethodInfo = new global::TUnit.Core.MethodMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests)), - Name = "Setup", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = global::System.Array.Empty(), - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.AssemblySetupTests", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests)), - Name = "AssemblySetupTests", - Namespace = "TUnit.TestProject.BeforeTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_AssemblySetupTests_Setup_Before_Test.TUnit_TestProject_BeforeTests_AssemblySetupTests_Setup_Before_TestInitializer.global_TUnit_TestProject_BeforeTests_AssemblySetupTests_Setup_0Params_Body - } -); - } -} - - -// ===== FILE SEPARATOR ===== - -// -#pragma warning disable - -#nullable enable -#pragma warning disable CS9113 // Parameter is unread. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Threading; -using System.Threading.Tasks; -using global::TUnit.Core; -using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_AssemblySetupTests_Setup__CancellationToken_Before_Test -{ - internal static class TUnit_TestProject_BeforeTests_AssemblySetupTests_Setup__CancellationToken_Before_TestInitializer - { - internal static async ValueTask global_TUnit_TestProject_BeforeTests_AssemblySetupTests_Setup_1Params_Body(object instance, TestContext context, CancellationToken cancellationToken) + static __registrationIndex => + new InstanceHookMethod + { + InitClassType = typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests), + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests)), + Name = "Setup", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = global::System.Array.Empty(), + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.AssemblySetupTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests)), + Name = "AssemblySetupTests", + Namespace = "TUnit.TestProject.BeforeTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_BeforeTests_AssemblySetupTests_Setup_Before_Test_Body + } + ); + private static ValueTask TUnit_TestProject_BeforeTests_AssemblySetupTests_Setup_Before_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) { - var typedInstance = (global::TUnit.TestProject.BeforeTests.AssemblySetupTests)instance; - await AsyncConvert.Convert(() => typedInstance.Setup(cancellationToken)); + try + { + var typedInstance = (global::TUnit.TestProject.BeforeTests.AssemblySetupTests)instance; + return new ValueTask(typedInstance.Setup()); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } } - } -} -namespace TUnit.Generated -{ - internal static partial class TUnit_HookRegistration - { static readonly int _h_TUnit_TestProject_BeforeTests_AssemblySetupTests_Setup__CancellationToken_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), - static __registrationIndex => - new InstanceHookMethod - { - InitClassType = typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests), - MethodInfo = new global::TUnit.Core.MethodMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests)), - Name = "Setup", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = new global::TUnit.Core.ParameterMetadata[] - { - global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::System.Threading.CancellationToken), "cancellationToken", new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.CancellationToken)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests).GetMethod("Setup", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[0]) - }, - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.AssemblySetupTests", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests)), - Name = "AssemblySetupTests", - Namespace = "TUnit.TestProject.BeforeTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_AssemblySetupTests_Setup__CancellationToken_Before_Test.TUnit_TestProject_BeforeTests_AssemblySetupTests_Setup__CancellationToken_Before_TestInitializer.global_TUnit_TestProject_BeforeTests_AssemblySetupTests_Setup_1Params_Body - } -); - } -} - - -// ===== FILE SEPARATOR ===== - -// -#pragma warning disable - -#nullable enable -#pragma warning disable CS9113 // Parameter is unread. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Threading; -using System.Threading.Tasks; -using global::TUnit.Core; -using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_AssemblySetupTests_SetupWithContext__TestContext_Before_Test -{ - internal static class TUnit_TestProject_BeforeTests_AssemblySetupTests_SetupWithContext__TestContext_Before_TestInitializer - { - internal static async ValueTask global_TUnit_TestProject_BeforeTests_AssemblySetupTests_SetupWithContext_1Params_Body(object instance, TestContext context, CancellationToken cancellationToken) + static __registrationIndex => + new InstanceHookMethod + { + InitClassType = typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests), + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests)), + Name = "Setup", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = new global::TUnit.Core.ParameterMetadata[] + { + global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::System.Threading.CancellationToken), "cancellationToken", new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.CancellationToken)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests).GetMethod("Setup", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[0]) + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.AssemblySetupTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests)), + Name = "AssemblySetupTests", + Namespace = "TUnit.TestProject.BeforeTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_BeforeTests_AssemblySetupTests_Setup__CancellationToken_Before_Test_Body + } + ); + private static ValueTask TUnit_TestProject_BeforeTests_AssemblySetupTests_Setup__CancellationToken_Before_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) { - var typedInstance = (global::TUnit.TestProject.BeforeTests.AssemblySetupTests)instance; - await AsyncConvert.Convert(() => typedInstance.SetupWithContext(context)); + try + { + var typedInstance = (global::TUnit.TestProject.BeforeTests.AssemblySetupTests)instance; + return new ValueTask(typedInstance.Setup(cancellationToken)); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } } - } -} -namespace TUnit.Generated -{ - internal static partial class TUnit_HookRegistration - { static readonly int _h_TUnit_TestProject_BeforeTests_AssemblySetupTests_SetupWithContext__TestContext_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), - static __registrationIndex => - new InstanceHookMethod - { - InitClassType = typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests), - MethodInfo = new global::TUnit.Core.MethodMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests)), - Name = "SetupWithContext", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = new global::TUnit.Core.ParameterMetadata[] - { - global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::TUnit.Core.TestContext), "testContext", new global::TUnit.Core.ConcreteType(typeof(global::TUnit.Core.TestContext)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests).GetMethod("SetupWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(global::TUnit.Core.TestContext) }, null)!.GetParameters()[0]) - }, - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.AssemblySetupTests", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests)), - Name = "AssemblySetupTests", - Namespace = "TUnit.TestProject.BeforeTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_AssemblySetupTests_SetupWithContext__TestContext_Before_Test.TUnit_TestProject_BeforeTests_AssemblySetupTests_SetupWithContext__TestContext_Before_TestInitializer.global_TUnit_TestProject_BeforeTests_AssemblySetupTests_SetupWithContext_1Params_Body - } -); - } -} - - -// ===== FILE SEPARATOR ===== - -// -#pragma warning disable - -#nullable enable -#pragma warning disable CS9113 // Parameter is unread. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Threading; -using System.Threading.Tasks; -using global::TUnit.Core; -using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_AssemblySetupTests_SetupWithContext__TestContext_CancellationToken_Before_Test -{ - internal static class TUnit_TestProject_BeforeTests_AssemblySetupTests_SetupWithContext__TestContext_CancellationToken_Before_TestInitializer - { - internal static async ValueTask global_TUnit_TestProject_BeforeTests_AssemblySetupTests_SetupWithContext_2Params_Body(object instance, TestContext context, CancellationToken cancellationToken) + static __registrationIndex => + new InstanceHookMethod + { + InitClassType = typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests), + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests)), + Name = "SetupWithContext", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = new global::TUnit.Core.ParameterMetadata[] + { + global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::TUnit.Core.TestContext), "testContext", new global::TUnit.Core.ConcreteType(typeof(global::TUnit.Core.TestContext)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests).GetMethod("SetupWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(global::TUnit.Core.TestContext) }, null)!.GetParameters()[0]) + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.AssemblySetupTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests)), + Name = "AssemblySetupTests", + Namespace = "TUnit.TestProject.BeforeTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_BeforeTests_AssemblySetupTests_SetupWithContext__TestContext_Before_Test_Body + } + ); + private static ValueTask TUnit_TestProject_BeforeTests_AssemblySetupTests_SetupWithContext__TestContext_Before_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) { - var typedInstance = (global::TUnit.TestProject.BeforeTests.AssemblySetupTests)instance; - await AsyncConvert.Convert(() => typedInstance.SetupWithContext(context, cancellationToken)); + try + { + var typedInstance = (global::TUnit.TestProject.BeforeTests.AssemblySetupTests)instance; + return new ValueTask(typedInstance.SetupWithContext(context)); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } } - } -} -namespace TUnit.Generated -{ - internal static partial class TUnit_HookRegistration - { static readonly int _h_TUnit_TestProject_BeforeTests_AssemblySetupTests_SetupWithContext__TestContext_CancellationToken_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), - static __registrationIndex => - new InstanceHookMethod - { - InitClassType = typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests), - MethodInfo = new global::TUnit.Core.MethodMetadata + static __registrationIndex => + new InstanceHookMethod + { + InitClassType = typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests), + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests)), + Name = "SetupWithContext", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = new global::TUnit.Core.ParameterMetadata[] + { + global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::TUnit.Core.TestContext), "testContext", new global::TUnit.Core.ConcreteType(typeof(global::TUnit.Core.TestContext)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests).GetMethod("SetupWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(global::TUnit.Core.TestContext), typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[0]), + global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::System.Threading.CancellationToken), "cancellationToken", new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.CancellationToken)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests).GetMethod("SetupWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(global::TUnit.Core.TestContext), typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[1]) + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.AssemblySetupTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests)), + Name = "AssemblySetupTests", + Namespace = "TUnit.TestProject.BeforeTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_BeforeTests_AssemblySetupTests_SetupWithContext__TestContext_CancellationToken_Before_Test_Body + } + ); + private static ValueTask TUnit_TestProject_BeforeTests_AssemblySetupTests_SetupWithContext__TestContext_CancellationToken_Before_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) { - Type = typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests)), - Name = "SetupWithContext", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = new global::TUnit.Core.ParameterMetadata[] - { - global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::TUnit.Core.TestContext), "testContext", new global::TUnit.Core.ConcreteType(typeof(global::TUnit.Core.TestContext)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests).GetMethod("SetupWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(global::TUnit.Core.TestContext), typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[0]), - global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::System.Threading.CancellationToken), "cancellationToken", new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.CancellationToken)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests).GetMethod("SetupWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(global::TUnit.Core.TestContext), typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[1]) - }, - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.AssemblySetupTests", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests)), - Name = "AssemblySetupTests", - Namespace = "TUnit.TestProject.BeforeTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_AssemblySetupTests_SetupWithContext__TestContext_CancellationToken_Before_Test.TUnit_TestProject_BeforeTests_AssemblySetupTests_SetupWithContext__TestContext_CancellationToken_Before_TestInitializer.global_TUnit_TestProject_BeforeTests_AssemblySetupTests_SetupWithContext_2Params_Body - } -); + try + { + var typedInstance = (global::TUnit.TestProject.BeforeTests.AssemblySetupTests)instance; + return new ValueTask(typedInstance.SetupWithContext(context, cancellationToken)); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } + } } } diff --git a/tests/TUnit.Core.SourceGenerator.Tests/ConflictingNamespaceTests.HooksTest_WithConflictingNamespace.DotNet10_0.verified.txt b/tests/TUnit.Core.SourceGenerator.Tests/ConflictingNamespaceTests.HooksTest_WithConflictingNamespace.DotNet10_0.verified.txt index 235a98679db..2e6a86de97c 100644 --- a/tests/TUnit.Core.SourceGenerator.Tests/ConflictingNamespaceTests.HooksTest_WithConflictingNamespace.DotNet10_0.verified.txt +++ b/tests/TUnit.Core.SourceGenerator.Tests/ConflictingNamespaceTests.HooksTest_WithConflictingNamespace.DotNet10_0.verified.txt @@ -1,137 +1,106 @@ -// +// #pragma warning disable #nullable enable #pragma warning disable CS9113 // Parameter is unread. using System; -using System.Collections.Generic; -using System.Linq; using System.Reflection; -using System.Runtime.CompilerServices; using System.Threading; using System.Threading.Tasks; using global::TUnit.Core; using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_Base1_BeforeAll1_Before_Class -{ - internal static class TUnit_TestProject_BeforeTests_Base1_BeforeAll1_Before_ClassInitializer - { - internal static async ValueTask global_TUnit_TestProject_BeforeTests_Base1_BeforeAll1_0Params_Body(ClassHookContext context, CancellationToken cancellationToken) - { - await AsyncConvert.Convert(() => global::TUnit.TestProject.BeforeTests.Base1.BeforeAll1()); - } - } -} namespace TUnit.Generated { internal static partial class TUnit_HookRegistration { static readonly int _h_TUnit_TestProject_BeforeTests_Base1_BeforeAll1_Before_Class = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeClassHooks, typeof(global::TUnit.TestProject.BeforeTests.Base1), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeClassHookIndex(), - static __registrationIndex => - new BeforeClassHookMethod - { - MethodInfo = new global::TUnit.Core.MethodMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.Base1), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base1)), - Name = "BeforeAll1", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = global::System.Array.Empty(), - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.Base1", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.Base1), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base1)), - Name = "Base1", - Namespace = "TUnit.TestProject.BeforeTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_Base1_BeforeAll1_Before_Class.TUnit_TestProject_BeforeTests_Base1_BeforeAll1_Before_ClassInitializer.global_TUnit_TestProject_BeforeTests_Base1_BeforeAll1_0Params_Body, - FilePath = "", - LineNumber = 5 - } -); - } -} - - -// ===== FILE SEPARATOR ===== - -// -#pragma warning disable - -#nullable enable -#pragma warning disable CS9113 // Parameter is unread. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Threading; -using System.Threading.Tasks; -using global::TUnit.Core; -using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_Base1_BeforeEach1_Before_Test -{ - internal static class TUnit_TestProject_BeforeTests_Base1_BeforeEach1_Before_TestInitializer - { - internal static async ValueTask global_TUnit_TestProject_BeforeTests_Base1_BeforeEach1_0Params_Body(object instance, TestContext context, CancellationToken cancellationToken) + static __registrationIndex => + new BeforeClassHookMethod + { + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.Base1), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base1)), + Name = "BeforeAll1", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = global::System.Array.Empty(), + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.Base1", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.Base1), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base1)), + Name = "Base1", + Namespace = "TUnit.TestProject.BeforeTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_BeforeTests_Base1_BeforeAll1_Before_Class_Body, + FilePath = "", + LineNumber = 5 + } + ); + private static ValueTask TUnit_TestProject_BeforeTests_Base1_BeforeAll1_Before_Class_Body(ClassHookContext context, CancellationToken cancellationToken) { - var typedInstance = (global::TUnit.TestProject.BeforeTests.Base1)instance; - await AsyncConvert.Convert(() => typedInstance.BeforeEach1()); + try + { + return new ValueTask(global::TUnit.TestProject.BeforeTests.Base1.BeforeAll1()); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } } - } -} -namespace TUnit.Generated -{ - internal static partial class TUnit_HookRegistration - { static readonly int _h_TUnit_TestProject_BeforeTests_Base1_BeforeEach1_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.Base1), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), - static __registrationIndex => - new InstanceHookMethod - { - InitClassType = typeof(global::TUnit.TestProject.BeforeTests.Base1), - MethodInfo = new global::TUnit.Core.MethodMetadata + static __registrationIndex => + new InstanceHookMethod + { + InitClassType = typeof(global::TUnit.TestProject.BeforeTests.Base1), + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.Base1), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base1)), + Name = "BeforeEach1", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = global::System.Array.Empty(), + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.Base1", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.Base1), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base1)), + Name = "Base1", + Namespace = "TUnit.TestProject.BeforeTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_BeforeTests_Base1_BeforeEach1_Before_Test_Body + } + ); + private static ValueTask TUnit_TestProject_BeforeTests_Base1_BeforeEach1_Before_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) { - Type = typeof(global::TUnit.TestProject.BeforeTests.Base1), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base1)), - Name = "BeforeEach1", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = global::System.Array.Empty(), - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.Base1", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.Base1), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base1)), - Name = "Base1", - Namespace = "TUnit.TestProject.BeforeTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_Base1_BeforeEach1_Before_Test.TUnit_TestProject_BeforeTests_Base1_BeforeEach1_Before_TestInitializer.global_TUnit_TestProject_BeforeTests_Base1_BeforeEach1_0Params_Body - } -); + try + { + var typedInstance = (global::TUnit.TestProject.BeforeTests.Base1)instance; + return new ValueTask(typedInstance.BeforeEach1()); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } + } } } @@ -144,134 +113,103 @@ namespace TUnit.Generated #nullable enable #pragma warning disable CS9113 // Parameter is unread. using System; -using System.Collections.Generic; -using System.Linq; using System.Reflection; -using System.Runtime.CompilerServices; using System.Threading; using System.Threading.Tasks; using global::TUnit.Core; using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_Base2_BeforeAll2_Before_Class -{ - internal static class TUnit_TestProject_BeforeTests_Base2_BeforeAll2_Before_ClassInitializer - { - internal static async ValueTask global_TUnit_TestProject_BeforeTests_Base2_BeforeAll2_0Params_Body(ClassHookContext context, CancellationToken cancellationToken) - { - await AsyncConvert.Convert(() => global::TUnit.TestProject.BeforeTests.Base2.BeforeAll2()); - } - } -} namespace TUnit.Generated { internal static partial class TUnit_HookRegistration { static readonly int _h_TUnit_TestProject_BeforeTests_Base2_BeforeAll2_Before_Class = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeClassHooks, typeof(global::TUnit.TestProject.BeforeTests.Base2), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeClassHookIndex(), - static __registrationIndex => - new BeforeClassHookMethod - { - MethodInfo = new global::TUnit.Core.MethodMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.Base2), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base2)), - Name = "BeforeAll2", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = global::System.Array.Empty(), - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.Base2", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.Base2), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base2)), - Name = "Base2", - Namespace = "TUnit.TestProject.BeforeTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_Base2_BeforeAll2_Before_Class.TUnit_TestProject_BeforeTests_Base2_BeforeAll2_Before_ClassInitializer.global_TUnit_TestProject_BeforeTests_Base2_BeforeAll2_0Params_Body, - FilePath = "", - LineNumber = 20 - } -); - } -} - - -// ===== FILE SEPARATOR ===== - -// -#pragma warning disable - -#nullable enable -#pragma warning disable CS9113 // Parameter is unread. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Threading; -using System.Threading.Tasks; -using global::TUnit.Core; -using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_Base2_BeforeEach2_Before_Test -{ - internal static class TUnit_TestProject_BeforeTests_Base2_BeforeEach2_Before_TestInitializer - { - internal static async ValueTask global_TUnit_TestProject_BeforeTests_Base2_BeforeEach2_0Params_Body(object instance, TestContext context, CancellationToken cancellationToken) + static __registrationIndex => + new BeforeClassHookMethod + { + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.Base2), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base2)), + Name = "BeforeAll2", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = global::System.Array.Empty(), + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.Base2", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.Base2), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base2)), + Name = "Base2", + Namespace = "TUnit.TestProject.BeforeTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_BeforeTests_Base2_BeforeAll2_Before_Class_Body, + FilePath = "", + LineNumber = 20 + } + ); + private static ValueTask TUnit_TestProject_BeforeTests_Base2_BeforeAll2_Before_Class_Body(ClassHookContext context, CancellationToken cancellationToken) { - var typedInstance = (global::TUnit.TestProject.BeforeTests.Base2)instance; - await AsyncConvert.Convert(() => typedInstance.BeforeEach2()); + try + { + return new ValueTask(global::TUnit.TestProject.BeforeTests.Base2.BeforeAll2()); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } } - } -} -namespace TUnit.Generated -{ - internal static partial class TUnit_HookRegistration - { static readonly int _h_TUnit_TestProject_BeforeTests_Base2_BeforeEach2_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.Base2), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), - static __registrationIndex => - new InstanceHookMethod - { - InitClassType = typeof(global::TUnit.TestProject.BeforeTests.Base2), - MethodInfo = new global::TUnit.Core.MethodMetadata + static __registrationIndex => + new InstanceHookMethod + { + InitClassType = typeof(global::TUnit.TestProject.BeforeTests.Base2), + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.Base2), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base2)), + Name = "BeforeEach2", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = global::System.Array.Empty(), + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.Base2", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.Base2), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base2)), + Name = "Base2", + Namespace = "TUnit.TestProject.BeforeTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_BeforeTests_Base2_BeforeEach2_Before_Test_Body + } + ); + private static ValueTask TUnit_TestProject_BeforeTests_Base2_BeforeEach2_Before_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) { - Type = typeof(global::TUnit.TestProject.BeforeTests.Base2), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base2)), - Name = "BeforeEach2", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = global::System.Array.Empty(), - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.Base2", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.Base2), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base2)), - Name = "Base2", - Namespace = "TUnit.TestProject.BeforeTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_Base2_BeforeEach2_Before_Test.TUnit_TestProject_BeforeTests_Base2_BeforeEach2_Before_TestInitializer.global_TUnit_TestProject_BeforeTests_Base2_BeforeEach2_0Params_Body - } -); + try + { + var typedInstance = (global::TUnit.TestProject.BeforeTests.Base2)instance; + return new ValueTask(typedInstance.BeforeEach2()); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } + } } } @@ -284,134 +222,103 @@ namespace TUnit.Generated #nullable enable #pragma warning disable CS9113 // Parameter is unread. using System; -using System.Collections.Generic; -using System.Linq; using System.Reflection; -using System.Runtime.CompilerServices; using System.Threading; using System.Threading.Tasks; using global::TUnit.Core; using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_Base3_BeforeAll3_Before_Class -{ - internal static class TUnit_TestProject_BeforeTests_Base3_BeforeAll3_Before_ClassInitializer - { - internal static async ValueTask global_TUnit_TestProject_BeforeTests_Base3_BeforeAll3_0Params_Body(ClassHookContext context, CancellationToken cancellationToken) - { - await AsyncConvert.Convert(() => global::TUnit.TestProject.BeforeTests.Base3.BeforeAll3()); - } - } -} namespace TUnit.Generated { internal static partial class TUnit_HookRegistration { static readonly int _h_TUnit_TestProject_BeforeTests_Base3_BeforeAll3_Before_Class = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeClassHooks, typeof(global::TUnit.TestProject.BeforeTests.Base3), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeClassHookIndex(), - static __registrationIndex => - new BeforeClassHookMethod - { - MethodInfo = new global::TUnit.Core.MethodMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.Base3), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base3)), - Name = "BeforeAll3", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = global::System.Array.Empty(), - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.Base3", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.Base3), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base3)), - Name = "Base3", - Namespace = "TUnit.TestProject.BeforeTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_Base3_BeforeAll3_Before_Class.TUnit_TestProject_BeforeTests_Base3_BeforeAll3_Before_ClassInitializer.global_TUnit_TestProject_BeforeTests_Base3_BeforeAll3_0Params_Body, - FilePath = "", - LineNumber = 35 - } -); - } -} - - -// ===== FILE SEPARATOR ===== - -// -#pragma warning disable - -#nullable enable -#pragma warning disable CS9113 // Parameter is unread. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Threading; -using System.Threading.Tasks; -using global::TUnit.Core; -using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_Base3_BeforeEach3_Before_Test -{ - internal static class TUnit_TestProject_BeforeTests_Base3_BeforeEach3_Before_TestInitializer - { - internal static async ValueTask global_TUnit_TestProject_BeforeTests_Base3_BeforeEach3_0Params_Body(object instance, TestContext context, CancellationToken cancellationToken) + static __registrationIndex => + new BeforeClassHookMethod + { + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.Base3), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base3)), + Name = "BeforeAll3", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = global::System.Array.Empty(), + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.Base3", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.Base3), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base3)), + Name = "Base3", + Namespace = "TUnit.TestProject.BeforeTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_BeforeTests_Base3_BeforeAll3_Before_Class_Body, + FilePath = "", + LineNumber = 35 + } + ); + private static ValueTask TUnit_TestProject_BeforeTests_Base3_BeforeAll3_Before_Class_Body(ClassHookContext context, CancellationToken cancellationToken) { - var typedInstance = (global::TUnit.TestProject.BeforeTests.Base3)instance; - await AsyncConvert.Convert(() => typedInstance.BeforeEach3()); + try + { + return new ValueTask(global::TUnit.TestProject.BeforeTests.Base3.BeforeAll3()); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } } - } -} -namespace TUnit.Generated -{ - internal static partial class TUnit_HookRegistration - { static readonly int _h_TUnit_TestProject_BeforeTests_Base3_BeforeEach3_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.Base3), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), - static __registrationIndex => - new InstanceHookMethod - { - InitClassType = typeof(global::TUnit.TestProject.BeforeTests.Base3), - MethodInfo = new global::TUnit.Core.MethodMetadata + static __registrationIndex => + new InstanceHookMethod + { + InitClassType = typeof(global::TUnit.TestProject.BeforeTests.Base3), + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.Base3), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base3)), + Name = "BeforeEach3", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = global::System.Array.Empty(), + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.Base3", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.Base3), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base3)), + Name = "Base3", + Namespace = "TUnit.TestProject.BeforeTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_BeforeTests_Base3_BeforeEach3_Before_Test_Body + } + ); + private static ValueTask TUnit_TestProject_BeforeTests_Base3_BeforeEach3_Before_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) { - Type = typeof(global::TUnit.TestProject.BeforeTests.Base3), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base3)), - Name = "BeforeEach3", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = global::System.Array.Empty(), - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.Base3", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.Base3), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base3)), - Name = "Base3", - Namespace = "TUnit.TestProject.BeforeTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_Base3_BeforeEach3_Before_Test.TUnit_TestProject_BeforeTests_Base3_BeforeEach3_Before_TestInitializer.global_TUnit_TestProject_BeforeTests_Base3_BeforeEach3_0Params_Body - } -); + try + { + var typedInstance = (global::TUnit.TestProject.BeforeTests.Base3)instance; + return new ValueTask(typedInstance.BeforeEach3()); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } + } } } @@ -424,573 +331,386 @@ namespace TUnit.Generated #nullable enable #pragma warning disable CS9113 // Parameter is unread. using System; -using System.Collections.Generic; -using System.Linq; using System.Reflection; -using System.Runtime.CompilerServices; using System.Threading; using System.Threading.Tasks; using global::TUnit.Core; using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp_Before_Class -{ - internal static class TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp_Before_ClassInitializer - { - internal static async ValueTask global_TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp_0Params_Body(ClassHookContext context, CancellationToken cancellationToken) - { - await AsyncConvert.Convert(() => global::TUnit.TestProject.BeforeTests.SetupTests.BeforeAllSetUp()); - } - } -} namespace TUnit.Generated { internal static partial class TUnit_HookRegistration { static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp_Before_Class = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeClassHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeClassHookIndex(), - static __registrationIndex => - new BeforeClassHookMethod - { - MethodInfo = new global::TUnit.Core.MethodMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), - Name = "BeforeAllSetUp", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = global::System.Array.Empty(), - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.SetupTests", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), - Name = "SetupTests", - Namespace = "TUnit.TestProject.BeforeTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp_Before_Class.TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp_Before_ClassInitializer.global_TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp_0Params_Body, - FilePath = "", - LineNumber = 50 - } -); - } -} - - -// ===== FILE SEPARATOR ===== - -// -#pragma warning disable - -#nullable enable -#pragma warning disable CS9113 // Parameter is unread. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Threading; -using System.Threading.Tasks; -using global::TUnit.Core; -using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_Before_Class -{ - internal static class TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_Before_ClassInitializer - { - internal static async ValueTask global_TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext_1Params_Body(ClassHookContext context, CancellationToken cancellationToken) + static __registrationIndex => + new BeforeClassHookMethod + { + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), + Name = "BeforeAllSetUp", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = global::System.Array.Empty(), + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.SetupTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), + Name = "SetupTests", + Namespace = "TUnit.TestProject.BeforeTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp_Before_Class_Body, + FilePath = "", + LineNumber = 50 + } + ); + private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp_Before_Class_Body(ClassHookContext context, CancellationToken cancellationToken) { - await AsyncConvert.Convert(() => global::TUnit.TestProject.BeforeTests.SetupTests.BeforeAllSetUpWithContext(context)); + try + { + return new ValueTask(global::TUnit.TestProject.BeforeTests.SetupTests.BeforeAllSetUp()); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } } - } -} -namespace TUnit.Generated -{ - internal static partial class TUnit_HookRegistration - { static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_Before_Class = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeClassHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeClassHookIndex(), - static __registrationIndex => - new BeforeClassHookMethod - { - MethodInfo = new global::TUnit.Core.MethodMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), - Name = "BeforeAllSetUpWithContext", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = new global::TUnit.Core.ParameterMetadata[] - { - global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::TUnit.Core.ClassHookContext), "context", new global::TUnit.Core.ConcreteType(typeof(global::TUnit.Core.ClassHookContext)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.SetupTests).GetMethod("BeforeAllSetUpWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::TUnit.Core.ClassHookContext) }, null)!.GetParameters()[0]) - }, - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.SetupTests", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), - Name = "SetupTests", - Namespace = "TUnit.TestProject.BeforeTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_Before_Class.TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_Before_ClassInitializer.global_TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext_1Params_Body, - FilePath = "", - LineNumber = 56 - } -); - } -} - - -// ===== FILE SEPARATOR ===== - -// -#pragma warning disable - -#nullable enable -#pragma warning disable CS9113 // Parameter is unread. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Threading; -using System.Threading.Tasks; -using global::TUnit.Core; -using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp__CancellationToken_Before_Class -{ - internal static class TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp__CancellationToken_Before_ClassInitializer - { - internal static async ValueTask global_TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp_1Params_Body(ClassHookContext context, CancellationToken cancellationToken) + static __registrationIndex => + new BeforeClassHookMethod + { + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), + Name = "BeforeAllSetUpWithContext", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = new global::TUnit.Core.ParameterMetadata[] + { + global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::TUnit.Core.ClassHookContext), "context", new global::TUnit.Core.ConcreteType(typeof(global::TUnit.Core.ClassHookContext)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.SetupTests).GetMethod("BeforeAllSetUpWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::TUnit.Core.ClassHookContext) }, null)!.GetParameters()[0]) + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.SetupTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), + Name = "SetupTests", + Namespace = "TUnit.TestProject.BeforeTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_Before_Class_Body, + FilePath = "", + LineNumber = 56 + } + ); + private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_Before_Class_Body(ClassHookContext context, CancellationToken cancellationToken) { - await AsyncConvert.Convert(() => global::TUnit.TestProject.BeforeTests.SetupTests.BeforeAllSetUp(cancellationToken)); + try + { + return new ValueTask(global::TUnit.TestProject.BeforeTests.SetupTests.BeforeAllSetUpWithContext(context)); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } } - } -} -namespace TUnit.Generated -{ - internal static partial class TUnit_HookRegistration - { static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp__CancellationToken_Before_Class = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeClassHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeClassHookIndex(), - static __registrationIndex => - new BeforeClassHookMethod - { - MethodInfo = new global::TUnit.Core.MethodMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), - Name = "BeforeAllSetUp", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = new global::TUnit.Core.ParameterMetadata[] - { - global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::System.Threading.CancellationToken), "cancellationToken", new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.CancellationToken)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.SetupTests).GetMethod("BeforeAllSetUp", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[0]) - }, - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.SetupTests", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), - Name = "SetupTests", - Namespace = "TUnit.TestProject.BeforeTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp__CancellationToken_Before_Class.TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp__CancellationToken_Before_ClassInitializer.global_TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp_1Params_Body, - FilePath = "", - LineNumber = 62 - } -); - } -} - - -// ===== FILE SEPARATOR ===== - -// -#pragma warning disable - -#nullable enable -#pragma warning disable CS9113 // Parameter is unread. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Threading; -using System.Threading.Tasks; -using global::TUnit.Core; -using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_CancellationToken_Before_Class -{ - internal static class TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_CancellationToken_Before_ClassInitializer - { - internal static async ValueTask global_TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext_2Params_Body(ClassHookContext context, CancellationToken cancellationToken) + static __registrationIndex => + new BeforeClassHookMethod + { + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), + Name = "BeforeAllSetUp", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = new global::TUnit.Core.ParameterMetadata[] + { + global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::System.Threading.CancellationToken), "cancellationToken", new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.CancellationToken)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.SetupTests).GetMethod("BeforeAllSetUp", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[0]) + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.SetupTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), + Name = "SetupTests", + Namespace = "TUnit.TestProject.BeforeTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp__CancellationToken_Before_Class_Body, + FilePath = "", + LineNumber = 62 + } + ); + private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp__CancellationToken_Before_Class_Body(ClassHookContext context, CancellationToken cancellationToken) { - await AsyncConvert.Convert(() => global::TUnit.TestProject.BeforeTests.SetupTests.BeforeAllSetUpWithContext(context, cancellationToken)); + try + { + return new ValueTask(global::TUnit.TestProject.BeforeTests.SetupTests.BeforeAllSetUp(cancellationToken)); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } } - } -} -namespace TUnit.Generated -{ - internal static partial class TUnit_HookRegistration - { static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_CancellationToken_Before_Class = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeClassHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeClassHookIndex(), - static __registrationIndex => - new BeforeClassHookMethod - { - MethodInfo = new global::TUnit.Core.MethodMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), - Name = "BeforeAllSetUpWithContext", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = new global::TUnit.Core.ParameterMetadata[] - { - global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::TUnit.Core.ClassHookContext), "context", new global::TUnit.Core.ConcreteType(typeof(global::TUnit.Core.ClassHookContext)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.SetupTests).GetMethod("BeforeAllSetUpWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::TUnit.Core.ClassHookContext), typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[0]), - global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::System.Threading.CancellationToken), "cancellationToken", new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.CancellationToken)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.SetupTests).GetMethod("BeforeAllSetUpWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::TUnit.Core.ClassHookContext), typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[1]) - }, - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.SetupTests", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), - Name = "SetupTests", - Namespace = "TUnit.TestProject.BeforeTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_CancellationToken_Before_Class.TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_CancellationToken_Before_ClassInitializer.global_TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext_2Params_Body, - FilePath = "", - LineNumber = 68 - } -); - } -} - - -// ===== FILE SEPARATOR ===== - -// -#pragma warning disable - -#nullable enable -#pragma warning disable CS9113 // Parameter is unread. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Threading; -using System.Threading.Tasks; -using global::TUnit.Core; -using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_SetupTests_Setup_Before_Test -{ - internal static class TUnit_TestProject_BeforeTests_SetupTests_Setup_Before_TestInitializer - { - internal static async ValueTask global_TUnit_TestProject_BeforeTests_SetupTests_Setup_0Params_Body(object instance, TestContext context, CancellationToken cancellationToken) + static __registrationIndex => + new BeforeClassHookMethod + { + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), + Name = "BeforeAllSetUpWithContext", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = new global::TUnit.Core.ParameterMetadata[] + { + global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::TUnit.Core.ClassHookContext), "context", new global::TUnit.Core.ConcreteType(typeof(global::TUnit.Core.ClassHookContext)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.SetupTests).GetMethod("BeforeAllSetUpWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::TUnit.Core.ClassHookContext), typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[0]), + global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::System.Threading.CancellationToken), "cancellationToken", new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.CancellationToken)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.SetupTests).GetMethod("BeforeAllSetUpWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::TUnit.Core.ClassHookContext), typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[1]) + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.SetupTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), + Name = "SetupTests", + Namespace = "TUnit.TestProject.BeforeTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_CancellationToken_Before_Class_Body, + FilePath = "", + LineNumber = 68 + } + ); + private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_CancellationToken_Before_Class_Body(ClassHookContext context, CancellationToken cancellationToken) { - var typedInstance = (global::TUnit.TestProject.BeforeTests.SetupTests)instance; - await AsyncConvert.Convert(() => typedInstance.Setup()); + try + { + return new ValueTask(global::TUnit.TestProject.BeforeTests.SetupTests.BeforeAllSetUpWithContext(context, cancellationToken)); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } } - } -} -namespace TUnit.Generated -{ - internal static partial class TUnit_HookRegistration - { static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_Setup_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), - static __registrationIndex => - new InstanceHookMethod - { - InitClassType = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), - MethodInfo = new global::TUnit.Core.MethodMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), - Name = "Setup", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = global::System.Array.Empty(), - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.SetupTests", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), - Name = "SetupTests", - Namespace = "TUnit.TestProject.BeforeTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_SetupTests_Setup_Before_Test.TUnit_TestProject_BeforeTests_SetupTests_Setup_Before_TestInitializer.global_TUnit_TestProject_BeforeTests_SetupTests_Setup_0Params_Body - } -); - } -} - - -// ===== FILE SEPARATOR ===== - -// -#pragma warning disable - -#nullable enable -#pragma warning disable CS9113 // Parameter is unread. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Threading; -using System.Threading.Tasks; -using global::TUnit.Core; -using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_SetupTests_Setup__CancellationToken_Before_Test -{ - internal static class TUnit_TestProject_BeforeTests_SetupTests_Setup__CancellationToken_Before_TestInitializer - { - internal static async ValueTask global_TUnit_TestProject_BeforeTests_SetupTests_Setup_1Params_Body(object instance, TestContext context, CancellationToken cancellationToken) + static __registrationIndex => + new InstanceHookMethod + { + InitClassType = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), + Name = "Setup", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = global::System.Array.Empty(), + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.SetupTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), + Name = "SetupTests", + Namespace = "TUnit.TestProject.BeforeTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_BeforeTests_SetupTests_Setup_Before_Test_Body + } + ); + private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_Setup_Before_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) { - var typedInstance = (global::TUnit.TestProject.BeforeTests.SetupTests)instance; - await AsyncConvert.Convert(() => typedInstance.Setup(cancellationToken)); + try + { + var typedInstance = (global::TUnit.TestProject.BeforeTests.SetupTests)instance; + return new ValueTask(typedInstance.Setup()); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } } - } -} -namespace TUnit.Generated -{ - internal static partial class TUnit_HookRegistration - { static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_Setup__CancellationToken_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), - static __registrationIndex => - new InstanceHookMethod - { - InitClassType = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), - MethodInfo = new global::TUnit.Core.MethodMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), - Name = "Setup", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = new global::TUnit.Core.ParameterMetadata[] - { - global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::System.Threading.CancellationToken), "cancellationToken", new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.CancellationToken)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.SetupTests).GetMethod("Setup", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[0]) - }, - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.SetupTests", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), - Name = "SetupTests", - Namespace = "TUnit.TestProject.BeforeTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_SetupTests_Setup__CancellationToken_Before_Test.TUnit_TestProject_BeforeTests_SetupTests_Setup__CancellationToken_Before_TestInitializer.global_TUnit_TestProject_BeforeTests_SetupTests_Setup_1Params_Body - } -); - } -} - - -// ===== FILE SEPARATOR ===== - -// -#pragma warning disable - -#nullable enable -#pragma warning disable CS9113 // Parameter is unread. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Threading; -using System.Threading.Tasks; -using global::TUnit.Core; -using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_Before_Test -{ - internal static class TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_Before_TestInitializer - { - internal static async ValueTask global_TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext_1Params_Body(object instance, TestContext context, CancellationToken cancellationToken) + static __registrationIndex => + new InstanceHookMethod + { + InitClassType = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), + Name = "Setup", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = new global::TUnit.Core.ParameterMetadata[] + { + global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::System.Threading.CancellationToken), "cancellationToken", new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.CancellationToken)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.SetupTests).GetMethod("Setup", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[0]) + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.SetupTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), + Name = "SetupTests", + Namespace = "TUnit.TestProject.BeforeTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_BeforeTests_SetupTests_Setup__CancellationToken_Before_Test_Body + } + ); + private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_Setup__CancellationToken_Before_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) { - var typedInstance = (global::TUnit.TestProject.BeforeTests.SetupTests)instance; - await AsyncConvert.Convert(() => typedInstance.SetupWithContext(context)); + try + { + var typedInstance = (global::TUnit.TestProject.BeforeTests.SetupTests)instance; + return new ValueTask(typedInstance.Setup(cancellationToken)); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } } - } -} -namespace TUnit.Generated -{ - internal static partial class TUnit_HookRegistration - { static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), - static __registrationIndex => - new InstanceHookMethod - { - InitClassType = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), - MethodInfo = new global::TUnit.Core.MethodMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), - Name = "SetupWithContext", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = new global::TUnit.Core.ParameterMetadata[] - { - global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::TUnit.Core.TestContext), "testContext", new global::TUnit.Core.ConcreteType(typeof(global::TUnit.Core.TestContext)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.SetupTests).GetMethod("SetupWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(global::TUnit.Core.TestContext) }, null)!.GetParameters()[0]) - }, - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.SetupTests", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), - Name = "SetupTests", - Namespace = "TUnit.TestProject.BeforeTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_Before_Test.TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_Before_TestInitializer.global_TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext_1Params_Body - } -); - } -} - - -// ===== FILE SEPARATOR ===== - -// -#pragma warning disable - -#nullable enable -#pragma warning disable CS9113 // Parameter is unread. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Threading; -using System.Threading.Tasks; -using global::TUnit.Core; -using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_CancellationToken_Before_Test -{ - internal static class TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_CancellationToken_Before_TestInitializer - { - internal static async ValueTask global_TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext_2Params_Body(object instance, TestContext context, CancellationToken cancellationToken) + static __registrationIndex => + new InstanceHookMethod + { + InitClassType = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), + Name = "SetupWithContext", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = new global::TUnit.Core.ParameterMetadata[] + { + global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::TUnit.Core.TestContext), "testContext", new global::TUnit.Core.ConcreteType(typeof(global::TUnit.Core.TestContext)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.SetupTests).GetMethod("SetupWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(global::TUnit.Core.TestContext) }, null)!.GetParameters()[0]) + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.SetupTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), + Name = "SetupTests", + Namespace = "TUnit.TestProject.BeforeTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_Before_Test_Body + } + ); + private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_Before_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) { - var typedInstance = (global::TUnit.TestProject.BeforeTests.SetupTests)instance; - await AsyncConvert.Convert(() => typedInstance.SetupWithContext(context, cancellationToken)); + try + { + var typedInstance = (global::TUnit.TestProject.BeforeTests.SetupTests)instance; + return new ValueTask(typedInstance.SetupWithContext(context)); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } } - } -} -namespace TUnit.Generated -{ - internal static partial class TUnit_HookRegistration - { static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_CancellationToken_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), - static __registrationIndex => - new InstanceHookMethod - { - InitClassType = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), - MethodInfo = new global::TUnit.Core.MethodMetadata + static __registrationIndex => + new InstanceHookMethod + { + InitClassType = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), + Name = "SetupWithContext", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = new global::TUnit.Core.ParameterMetadata[] + { + global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::TUnit.Core.TestContext), "testContext", new global::TUnit.Core.ConcreteType(typeof(global::TUnit.Core.TestContext)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.SetupTests).GetMethod("SetupWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(global::TUnit.Core.TestContext), typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[0]), + global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::System.Threading.CancellationToken), "cancellationToken", new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.CancellationToken)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.SetupTests).GetMethod("SetupWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(global::TUnit.Core.TestContext), typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[1]) + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.SetupTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), + Name = "SetupTests", + Namespace = "TUnit.TestProject.BeforeTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_CancellationToken_Before_Test_Body + } + ); + private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_CancellationToken_Before_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) { - Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), - Name = "SetupWithContext", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = new global::TUnit.Core.ParameterMetadata[] - { - global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::TUnit.Core.TestContext), "testContext", new global::TUnit.Core.ConcreteType(typeof(global::TUnit.Core.TestContext)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.SetupTests).GetMethod("SetupWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(global::TUnit.Core.TestContext), typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[0]), - global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::System.Threading.CancellationToken), "cancellationToken", new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.CancellationToken)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.SetupTests).GetMethod("SetupWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(global::TUnit.Core.TestContext), typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[1]) - }, - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.SetupTests", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), - Name = "SetupTests", - Namespace = "TUnit.TestProject.BeforeTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_CancellationToken_Before_Test.TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_CancellationToken_Before_TestInitializer.global_TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext_2Params_Body - } -); + try + { + var typedInstance = (global::TUnit.TestProject.BeforeTests.SetupTests)instance; + return new ValueTask(typedInstance.SetupWithContext(context, cancellationToken)); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } + } } } diff --git a/tests/TUnit.Core.SourceGenerator.Tests/ConflictingNamespaceTests.HooksTest_WithConflictingNamespace.DotNet8_0.verified.txt b/tests/TUnit.Core.SourceGenerator.Tests/ConflictingNamespaceTests.HooksTest_WithConflictingNamespace.DotNet8_0.verified.txt index 235a98679db..2e6a86de97c 100644 --- a/tests/TUnit.Core.SourceGenerator.Tests/ConflictingNamespaceTests.HooksTest_WithConflictingNamespace.DotNet8_0.verified.txt +++ b/tests/TUnit.Core.SourceGenerator.Tests/ConflictingNamespaceTests.HooksTest_WithConflictingNamespace.DotNet8_0.verified.txt @@ -1,137 +1,106 @@ -// +// #pragma warning disable #nullable enable #pragma warning disable CS9113 // Parameter is unread. using System; -using System.Collections.Generic; -using System.Linq; using System.Reflection; -using System.Runtime.CompilerServices; using System.Threading; using System.Threading.Tasks; using global::TUnit.Core; using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_Base1_BeforeAll1_Before_Class -{ - internal static class TUnit_TestProject_BeforeTests_Base1_BeforeAll1_Before_ClassInitializer - { - internal static async ValueTask global_TUnit_TestProject_BeforeTests_Base1_BeforeAll1_0Params_Body(ClassHookContext context, CancellationToken cancellationToken) - { - await AsyncConvert.Convert(() => global::TUnit.TestProject.BeforeTests.Base1.BeforeAll1()); - } - } -} namespace TUnit.Generated { internal static partial class TUnit_HookRegistration { static readonly int _h_TUnit_TestProject_BeforeTests_Base1_BeforeAll1_Before_Class = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeClassHooks, typeof(global::TUnit.TestProject.BeforeTests.Base1), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeClassHookIndex(), - static __registrationIndex => - new BeforeClassHookMethod - { - MethodInfo = new global::TUnit.Core.MethodMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.Base1), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base1)), - Name = "BeforeAll1", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = global::System.Array.Empty(), - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.Base1", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.Base1), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base1)), - Name = "Base1", - Namespace = "TUnit.TestProject.BeforeTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_Base1_BeforeAll1_Before_Class.TUnit_TestProject_BeforeTests_Base1_BeforeAll1_Before_ClassInitializer.global_TUnit_TestProject_BeforeTests_Base1_BeforeAll1_0Params_Body, - FilePath = "", - LineNumber = 5 - } -); - } -} - - -// ===== FILE SEPARATOR ===== - -// -#pragma warning disable - -#nullable enable -#pragma warning disable CS9113 // Parameter is unread. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Threading; -using System.Threading.Tasks; -using global::TUnit.Core; -using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_Base1_BeforeEach1_Before_Test -{ - internal static class TUnit_TestProject_BeforeTests_Base1_BeforeEach1_Before_TestInitializer - { - internal static async ValueTask global_TUnit_TestProject_BeforeTests_Base1_BeforeEach1_0Params_Body(object instance, TestContext context, CancellationToken cancellationToken) + static __registrationIndex => + new BeforeClassHookMethod + { + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.Base1), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base1)), + Name = "BeforeAll1", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = global::System.Array.Empty(), + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.Base1", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.Base1), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base1)), + Name = "Base1", + Namespace = "TUnit.TestProject.BeforeTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_BeforeTests_Base1_BeforeAll1_Before_Class_Body, + FilePath = "", + LineNumber = 5 + } + ); + private static ValueTask TUnit_TestProject_BeforeTests_Base1_BeforeAll1_Before_Class_Body(ClassHookContext context, CancellationToken cancellationToken) { - var typedInstance = (global::TUnit.TestProject.BeforeTests.Base1)instance; - await AsyncConvert.Convert(() => typedInstance.BeforeEach1()); + try + { + return new ValueTask(global::TUnit.TestProject.BeforeTests.Base1.BeforeAll1()); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } } - } -} -namespace TUnit.Generated -{ - internal static partial class TUnit_HookRegistration - { static readonly int _h_TUnit_TestProject_BeforeTests_Base1_BeforeEach1_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.Base1), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), - static __registrationIndex => - new InstanceHookMethod - { - InitClassType = typeof(global::TUnit.TestProject.BeforeTests.Base1), - MethodInfo = new global::TUnit.Core.MethodMetadata + static __registrationIndex => + new InstanceHookMethod + { + InitClassType = typeof(global::TUnit.TestProject.BeforeTests.Base1), + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.Base1), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base1)), + Name = "BeforeEach1", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = global::System.Array.Empty(), + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.Base1", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.Base1), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base1)), + Name = "Base1", + Namespace = "TUnit.TestProject.BeforeTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_BeforeTests_Base1_BeforeEach1_Before_Test_Body + } + ); + private static ValueTask TUnit_TestProject_BeforeTests_Base1_BeforeEach1_Before_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) { - Type = typeof(global::TUnit.TestProject.BeforeTests.Base1), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base1)), - Name = "BeforeEach1", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = global::System.Array.Empty(), - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.Base1", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.Base1), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base1)), - Name = "Base1", - Namespace = "TUnit.TestProject.BeforeTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_Base1_BeforeEach1_Before_Test.TUnit_TestProject_BeforeTests_Base1_BeforeEach1_Before_TestInitializer.global_TUnit_TestProject_BeforeTests_Base1_BeforeEach1_0Params_Body - } -); + try + { + var typedInstance = (global::TUnit.TestProject.BeforeTests.Base1)instance; + return new ValueTask(typedInstance.BeforeEach1()); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } + } } } @@ -144,134 +113,103 @@ namespace TUnit.Generated #nullable enable #pragma warning disable CS9113 // Parameter is unread. using System; -using System.Collections.Generic; -using System.Linq; using System.Reflection; -using System.Runtime.CompilerServices; using System.Threading; using System.Threading.Tasks; using global::TUnit.Core; using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_Base2_BeforeAll2_Before_Class -{ - internal static class TUnit_TestProject_BeforeTests_Base2_BeforeAll2_Before_ClassInitializer - { - internal static async ValueTask global_TUnit_TestProject_BeforeTests_Base2_BeforeAll2_0Params_Body(ClassHookContext context, CancellationToken cancellationToken) - { - await AsyncConvert.Convert(() => global::TUnit.TestProject.BeforeTests.Base2.BeforeAll2()); - } - } -} namespace TUnit.Generated { internal static partial class TUnit_HookRegistration { static readonly int _h_TUnit_TestProject_BeforeTests_Base2_BeforeAll2_Before_Class = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeClassHooks, typeof(global::TUnit.TestProject.BeforeTests.Base2), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeClassHookIndex(), - static __registrationIndex => - new BeforeClassHookMethod - { - MethodInfo = new global::TUnit.Core.MethodMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.Base2), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base2)), - Name = "BeforeAll2", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = global::System.Array.Empty(), - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.Base2", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.Base2), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base2)), - Name = "Base2", - Namespace = "TUnit.TestProject.BeforeTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_Base2_BeforeAll2_Before_Class.TUnit_TestProject_BeforeTests_Base2_BeforeAll2_Before_ClassInitializer.global_TUnit_TestProject_BeforeTests_Base2_BeforeAll2_0Params_Body, - FilePath = "", - LineNumber = 20 - } -); - } -} - - -// ===== FILE SEPARATOR ===== - -// -#pragma warning disable - -#nullable enable -#pragma warning disable CS9113 // Parameter is unread. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Threading; -using System.Threading.Tasks; -using global::TUnit.Core; -using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_Base2_BeforeEach2_Before_Test -{ - internal static class TUnit_TestProject_BeforeTests_Base2_BeforeEach2_Before_TestInitializer - { - internal static async ValueTask global_TUnit_TestProject_BeforeTests_Base2_BeforeEach2_0Params_Body(object instance, TestContext context, CancellationToken cancellationToken) + static __registrationIndex => + new BeforeClassHookMethod + { + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.Base2), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base2)), + Name = "BeforeAll2", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = global::System.Array.Empty(), + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.Base2", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.Base2), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base2)), + Name = "Base2", + Namespace = "TUnit.TestProject.BeforeTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_BeforeTests_Base2_BeforeAll2_Before_Class_Body, + FilePath = "", + LineNumber = 20 + } + ); + private static ValueTask TUnit_TestProject_BeforeTests_Base2_BeforeAll2_Before_Class_Body(ClassHookContext context, CancellationToken cancellationToken) { - var typedInstance = (global::TUnit.TestProject.BeforeTests.Base2)instance; - await AsyncConvert.Convert(() => typedInstance.BeforeEach2()); + try + { + return new ValueTask(global::TUnit.TestProject.BeforeTests.Base2.BeforeAll2()); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } } - } -} -namespace TUnit.Generated -{ - internal static partial class TUnit_HookRegistration - { static readonly int _h_TUnit_TestProject_BeforeTests_Base2_BeforeEach2_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.Base2), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), - static __registrationIndex => - new InstanceHookMethod - { - InitClassType = typeof(global::TUnit.TestProject.BeforeTests.Base2), - MethodInfo = new global::TUnit.Core.MethodMetadata + static __registrationIndex => + new InstanceHookMethod + { + InitClassType = typeof(global::TUnit.TestProject.BeforeTests.Base2), + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.Base2), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base2)), + Name = "BeforeEach2", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = global::System.Array.Empty(), + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.Base2", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.Base2), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base2)), + Name = "Base2", + Namespace = "TUnit.TestProject.BeforeTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_BeforeTests_Base2_BeforeEach2_Before_Test_Body + } + ); + private static ValueTask TUnit_TestProject_BeforeTests_Base2_BeforeEach2_Before_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) { - Type = typeof(global::TUnit.TestProject.BeforeTests.Base2), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base2)), - Name = "BeforeEach2", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = global::System.Array.Empty(), - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.Base2", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.Base2), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base2)), - Name = "Base2", - Namespace = "TUnit.TestProject.BeforeTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_Base2_BeforeEach2_Before_Test.TUnit_TestProject_BeforeTests_Base2_BeforeEach2_Before_TestInitializer.global_TUnit_TestProject_BeforeTests_Base2_BeforeEach2_0Params_Body - } -); + try + { + var typedInstance = (global::TUnit.TestProject.BeforeTests.Base2)instance; + return new ValueTask(typedInstance.BeforeEach2()); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } + } } } @@ -284,134 +222,103 @@ namespace TUnit.Generated #nullable enable #pragma warning disable CS9113 // Parameter is unread. using System; -using System.Collections.Generic; -using System.Linq; using System.Reflection; -using System.Runtime.CompilerServices; using System.Threading; using System.Threading.Tasks; using global::TUnit.Core; using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_Base3_BeforeAll3_Before_Class -{ - internal static class TUnit_TestProject_BeforeTests_Base3_BeforeAll3_Before_ClassInitializer - { - internal static async ValueTask global_TUnit_TestProject_BeforeTests_Base3_BeforeAll3_0Params_Body(ClassHookContext context, CancellationToken cancellationToken) - { - await AsyncConvert.Convert(() => global::TUnit.TestProject.BeforeTests.Base3.BeforeAll3()); - } - } -} namespace TUnit.Generated { internal static partial class TUnit_HookRegistration { static readonly int _h_TUnit_TestProject_BeforeTests_Base3_BeforeAll3_Before_Class = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeClassHooks, typeof(global::TUnit.TestProject.BeforeTests.Base3), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeClassHookIndex(), - static __registrationIndex => - new BeforeClassHookMethod - { - MethodInfo = new global::TUnit.Core.MethodMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.Base3), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base3)), - Name = "BeforeAll3", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = global::System.Array.Empty(), - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.Base3", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.Base3), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base3)), - Name = "Base3", - Namespace = "TUnit.TestProject.BeforeTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_Base3_BeforeAll3_Before_Class.TUnit_TestProject_BeforeTests_Base3_BeforeAll3_Before_ClassInitializer.global_TUnit_TestProject_BeforeTests_Base3_BeforeAll3_0Params_Body, - FilePath = "", - LineNumber = 35 - } -); - } -} - - -// ===== FILE SEPARATOR ===== - -// -#pragma warning disable - -#nullable enable -#pragma warning disable CS9113 // Parameter is unread. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Threading; -using System.Threading.Tasks; -using global::TUnit.Core; -using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_Base3_BeforeEach3_Before_Test -{ - internal static class TUnit_TestProject_BeforeTests_Base3_BeforeEach3_Before_TestInitializer - { - internal static async ValueTask global_TUnit_TestProject_BeforeTests_Base3_BeforeEach3_0Params_Body(object instance, TestContext context, CancellationToken cancellationToken) + static __registrationIndex => + new BeforeClassHookMethod + { + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.Base3), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base3)), + Name = "BeforeAll3", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = global::System.Array.Empty(), + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.Base3", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.Base3), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base3)), + Name = "Base3", + Namespace = "TUnit.TestProject.BeforeTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_BeforeTests_Base3_BeforeAll3_Before_Class_Body, + FilePath = "", + LineNumber = 35 + } + ); + private static ValueTask TUnit_TestProject_BeforeTests_Base3_BeforeAll3_Before_Class_Body(ClassHookContext context, CancellationToken cancellationToken) { - var typedInstance = (global::TUnit.TestProject.BeforeTests.Base3)instance; - await AsyncConvert.Convert(() => typedInstance.BeforeEach3()); + try + { + return new ValueTask(global::TUnit.TestProject.BeforeTests.Base3.BeforeAll3()); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } } - } -} -namespace TUnit.Generated -{ - internal static partial class TUnit_HookRegistration - { static readonly int _h_TUnit_TestProject_BeforeTests_Base3_BeforeEach3_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.Base3), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), - static __registrationIndex => - new InstanceHookMethod - { - InitClassType = typeof(global::TUnit.TestProject.BeforeTests.Base3), - MethodInfo = new global::TUnit.Core.MethodMetadata + static __registrationIndex => + new InstanceHookMethod + { + InitClassType = typeof(global::TUnit.TestProject.BeforeTests.Base3), + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.Base3), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base3)), + Name = "BeforeEach3", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = global::System.Array.Empty(), + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.Base3", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.Base3), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base3)), + Name = "Base3", + Namespace = "TUnit.TestProject.BeforeTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_BeforeTests_Base3_BeforeEach3_Before_Test_Body + } + ); + private static ValueTask TUnit_TestProject_BeforeTests_Base3_BeforeEach3_Before_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) { - Type = typeof(global::TUnit.TestProject.BeforeTests.Base3), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base3)), - Name = "BeforeEach3", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = global::System.Array.Empty(), - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.Base3", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.Base3), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base3)), - Name = "Base3", - Namespace = "TUnit.TestProject.BeforeTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_Base3_BeforeEach3_Before_Test.TUnit_TestProject_BeforeTests_Base3_BeforeEach3_Before_TestInitializer.global_TUnit_TestProject_BeforeTests_Base3_BeforeEach3_0Params_Body - } -); + try + { + var typedInstance = (global::TUnit.TestProject.BeforeTests.Base3)instance; + return new ValueTask(typedInstance.BeforeEach3()); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } + } } } @@ -424,573 +331,386 @@ namespace TUnit.Generated #nullable enable #pragma warning disable CS9113 // Parameter is unread. using System; -using System.Collections.Generic; -using System.Linq; using System.Reflection; -using System.Runtime.CompilerServices; using System.Threading; using System.Threading.Tasks; using global::TUnit.Core; using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp_Before_Class -{ - internal static class TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp_Before_ClassInitializer - { - internal static async ValueTask global_TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp_0Params_Body(ClassHookContext context, CancellationToken cancellationToken) - { - await AsyncConvert.Convert(() => global::TUnit.TestProject.BeforeTests.SetupTests.BeforeAllSetUp()); - } - } -} namespace TUnit.Generated { internal static partial class TUnit_HookRegistration { static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp_Before_Class = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeClassHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeClassHookIndex(), - static __registrationIndex => - new BeforeClassHookMethod - { - MethodInfo = new global::TUnit.Core.MethodMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), - Name = "BeforeAllSetUp", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = global::System.Array.Empty(), - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.SetupTests", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), - Name = "SetupTests", - Namespace = "TUnit.TestProject.BeforeTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp_Before_Class.TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp_Before_ClassInitializer.global_TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp_0Params_Body, - FilePath = "", - LineNumber = 50 - } -); - } -} - - -// ===== FILE SEPARATOR ===== - -// -#pragma warning disable - -#nullable enable -#pragma warning disable CS9113 // Parameter is unread. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Threading; -using System.Threading.Tasks; -using global::TUnit.Core; -using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_Before_Class -{ - internal static class TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_Before_ClassInitializer - { - internal static async ValueTask global_TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext_1Params_Body(ClassHookContext context, CancellationToken cancellationToken) + static __registrationIndex => + new BeforeClassHookMethod + { + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), + Name = "BeforeAllSetUp", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = global::System.Array.Empty(), + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.SetupTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), + Name = "SetupTests", + Namespace = "TUnit.TestProject.BeforeTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp_Before_Class_Body, + FilePath = "", + LineNumber = 50 + } + ); + private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp_Before_Class_Body(ClassHookContext context, CancellationToken cancellationToken) { - await AsyncConvert.Convert(() => global::TUnit.TestProject.BeforeTests.SetupTests.BeforeAllSetUpWithContext(context)); + try + { + return new ValueTask(global::TUnit.TestProject.BeforeTests.SetupTests.BeforeAllSetUp()); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } } - } -} -namespace TUnit.Generated -{ - internal static partial class TUnit_HookRegistration - { static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_Before_Class = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeClassHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeClassHookIndex(), - static __registrationIndex => - new BeforeClassHookMethod - { - MethodInfo = new global::TUnit.Core.MethodMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), - Name = "BeforeAllSetUpWithContext", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = new global::TUnit.Core.ParameterMetadata[] - { - global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::TUnit.Core.ClassHookContext), "context", new global::TUnit.Core.ConcreteType(typeof(global::TUnit.Core.ClassHookContext)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.SetupTests).GetMethod("BeforeAllSetUpWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::TUnit.Core.ClassHookContext) }, null)!.GetParameters()[0]) - }, - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.SetupTests", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), - Name = "SetupTests", - Namespace = "TUnit.TestProject.BeforeTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_Before_Class.TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_Before_ClassInitializer.global_TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext_1Params_Body, - FilePath = "", - LineNumber = 56 - } -); - } -} - - -// ===== FILE SEPARATOR ===== - -// -#pragma warning disable - -#nullable enable -#pragma warning disable CS9113 // Parameter is unread. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Threading; -using System.Threading.Tasks; -using global::TUnit.Core; -using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp__CancellationToken_Before_Class -{ - internal static class TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp__CancellationToken_Before_ClassInitializer - { - internal static async ValueTask global_TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp_1Params_Body(ClassHookContext context, CancellationToken cancellationToken) + static __registrationIndex => + new BeforeClassHookMethod + { + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), + Name = "BeforeAllSetUpWithContext", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = new global::TUnit.Core.ParameterMetadata[] + { + global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::TUnit.Core.ClassHookContext), "context", new global::TUnit.Core.ConcreteType(typeof(global::TUnit.Core.ClassHookContext)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.SetupTests).GetMethod("BeforeAllSetUpWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::TUnit.Core.ClassHookContext) }, null)!.GetParameters()[0]) + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.SetupTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), + Name = "SetupTests", + Namespace = "TUnit.TestProject.BeforeTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_Before_Class_Body, + FilePath = "", + LineNumber = 56 + } + ); + private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_Before_Class_Body(ClassHookContext context, CancellationToken cancellationToken) { - await AsyncConvert.Convert(() => global::TUnit.TestProject.BeforeTests.SetupTests.BeforeAllSetUp(cancellationToken)); + try + { + return new ValueTask(global::TUnit.TestProject.BeforeTests.SetupTests.BeforeAllSetUpWithContext(context)); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } } - } -} -namespace TUnit.Generated -{ - internal static partial class TUnit_HookRegistration - { static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp__CancellationToken_Before_Class = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeClassHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeClassHookIndex(), - static __registrationIndex => - new BeforeClassHookMethod - { - MethodInfo = new global::TUnit.Core.MethodMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), - Name = "BeforeAllSetUp", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = new global::TUnit.Core.ParameterMetadata[] - { - global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::System.Threading.CancellationToken), "cancellationToken", new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.CancellationToken)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.SetupTests).GetMethod("BeforeAllSetUp", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[0]) - }, - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.SetupTests", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), - Name = "SetupTests", - Namespace = "TUnit.TestProject.BeforeTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp__CancellationToken_Before_Class.TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp__CancellationToken_Before_ClassInitializer.global_TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp_1Params_Body, - FilePath = "", - LineNumber = 62 - } -); - } -} - - -// ===== FILE SEPARATOR ===== - -// -#pragma warning disable - -#nullable enable -#pragma warning disable CS9113 // Parameter is unread. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Threading; -using System.Threading.Tasks; -using global::TUnit.Core; -using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_CancellationToken_Before_Class -{ - internal static class TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_CancellationToken_Before_ClassInitializer - { - internal static async ValueTask global_TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext_2Params_Body(ClassHookContext context, CancellationToken cancellationToken) + static __registrationIndex => + new BeforeClassHookMethod + { + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), + Name = "BeforeAllSetUp", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = new global::TUnit.Core.ParameterMetadata[] + { + global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::System.Threading.CancellationToken), "cancellationToken", new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.CancellationToken)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.SetupTests).GetMethod("BeforeAllSetUp", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[0]) + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.SetupTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), + Name = "SetupTests", + Namespace = "TUnit.TestProject.BeforeTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp__CancellationToken_Before_Class_Body, + FilePath = "", + LineNumber = 62 + } + ); + private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp__CancellationToken_Before_Class_Body(ClassHookContext context, CancellationToken cancellationToken) { - await AsyncConvert.Convert(() => global::TUnit.TestProject.BeforeTests.SetupTests.BeforeAllSetUpWithContext(context, cancellationToken)); + try + { + return new ValueTask(global::TUnit.TestProject.BeforeTests.SetupTests.BeforeAllSetUp(cancellationToken)); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } } - } -} -namespace TUnit.Generated -{ - internal static partial class TUnit_HookRegistration - { static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_CancellationToken_Before_Class = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeClassHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeClassHookIndex(), - static __registrationIndex => - new BeforeClassHookMethod - { - MethodInfo = new global::TUnit.Core.MethodMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), - Name = "BeforeAllSetUpWithContext", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = new global::TUnit.Core.ParameterMetadata[] - { - global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::TUnit.Core.ClassHookContext), "context", new global::TUnit.Core.ConcreteType(typeof(global::TUnit.Core.ClassHookContext)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.SetupTests).GetMethod("BeforeAllSetUpWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::TUnit.Core.ClassHookContext), typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[0]), - global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::System.Threading.CancellationToken), "cancellationToken", new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.CancellationToken)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.SetupTests).GetMethod("BeforeAllSetUpWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::TUnit.Core.ClassHookContext), typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[1]) - }, - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.SetupTests", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), - Name = "SetupTests", - Namespace = "TUnit.TestProject.BeforeTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_CancellationToken_Before_Class.TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_CancellationToken_Before_ClassInitializer.global_TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext_2Params_Body, - FilePath = "", - LineNumber = 68 - } -); - } -} - - -// ===== FILE SEPARATOR ===== - -// -#pragma warning disable - -#nullable enable -#pragma warning disable CS9113 // Parameter is unread. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Threading; -using System.Threading.Tasks; -using global::TUnit.Core; -using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_SetupTests_Setup_Before_Test -{ - internal static class TUnit_TestProject_BeforeTests_SetupTests_Setup_Before_TestInitializer - { - internal static async ValueTask global_TUnit_TestProject_BeforeTests_SetupTests_Setup_0Params_Body(object instance, TestContext context, CancellationToken cancellationToken) + static __registrationIndex => + new BeforeClassHookMethod + { + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), + Name = "BeforeAllSetUpWithContext", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = new global::TUnit.Core.ParameterMetadata[] + { + global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::TUnit.Core.ClassHookContext), "context", new global::TUnit.Core.ConcreteType(typeof(global::TUnit.Core.ClassHookContext)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.SetupTests).GetMethod("BeforeAllSetUpWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::TUnit.Core.ClassHookContext), typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[0]), + global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::System.Threading.CancellationToken), "cancellationToken", new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.CancellationToken)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.SetupTests).GetMethod("BeforeAllSetUpWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::TUnit.Core.ClassHookContext), typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[1]) + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.SetupTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), + Name = "SetupTests", + Namespace = "TUnit.TestProject.BeforeTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_CancellationToken_Before_Class_Body, + FilePath = "", + LineNumber = 68 + } + ); + private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_CancellationToken_Before_Class_Body(ClassHookContext context, CancellationToken cancellationToken) { - var typedInstance = (global::TUnit.TestProject.BeforeTests.SetupTests)instance; - await AsyncConvert.Convert(() => typedInstance.Setup()); + try + { + return new ValueTask(global::TUnit.TestProject.BeforeTests.SetupTests.BeforeAllSetUpWithContext(context, cancellationToken)); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } } - } -} -namespace TUnit.Generated -{ - internal static partial class TUnit_HookRegistration - { static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_Setup_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), - static __registrationIndex => - new InstanceHookMethod - { - InitClassType = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), - MethodInfo = new global::TUnit.Core.MethodMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), - Name = "Setup", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = global::System.Array.Empty(), - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.SetupTests", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), - Name = "SetupTests", - Namespace = "TUnit.TestProject.BeforeTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_SetupTests_Setup_Before_Test.TUnit_TestProject_BeforeTests_SetupTests_Setup_Before_TestInitializer.global_TUnit_TestProject_BeforeTests_SetupTests_Setup_0Params_Body - } -); - } -} - - -// ===== FILE SEPARATOR ===== - -// -#pragma warning disable - -#nullable enable -#pragma warning disable CS9113 // Parameter is unread. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Threading; -using System.Threading.Tasks; -using global::TUnit.Core; -using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_SetupTests_Setup__CancellationToken_Before_Test -{ - internal static class TUnit_TestProject_BeforeTests_SetupTests_Setup__CancellationToken_Before_TestInitializer - { - internal static async ValueTask global_TUnit_TestProject_BeforeTests_SetupTests_Setup_1Params_Body(object instance, TestContext context, CancellationToken cancellationToken) + static __registrationIndex => + new InstanceHookMethod + { + InitClassType = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), + Name = "Setup", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = global::System.Array.Empty(), + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.SetupTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), + Name = "SetupTests", + Namespace = "TUnit.TestProject.BeforeTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_BeforeTests_SetupTests_Setup_Before_Test_Body + } + ); + private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_Setup_Before_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) { - var typedInstance = (global::TUnit.TestProject.BeforeTests.SetupTests)instance; - await AsyncConvert.Convert(() => typedInstance.Setup(cancellationToken)); + try + { + var typedInstance = (global::TUnit.TestProject.BeforeTests.SetupTests)instance; + return new ValueTask(typedInstance.Setup()); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } } - } -} -namespace TUnit.Generated -{ - internal static partial class TUnit_HookRegistration - { static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_Setup__CancellationToken_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), - static __registrationIndex => - new InstanceHookMethod - { - InitClassType = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), - MethodInfo = new global::TUnit.Core.MethodMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), - Name = "Setup", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = new global::TUnit.Core.ParameterMetadata[] - { - global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::System.Threading.CancellationToken), "cancellationToken", new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.CancellationToken)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.SetupTests).GetMethod("Setup", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[0]) - }, - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.SetupTests", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), - Name = "SetupTests", - Namespace = "TUnit.TestProject.BeforeTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_SetupTests_Setup__CancellationToken_Before_Test.TUnit_TestProject_BeforeTests_SetupTests_Setup__CancellationToken_Before_TestInitializer.global_TUnit_TestProject_BeforeTests_SetupTests_Setup_1Params_Body - } -); - } -} - - -// ===== FILE SEPARATOR ===== - -// -#pragma warning disable - -#nullable enable -#pragma warning disable CS9113 // Parameter is unread. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Threading; -using System.Threading.Tasks; -using global::TUnit.Core; -using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_Before_Test -{ - internal static class TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_Before_TestInitializer - { - internal static async ValueTask global_TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext_1Params_Body(object instance, TestContext context, CancellationToken cancellationToken) + static __registrationIndex => + new InstanceHookMethod + { + InitClassType = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), + Name = "Setup", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = new global::TUnit.Core.ParameterMetadata[] + { + global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::System.Threading.CancellationToken), "cancellationToken", new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.CancellationToken)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.SetupTests).GetMethod("Setup", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[0]) + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.SetupTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), + Name = "SetupTests", + Namespace = "TUnit.TestProject.BeforeTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_BeforeTests_SetupTests_Setup__CancellationToken_Before_Test_Body + } + ); + private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_Setup__CancellationToken_Before_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) { - var typedInstance = (global::TUnit.TestProject.BeforeTests.SetupTests)instance; - await AsyncConvert.Convert(() => typedInstance.SetupWithContext(context)); + try + { + var typedInstance = (global::TUnit.TestProject.BeforeTests.SetupTests)instance; + return new ValueTask(typedInstance.Setup(cancellationToken)); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } } - } -} -namespace TUnit.Generated -{ - internal static partial class TUnit_HookRegistration - { static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), - static __registrationIndex => - new InstanceHookMethod - { - InitClassType = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), - MethodInfo = new global::TUnit.Core.MethodMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), - Name = "SetupWithContext", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = new global::TUnit.Core.ParameterMetadata[] - { - global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::TUnit.Core.TestContext), "testContext", new global::TUnit.Core.ConcreteType(typeof(global::TUnit.Core.TestContext)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.SetupTests).GetMethod("SetupWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(global::TUnit.Core.TestContext) }, null)!.GetParameters()[0]) - }, - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.SetupTests", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), - Name = "SetupTests", - Namespace = "TUnit.TestProject.BeforeTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_Before_Test.TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_Before_TestInitializer.global_TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext_1Params_Body - } -); - } -} - - -// ===== FILE SEPARATOR ===== - -// -#pragma warning disable - -#nullable enable -#pragma warning disable CS9113 // Parameter is unread. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Threading; -using System.Threading.Tasks; -using global::TUnit.Core; -using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_CancellationToken_Before_Test -{ - internal static class TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_CancellationToken_Before_TestInitializer - { - internal static async ValueTask global_TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext_2Params_Body(object instance, TestContext context, CancellationToken cancellationToken) + static __registrationIndex => + new InstanceHookMethod + { + InitClassType = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), + Name = "SetupWithContext", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = new global::TUnit.Core.ParameterMetadata[] + { + global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::TUnit.Core.TestContext), "testContext", new global::TUnit.Core.ConcreteType(typeof(global::TUnit.Core.TestContext)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.SetupTests).GetMethod("SetupWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(global::TUnit.Core.TestContext) }, null)!.GetParameters()[0]) + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.SetupTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), + Name = "SetupTests", + Namespace = "TUnit.TestProject.BeforeTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_Before_Test_Body + } + ); + private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_Before_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) { - var typedInstance = (global::TUnit.TestProject.BeforeTests.SetupTests)instance; - await AsyncConvert.Convert(() => typedInstance.SetupWithContext(context, cancellationToken)); + try + { + var typedInstance = (global::TUnit.TestProject.BeforeTests.SetupTests)instance; + return new ValueTask(typedInstance.SetupWithContext(context)); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } } - } -} -namespace TUnit.Generated -{ - internal static partial class TUnit_HookRegistration - { static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_CancellationToken_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), - static __registrationIndex => - new InstanceHookMethod - { - InitClassType = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), - MethodInfo = new global::TUnit.Core.MethodMetadata + static __registrationIndex => + new InstanceHookMethod + { + InitClassType = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), + Name = "SetupWithContext", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = new global::TUnit.Core.ParameterMetadata[] + { + global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::TUnit.Core.TestContext), "testContext", new global::TUnit.Core.ConcreteType(typeof(global::TUnit.Core.TestContext)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.SetupTests).GetMethod("SetupWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(global::TUnit.Core.TestContext), typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[0]), + global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::System.Threading.CancellationToken), "cancellationToken", new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.CancellationToken)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.SetupTests).GetMethod("SetupWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(global::TUnit.Core.TestContext), typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[1]) + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.SetupTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), + Name = "SetupTests", + Namespace = "TUnit.TestProject.BeforeTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_CancellationToken_Before_Test_Body + } + ); + private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_CancellationToken_Before_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) { - Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), - Name = "SetupWithContext", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = new global::TUnit.Core.ParameterMetadata[] - { - global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::TUnit.Core.TestContext), "testContext", new global::TUnit.Core.ConcreteType(typeof(global::TUnit.Core.TestContext)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.SetupTests).GetMethod("SetupWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(global::TUnit.Core.TestContext), typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[0]), - global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::System.Threading.CancellationToken), "cancellationToken", new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.CancellationToken)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.SetupTests).GetMethod("SetupWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(global::TUnit.Core.TestContext), typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[1]) - }, - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.SetupTests", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), - Name = "SetupTests", - Namespace = "TUnit.TestProject.BeforeTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_CancellationToken_Before_Test.TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_CancellationToken_Before_TestInitializer.global_TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext_2Params_Body - } -); + try + { + var typedInstance = (global::TUnit.TestProject.BeforeTests.SetupTests)instance; + return new ValueTask(typedInstance.SetupWithContext(context, cancellationToken)); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } + } } } diff --git a/tests/TUnit.Core.SourceGenerator.Tests/ConflictingNamespaceTests.HooksTest_WithConflictingNamespace.DotNet9_0.verified.txt b/tests/TUnit.Core.SourceGenerator.Tests/ConflictingNamespaceTests.HooksTest_WithConflictingNamespace.DotNet9_0.verified.txt index 235a98679db..2e6a86de97c 100644 --- a/tests/TUnit.Core.SourceGenerator.Tests/ConflictingNamespaceTests.HooksTest_WithConflictingNamespace.DotNet9_0.verified.txt +++ b/tests/TUnit.Core.SourceGenerator.Tests/ConflictingNamespaceTests.HooksTest_WithConflictingNamespace.DotNet9_0.verified.txt @@ -1,137 +1,106 @@ -// +// #pragma warning disable #nullable enable #pragma warning disable CS9113 // Parameter is unread. using System; -using System.Collections.Generic; -using System.Linq; using System.Reflection; -using System.Runtime.CompilerServices; using System.Threading; using System.Threading.Tasks; using global::TUnit.Core; using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_Base1_BeforeAll1_Before_Class -{ - internal static class TUnit_TestProject_BeforeTests_Base1_BeforeAll1_Before_ClassInitializer - { - internal static async ValueTask global_TUnit_TestProject_BeforeTests_Base1_BeforeAll1_0Params_Body(ClassHookContext context, CancellationToken cancellationToken) - { - await AsyncConvert.Convert(() => global::TUnit.TestProject.BeforeTests.Base1.BeforeAll1()); - } - } -} namespace TUnit.Generated { internal static partial class TUnit_HookRegistration { static readonly int _h_TUnit_TestProject_BeforeTests_Base1_BeforeAll1_Before_Class = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeClassHooks, typeof(global::TUnit.TestProject.BeforeTests.Base1), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeClassHookIndex(), - static __registrationIndex => - new BeforeClassHookMethod - { - MethodInfo = new global::TUnit.Core.MethodMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.Base1), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base1)), - Name = "BeforeAll1", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = global::System.Array.Empty(), - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.Base1", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.Base1), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base1)), - Name = "Base1", - Namespace = "TUnit.TestProject.BeforeTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_Base1_BeforeAll1_Before_Class.TUnit_TestProject_BeforeTests_Base1_BeforeAll1_Before_ClassInitializer.global_TUnit_TestProject_BeforeTests_Base1_BeforeAll1_0Params_Body, - FilePath = "", - LineNumber = 5 - } -); - } -} - - -// ===== FILE SEPARATOR ===== - -// -#pragma warning disable - -#nullable enable -#pragma warning disable CS9113 // Parameter is unread. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Threading; -using System.Threading.Tasks; -using global::TUnit.Core; -using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_Base1_BeforeEach1_Before_Test -{ - internal static class TUnit_TestProject_BeforeTests_Base1_BeforeEach1_Before_TestInitializer - { - internal static async ValueTask global_TUnit_TestProject_BeforeTests_Base1_BeforeEach1_0Params_Body(object instance, TestContext context, CancellationToken cancellationToken) + static __registrationIndex => + new BeforeClassHookMethod + { + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.Base1), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base1)), + Name = "BeforeAll1", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = global::System.Array.Empty(), + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.Base1", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.Base1), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base1)), + Name = "Base1", + Namespace = "TUnit.TestProject.BeforeTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_BeforeTests_Base1_BeforeAll1_Before_Class_Body, + FilePath = "", + LineNumber = 5 + } + ); + private static ValueTask TUnit_TestProject_BeforeTests_Base1_BeforeAll1_Before_Class_Body(ClassHookContext context, CancellationToken cancellationToken) { - var typedInstance = (global::TUnit.TestProject.BeforeTests.Base1)instance; - await AsyncConvert.Convert(() => typedInstance.BeforeEach1()); + try + { + return new ValueTask(global::TUnit.TestProject.BeforeTests.Base1.BeforeAll1()); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } } - } -} -namespace TUnit.Generated -{ - internal static partial class TUnit_HookRegistration - { static readonly int _h_TUnit_TestProject_BeforeTests_Base1_BeforeEach1_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.Base1), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), - static __registrationIndex => - new InstanceHookMethod - { - InitClassType = typeof(global::TUnit.TestProject.BeforeTests.Base1), - MethodInfo = new global::TUnit.Core.MethodMetadata + static __registrationIndex => + new InstanceHookMethod + { + InitClassType = typeof(global::TUnit.TestProject.BeforeTests.Base1), + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.Base1), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base1)), + Name = "BeforeEach1", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = global::System.Array.Empty(), + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.Base1", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.Base1), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base1)), + Name = "Base1", + Namespace = "TUnit.TestProject.BeforeTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_BeforeTests_Base1_BeforeEach1_Before_Test_Body + } + ); + private static ValueTask TUnit_TestProject_BeforeTests_Base1_BeforeEach1_Before_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) { - Type = typeof(global::TUnit.TestProject.BeforeTests.Base1), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base1)), - Name = "BeforeEach1", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = global::System.Array.Empty(), - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.Base1", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.Base1), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base1)), - Name = "Base1", - Namespace = "TUnit.TestProject.BeforeTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_Base1_BeforeEach1_Before_Test.TUnit_TestProject_BeforeTests_Base1_BeforeEach1_Before_TestInitializer.global_TUnit_TestProject_BeforeTests_Base1_BeforeEach1_0Params_Body - } -); + try + { + var typedInstance = (global::TUnit.TestProject.BeforeTests.Base1)instance; + return new ValueTask(typedInstance.BeforeEach1()); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } + } } } @@ -144,134 +113,103 @@ namespace TUnit.Generated #nullable enable #pragma warning disable CS9113 // Parameter is unread. using System; -using System.Collections.Generic; -using System.Linq; using System.Reflection; -using System.Runtime.CompilerServices; using System.Threading; using System.Threading.Tasks; using global::TUnit.Core; using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_Base2_BeforeAll2_Before_Class -{ - internal static class TUnit_TestProject_BeforeTests_Base2_BeforeAll2_Before_ClassInitializer - { - internal static async ValueTask global_TUnit_TestProject_BeforeTests_Base2_BeforeAll2_0Params_Body(ClassHookContext context, CancellationToken cancellationToken) - { - await AsyncConvert.Convert(() => global::TUnit.TestProject.BeforeTests.Base2.BeforeAll2()); - } - } -} namespace TUnit.Generated { internal static partial class TUnit_HookRegistration { static readonly int _h_TUnit_TestProject_BeforeTests_Base2_BeforeAll2_Before_Class = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeClassHooks, typeof(global::TUnit.TestProject.BeforeTests.Base2), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeClassHookIndex(), - static __registrationIndex => - new BeforeClassHookMethod - { - MethodInfo = new global::TUnit.Core.MethodMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.Base2), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base2)), - Name = "BeforeAll2", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = global::System.Array.Empty(), - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.Base2", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.Base2), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base2)), - Name = "Base2", - Namespace = "TUnit.TestProject.BeforeTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_Base2_BeforeAll2_Before_Class.TUnit_TestProject_BeforeTests_Base2_BeforeAll2_Before_ClassInitializer.global_TUnit_TestProject_BeforeTests_Base2_BeforeAll2_0Params_Body, - FilePath = "", - LineNumber = 20 - } -); - } -} - - -// ===== FILE SEPARATOR ===== - -// -#pragma warning disable - -#nullable enable -#pragma warning disable CS9113 // Parameter is unread. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Threading; -using System.Threading.Tasks; -using global::TUnit.Core; -using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_Base2_BeforeEach2_Before_Test -{ - internal static class TUnit_TestProject_BeforeTests_Base2_BeforeEach2_Before_TestInitializer - { - internal static async ValueTask global_TUnit_TestProject_BeforeTests_Base2_BeforeEach2_0Params_Body(object instance, TestContext context, CancellationToken cancellationToken) + static __registrationIndex => + new BeforeClassHookMethod + { + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.Base2), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base2)), + Name = "BeforeAll2", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = global::System.Array.Empty(), + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.Base2", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.Base2), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base2)), + Name = "Base2", + Namespace = "TUnit.TestProject.BeforeTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_BeforeTests_Base2_BeforeAll2_Before_Class_Body, + FilePath = "", + LineNumber = 20 + } + ); + private static ValueTask TUnit_TestProject_BeforeTests_Base2_BeforeAll2_Before_Class_Body(ClassHookContext context, CancellationToken cancellationToken) { - var typedInstance = (global::TUnit.TestProject.BeforeTests.Base2)instance; - await AsyncConvert.Convert(() => typedInstance.BeforeEach2()); + try + { + return new ValueTask(global::TUnit.TestProject.BeforeTests.Base2.BeforeAll2()); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } } - } -} -namespace TUnit.Generated -{ - internal static partial class TUnit_HookRegistration - { static readonly int _h_TUnit_TestProject_BeforeTests_Base2_BeforeEach2_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.Base2), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), - static __registrationIndex => - new InstanceHookMethod - { - InitClassType = typeof(global::TUnit.TestProject.BeforeTests.Base2), - MethodInfo = new global::TUnit.Core.MethodMetadata + static __registrationIndex => + new InstanceHookMethod + { + InitClassType = typeof(global::TUnit.TestProject.BeforeTests.Base2), + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.Base2), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base2)), + Name = "BeforeEach2", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = global::System.Array.Empty(), + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.Base2", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.Base2), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base2)), + Name = "Base2", + Namespace = "TUnit.TestProject.BeforeTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_BeforeTests_Base2_BeforeEach2_Before_Test_Body + } + ); + private static ValueTask TUnit_TestProject_BeforeTests_Base2_BeforeEach2_Before_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) { - Type = typeof(global::TUnit.TestProject.BeforeTests.Base2), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base2)), - Name = "BeforeEach2", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = global::System.Array.Empty(), - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.Base2", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.Base2), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base2)), - Name = "Base2", - Namespace = "TUnit.TestProject.BeforeTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_Base2_BeforeEach2_Before_Test.TUnit_TestProject_BeforeTests_Base2_BeforeEach2_Before_TestInitializer.global_TUnit_TestProject_BeforeTests_Base2_BeforeEach2_0Params_Body - } -); + try + { + var typedInstance = (global::TUnit.TestProject.BeforeTests.Base2)instance; + return new ValueTask(typedInstance.BeforeEach2()); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } + } } } @@ -284,134 +222,103 @@ namespace TUnit.Generated #nullable enable #pragma warning disable CS9113 // Parameter is unread. using System; -using System.Collections.Generic; -using System.Linq; using System.Reflection; -using System.Runtime.CompilerServices; using System.Threading; using System.Threading.Tasks; using global::TUnit.Core; using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_Base3_BeforeAll3_Before_Class -{ - internal static class TUnit_TestProject_BeforeTests_Base3_BeforeAll3_Before_ClassInitializer - { - internal static async ValueTask global_TUnit_TestProject_BeforeTests_Base3_BeforeAll3_0Params_Body(ClassHookContext context, CancellationToken cancellationToken) - { - await AsyncConvert.Convert(() => global::TUnit.TestProject.BeforeTests.Base3.BeforeAll3()); - } - } -} namespace TUnit.Generated { internal static partial class TUnit_HookRegistration { static readonly int _h_TUnit_TestProject_BeforeTests_Base3_BeforeAll3_Before_Class = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeClassHooks, typeof(global::TUnit.TestProject.BeforeTests.Base3), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeClassHookIndex(), - static __registrationIndex => - new BeforeClassHookMethod - { - MethodInfo = new global::TUnit.Core.MethodMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.Base3), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base3)), - Name = "BeforeAll3", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = global::System.Array.Empty(), - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.Base3", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.Base3), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base3)), - Name = "Base3", - Namespace = "TUnit.TestProject.BeforeTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_Base3_BeforeAll3_Before_Class.TUnit_TestProject_BeforeTests_Base3_BeforeAll3_Before_ClassInitializer.global_TUnit_TestProject_BeforeTests_Base3_BeforeAll3_0Params_Body, - FilePath = "", - LineNumber = 35 - } -); - } -} - - -// ===== FILE SEPARATOR ===== - -// -#pragma warning disable - -#nullable enable -#pragma warning disable CS9113 // Parameter is unread. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Threading; -using System.Threading.Tasks; -using global::TUnit.Core; -using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_Base3_BeforeEach3_Before_Test -{ - internal static class TUnit_TestProject_BeforeTests_Base3_BeforeEach3_Before_TestInitializer - { - internal static async ValueTask global_TUnit_TestProject_BeforeTests_Base3_BeforeEach3_0Params_Body(object instance, TestContext context, CancellationToken cancellationToken) + static __registrationIndex => + new BeforeClassHookMethod + { + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.Base3), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base3)), + Name = "BeforeAll3", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = global::System.Array.Empty(), + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.Base3", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.Base3), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base3)), + Name = "Base3", + Namespace = "TUnit.TestProject.BeforeTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_BeforeTests_Base3_BeforeAll3_Before_Class_Body, + FilePath = "", + LineNumber = 35 + } + ); + private static ValueTask TUnit_TestProject_BeforeTests_Base3_BeforeAll3_Before_Class_Body(ClassHookContext context, CancellationToken cancellationToken) { - var typedInstance = (global::TUnit.TestProject.BeforeTests.Base3)instance; - await AsyncConvert.Convert(() => typedInstance.BeforeEach3()); + try + { + return new ValueTask(global::TUnit.TestProject.BeforeTests.Base3.BeforeAll3()); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } } - } -} -namespace TUnit.Generated -{ - internal static partial class TUnit_HookRegistration - { static readonly int _h_TUnit_TestProject_BeforeTests_Base3_BeforeEach3_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.Base3), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), - static __registrationIndex => - new InstanceHookMethod - { - InitClassType = typeof(global::TUnit.TestProject.BeforeTests.Base3), - MethodInfo = new global::TUnit.Core.MethodMetadata + static __registrationIndex => + new InstanceHookMethod + { + InitClassType = typeof(global::TUnit.TestProject.BeforeTests.Base3), + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.Base3), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base3)), + Name = "BeforeEach3", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = global::System.Array.Empty(), + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.Base3", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.Base3), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base3)), + Name = "Base3", + Namespace = "TUnit.TestProject.BeforeTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_BeforeTests_Base3_BeforeEach3_Before_Test_Body + } + ); + private static ValueTask TUnit_TestProject_BeforeTests_Base3_BeforeEach3_Before_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) { - Type = typeof(global::TUnit.TestProject.BeforeTests.Base3), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base3)), - Name = "BeforeEach3", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = global::System.Array.Empty(), - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.Base3", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.Base3), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base3)), - Name = "Base3", - Namespace = "TUnit.TestProject.BeforeTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_Base3_BeforeEach3_Before_Test.TUnit_TestProject_BeforeTests_Base3_BeforeEach3_Before_TestInitializer.global_TUnit_TestProject_BeforeTests_Base3_BeforeEach3_0Params_Body - } -); + try + { + var typedInstance = (global::TUnit.TestProject.BeforeTests.Base3)instance; + return new ValueTask(typedInstance.BeforeEach3()); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } + } } } @@ -424,573 +331,386 @@ namespace TUnit.Generated #nullable enable #pragma warning disable CS9113 // Parameter is unread. using System; -using System.Collections.Generic; -using System.Linq; using System.Reflection; -using System.Runtime.CompilerServices; using System.Threading; using System.Threading.Tasks; using global::TUnit.Core; using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp_Before_Class -{ - internal static class TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp_Before_ClassInitializer - { - internal static async ValueTask global_TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp_0Params_Body(ClassHookContext context, CancellationToken cancellationToken) - { - await AsyncConvert.Convert(() => global::TUnit.TestProject.BeforeTests.SetupTests.BeforeAllSetUp()); - } - } -} namespace TUnit.Generated { internal static partial class TUnit_HookRegistration { static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp_Before_Class = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeClassHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeClassHookIndex(), - static __registrationIndex => - new BeforeClassHookMethod - { - MethodInfo = new global::TUnit.Core.MethodMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), - Name = "BeforeAllSetUp", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = global::System.Array.Empty(), - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.SetupTests", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), - Name = "SetupTests", - Namespace = "TUnit.TestProject.BeforeTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp_Before_Class.TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp_Before_ClassInitializer.global_TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp_0Params_Body, - FilePath = "", - LineNumber = 50 - } -); - } -} - - -// ===== FILE SEPARATOR ===== - -// -#pragma warning disable - -#nullable enable -#pragma warning disable CS9113 // Parameter is unread. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Threading; -using System.Threading.Tasks; -using global::TUnit.Core; -using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_Before_Class -{ - internal static class TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_Before_ClassInitializer - { - internal static async ValueTask global_TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext_1Params_Body(ClassHookContext context, CancellationToken cancellationToken) + static __registrationIndex => + new BeforeClassHookMethod + { + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), + Name = "BeforeAllSetUp", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = global::System.Array.Empty(), + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.SetupTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), + Name = "SetupTests", + Namespace = "TUnit.TestProject.BeforeTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp_Before_Class_Body, + FilePath = "", + LineNumber = 50 + } + ); + private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp_Before_Class_Body(ClassHookContext context, CancellationToken cancellationToken) { - await AsyncConvert.Convert(() => global::TUnit.TestProject.BeforeTests.SetupTests.BeforeAllSetUpWithContext(context)); + try + { + return new ValueTask(global::TUnit.TestProject.BeforeTests.SetupTests.BeforeAllSetUp()); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } } - } -} -namespace TUnit.Generated -{ - internal static partial class TUnit_HookRegistration - { static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_Before_Class = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeClassHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeClassHookIndex(), - static __registrationIndex => - new BeforeClassHookMethod - { - MethodInfo = new global::TUnit.Core.MethodMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), - Name = "BeforeAllSetUpWithContext", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = new global::TUnit.Core.ParameterMetadata[] - { - global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::TUnit.Core.ClassHookContext), "context", new global::TUnit.Core.ConcreteType(typeof(global::TUnit.Core.ClassHookContext)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.SetupTests).GetMethod("BeforeAllSetUpWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::TUnit.Core.ClassHookContext) }, null)!.GetParameters()[0]) - }, - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.SetupTests", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), - Name = "SetupTests", - Namespace = "TUnit.TestProject.BeforeTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_Before_Class.TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_Before_ClassInitializer.global_TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext_1Params_Body, - FilePath = "", - LineNumber = 56 - } -); - } -} - - -// ===== FILE SEPARATOR ===== - -// -#pragma warning disable - -#nullable enable -#pragma warning disable CS9113 // Parameter is unread. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Threading; -using System.Threading.Tasks; -using global::TUnit.Core; -using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp__CancellationToken_Before_Class -{ - internal static class TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp__CancellationToken_Before_ClassInitializer - { - internal static async ValueTask global_TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp_1Params_Body(ClassHookContext context, CancellationToken cancellationToken) + static __registrationIndex => + new BeforeClassHookMethod + { + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), + Name = "BeforeAllSetUpWithContext", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = new global::TUnit.Core.ParameterMetadata[] + { + global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::TUnit.Core.ClassHookContext), "context", new global::TUnit.Core.ConcreteType(typeof(global::TUnit.Core.ClassHookContext)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.SetupTests).GetMethod("BeforeAllSetUpWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::TUnit.Core.ClassHookContext) }, null)!.GetParameters()[0]) + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.SetupTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), + Name = "SetupTests", + Namespace = "TUnit.TestProject.BeforeTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_Before_Class_Body, + FilePath = "", + LineNumber = 56 + } + ); + private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_Before_Class_Body(ClassHookContext context, CancellationToken cancellationToken) { - await AsyncConvert.Convert(() => global::TUnit.TestProject.BeforeTests.SetupTests.BeforeAllSetUp(cancellationToken)); + try + { + return new ValueTask(global::TUnit.TestProject.BeforeTests.SetupTests.BeforeAllSetUpWithContext(context)); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } } - } -} -namespace TUnit.Generated -{ - internal static partial class TUnit_HookRegistration - { static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp__CancellationToken_Before_Class = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeClassHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeClassHookIndex(), - static __registrationIndex => - new BeforeClassHookMethod - { - MethodInfo = new global::TUnit.Core.MethodMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), - Name = "BeforeAllSetUp", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = new global::TUnit.Core.ParameterMetadata[] - { - global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::System.Threading.CancellationToken), "cancellationToken", new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.CancellationToken)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.SetupTests).GetMethod("BeforeAllSetUp", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[0]) - }, - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.SetupTests", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), - Name = "SetupTests", - Namespace = "TUnit.TestProject.BeforeTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp__CancellationToken_Before_Class.TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp__CancellationToken_Before_ClassInitializer.global_TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp_1Params_Body, - FilePath = "", - LineNumber = 62 - } -); - } -} - - -// ===== FILE SEPARATOR ===== - -// -#pragma warning disable - -#nullable enable -#pragma warning disable CS9113 // Parameter is unread. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Threading; -using System.Threading.Tasks; -using global::TUnit.Core; -using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_CancellationToken_Before_Class -{ - internal static class TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_CancellationToken_Before_ClassInitializer - { - internal static async ValueTask global_TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext_2Params_Body(ClassHookContext context, CancellationToken cancellationToken) + static __registrationIndex => + new BeforeClassHookMethod + { + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), + Name = "BeforeAllSetUp", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = new global::TUnit.Core.ParameterMetadata[] + { + global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::System.Threading.CancellationToken), "cancellationToken", new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.CancellationToken)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.SetupTests).GetMethod("BeforeAllSetUp", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[0]) + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.SetupTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), + Name = "SetupTests", + Namespace = "TUnit.TestProject.BeforeTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp__CancellationToken_Before_Class_Body, + FilePath = "", + LineNumber = 62 + } + ); + private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp__CancellationToken_Before_Class_Body(ClassHookContext context, CancellationToken cancellationToken) { - await AsyncConvert.Convert(() => global::TUnit.TestProject.BeforeTests.SetupTests.BeforeAllSetUpWithContext(context, cancellationToken)); + try + { + return new ValueTask(global::TUnit.TestProject.BeforeTests.SetupTests.BeforeAllSetUp(cancellationToken)); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } } - } -} -namespace TUnit.Generated -{ - internal static partial class TUnit_HookRegistration - { static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_CancellationToken_Before_Class = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeClassHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeClassHookIndex(), - static __registrationIndex => - new BeforeClassHookMethod - { - MethodInfo = new global::TUnit.Core.MethodMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), - Name = "BeforeAllSetUpWithContext", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = new global::TUnit.Core.ParameterMetadata[] - { - global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::TUnit.Core.ClassHookContext), "context", new global::TUnit.Core.ConcreteType(typeof(global::TUnit.Core.ClassHookContext)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.SetupTests).GetMethod("BeforeAllSetUpWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::TUnit.Core.ClassHookContext), typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[0]), - global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::System.Threading.CancellationToken), "cancellationToken", new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.CancellationToken)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.SetupTests).GetMethod("BeforeAllSetUpWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::TUnit.Core.ClassHookContext), typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[1]) - }, - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.SetupTests", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), - Name = "SetupTests", - Namespace = "TUnit.TestProject.BeforeTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_CancellationToken_Before_Class.TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_CancellationToken_Before_ClassInitializer.global_TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext_2Params_Body, - FilePath = "", - LineNumber = 68 - } -); - } -} - - -// ===== FILE SEPARATOR ===== - -// -#pragma warning disable - -#nullable enable -#pragma warning disable CS9113 // Parameter is unread. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Threading; -using System.Threading.Tasks; -using global::TUnit.Core; -using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_SetupTests_Setup_Before_Test -{ - internal static class TUnit_TestProject_BeforeTests_SetupTests_Setup_Before_TestInitializer - { - internal static async ValueTask global_TUnit_TestProject_BeforeTests_SetupTests_Setup_0Params_Body(object instance, TestContext context, CancellationToken cancellationToken) + static __registrationIndex => + new BeforeClassHookMethod + { + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), + Name = "BeforeAllSetUpWithContext", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = new global::TUnit.Core.ParameterMetadata[] + { + global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::TUnit.Core.ClassHookContext), "context", new global::TUnit.Core.ConcreteType(typeof(global::TUnit.Core.ClassHookContext)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.SetupTests).GetMethod("BeforeAllSetUpWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::TUnit.Core.ClassHookContext), typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[0]), + global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::System.Threading.CancellationToken), "cancellationToken", new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.CancellationToken)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.SetupTests).GetMethod("BeforeAllSetUpWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::TUnit.Core.ClassHookContext), typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[1]) + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.SetupTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), + Name = "SetupTests", + Namespace = "TUnit.TestProject.BeforeTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_CancellationToken_Before_Class_Body, + FilePath = "", + LineNumber = 68 + } + ); + private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_CancellationToken_Before_Class_Body(ClassHookContext context, CancellationToken cancellationToken) { - var typedInstance = (global::TUnit.TestProject.BeforeTests.SetupTests)instance; - await AsyncConvert.Convert(() => typedInstance.Setup()); + try + { + return new ValueTask(global::TUnit.TestProject.BeforeTests.SetupTests.BeforeAllSetUpWithContext(context, cancellationToken)); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } } - } -} -namespace TUnit.Generated -{ - internal static partial class TUnit_HookRegistration - { static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_Setup_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), - static __registrationIndex => - new InstanceHookMethod - { - InitClassType = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), - MethodInfo = new global::TUnit.Core.MethodMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), - Name = "Setup", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = global::System.Array.Empty(), - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.SetupTests", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), - Name = "SetupTests", - Namespace = "TUnit.TestProject.BeforeTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_SetupTests_Setup_Before_Test.TUnit_TestProject_BeforeTests_SetupTests_Setup_Before_TestInitializer.global_TUnit_TestProject_BeforeTests_SetupTests_Setup_0Params_Body - } -); - } -} - - -// ===== FILE SEPARATOR ===== - -// -#pragma warning disable - -#nullable enable -#pragma warning disable CS9113 // Parameter is unread. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Threading; -using System.Threading.Tasks; -using global::TUnit.Core; -using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_SetupTests_Setup__CancellationToken_Before_Test -{ - internal static class TUnit_TestProject_BeforeTests_SetupTests_Setup__CancellationToken_Before_TestInitializer - { - internal static async ValueTask global_TUnit_TestProject_BeforeTests_SetupTests_Setup_1Params_Body(object instance, TestContext context, CancellationToken cancellationToken) + static __registrationIndex => + new InstanceHookMethod + { + InitClassType = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), + Name = "Setup", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = global::System.Array.Empty(), + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.SetupTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), + Name = "SetupTests", + Namespace = "TUnit.TestProject.BeforeTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_BeforeTests_SetupTests_Setup_Before_Test_Body + } + ); + private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_Setup_Before_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) { - var typedInstance = (global::TUnit.TestProject.BeforeTests.SetupTests)instance; - await AsyncConvert.Convert(() => typedInstance.Setup(cancellationToken)); + try + { + var typedInstance = (global::TUnit.TestProject.BeforeTests.SetupTests)instance; + return new ValueTask(typedInstance.Setup()); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } } - } -} -namespace TUnit.Generated -{ - internal static partial class TUnit_HookRegistration - { static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_Setup__CancellationToken_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), - static __registrationIndex => - new InstanceHookMethod - { - InitClassType = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), - MethodInfo = new global::TUnit.Core.MethodMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), - Name = "Setup", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = new global::TUnit.Core.ParameterMetadata[] - { - global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::System.Threading.CancellationToken), "cancellationToken", new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.CancellationToken)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.SetupTests).GetMethod("Setup", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[0]) - }, - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.SetupTests", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), - Name = "SetupTests", - Namespace = "TUnit.TestProject.BeforeTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_SetupTests_Setup__CancellationToken_Before_Test.TUnit_TestProject_BeforeTests_SetupTests_Setup__CancellationToken_Before_TestInitializer.global_TUnit_TestProject_BeforeTests_SetupTests_Setup_1Params_Body - } -); - } -} - - -// ===== FILE SEPARATOR ===== - -// -#pragma warning disable - -#nullable enable -#pragma warning disable CS9113 // Parameter is unread. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Threading; -using System.Threading.Tasks; -using global::TUnit.Core; -using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_Before_Test -{ - internal static class TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_Before_TestInitializer - { - internal static async ValueTask global_TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext_1Params_Body(object instance, TestContext context, CancellationToken cancellationToken) + static __registrationIndex => + new InstanceHookMethod + { + InitClassType = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), + Name = "Setup", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = new global::TUnit.Core.ParameterMetadata[] + { + global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::System.Threading.CancellationToken), "cancellationToken", new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.CancellationToken)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.SetupTests).GetMethod("Setup", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[0]) + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.SetupTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), + Name = "SetupTests", + Namespace = "TUnit.TestProject.BeforeTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_BeforeTests_SetupTests_Setup__CancellationToken_Before_Test_Body + } + ); + private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_Setup__CancellationToken_Before_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) { - var typedInstance = (global::TUnit.TestProject.BeforeTests.SetupTests)instance; - await AsyncConvert.Convert(() => typedInstance.SetupWithContext(context)); + try + { + var typedInstance = (global::TUnit.TestProject.BeforeTests.SetupTests)instance; + return new ValueTask(typedInstance.Setup(cancellationToken)); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } } - } -} -namespace TUnit.Generated -{ - internal static partial class TUnit_HookRegistration - { static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), - static __registrationIndex => - new InstanceHookMethod - { - InitClassType = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), - MethodInfo = new global::TUnit.Core.MethodMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), - Name = "SetupWithContext", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = new global::TUnit.Core.ParameterMetadata[] - { - global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::TUnit.Core.TestContext), "testContext", new global::TUnit.Core.ConcreteType(typeof(global::TUnit.Core.TestContext)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.SetupTests).GetMethod("SetupWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(global::TUnit.Core.TestContext) }, null)!.GetParameters()[0]) - }, - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.SetupTests", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), - Name = "SetupTests", - Namespace = "TUnit.TestProject.BeforeTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_Before_Test.TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_Before_TestInitializer.global_TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext_1Params_Body - } -); - } -} - - -// ===== FILE SEPARATOR ===== - -// -#pragma warning disable - -#nullable enable -#pragma warning disable CS9113 // Parameter is unread. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Threading; -using System.Threading.Tasks; -using global::TUnit.Core; -using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_CancellationToken_Before_Test -{ - internal static class TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_CancellationToken_Before_TestInitializer - { - internal static async ValueTask global_TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext_2Params_Body(object instance, TestContext context, CancellationToken cancellationToken) + static __registrationIndex => + new InstanceHookMethod + { + InitClassType = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), + Name = "SetupWithContext", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = new global::TUnit.Core.ParameterMetadata[] + { + global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::TUnit.Core.TestContext), "testContext", new global::TUnit.Core.ConcreteType(typeof(global::TUnit.Core.TestContext)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.SetupTests).GetMethod("SetupWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(global::TUnit.Core.TestContext) }, null)!.GetParameters()[0]) + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.SetupTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), + Name = "SetupTests", + Namespace = "TUnit.TestProject.BeforeTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_Before_Test_Body + } + ); + private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_Before_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) { - var typedInstance = (global::TUnit.TestProject.BeforeTests.SetupTests)instance; - await AsyncConvert.Convert(() => typedInstance.SetupWithContext(context, cancellationToken)); + try + { + var typedInstance = (global::TUnit.TestProject.BeforeTests.SetupTests)instance; + return new ValueTask(typedInstance.SetupWithContext(context)); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } } - } -} -namespace TUnit.Generated -{ - internal static partial class TUnit_HookRegistration - { static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_CancellationToken_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), - static __registrationIndex => - new InstanceHookMethod - { - InitClassType = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), - MethodInfo = new global::TUnit.Core.MethodMetadata + static __registrationIndex => + new InstanceHookMethod + { + InitClassType = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), + Name = "SetupWithContext", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = new global::TUnit.Core.ParameterMetadata[] + { + global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::TUnit.Core.TestContext), "testContext", new global::TUnit.Core.ConcreteType(typeof(global::TUnit.Core.TestContext)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.SetupTests).GetMethod("SetupWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(global::TUnit.Core.TestContext), typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[0]), + global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::System.Threading.CancellationToken), "cancellationToken", new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.CancellationToken)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.SetupTests).GetMethod("SetupWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(global::TUnit.Core.TestContext), typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[1]) + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.SetupTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), + Name = "SetupTests", + Namespace = "TUnit.TestProject.BeforeTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_CancellationToken_Before_Test_Body + } + ); + private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_CancellationToken_Before_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) { - Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), - Name = "SetupWithContext", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = new global::TUnit.Core.ParameterMetadata[] - { - global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::TUnit.Core.TestContext), "testContext", new global::TUnit.Core.ConcreteType(typeof(global::TUnit.Core.TestContext)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.SetupTests).GetMethod("SetupWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(global::TUnit.Core.TestContext), typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[0]), - global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::System.Threading.CancellationToken), "cancellationToken", new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.CancellationToken)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.SetupTests).GetMethod("SetupWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(global::TUnit.Core.TestContext), typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[1]) - }, - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.SetupTests", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), - Name = "SetupTests", - Namespace = "TUnit.TestProject.BeforeTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_CancellationToken_Before_Test.TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_CancellationToken_Before_TestInitializer.global_TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext_2Params_Body - } -); + try + { + var typedInstance = (global::TUnit.TestProject.BeforeTests.SetupTests)instance; + return new ValueTask(typedInstance.SetupWithContext(context, cancellationToken)); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } + } } } diff --git a/tests/TUnit.Core.SourceGenerator.Tests/ConflictingNamespaceTests.HooksTest_WithConflictingNamespace.Net4_7.verified.txt b/tests/TUnit.Core.SourceGenerator.Tests/ConflictingNamespaceTests.HooksTest_WithConflictingNamespace.Net4_7.verified.txt index 73531f36097..2e6a86de97c 100644 --- a/tests/TUnit.Core.SourceGenerator.Tests/ConflictingNamespaceTests.HooksTest_WithConflictingNamespace.Net4_7.verified.txt +++ b/tests/TUnit.Core.SourceGenerator.Tests/ConflictingNamespaceTests.HooksTest_WithConflictingNamespace.Net4_7.verified.txt @@ -4,134 +4,103 @@ #nullable enable #pragma warning disable CS9113 // Parameter is unread. using System; -using System.Collections.Generic; -using System.Linq; using System.Reflection; -using System.Runtime.CompilerServices; using System.Threading; using System.Threading.Tasks; using global::TUnit.Core; using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_Base1_BeforeAll1_Before_Class -{ - internal static class TUnit_TestProject_BeforeTests_Base1_BeforeAll1_Before_ClassInitializer - { - internal static async ValueTask global_TUnit_TestProject_BeforeTests_Base1_BeforeAll1_0Params_Body(ClassHookContext context, CancellationToken cancellationToken) - { - await AsyncConvert.Convert(() => global::TUnit.TestProject.BeforeTests.Base1.BeforeAll1()); - } - } -} namespace TUnit.Generated { internal static partial class TUnit_HookRegistration { static readonly int _h_TUnit_TestProject_BeforeTests_Base1_BeforeAll1_Before_Class = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeClassHooks, typeof(global::TUnit.TestProject.BeforeTests.Base1), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeClassHookIndex(), - static __registrationIndex => - new BeforeClassHookMethod - { - MethodInfo = new global::TUnit.Core.MethodMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.Base1), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base1)), - Name = "BeforeAll1", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = global::System.Array.Empty(), - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.Base1", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.Base1), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base1)), - Name = "Base1", - Namespace = "TUnit.TestProject.BeforeTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_Base1_BeforeAll1_Before_Class.TUnit_TestProject_BeforeTests_Base1_BeforeAll1_Before_ClassInitializer.global_TUnit_TestProject_BeforeTests_Base1_BeforeAll1_0Params_Body, - FilePath = "", - LineNumber = 5 - } -); - } -} - - -// ===== FILE SEPARATOR ===== - -// -#pragma warning disable - -#nullable enable -#pragma warning disable CS9113 // Parameter is unread. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Threading; -using System.Threading.Tasks; -using global::TUnit.Core; -using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_Base1_BeforeEach1_Before_Test -{ - internal static class TUnit_TestProject_BeforeTests_Base1_BeforeEach1_Before_TestInitializer - { - internal static async ValueTask global_TUnit_TestProject_BeforeTests_Base1_BeforeEach1_0Params_Body(object instance, TestContext context, CancellationToken cancellationToken) + static __registrationIndex => + new BeforeClassHookMethod + { + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.Base1), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base1)), + Name = "BeforeAll1", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = global::System.Array.Empty(), + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.Base1", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.Base1), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base1)), + Name = "Base1", + Namespace = "TUnit.TestProject.BeforeTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_BeforeTests_Base1_BeforeAll1_Before_Class_Body, + FilePath = "", + LineNumber = 5 + } + ); + private static ValueTask TUnit_TestProject_BeforeTests_Base1_BeforeAll1_Before_Class_Body(ClassHookContext context, CancellationToken cancellationToken) { - var typedInstance = (global::TUnit.TestProject.BeforeTests.Base1)instance; - await AsyncConvert.Convert(() => typedInstance.BeforeEach1()); + try + { + return new ValueTask(global::TUnit.TestProject.BeforeTests.Base1.BeforeAll1()); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } } - } -} -namespace TUnit.Generated -{ - internal static partial class TUnit_HookRegistration - { static readonly int _h_TUnit_TestProject_BeforeTests_Base1_BeforeEach1_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.Base1), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), - static __registrationIndex => - new InstanceHookMethod - { - InitClassType = typeof(global::TUnit.TestProject.BeforeTests.Base1), - MethodInfo = new global::TUnit.Core.MethodMetadata + static __registrationIndex => + new InstanceHookMethod + { + InitClassType = typeof(global::TUnit.TestProject.BeforeTests.Base1), + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.Base1), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base1)), + Name = "BeforeEach1", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = global::System.Array.Empty(), + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.Base1", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.Base1), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base1)), + Name = "Base1", + Namespace = "TUnit.TestProject.BeforeTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_BeforeTests_Base1_BeforeEach1_Before_Test_Body + } + ); + private static ValueTask TUnit_TestProject_BeforeTests_Base1_BeforeEach1_Before_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) { - Type = typeof(global::TUnit.TestProject.BeforeTests.Base1), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base1)), - Name = "BeforeEach1", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = global::System.Array.Empty(), - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.Base1", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.Base1), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base1)), - Name = "Base1", - Namespace = "TUnit.TestProject.BeforeTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_Base1_BeforeEach1_Before_Test.TUnit_TestProject_BeforeTests_Base1_BeforeEach1_Before_TestInitializer.global_TUnit_TestProject_BeforeTests_Base1_BeforeEach1_0Params_Body - } -); + try + { + var typedInstance = (global::TUnit.TestProject.BeforeTests.Base1)instance; + return new ValueTask(typedInstance.BeforeEach1()); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } + } } } @@ -144,134 +113,103 @@ namespace TUnit.Generated #nullable enable #pragma warning disable CS9113 // Parameter is unread. using System; -using System.Collections.Generic; -using System.Linq; using System.Reflection; -using System.Runtime.CompilerServices; using System.Threading; using System.Threading.Tasks; using global::TUnit.Core; using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_Base2_BeforeAll2_Before_Class -{ - internal static class TUnit_TestProject_BeforeTests_Base2_BeforeAll2_Before_ClassInitializer - { - internal static async ValueTask global_TUnit_TestProject_BeforeTests_Base2_BeforeAll2_0Params_Body(ClassHookContext context, CancellationToken cancellationToken) - { - await AsyncConvert.Convert(() => global::TUnit.TestProject.BeforeTests.Base2.BeforeAll2()); - } - } -} namespace TUnit.Generated { internal static partial class TUnit_HookRegistration { static readonly int _h_TUnit_TestProject_BeforeTests_Base2_BeforeAll2_Before_Class = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeClassHooks, typeof(global::TUnit.TestProject.BeforeTests.Base2), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeClassHookIndex(), - static __registrationIndex => - new BeforeClassHookMethod - { - MethodInfo = new global::TUnit.Core.MethodMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.Base2), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base2)), - Name = "BeforeAll2", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = global::System.Array.Empty(), - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.Base2", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.Base2), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base2)), - Name = "Base2", - Namespace = "TUnit.TestProject.BeforeTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_Base2_BeforeAll2_Before_Class.TUnit_TestProject_BeforeTests_Base2_BeforeAll2_Before_ClassInitializer.global_TUnit_TestProject_BeforeTests_Base2_BeforeAll2_0Params_Body, - FilePath = "", - LineNumber = 20 - } -); - } -} - - -// ===== FILE SEPARATOR ===== - -// -#pragma warning disable - -#nullable enable -#pragma warning disable CS9113 // Parameter is unread. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Threading; -using System.Threading.Tasks; -using global::TUnit.Core; -using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_Base2_BeforeEach2_Before_Test -{ - internal static class TUnit_TestProject_BeforeTests_Base2_BeforeEach2_Before_TestInitializer - { - internal static async ValueTask global_TUnit_TestProject_BeforeTests_Base2_BeforeEach2_0Params_Body(object instance, TestContext context, CancellationToken cancellationToken) + static __registrationIndex => + new BeforeClassHookMethod + { + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.Base2), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base2)), + Name = "BeforeAll2", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = global::System.Array.Empty(), + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.Base2", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.Base2), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base2)), + Name = "Base2", + Namespace = "TUnit.TestProject.BeforeTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_BeforeTests_Base2_BeforeAll2_Before_Class_Body, + FilePath = "", + LineNumber = 20 + } + ); + private static ValueTask TUnit_TestProject_BeforeTests_Base2_BeforeAll2_Before_Class_Body(ClassHookContext context, CancellationToken cancellationToken) { - var typedInstance = (global::TUnit.TestProject.BeforeTests.Base2)instance; - await AsyncConvert.Convert(() => typedInstance.BeforeEach2()); + try + { + return new ValueTask(global::TUnit.TestProject.BeforeTests.Base2.BeforeAll2()); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } } - } -} -namespace TUnit.Generated -{ - internal static partial class TUnit_HookRegistration - { static readonly int _h_TUnit_TestProject_BeforeTests_Base2_BeforeEach2_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.Base2), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), - static __registrationIndex => - new InstanceHookMethod - { - InitClassType = typeof(global::TUnit.TestProject.BeforeTests.Base2), - MethodInfo = new global::TUnit.Core.MethodMetadata + static __registrationIndex => + new InstanceHookMethod + { + InitClassType = typeof(global::TUnit.TestProject.BeforeTests.Base2), + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.Base2), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base2)), + Name = "BeforeEach2", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = global::System.Array.Empty(), + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.Base2", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.Base2), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base2)), + Name = "Base2", + Namespace = "TUnit.TestProject.BeforeTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_BeforeTests_Base2_BeforeEach2_Before_Test_Body + } + ); + private static ValueTask TUnit_TestProject_BeforeTests_Base2_BeforeEach2_Before_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) { - Type = typeof(global::TUnit.TestProject.BeforeTests.Base2), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base2)), - Name = "BeforeEach2", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = global::System.Array.Empty(), - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.Base2", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.Base2), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base2)), - Name = "Base2", - Namespace = "TUnit.TestProject.BeforeTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_Base2_BeforeEach2_Before_Test.TUnit_TestProject_BeforeTests_Base2_BeforeEach2_Before_TestInitializer.global_TUnit_TestProject_BeforeTests_Base2_BeforeEach2_0Params_Body - } -); + try + { + var typedInstance = (global::TUnit.TestProject.BeforeTests.Base2)instance; + return new ValueTask(typedInstance.BeforeEach2()); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } + } } } @@ -284,134 +222,103 @@ namespace TUnit.Generated #nullable enable #pragma warning disable CS9113 // Parameter is unread. using System; -using System.Collections.Generic; -using System.Linq; using System.Reflection; -using System.Runtime.CompilerServices; using System.Threading; using System.Threading.Tasks; using global::TUnit.Core; using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_Base3_BeforeAll3_Before_Class -{ - internal static class TUnit_TestProject_BeforeTests_Base3_BeforeAll3_Before_ClassInitializer - { - internal static async ValueTask global_TUnit_TestProject_BeforeTests_Base3_BeforeAll3_0Params_Body(ClassHookContext context, CancellationToken cancellationToken) - { - await AsyncConvert.Convert(() => global::TUnit.TestProject.BeforeTests.Base3.BeforeAll3()); - } - } -} namespace TUnit.Generated { internal static partial class TUnit_HookRegistration { static readonly int _h_TUnit_TestProject_BeforeTests_Base3_BeforeAll3_Before_Class = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeClassHooks, typeof(global::TUnit.TestProject.BeforeTests.Base3), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeClassHookIndex(), - static __registrationIndex => - new BeforeClassHookMethod - { - MethodInfo = new global::TUnit.Core.MethodMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.Base3), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base3)), - Name = "BeforeAll3", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = global::System.Array.Empty(), - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.Base3", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.Base3), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base3)), - Name = "Base3", - Namespace = "TUnit.TestProject.BeforeTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_Base3_BeforeAll3_Before_Class.TUnit_TestProject_BeforeTests_Base3_BeforeAll3_Before_ClassInitializer.global_TUnit_TestProject_BeforeTests_Base3_BeforeAll3_0Params_Body, - FilePath = "", - LineNumber = 35 - } -); - } -} - - -// ===== FILE SEPARATOR ===== - -// -#pragma warning disable - -#nullable enable -#pragma warning disable CS9113 // Parameter is unread. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Threading; -using System.Threading.Tasks; -using global::TUnit.Core; -using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_Base3_BeforeEach3_Before_Test -{ - internal static class TUnit_TestProject_BeforeTests_Base3_BeforeEach3_Before_TestInitializer - { - internal static async ValueTask global_TUnit_TestProject_BeforeTests_Base3_BeforeEach3_0Params_Body(object instance, TestContext context, CancellationToken cancellationToken) + static __registrationIndex => + new BeforeClassHookMethod + { + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.Base3), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base3)), + Name = "BeforeAll3", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = global::System.Array.Empty(), + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.Base3", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.Base3), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base3)), + Name = "Base3", + Namespace = "TUnit.TestProject.BeforeTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_BeforeTests_Base3_BeforeAll3_Before_Class_Body, + FilePath = "", + LineNumber = 35 + } + ); + private static ValueTask TUnit_TestProject_BeforeTests_Base3_BeforeAll3_Before_Class_Body(ClassHookContext context, CancellationToken cancellationToken) { - var typedInstance = (global::TUnit.TestProject.BeforeTests.Base3)instance; - await AsyncConvert.Convert(() => typedInstance.BeforeEach3()); + try + { + return new ValueTask(global::TUnit.TestProject.BeforeTests.Base3.BeforeAll3()); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } } - } -} -namespace TUnit.Generated -{ - internal static partial class TUnit_HookRegistration - { static readonly int _h_TUnit_TestProject_BeforeTests_Base3_BeforeEach3_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.Base3), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), - static __registrationIndex => - new InstanceHookMethod - { - InitClassType = typeof(global::TUnit.TestProject.BeforeTests.Base3), - MethodInfo = new global::TUnit.Core.MethodMetadata + static __registrationIndex => + new InstanceHookMethod + { + InitClassType = typeof(global::TUnit.TestProject.BeforeTests.Base3), + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.Base3), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base3)), + Name = "BeforeEach3", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = global::System.Array.Empty(), + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.Base3", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.Base3), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base3)), + Name = "Base3", + Namespace = "TUnit.TestProject.BeforeTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_BeforeTests_Base3_BeforeEach3_Before_Test_Body + } + ); + private static ValueTask TUnit_TestProject_BeforeTests_Base3_BeforeEach3_Before_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) { - Type = typeof(global::TUnit.TestProject.BeforeTests.Base3), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base3)), - Name = "BeforeEach3", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = global::System.Array.Empty(), - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.Base3", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.Base3), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.Base3)), - Name = "Base3", - Namespace = "TUnit.TestProject.BeforeTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_Base3_BeforeEach3_Before_Test.TUnit_TestProject_BeforeTests_Base3_BeforeEach3_Before_TestInitializer.global_TUnit_TestProject_BeforeTests_Base3_BeforeEach3_0Params_Body - } -); + try + { + var typedInstance = (global::TUnit.TestProject.BeforeTests.Base3)instance; + return new ValueTask(typedInstance.BeforeEach3()); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } + } } } @@ -424,573 +331,386 @@ namespace TUnit.Generated #nullable enable #pragma warning disable CS9113 // Parameter is unread. using System; -using System.Collections.Generic; -using System.Linq; using System.Reflection; -using System.Runtime.CompilerServices; using System.Threading; using System.Threading.Tasks; using global::TUnit.Core; using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp_Before_Class -{ - internal static class TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp_Before_ClassInitializer - { - internal static async ValueTask global_TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp_0Params_Body(ClassHookContext context, CancellationToken cancellationToken) - { - await AsyncConvert.Convert(() => global::TUnit.TestProject.BeforeTests.SetupTests.BeforeAllSetUp()); - } - } -} namespace TUnit.Generated { internal static partial class TUnit_HookRegistration { static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp_Before_Class = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeClassHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeClassHookIndex(), - static __registrationIndex => - new BeforeClassHookMethod - { - MethodInfo = new global::TUnit.Core.MethodMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), - Name = "BeforeAllSetUp", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = global::System.Array.Empty(), - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.SetupTests", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), - Name = "SetupTests", - Namespace = "TUnit.TestProject.BeforeTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp_Before_Class.TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp_Before_ClassInitializer.global_TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp_0Params_Body, - FilePath = "", - LineNumber = 50 - } -); - } -} - - -// ===== FILE SEPARATOR ===== - -// -#pragma warning disable - -#nullable enable -#pragma warning disable CS9113 // Parameter is unread. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Threading; -using System.Threading.Tasks; -using global::TUnit.Core; -using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_Before_Class -{ - internal static class TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_Before_ClassInitializer - { - internal static async ValueTask global_TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext_1Params_Body(ClassHookContext context, CancellationToken cancellationToken) + static __registrationIndex => + new BeforeClassHookMethod + { + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), + Name = "BeforeAllSetUp", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = global::System.Array.Empty(), + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.SetupTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), + Name = "SetupTests", + Namespace = "TUnit.TestProject.BeforeTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp_Before_Class_Body, + FilePath = "", + LineNumber = 50 + } + ); + private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp_Before_Class_Body(ClassHookContext context, CancellationToken cancellationToken) { - await AsyncConvert.Convert(() => global::TUnit.TestProject.BeforeTests.SetupTests.BeforeAllSetUpWithContext(context)); + try + { + return new ValueTask(global::TUnit.TestProject.BeforeTests.SetupTests.BeforeAllSetUp()); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } } - } -} -namespace TUnit.Generated -{ - internal static partial class TUnit_HookRegistration - { static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_Before_Class = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeClassHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeClassHookIndex(), - static __registrationIndex => - new BeforeClassHookMethod - { - MethodInfo = new global::TUnit.Core.MethodMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), - Name = "BeforeAllSetUpWithContext", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = new global::TUnit.Core.ParameterMetadata[] - { - global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::TUnit.Core.ClassHookContext), "context", new global::TUnit.Core.ConcreteType(typeof(global::TUnit.Core.ClassHookContext)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.SetupTests).GetMethod("BeforeAllSetUpWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::TUnit.Core.ClassHookContext) }, null)!.GetParameters()[0]) - }, - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.SetupTests", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), - Name = "SetupTests", - Namespace = "TUnit.TestProject.BeforeTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_Before_Class.TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_Before_ClassInitializer.global_TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext_1Params_Body, - FilePath = "", - LineNumber = 56 - } -); - } -} - - -// ===== FILE SEPARATOR ===== - -// -#pragma warning disable - -#nullable enable -#pragma warning disable CS9113 // Parameter is unread. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Threading; -using System.Threading.Tasks; -using global::TUnit.Core; -using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp__CancellationToken_Before_Class -{ - internal static class TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp__CancellationToken_Before_ClassInitializer - { - internal static async ValueTask global_TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp_1Params_Body(ClassHookContext context, CancellationToken cancellationToken) + static __registrationIndex => + new BeforeClassHookMethod + { + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), + Name = "BeforeAllSetUpWithContext", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = new global::TUnit.Core.ParameterMetadata[] + { + global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::TUnit.Core.ClassHookContext), "context", new global::TUnit.Core.ConcreteType(typeof(global::TUnit.Core.ClassHookContext)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.SetupTests).GetMethod("BeforeAllSetUpWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::TUnit.Core.ClassHookContext) }, null)!.GetParameters()[0]) + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.SetupTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), + Name = "SetupTests", + Namespace = "TUnit.TestProject.BeforeTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_Before_Class_Body, + FilePath = "", + LineNumber = 56 + } + ); + private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_Before_Class_Body(ClassHookContext context, CancellationToken cancellationToken) { - await AsyncConvert.Convert(() => global::TUnit.TestProject.BeforeTests.SetupTests.BeforeAllSetUp(cancellationToken)); + try + { + return new ValueTask(global::TUnit.TestProject.BeforeTests.SetupTests.BeforeAllSetUpWithContext(context)); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } } - } -} -namespace TUnit.Generated -{ - internal static partial class TUnit_HookRegistration - { static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp__CancellationToken_Before_Class = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeClassHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeClassHookIndex(), - static __registrationIndex => - new BeforeClassHookMethod - { - MethodInfo = new global::TUnit.Core.MethodMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), - Name = "BeforeAllSetUp", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = new global::TUnit.Core.ParameterMetadata[] - { - global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::System.Threading.CancellationToken), "cancellationToken", new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.CancellationToken)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.SetupTests).GetMethod("BeforeAllSetUp", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[0]) - }, - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.SetupTests", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), - Name = "SetupTests", - Namespace = "TUnit.TestProject.BeforeTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp__CancellationToken_Before_Class.TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp__CancellationToken_Before_ClassInitializer.global_TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp_1Params_Body, - FilePath = "", - LineNumber = 62 - } -); - } -} - - -// ===== FILE SEPARATOR ===== - -// -#pragma warning disable - -#nullable enable -#pragma warning disable CS9113 // Parameter is unread. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Threading; -using System.Threading.Tasks; -using global::TUnit.Core; -using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_CancellationToken_Before_Class -{ - internal static class TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_CancellationToken_Before_ClassInitializer - { - internal static async ValueTask global_TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext_2Params_Body(ClassHookContext context, CancellationToken cancellationToken) + static __registrationIndex => + new BeforeClassHookMethod + { + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), + Name = "BeforeAllSetUp", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = new global::TUnit.Core.ParameterMetadata[] + { + global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::System.Threading.CancellationToken), "cancellationToken", new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.CancellationToken)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.SetupTests).GetMethod("BeforeAllSetUp", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[0]) + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.SetupTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), + Name = "SetupTests", + Namespace = "TUnit.TestProject.BeforeTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp__CancellationToken_Before_Class_Body, + FilePath = "", + LineNumber = 62 + } + ); + private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp__CancellationToken_Before_Class_Body(ClassHookContext context, CancellationToken cancellationToken) { - await AsyncConvert.Convert(() => global::TUnit.TestProject.BeforeTests.SetupTests.BeforeAllSetUpWithContext(context, cancellationToken)); + try + { + return new ValueTask(global::TUnit.TestProject.BeforeTests.SetupTests.BeforeAllSetUp(cancellationToken)); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } } - } -} -namespace TUnit.Generated -{ - internal static partial class TUnit_HookRegistration - { static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_CancellationToken_Before_Class = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeClassHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeClassHookIndex(), - static __registrationIndex => - new BeforeClassHookMethod - { - MethodInfo = new global::TUnit.Core.MethodMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), - Name = "BeforeAllSetUpWithContext", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = new global::TUnit.Core.ParameterMetadata[] - { - global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::TUnit.Core.ClassHookContext), "context", new global::TUnit.Core.ConcreteType(typeof(global::TUnit.Core.ClassHookContext)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.SetupTests).GetMethod("BeforeAllSetUpWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::TUnit.Core.ClassHookContext), typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[0]), - global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::System.Threading.CancellationToken), "cancellationToken", new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.CancellationToken)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.SetupTests).GetMethod("BeforeAllSetUpWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::TUnit.Core.ClassHookContext), typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[1]) - }, - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.SetupTests", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), - Name = "SetupTests", - Namespace = "TUnit.TestProject.BeforeTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_CancellationToken_Before_Class.TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_CancellationToken_Before_ClassInitializer.global_TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext_2Params_Body, - FilePath = "", - LineNumber = 68 - } -); - } -} - - -// ===== FILE SEPARATOR ===== - -// -#pragma warning disable - -#nullable enable -#pragma warning disable CS9113 // Parameter is unread. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Threading; -using System.Threading.Tasks; -using global::TUnit.Core; -using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_SetupTests_Setup_Before_Test -{ - internal static class TUnit_TestProject_BeforeTests_SetupTests_Setup_Before_TestInitializer - { - internal static async ValueTask global_TUnit_TestProject_BeforeTests_SetupTests_Setup_0Params_Body(object instance, TestContext context, CancellationToken cancellationToken) + static __registrationIndex => + new BeforeClassHookMethod + { + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), + Name = "BeforeAllSetUpWithContext", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = new global::TUnit.Core.ParameterMetadata[] + { + global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::TUnit.Core.ClassHookContext), "context", new global::TUnit.Core.ConcreteType(typeof(global::TUnit.Core.ClassHookContext)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.SetupTests).GetMethod("BeforeAllSetUpWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::TUnit.Core.ClassHookContext), typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[0]), + global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::System.Threading.CancellationToken), "cancellationToken", new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.CancellationToken)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.SetupTests).GetMethod("BeforeAllSetUpWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::TUnit.Core.ClassHookContext), typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[1]) + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.SetupTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), + Name = "SetupTests", + Namespace = "TUnit.TestProject.BeforeTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_CancellationToken_Before_Class_Body, + FilePath = "", + LineNumber = 68 + } + ); + private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_CancellationToken_Before_Class_Body(ClassHookContext context, CancellationToken cancellationToken) { - var typedInstance = (global::TUnit.TestProject.BeforeTests.SetupTests)instance; - await AsyncConvert.Convert(() => typedInstance.Setup()); + try + { + return new ValueTask(global::TUnit.TestProject.BeforeTests.SetupTests.BeforeAllSetUpWithContext(context, cancellationToken)); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } } - } -} -namespace TUnit.Generated -{ - internal static partial class TUnit_HookRegistration - { static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_Setup_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), - static __registrationIndex => - new InstanceHookMethod - { - InitClassType = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), - MethodInfo = new global::TUnit.Core.MethodMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), - Name = "Setup", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = global::System.Array.Empty(), - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.SetupTests", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), - Name = "SetupTests", - Namespace = "TUnit.TestProject.BeforeTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_SetupTests_Setup_Before_Test.TUnit_TestProject_BeforeTests_SetupTests_Setup_Before_TestInitializer.global_TUnit_TestProject_BeforeTests_SetupTests_Setup_0Params_Body - } -); - } -} - - -// ===== FILE SEPARATOR ===== - -// -#pragma warning disable - -#nullable enable -#pragma warning disable CS9113 // Parameter is unread. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Threading; -using System.Threading.Tasks; -using global::TUnit.Core; -using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_SetupTests_Setup__CancellationToken_Before_Test -{ - internal static class TUnit_TestProject_BeforeTests_SetupTests_Setup__CancellationToken_Before_TestInitializer - { - internal static async ValueTask global_TUnit_TestProject_BeforeTests_SetupTests_Setup_1Params_Body(object instance, TestContext context, CancellationToken cancellationToken) + static __registrationIndex => + new InstanceHookMethod + { + InitClassType = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), + Name = "Setup", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = global::System.Array.Empty(), + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.SetupTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), + Name = "SetupTests", + Namespace = "TUnit.TestProject.BeforeTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_BeforeTests_SetupTests_Setup_Before_Test_Body + } + ); + private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_Setup_Before_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) { - var typedInstance = (global::TUnit.TestProject.BeforeTests.SetupTests)instance; - await AsyncConvert.Convert(() => typedInstance.Setup(cancellationToken)); + try + { + var typedInstance = (global::TUnit.TestProject.BeforeTests.SetupTests)instance; + return new ValueTask(typedInstance.Setup()); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } } - } -} -namespace TUnit.Generated -{ - internal static partial class TUnit_HookRegistration - { static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_Setup__CancellationToken_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), - static __registrationIndex => - new InstanceHookMethod - { - InitClassType = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), - MethodInfo = new global::TUnit.Core.MethodMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), - Name = "Setup", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = new global::TUnit.Core.ParameterMetadata[] - { - global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::System.Threading.CancellationToken), "cancellationToken", new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.CancellationToken)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.SetupTests).GetMethod("Setup", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[0]) - }, - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.SetupTests", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), - Name = "SetupTests", - Namespace = "TUnit.TestProject.BeforeTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_SetupTests_Setup__CancellationToken_Before_Test.TUnit_TestProject_BeforeTests_SetupTests_Setup__CancellationToken_Before_TestInitializer.global_TUnit_TestProject_BeforeTests_SetupTests_Setup_1Params_Body - } -); - } -} - - -// ===== FILE SEPARATOR ===== - -// -#pragma warning disable - -#nullable enable -#pragma warning disable CS9113 // Parameter is unread. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Threading; -using System.Threading.Tasks; -using global::TUnit.Core; -using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_Before_Test -{ - internal static class TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_Before_TestInitializer - { - internal static async ValueTask global_TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext_1Params_Body(object instance, TestContext context, CancellationToken cancellationToken) + static __registrationIndex => + new InstanceHookMethod + { + InitClassType = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), + Name = "Setup", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = new global::TUnit.Core.ParameterMetadata[] + { + global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::System.Threading.CancellationToken), "cancellationToken", new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.CancellationToken)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.SetupTests).GetMethod("Setup", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[0]) + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.SetupTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), + Name = "SetupTests", + Namespace = "TUnit.TestProject.BeforeTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_BeforeTests_SetupTests_Setup__CancellationToken_Before_Test_Body + } + ); + private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_Setup__CancellationToken_Before_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) { - var typedInstance = (global::TUnit.TestProject.BeforeTests.SetupTests)instance; - await AsyncConvert.Convert(() => typedInstance.SetupWithContext(context)); + try + { + var typedInstance = (global::TUnit.TestProject.BeforeTests.SetupTests)instance; + return new ValueTask(typedInstance.Setup(cancellationToken)); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } } - } -} -namespace TUnit.Generated -{ - internal static partial class TUnit_HookRegistration - { static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), - static __registrationIndex => - new InstanceHookMethod - { - InitClassType = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), - MethodInfo = new global::TUnit.Core.MethodMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), - Name = "SetupWithContext", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = new global::TUnit.Core.ParameterMetadata[] - { - global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::TUnit.Core.TestContext), "testContext", new global::TUnit.Core.ConcreteType(typeof(global::TUnit.Core.TestContext)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.SetupTests).GetMethod("SetupWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(global::TUnit.Core.TestContext) }, null)!.GetParameters()[0]) - }, - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.SetupTests", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), - Name = "SetupTests", - Namespace = "TUnit.TestProject.BeforeTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_Before_Test.TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_Before_TestInitializer.global_TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext_1Params_Body - } -); - } -} - - -// ===== FILE SEPARATOR ===== - -// -#pragma warning disable - -#nullable enable -#pragma warning disable CS9113 // Parameter is unread. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Threading; -using System.Threading.Tasks; -using global::TUnit.Core; -using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_CancellationToken_Before_Test -{ - internal static class TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_CancellationToken_Before_TestInitializer - { - internal static async ValueTask global_TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext_2Params_Body(object instance, TestContext context, CancellationToken cancellationToken) + static __registrationIndex => + new InstanceHookMethod + { + InitClassType = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), + Name = "SetupWithContext", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = new global::TUnit.Core.ParameterMetadata[] + { + global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::TUnit.Core.TestContext), "testContext", new global::TUnit.Core.ConcreteType(typeof(global::TUnit.Core.TestContext)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.SetupTests).GetMethod("SetupWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(global::TUnit.Core.TestContext) }, null)!.GetParameters()[0]) + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.SetupTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), + Name = "SetupTests", + Namespace = "TUnit.TestProject.BeforeTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_Before_Test_Body + } + ); + private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_Before_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) { - var typedInstance = (global::TUnit.TestProject.BeforeTests.SetupTests)instance; - await AsyncConvert.Convert(() => typedInstance.SetupWithContext(context, cancellationToken)); + try + { + var typedInstance = (global::TUnit.TestProject.BeforeTests.SetupTests)instance; + return new ValueTask(typedInstance.SetupWithContext(context)); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } } - } -} -namespace TUnit.Generated -{ - internal static partial class TUnit_HookRegistration - { static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_CancellationToken_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), - static __registrationIndex => - new InstanceHookMethod - { - InitClassType = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), - MethodInfo = new global::TUnit.Core.MethodMetadata + static __registrationIndex => + new InstanceHookMethod + { + InitClassType = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), + Name = "SetupWithContext", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = new global::TUnit.Core.ParameterMetadata[] + { + global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::TUnit.Core.TestContext), "testContext", new global::TUnit.Core.ConcreteType(typeof(global::TUnit.Core.TestContext)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.SetupTests).GetMethod("SetupWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(global::TUnit.Core.TestContext), typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[0]), + global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::System.Threading.CancellationToken), "cancellationToken", new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.CancellationToken)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.SetupTests).GetMethod("SetupWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(global::TUnit.Core.TestContext), typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[1]) + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.SetupTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), + Name = "SetupTests", + Namespace = "TUnit.TestProject.BeforeTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_CancellationToken_Before_Test_Body + } + ); + private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_CancellationToken_Before_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) { - Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), - Name = "SetupWithContext", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = new global::TUnit.Core.ParameterMetadata[] - { - global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::TUnit.Core.TestContext), "testContext", new global::TUnit.Core.ConcreteType(typeof(global::TUnit.Core.TestContext)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.SetupTests).GetMethod("SetupWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(global::TUnit.Core.TestContext), typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[0]), - global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::System.Threading.CancellationToken), "cancellationToken", new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.CancellationToken)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.SetupTests).GetMethod("SetupWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(global::TUnit.Core.TestContext), typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[1]) - }, - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.SetupTests", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.SetupTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.SetupTests)), - Name = "SetupTests", - Namespace = "TUnit.TestProject.BeforeTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_CancellationToken_Before_Test.TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_CancellationToken_Before_TestInitializer.global_TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext_2Params_Body - } -); + try + { + var typedInstance = (global::TUnit.TestProject.BeforeTests.SetupTests)instance; + return new ValueTask(typedInstance.SetupWithContext(context, cancellationToken)); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } + } } } diff --git a/tests/TUnit.Core.SourceGenerator.Tests/GlobalStaticAfterEachTests.Test.verified.txt b/tests/TUnit.Core.SourceGenerator.Tests/GlobalStaticAfterEachTests.Test.verified.txt index 1eb152ef4e8..d1d05bc1cb6 100644 --- a/tests/TUnit.Core.SourceGenerator.Tests/GlobalStaticAfterEachTests.Test.verified.txt +++ b/tests/TUnit.Core.SourceGenerator.Tests/GlobalStaticAfterEachTests.Test.verified.txt @@ -4,206 +4,108 @@ #nullable enable #pragma warning disable CS9113 // Parameter is unread. using System; -using System.Collections.Generic; -using System.Linq; using System.Reflection; -using System.Runtime.CompilerServices; using System.Threading; using System.Threading.Tasks; using global::TUnit.Core; using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_AfterTests_GlobalBase1_AfterEach1_After_Test -{ - internal static class TUnit_TestProject_AfterTests_GlobalBase1_AfterEach1_After_TestInitializer - { - internal static async ValueTask global_TUnit_TestProject_AfterTests_GlobalBase1_AfterEach1_0Params_Body(object instance, TestContext context, CancellationToken cancellationToken) - { - var typedInstance = (global::TUnit.TestProject.AfterTests.GlobalBase1)instance; - await AsyncConvert.Convert(() => typedInstance.AfterEach1()); - } - } -} namespace TUnit.Generated { internal static partial class TUnit_HookRegistration { static readonly int _h_TUnit_TestProject_AfterTests_GlobalBase1_AfterEach1_After_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterTestHooks, typeof(global::TUnit.TestProject.AfterTests.GlobalBase1), global::TUnit.Core.HookRegistrationIndices.GetNextAfterTestHookIndex(), - static __registrationIndex => - new InstanceHookMethod - { - InitClassType = typeof(global::TUnit.TestProject.AfterTests.GlobalBase1), - MethodInfo = new global::TUnit.Core.MethodMetadata - { - Type = typeof(global::TUnit.TestProject.AfterTests.GlobalBase1), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.GlobalBase1)), - Name = "AfterEach1", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = global::System.Array.Empty(), - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.AfterTests.GlobalBase1", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.AfterTests.GlobalBase1), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.GlobalBase1)), - Name = "GlobalBase1", - Namespace = "TUnit.TestProject.AfterTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_AfterTests_GlobalBase1_AfterEach1_After_Test.TUnit_TestProject_AfterTests_GlobalBase1_AfterEach1_After_TestInitializer.global_TUnit_TestProject_AfterTests_GlobalBase1_AfterEach1_0Params_Body - } -); - } -} - - -// ===== FILE SEPARATOR ===== - -// -#pragma warning disable - -#nullable enable -#pragma warning disable CS9113 // Parameter is unread. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Threading; -using System.Threading.Tasks; -using global::TUnit.Core; -using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_AfterTests_GlobalBase2_AfterEach2_After_Test -{ - internal static class TUnit_TestProject_AfterTests_GlobalBase2_AfterEach2_After_TestInitializer - { - internal static async ValueTask global_TUnit_TestProject_AfterTests_GlobalBase2_AfterEach2_0Params_Body(object instance, TestContext context, CancellationToken cancellationToken) + static __registrationIndex => + new InstanceHookMethod + { + InitClassType = typeof(global::TUnit.TestProject.AfterTests.GlobalBase1), + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.AfterTests.GlobalBase1), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.GlobalBase1)), + Name = "AfterEach1", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = global::System.Array.Empty(), + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.AfterTests.GlobalBase1", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.AfterTests.GlobalBase1), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.GlobalBase1)), + Name = "GlobalBase1", + Namespace = "TUnit.TestProject.AfterTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_AfterTests_GlobalBase1_AfterEach1_After_Test_Body + } + ); + private static ValueTask TUnit_TestProject_AfterTests_GlobalBase1_AfterEach1_After_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) { - var typedInstance = (global::TUnit.TestProject.AfterTests.GlobalBase2)instance; - await AsyncConvert.Convert(() => typedInstance.AfterEach2()); + try + { + var typedInstance = (global::TUnit.TestProject.AfterTests.GlobalBase1)instance; + return new ValueTask(typedInstance.AfterEach1()); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } } - } -} -namespace TUnit.Generated -{ - internal static partial class TUnit_HookRegistration - { - static readonly int _h_TUnit_TestProject_AfterTests_GlobalBase2_AfterEach2_After_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterTestHooks, typeof(global::TUnit.TestProject.AfterTests.GlobalBase2), global::TUnit.Core.HookRegistrationIndices.GetNextAfterTestHookIndex(), - static __registrationIndex => - new InstanceHookMethod - { - InitClassType = typeof(global::TUnit.TestProject.AfterTests.GlobalBase2), - MethodInfo = new global::TUnit.Core.MethodMetadata - { - Type = typeof(global::TUnit.TestProject.AfterTests.GlobalBase2), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.GlobalBase2)), - Name = "AfterEach2", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = global::System.Array.Empty(), - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.AfterTests.GlobalBase2", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.AfterTests.GlobalBase2), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.GlobalBase2)), - Name = "GlobalBase2", - Namespace = "TUnit.TestProject.AfterTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_AfterTests_GlobalBase2_AfterEach2_After_Test.TUnit_TestProject_AfterTests_GlobalBase2_AfterEach2_After_TestInitializer.global_TUnit_TestProject_AfterTests_GlobalBase2_AfterEach2_0Params_Body - } -); - } -} - - -// ===== FILE SEPARATOR ===== - -// -#pragma warning disable - -#nullable enable -#pragma warning disable CS9113 // Parameter is unread. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Threading; -using System.Threading.Tasks; -using global::TUnit.Core; -using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_AfterTests_GlobalBase3_AfterEach3_After_Test -{ - internal static class TUnit_TestProject_AfterTests_GlobalBase3_AfterEach3_After_TestInitializer - { - internal static async ValueTask global_TUnit_TestProject_AfterTests_GlobalBase3_AfterEach3_0Params_Body(object instance, TestContext context, CancellationToken cancellationToken) + static readonly int _h_TUnit_TestProject_AfterTests_GlobalBase1_AfterAll1__TestContext_AfterEvery_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterEveryTestHooks, global::TUnit.Core.HookRegistrationIndices.GetNextAfterEveryTestHookIndex(), + static __registrationIndex => + new AfterTestHookMethod + { + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.AfterTests.GlobalBase1), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.GlobalBase1)), + Name = "AfterAll1", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = new global::TUnit.Core.ParameterMetadata[] + { + global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::TUnit.Core.TestContext), "context", new global::TUnit.Core.ConcreteType(typeof(global::TUnit.Core.TestContext)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.AfterTests.GlobalBase1).GetMethod("AfterAll1", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::TUnit.Core.TestContext) }, null)!.GetParameters()[0]) + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.AfterTests.GlobalBase1", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.AfterTests.GlobalBase1), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.GlobalBase1)), + Name = "GlobalBase1", + Namespace = "TUnit.TestProject.AfterTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_AfterTests_GlobalBase1_AfterAll1__TestContext_AfterEvery_Test_Body, + FilePath = "", + LineNumber = 5 + } + ); + private static ValueTask TUnit_TestProject_AfterTests_GlobalBase1_AfterAll1__TestContext_AfterEvery_Test_Body(TestContext context, CancellationToken cancellationToken) { - var typedInstance = (global::TUnit.TestProject.AfterTests.GlobalBase3)instance; - await AsyncConvert.Convert(() => typedInstance.AfterEach3()); + try + { + return new ValueTask(global::TUnit.TestProject.AfterTests.GlobalBase1.AfterAll1(context)); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } } } } -namespace TUnit.Generated -{ - internal static partial class TUnit_HookRegistration - { - static readonly int _h_TUnit_TestProject_AfterTests_GlobalBase3_AfterEach3_After_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterTestHooks, typeof(global::TUnit.TestProject.AfterTests.GlobalBase3), global::TUnit.Core.HookRegistrationIndices.GetNextAfterTestHookIndex(), - static __registrationIndex => - new InstanceHookMethod - { - InitClassType = typeof(global::TUnit.TestProject.AfterTests.GlobalBase3), - MethodInfo = new global::TUnit.Core.MethodMetadata - { - Type = typeof(global::TUnit.TestProject.AfterTests.GlobalBase3), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.GlobalBase3)), - Name = "AfterEach3", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = global::System.Array.Empty(), - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.AfterTests.GlobalBase3", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.AfterTests.GlobalBase3), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.GlobalBase3)), - Name = "GlobalBase3", - Namespace = "TUnit.TestProject.AfterTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_AfterTests_GlobalBase3_AfterEach3_After_Test.TUnit_TestProject_AfterTests_GlobalBase3_AfterEach3_After_TestInitializer.global_TUnit_TestProject_AfterTests_GlobalBase3_AfterEach3_0Params_Body - } -); - } -} // ===== FILE SEPARATOR ===== @@ -214,212 +116,108 @@ namespace TUnit.Generated #nullable enable #pragma warning disable CS9113 // Parameter is unread. using System; -using System.Collections.Generic; -using System.Linq; using System.Reflection; -using System.Runtime.CompilerServices; using System.Threading; using System.Threading.Tasks; using global::TUnit.Core; using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_AfterTests_GlobalCleanUpTests_CleanUp_After_Test -{ - internal static class TUnit_TestProject_AfterTests_GlobalCleanUpTests_CleanUp_After_TestInitializer - { - internal static async ValueTask global_TUnit_TestProject_AfterTests_GlobalCleanUpTests_CleanUp_0Params_Body(object instance, TestContext context, CancellationToken cancellationToken) - { - var typedInstance = (global::TUnit.TestProject.AfterTests.GlobalCleanUpTests)instance; - await AsyncConvert.Convert(() => typedInstance.CleanUp()); - } - } -} namespace TUnit.Generated { internal static partial class TUnit_HookRegistration { - static readonly int _h_TUnit_TestProject_AfterTests_GlobalCleanUpTests_CleanUp_After_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterTestHooks, typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests), global::TUnit.Core.HookRegistrationIndices.GetNextAfterTestHookIndex(), - static __registrationIndex => - new InstanceHookMethod - { - InitClassType = typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests), - MethodInfo = new global::TUnit.Core.MethodMetadata - { - Type = typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests)), - Name = "CleanUp", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = global::System.Array.Empty(), - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.AfterTests.GlobalCleanUpTests", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests)), - Name = "GlobalCleanUpTests", - Namespace = "TUnit.TestProject.AfterTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_AfterTests_GlobalCleanUpTests_CleanUp_After_Test.TUnit_TestProject_AfterTests_GlobalCleanUpTests_CleanUp_After_TestInitializer.global_TUnit_TestProject_AfterTests_GlobalCleanUpTests_CleanUp_0Params_Body - } -); - } -} - - -// ===== FILE SEPARATOR ===== - -// -#pragma warning disable - -#nullable enable -#pragma warning disable CS9113 // Parameter is unread. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Threading; -using System.Threading.Tasks; -using global::TUnit.Core; -using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_AfterTests_GlobalCleanUpTests_CleanUp__CancellationToken_After_Test -{ - internal static class TUnit_TestProject_AfterTests_GlobalCleanUpTests_CleanUp__CancellationToken_After_TestInitializer - { - internal static async ValueTask global_TUnit_TestProject_AfterTests_GlobalCleanUpTests_CleanUp_1Params_Body(object instance, TestContext context, CancellationToken cancellationToken) + static readonly int _h_TUnit_TestProject_AfterTests_GlobalBase2_AfterEach2_After_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterTestHooks, typeof(global::TUnit.TestProject.AfterTests.GlobalBase2), global::TUnit.Core.HookRegistrationIndices.GetNextAfterTestHookIndex(), + static __registrationIndex => + new InstanceHookMethod + { + InitClassType = typeof(global::TUnit.TestProject.AfterTests.GlobalBase2), + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.AfterTests.GlobalBase2), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.GlobalBase2)), + Name = "AfterEach2", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = global::System.Array.Empty(), + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.AfterTests.GlobalBase2", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.AfterTests.GlobalBase2), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.GlobalBase2)), + Name = "GlobalBase2", + Namespace = "TUnit.TestProject.AfterTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_AfterTests_GlobalBase2_AfterEach2_After_Test_Body + } + ); + private static ValueTask TUnit_TestProject_AfterTests_GlobalBase2_AfterEach2_After_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) { - var typedInstance = (global::TUnit.TestProject.AfterTests.GlobalCleanUpTests)instance; - await AsyncConvert.Convert(() => typedInstance.CleanUp(cancellationToken)); + try + { + var typedInstance = (global::TUnit.TestProject.AfterTests.GlobalBase2)instance; + return new ValueTask(typedInstance.AfterEach2()); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } } - } -} -namespace TUnit.Generated -{ - internal static partial class TUnit_HookRegistration - { - static readonly int _h_TUnit_TestProject_AfterTests_GlobalCleanUpTests_CleanUp__CancellationToken_After_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterTestHooks, typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests), global::TUnit.Core.HookRegistrationIndices.GetNextAfterTestHookIndex(), - static __registrationIndex => - new InstanceHookMethod - { - InitClassType = typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests), - MethodInfo = new global::TUnit.Core.MethodMetadata - { - Type = typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests)), - Name = "CleanUp", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = new global::TUnit.Core.ParameterMetadata[] - { - global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::System.Threading.CancellationToken), "cancellationToken", new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.CancellationToken)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests).GetMethod("CleanUp", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[0]) - }, - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.AfterTests.GlobalCleanUpTests", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests)), - Name = "GlobalCleanUpTests", - Namespace = "TUnit.TestProject.AfterTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_AfterTests_GlobalCleanUpTests_CleanUp__CancellationToken_After_Test.TUnit_TestProject_AfterTests_GlobalCleanUpTests_CleanUp__CancellationToken_After_TestInitializer.global_TUnit_TestProject_AfterTests_GlobalCleanUpTests_CleanUp_1Params_Body - } -); - } -} - - -// ===== FILE SEPARATOR ===== - -// -#pragma warning disable - -#nullable enable -#pragma warning disable CS9113 // Parameter is unread. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Threading; -using System.Threading.Tasks; -using global::TUnit.Core; -using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_AfterTests_GlobalCleanUpTests_CleanUpWithContext__TestContext_After_Test -{ - internal static class TUnit_TestProject_AfterTests_GlobalCleanUpTests_CleanUpWithContext__TestContext_After_TestInitializer - { - internal static async ValueTask global_TUnit_TestProject_AfterTests_GlobalCleanUpTests_CleanUpWithContext_1Params_Body(object instance, TestContext context, CancellationToken cancellationToken) + static readonly int _h_TUnit_TestProject_AfterTests_GlobalBase2_AfterAll2__TestContext_AfterEvery_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterEveryTestHooks, global::TUnit.Core.HookRegistrationIndices.GetNextAfterEveryTestHookIndex(), + static __registrationIndex => + new AfterTestHookMethod + { + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.AfterTests.GlobalBase2), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.GlobalBase2)), + Name = "AfterAll2", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = new global::TUnit.Core.ParameterMetadata[] + { + global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::TUnit.Core.TestContext), "context", new global::TUnit.Core.ConcreteType(typeof(global::TUnit.Core.TestContext)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.AfterTests.GlobalBase2).GetMethod("AfterAll2", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::TUnit.Core.TestContext) }, null)!.GetParameters()[0]) + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.AfterTests.GlobalBase2", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.AfterTests.GlobalBase2), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.GlobalBase2)), + Name = "GlobalBase2", + Namespace = "TUnit.TestProject.AfterTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_AfterTests_GlobalBase2_AfterAll2__TestContext_AfterEvery_Test_Body, + FilePath = "", + LineNumber = 20 + } + ); + private static ValueTask TUnit_TestProject_AfterTests_GlobalBase2_AfterAll2__TestContext_AfterEvery_Test_Body(TestContext context, CancellationToken cancellationToken) { - var typedInstance = (global::TUnit.TestProject.AfterTests.GlobalCleanUpTests)instance; - await AsyncConvert.Convert(() => typedInstance.CleanUpWithContext(context)); + try + { + return new ValueTask(global::TUnit.TestProject.AfterTests.GlobalBase2.AfterAll2(context)); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } } } } -namespace TUnit.Generated -{ - internal static partial class TUnit_HookRegistration - { - static readonly int _h_TUnit_TestProject_AfterTests_GlobalCleanUpTests_CleanUpWithContext__TestContext_After_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterTestHooks, typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests), global::TUnit.Core.HookRegistrationIndices.GetNextAfterTestHookIndex(), - static __registrationIndex => - new InstanceHookMethod - { - InitClassType = typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests), - MethodInfo = new global::TUnit.Core.MethodMetadata - { - Type = typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests)), - Name = "CleanUpWithContext", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = new global::TUnit.Core.ParameterMetadata[] - { - global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::TUnit.Core.TestContext), "testContext", new global::TUnit.Core.ConcreteType(typeof(global::TUnit.Core.TestContext)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests).GetMethod("CleanUpWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(global::TUnit.Core.TestContext) }, null)!.GetParameters()[0]) - }, - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.AfterTests.GlobalCleanUpTests", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests)), - Name = "GlobalCleanUpTests", - Namespace = "TUnit.TestProject.AfterTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_AfterTests_GlobalCleanUpTests_CleanUpWithContext__TestContext_After_Test.TUnit_TestProject_AfterTests_GlobalCleanUpTests_CleanUpWithContext__TestContext_After_TestInitializer.global_TUnit_TestProject_AfterTests_GlobalCleanUpTests_CleanUpWithContext_1Params_Body - } -); - } -} // ===== FILE SEPARATOR ===== @@ -430,141 +228,106 @@ namespace TUnit.Generated #nullable enable #pragma warning disable CS9113 // Parameter is unread. using System; -using System.Collections.Generic; -using System.Linq; using System.Reflection; -using System.Runtime.CompilerServices; using System.Threading; using System.Threading.Tasks; using global::TUnit.Core; using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_AfterTests_GlobalCleanUpTests_CleanUpWithContext__TestContext_CancellationToken_After_Test -{ - internal static class TUnit_TestProject_AfterTests_GlobalCleanUpTests_CleanUpWithContext__TestContext_CancellationToken_After_TestInitializer - { - internal static async ValueTask global_TUnit_TestProject_AfterTests_GlobalCleanUpTests_CleanUpWithContext_2Params_Body(object instance, TestContext context, CancellationToken cancellationToken) - { - var typedInstance = (global::TUnit.TestProject.AfterTests.GlobalCleanUpTests)instance; - await AsyncConvert.Convert(() => typedInstance.CleanUpWithContext(context, cancellationToken)); - } - } -} namespace TUnit.Generated { internal static partial class TUnit_HookRegistration { - static readonly int _h_TUnit_TestProject_AfterTests_GlobalCleanUpTests_CleanUpWithContext__TestContext_CancellationToken_After_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterTestHooks, typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests), global::TUnit.Core.HookRegistrationIndices.GetNextAfterTestHookIndex(), - static __registrationIndex => - new InstanceHookMethod - { - InitClassType = typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests), - MethodInfo = new global::TUnit.Core.MethodMetadata - { - Type = typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests)), - Name = "CleanUpWithContext", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = new global::TUnit.Core.ParameterMetadata[] - { - global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::TUnit.Core.TestContext), "testContext", new global::TUnit.Core.ConcreteType(typeof(global::TUnit.Core.TestContext)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests).GetMethod("CleanUpWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(global::TUnit.Core.TestContext), typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[0]), - global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::System.Threading.CancellationToken), "cancellationToken", new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.CancellationToken)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests).GetMethod("CleanUpWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(global::TUnit.Core.TestContext), typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[1]) - }, - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.AfterTests.GlobalCleanUpTests", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests)), - Name = "GlobalCleanUpTests", - Namespace = "TUnit.TestProject.AfterTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_AfterTests_GlobalCleanUpTests_CleanUpWithContext__TestContext_CancellationToken_After_Test.TUnit_TestProject_AfterTests_GlobalCleanUpTests_CleanUpWithContext__TestContext_CancellationToken_After_TestInitializer.global_TUnit_TestProject_AfterTests_GlobalCleanUpTests_CleanUpWithContext_2Params_Body - } -); - } -} - - -// ===== FILE SEPARATOR ===== - -// -#pragma warning disable - -#nullable enable -#pragma warning disable CS9113 // Parameter is unread. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Threading; -using System.Threading.Tasks; -using global::TUnit.Core; -using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_AfterTests_GlobalBase1_AfterAll1__TestContext_AfterEvery_Test -{ - internal static class TUnit_TestProject_AfterTests_GlobalBase1_AfterAll1__TestContext_AfterEvery_TestInitializer - { - internal static async ValueTask global_TUnit_TestProject_AfterTests_GlobalBase1_AfterAll1_1Params_Body(TestContext context, CancellationToken cancellationToken) + static readonly int _h_TUnit_TestProject_AfterTests_GlobalBase3_AfterEach3_After_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterTestHooks, typeof(global::TUnit.TestProject.AfterTests.GlobalBase3), global::TUnit.Core.HookRegistrationIndices.GetNextAfterTestHookIndex(), + static __registrationIndex => + new InstanceHookMethod + { + InitClassType = typeof(global::TUnit.TestProject.AfterTests.GlobalBase3), + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.AfterTests.GlobalBase3), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.GlobalBase3)), + Name = "AfterEach3", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = global::System.Array.Empty(), + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.AfterTests.GlobalBase3", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.AfterTests.GlobalBase3), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.GlobalBase3)), + Name = "GlobalBase3", + Namespace = "TUnit.TestProject.AfterTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_AfterTests_GlobalBase3_AfterEach3_After_Test_Body + } + ); + private static ValueTask TUnit_TestProject_AfterTests_GlobalBase3_AfterEach3_After_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) { - await AsyncConvert.Convert(() => global::TUnit.TestProject.AfterTests.GlobalBase1.AfterAll1(context)); + try + { + var typedInstance = (global::TUnit.TestProject.AfterTests.GlobalBase3)instance; + return new ValueTask(typedInstance.AfterEach3()); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } } - } -} -namespace TUnit.Generated -{ - internal static partial class TUnit_HookRegistration - { - static readonly int _h_TUnit_TestProject_AfterTests_GlobalBase1_AfterAll1__TestContext_AfterEvery_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterEveryTestHooks, global::TUnit.Core.HookRegistrationIndices.GetNextAfterEveryTestHookIndex(), - static __registrationIndex => - new AfterTestHookMethod - { - MethodInfo = new global::TUnit.Core.MethodMetadata + static readonly int _h_TUnit_TestProject_AfterTests_GlobalBase3_AfterAll3__TestContext_AfterEvery_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterEveryTestHooks, global::TUnit.Core.HookRegistrationIndices.GetNextAfterEveryTestHookIndex(), + static __registrationIndex => + new AfterTestHookMethod + { + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.AfterTests.GlobalBase3), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.GlobalBase3)), + Name = "AfterAll3", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = new global::TUnit.Core.ParameterMetadata[] + { + global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::TUnit.Core.TestContext), "context", new global::TUnit.Core.ConcreteType(typeof(global::TUnit.Core.TestContext)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.AfterTests.GlobalBase3).GetMethod("AfterAll3", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::TUnit.Core.TestContext) }, null)!.GetParameters()[0]) + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.AfterTests.GlobalBase3", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.AfterTests.GlobalBase3), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.GlobalBase3)), + Name = "GlobalBase3", + Namespace = "TUnit.TestProject.AfterTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_AfterTests_GlobalBase3_AfterAll3__TestContext_AfterEvery_Test_Body, + FilePath = "", + LineNumber = 35 + } + ); + private static ValueTask TUnit_TestProject_AfterTests_GlobalBase3_AfterAll3__TestContext_AfterEvery_Test_Body(TestContext context, CancellationToken cancellationToken) { - Type = typeof(global::TUnit.TestProject.AfterTests.GlobalBase1), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.GlobalBase1)), - Name = "AfterAll1", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = new global::TUnit.Core.ParameterMetadata[] - { - global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::TUnit.Core.TestContext), "context", new global::TUnit.Core.ConcreteType(typeof(global::TUnit.Core.TestContext)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.AfterTests.GlobalBase1).GetMethod("AfterAll1", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::TUnit.Core.TestContext) }, null)!.GetParameters()[0]) - }, - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.AfterTests.GlobalBase1", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.AfterTests.GlobalBase1), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.GlobalBase1)), - Name = "GlobalBase1", - Namespace = "TUnit.TestProject.AfterTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_AfterTests_GlobalBase1_AfterAll1__TestContext_AfterEvery_Test.TUnit_TestProject_AfterTests_GlobalBase1_AfterAll1__TestContext_AfterEvery_TestInitializer.global_TUnit_TestProject_AfterTests_GlobalBase1_AfterAll1_1Params_Body, - FilePath = "", - LineNumber = 5 - } -); + try + { + return new ValueTask(global::TUnit.TestProject.AfterTests.GlobalBase3.AfterAll3(context)); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } + } } } @@ -577,433 +340,390 @@ namespace TUnit.Generated #nullable enable #pragma warning disable CS9113 // Parameter is unread. using System; -using System.Collections.Generic; -using System.Linq; using System.Reflection; -using System.Runtime.CompilerServices; using System.Threading; using System.Threading.Tasks; using global::TUnit.Core; using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_AfterTests_GlobalBase2_AfterAll2__TestContext_AfterEvery_Test -{ - internal static class TUnit_TestProject_AfterTests_GlobalBase2_AfterAll2__TestContext_AfterEvery_TestInitializer - { - internal static async ValueTask global_TUnit_TestProject_AfterTests_GlobalBase2_AfterAll2_1Params_Body(TestContext context, CancellationToken cancellationToken) - { - await AsyncConvert.Convert(() => global::TUnit.TestProject.AfterTests.GlobalBase2.AfterAll2(context)); - } - } -} namespace TUnit.Generated { internal static partial class TUnit_HookRegistration { - static readonly int _h_TUnit_TestProject_AfterTests_GlobalBase2_AfterAll2__TestContext_AfterEvery_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterEveryTestHooks, global::TUnit.Core.HookRegistrationIndices.GetNextAfterEveryTestHookIndex(), - static __registrationIndex => - new AfterTestHookMethod - { - MethodInfo = new global::TUnit.Core.MethodMetadata + static readonly int _h_TUnit_TestProject_AfterTests_GlobalCleanUpTests_CleanUp_After_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterTestHooks, typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests), global::TUnit.Core.HookRegistrationIndices.GetNextAfterTestHookIndex(), + static __registrationIndex => + new InstanceHookMethod + { + InitClassType = typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests), + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests)), + Name = "CleanUp", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = global::System.Array.Empty(), + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.AfterTests.GlobalCleanUpTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests)), + Name = "GlobalCleanUpTests", + Namespace = "TUnit.TestProject.AfterTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_AfterTests_GlobalCleanUpTests_CleanUp_After_Test_Body + } + ); + private static ValueTask TUnit_TestProject_AfterTests_GlobalCleanUpTests_CleanUp_After_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) { - Type = typeof(global::TUnit.TestProject.AfterTests.GlobalBase2), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.GlobalBase2)), - Name = "AfterAll2", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = new global::TUnit.Core.ParameterMetadata[] - { - global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::TUnit.Core.TestContext), "context", new global::TUnit.Core.ConcreteType(typeof(global::TUnit.Core.TestContext)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.AfterTests.GlobalBase2).GetMethod("AfterAll2", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::TUnit.Core.TestContext) }, null)!.GetParameters()[0]) - }, - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.AfterTests.GlobalBase2", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.AfterTests.GlobalBase2), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.GlobalBase2)), - Name = "GlobalBase2", - Namespace = "TUnit.TestProject.AfterTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_AfterTests_GlobalBase2_AfterAll2__TestContext_AfterEvery_Test.TUnit_TestProject_AfterTests_GlobalBase2_AfterAll2__TestContext_AfterEvery_TestInitializer.global_TUnit_TestProject_AfterTests_GlobalBase2_AfterAll2_1Params_Body, - FilePath = "", - LineNumber = 20 - } -); - } -} - - -// ===== FILE SEPARATOR ===== - -// -#pragma warning disable - -#nullable enable -#pragma warning disable CS9113 // Parameter is unread. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Threading; -using System.Threading.Tasks; -using global::TUnit.Core; -using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_AfterTests_GlobalBase3_AfterAll3__TestContext_AfterEvery_Test -{ - internal static class TUnit_TestProject_AfterTests_GlobalBase3_AfterAll3__TestContext_AfterEvery_TestInitializer - { - internal static async ValueTask global_TUnit_TestProject_AfterTests_GlobalBase3_AfterAll3_1Params_Body(TestContext context, CancellationToken cancellationToken) + try + { + var typedInstance = (global::TUnit.TestProject.AfterTests.GlobalCleanUpTests)instance; + return new ValueTask(typedInstance.CleanUp()); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } + } + static readonly int _h_TUnit_TestProject_AfterTests_GlobalCleanUpTests_CleanUp__CancellationToken_After_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterTestHooks, typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests), global::TUnit.Core.HookRegistrationIndices.GetNextAfterTestHookIndex(), + static __registrationIndex => + new InstanceHookMethod + { + InitClassType = typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests), + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests)), + Name = "CleanUp", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = new global::TUnit.Core.ParameterMetadata[] + { + global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::System.Threading.CancellationToken), "cancellationToken", new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.CancellationToken)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests).GetMethod("CleanUp", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[0]) + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.AfterTests.GlobalCleanUpTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests)), + Name = "GlobalCleanUpTests", + Namespace = "TUnit.TestProject.AfterTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_AfterTests_GlobalCleanUpTests_CleanUp__CancellationToken_After_Test_Body + } + ); + private static ValueTask TUnit_TestProject_AfterTests_GlobalCleanUpTests_CleanUp__CancellationToken_After_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) { - await AsyncConvert.Convert(() => global::TUnit.TestProject.AfterTests.GlobalBase3.AfterAll3(context)); + try + { + var typedInstance = (global::TUnit.TestProject.AfterTests.GlobalCleanUpTests)instance; + return new ValueTask(typedInstance.CleanUp(cancellationToken)); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } } - } -} -namespace TUnit.Generated -{ - internal static partial class TUnit_HookRegistration - { - static readonly int _h_TUnit_TestProject_AfterTests_GlobalBase3_AfterAll3__TestContext_AfterEvery_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterEveryTestHooks, global::TUnit.Core.HookRegistrationIndices.GetNextAfterEveryTestHookIndex(), - static __registrationIndex => - new AfterTestHookMethod - { - MethodInfo = new global::TUnit.Core.MethodMetadata + static readonly int _h_TUnit_TestProject_AfterTests_GlobalCleanUpTests_CleanUpWithContext__TestContext_After_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterTestHooks, typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests), global::TUnit.Core.HookRegistrationIndices.GetNextAfterTestHookIndex(), + static __registrationIndex => + new InstanceHookMethod + { + InitClassType = typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests), + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests)), + Name = "CleanUpWithContext", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = new global::TUnit.Core.ParameterMetadata[] + { + global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::TUnit.Core.TestContext), "testContext", new global::TUnit.Core.ConcreteType(typeof(global::TUnit.Core.TestContext)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests).GetMethod("CleanUpWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(global::TUnit.Core.TestContext) }, null)!.GetParameters()[0]) + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.AfterTests.GlobalCleanUpTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests)), + Name = "GlobalCleanUpTests", + Namespace = "TUnit.TestProject.AfterTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_AfterTests_GlobalCleanUpTests_CleanUpWithContext__TestContext_After_Test_Body + } + ); + private static ValueTask TUnit_TestProject_AfterTests_GlobalCleanUpTests_CleanUpWithContext__TestContext_After_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) { - Type = typeof(global::TUnit.TestProject.AfterTests.GlobalBase3), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.GlobalBase3)), - Name = "AfterAll3", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = new global::TUnit.Core.ParameterMetadata[] - { - global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::TUnit.Core.TestContext), "context", new global::TUnit.Core.ConcreteType(typeof(global::TUnit.Core.TestContext)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.AfterTests.GlobalBase3).GetMethod("AfterAll3", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::TUnit.Core.TestContext) }, null)!.GetParameters()[0]) - }, - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.AfterTests.GlobalBase3", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.AfterTests.GlobalBase3), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.GlobalBase3)), - Name = "GlobalBase3", - Namespace = "TUnit.TestProject.AfterTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_AfterTests_GlobalBase3_AfterAll3__TestContext_AfterEvery_Test.TUnit_TestProject_AfterTests_GlobalBase3_AfterAll3__TestContext_AfterEvery_TestInitializer.global_TUnit_TestProject_AfterTests_GlobalBase3_AfterAll3_1Params_Body, - FilePath = "", - LineNumber = 35 - } -); - } -} - - -// ===== FILE SEPARATOR ===== - -// -#pragma warning disable - -#nullable enable -#pragma warning disable CS9113 // Parameter is unread. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Threading; -using System.Threading.Tasks; -using global::TUnit.Core; -using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_AfterTests_GlobalCleanUpTests_AfterAllCleanUp__TestContext_AfterEvery_Test -{ - internal static class TUnit_TestProject_AfterTests_GlobalCleanUpTests_AfterAllCleanUp__TestContext_AfterEvery_TestInitializer - { - internal static async ValueTask global_TUnit_TestProject_AfterTests_GlobalCleanUpTests_AfterAllCleanUp_1Params_Body(TestContext context, CancellationToken cancellationToken) + try + { + var typedInstance = (global::TUnit.TestProject.AfterTests.GlobalCleanUpTests)instance; + return new ValueTask(typedInstance.CleanUpWithContext(context)); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } + } + static readonly int _h_TUnit_TestProject_AfterTests_GlobalCleanUpTests_CleanUpWithContext__TestContext_CancellationToken_After_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterTestHooks, typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests), global::TUnit.Core.HookRegistrationIndices.GetNextAfterTestHookIndex(), + static __registrationIndex => + new InstanceHookMethod + { + InitClassType = typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests), + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests)), + Name = "CleanUpWithContext", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = new global::TUnit.Core.ParameterMetadata[] + { + global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::TUnit.Core.TestContext), "testContext", new global::TUnit.Core.ConcreteType(typeof(global::TUnit.Core.TestContext)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests).GetMethod("CleanUpWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(global::TUnit.Core.TestContext), typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[0]), + global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::System.Threading.CancellationToken), "cancellationToken", new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.CancellationToken)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests).GetMethod("CleanUpWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(global::TUnit.Core.TestContext), typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[1]) + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.AfterTests.GlobalCleanUpTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests)), + Name = "GlobalCleanUpTests", + Namespace = "TUnit.TestProject.AfterTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_AfterTests_GlobalCleanUpTests_CleanUpWithContext__TestContext_CancellationToken_After_Test_Body + } + ); + private static ValueTask TUnit_TestProject_AfterTests_GlobalCleanUpTests_CleanUpWithContext__TestContext_CancellationToken_After_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) { - await AsyncConvert.Convert(() => global::TUnit.TestProject.AfterTests.GlobalCleanUpTests.AfterAllCleanUp(context)); + try + { + var typedInstance = (global::TUnit.TestProject.AfterTests.GlobalCleanUpTests)instance; + return new ValueTask(typedInstance.CleanUpWithContext(context, cancellationToken)); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } } - } -} -namespace TUnit.Generated -{ - internal static partial class TUnit_HookRegistration - { static readonly int _h_TUnit_TestProject_AfterTests_GlobalCleanUpTests_AfterAllCleanUp__TestContext_AfterEvery_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterEveryTestHooks, global::TUnit.Core.HookRegistrationIndices.GetNextAfterEveryTestHookIndex(), - static __registrationIndex => - new AfterTestHookMethod - { - MethodInfo = new global::TUnit.Core.MethodMetadata - { - Type = typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests)), - Name = "AfterAllCleanUp", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = new global::TUnit.Core.ParameterMetadata[] - { - global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::TUnit.Core.TestContext), "context", new global::TUnit.Core.ConcreteType(typeof(global::TUnit.Core.TestContext)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests).GetMethod("AfterAllCleanUp", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::TUnit.Core.TestContext) }, null)!.GetParameters()[0]) - }, - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.AfterTests.GlobalCleanUpTests", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests)), - Name = "GlobalCleanUpTests", - Namespace = "TUnit.TestProject.AfterTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_AfterTests_GlobalCleanUpTests_AfterAllCleanUp__TestContext_AfterEvery_Test.TUnit_TestProject_AfterTests_GlobalCleanUpTests_AfterAllCleanUp__TestContext_AfterEvery_TestInitializer.global_TUnit_TestProject_AfterTests_GlobalCleanUpTests_AfterAllCleanUp_1Params_Body, - FilePath = "", - LineNumber = 50 - } -); - } -} - - -// ===== FILE SEPARATOR ===== - -// -#pragma warning disable - -#nullable enable -#pragma warning disable CS9113 // Parameter is unread. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Threading; -using System.Threading.Tasks; -using global::TUnit.Core; -using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_AfterTests_GlobalCleanUpTests_AfterAllCleanUp__TestContext_CancellationToken_AfterEvery_Test -{ - internal static class TUnit_TestProject_AfterTests_GlobalCleanUpTests_AfterAllCleanUp__TestContext_CancellationToken_AfterEvery_TestInitializer - { - internal static async ValueTask global_TUnit_TestProject_AfterTests_GlobalCleanUpTests_AfterAllCleanUp_2Params_Body(TestContext context, CancellationToken cancellationToken) + static __registrationIndex => + new AfterTestHookMethod + { + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests)), + Name = "AfterAllCleanUp", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = new global::TUnit.Core.ParameterMetadata[] + { + global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::TUnit.Core.TestContext), "context", new global::TUnit.Core.ConcreteType(typeof(global::TUnit.Core.TestContext)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests).GetMethod("AfterAllCleanUp", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::TUnit.Core.TestContext) }, null)!.GetParameters()[0]) + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.AfterTests.GlobalCleanUpTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests)), + Name = "GlobalCleanUpTests", + Namespace = "TUnit.TestProject.AfterTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_AfterTests_GlobalCleanUpTests_AfterAllCleanUp__TestContext_AfterEvery_Test_Body, + FilePath = "", + LineNumber = 50 + } + ); + private static ValueTask TUnit_TestProject_AfterTests_GlobalCleanUpTests_AfterAllCleanUp__TestContext_AfterEvery_Test_Body(TestContext context, CancellationToken cancellationToken) { - await AsyncConvert.Convert(() => global::TUnit.TestProject.AfterTests.GlobalCleanUpTests.AfterAllCleanUp(context, cancellationToken)); + try + { + return new ValueTask(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests.AfterAllCleanUp(context)); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } } - } -} -namespace TUnit.Generated -{ - internal static partial class TUnit_HookRegistration - { static readonly int _h_TUnit_TestProject_AfterTests_GlobalCleanUpTests_AfterAllCleanUp__TestContext_CancellationToken_AfterEvery_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterEveryTestHooks, global::TUnit.Core.HookRegistrationIndices.GetNextAfterEveryTestHookIndex(), - static __registrationIndex => - new AfterTestHookMethod - { - MethodInfo = new global::TUnit.Core.MethodMetadata - { - Type = typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests)), - Name = "AfterAllCleanUp", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = new global::TUnit.Core.ParameterMetadata[] - { - global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::TUnit.Core.TestContext), "context", new global::TUnit.Core.ConcreteType(typeof(global::TUnit.Core.TestContext)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests).GetMethod("AfterAllCleanUp", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::TUnit.Core.TestContext), typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[0]), - global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::System.Threading.CancellationToken), "cancellationToken", new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.CancellationToken)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests).GetMethod("AfterAllCleanUp", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::TUnit.Core.TestContext), typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[1]) - }, - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.AfterTests.GlobalCleanUpTests", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests)), - Name = "GlobalCleanUpTests", - Namespace = "TUnit.TestProject.AfterTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_AfterTests_GlobalCleanUpTests_AfterAllCleanUp__TestContext_CancellationToken_AfterEvery_Test.TUnit_TestProject_AfterTests_GlobalCleanUpTests_AfterAllCleanUp__TestContext_CancellationToken_AfterEvery_TestInitializer.global_TUnit_TestProject_AfterTests_GlobalCleanUpTests_AfterAllCleanUp_2Params_Body, - FilePath = "", - LineNumber = 56 - } -); - } -} - - -// ===== FILE SEPARATOR ===== - -// -#pragma warning disable - -#nullable enable -#pragma warning disable CS9113 // Parameter is unread. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Threading; -using System.Threading.Tasks; -using global::TUnit.Core; -using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_AfterTests_GlobalCleanUpTests_AfterAllCleanUpWithContext__TestContext_AfterEvery_Test -{ - internal static class TUnit_TestProject_AfterTests_GlobalCleanUpTests_AfterAllCleanUpWithContext__TestContext_AfterEvery_TestInitializer - { - internal static async ValueTask global_TUnit_TestProject_AfterTests_GlobalCleanUpTests_AfterAllCleanUpWithContext_1Params_Body(TestContext context, CancellationToken cancellationToken) + static __registrationIndex => + new AfterTestHookMethod + { + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests)), + Name = "AfterAllCleanUp", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = new global::TUnit.Core.ParameterMetadata[] + { + global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::TUnit.Core.TestContext), "context", new global::TUnit.Core.ConcreteType(typeof(global::TUnit.Core.TestContext)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests).GetMethod("AfterAllCleanUp", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::TUnit.Core.TestContext), typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[0]), + global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::System.Threading.CancellationToken), "cancellationToken", new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.CancellationToken)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests).GetMethod("AfterAllCleanUp", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::TUnit.Core.TestContext), typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[1]) + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.AfterTests.GlobalCleanUpTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests)), + Name = "GlobalCleanUpTests", + Namespace = "TUnit.TestProject.AfterTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_AfterTests_GlobalCleanUpTests_AfterAllCleanUp__TestContext_CancellationToken_AfterEvery_Test_Body, + FilePath = "", + LineNumber = 56 + } + ); + private static ValueTask TUnit_TestProject_AfterTests_GlobalCleanUpTests_AfterAllCleanUp__TestContext_CancellationToken_AfterEvery_Test_Body(TestContext context, CancellationToken cancellationToken) { - await AsyncConvert.Convert(() => global::TUnit.TestProject.AfterTests.GlobalCleanUpTests.AfterAllCleanUpWithContext(context)); + try + { + return new ValueTask(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests.AfterAllCleanUp(context, cancellationToken)); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } } - } -} -namespace TUnit.Generated -{ - internal static partial class TUnit_HookRegistration - { static readonly int _h_TUnit_TestProject_AfterTests_GlobalCleanUpTests_AfterAllCleanUpWithContext__TestContext_AfterEvery_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterEveryTestHooks, global::TUnit.Core.HookRegistrationIndices.GetNextAfterEveryTestHookIndex(), - static __registrationIndex => - new AfterTestHookMethod - { - MethodInfo = new global::TUnit.Core.MethodMetadata - { - Type = typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests)), - Name = "AfterAllCleanUpWithContext", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = new global::TUnit.Core.ParameterMetadata[] - { - global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::TUnit.Core.TestContext), "context", new global::TUnit.Core.ConcreteType(typeof(global::TUnit.Core.TestContext)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests).GetMethod("AfterAllCleanUpWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::TUnit.Core.TestContext) }, null)!.GetParameters()[0]) - }, - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.AfterTests.GlobalCleanUpTests", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests)), - Name = "GlobalCleanUpTests", - Namespace = "TUnit.TestProject.AfterTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_AfterTests_GlobalCleanUpTests_AfterAllCleanUpWithContext__TestContext_AfterEvery_Test.TUnit_TestProject_AfterTests_GlobalCleanUpTests_AfterAllCleanUpWithContext__TestContext_AfterEvery_TestInitializer.global_TUnit_TestProject_AfterTests_GlobalCleanUpTests_AfterAllCleanUpWithContext_1Params_Body, - FilePath = "", - LineNumber = 62 - } -); - } -} - - -// ===== FILE SEPARATOR ===== - -// -#pragma warning disable - -#nullable enable -#pragma warning disable CS9113 // Parameter is unread. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Threading; -using System.Threading.Tasks; -using global::TUnit.Core; -using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_AfterTests_GlobalCleanUpTests_AfterAllCleanUpWithContext__TestContext_CancellationToken_AfterEvery_Test -{ - internal static class TUnit_TestProject_AfterTests_GlobalCleanUpTests_AfterAllCleanUpWithContext__TestContext_CancellationToken_AfterEvery_TestInitializer - { - internal static async ValueTask global_TUnit_TestProject_AfterTests_GlobalCleanUpTests_AfterAllCleanUpWithContext_2Params_Body(TestContext context, CancellationToken cancellationToken) + static __registrationIndex => + new AfterTestHookMethod + { + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests)), + Name = "AfterAllCleanUpWithContext", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = new global::TUnit.Core.ParameterMetadata[] + { + global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::TUnit.Core.TestContext), "context", new global::TUnit.Core.ConcreteType(typeof(global::TUnit.Core.TestContext)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests).GetMethod("AfterAllCleanUpWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::TUnit.Core.TestContext) }, null)!.GetParameters()[0]) + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.AfterTests.GlobalCleanUpTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests)), + Name = "GlobalCleanUpTests", + Namespace = "TUnit.TestProject.AfterTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_AfterTests_GlobalCleanUpTests_AfterAllCleanUpWithContext__TestContext_AfterEvery_Test_Body, + FilePath = "", + LineNumber = 62 + } + ); + private static ValueTask TUnit_TestProject_AfterTests_GlobalCleanUpTests_AfterAllCleanUpWithContext__TestContext_AfterEvery_Test_Body(TestContext context, CancellationToken cancellationToken) { - await AsyncConvert.Convert(() => global::TUnit.TestProject.AfterTests.GlobalCleanUpTests.AfterAllCleanUpWithContext(context, cancellationToken)); + try + { + return new ValueTask(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests.AfterAllCleanUpWithContext(context)); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } } - } -} -namespace TUnit.Generated -{ - internal static partial class TUnit_HookRegistration - { static readonly int _h_TUnit_TestProject_AfterTests_GlobalCleanUpTests_AfterAllCleanUpWithContext__TestContext_CancellationToken_AfterEvery_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterEveryTestHooks, global::TUnit.Core.HookRegistrationIndices.GetNextAfterEveryTestHookIndex(), - static __registrationIndex => - new AfterTestHookMethod - { - MethodInfo = new global::TUnit.Core.MethodMetadata + static __registrationIndex => + new AfterTestHookMethod + { + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests)), + Name = "AfterAllCleanUpWithContext", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = new global::TUnit.Core.ParameterMetadata[] + { + global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::TUnit.Core.TestContext), "context", new global::TUnit.Core.ConcreteType(typeof(global::TUnit.Core.TestContext)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests).GetMethod("AfterAllCleanUpWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::TUnit.Core.TestContext), typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[0]), + global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::System.Threading.CancellationToken), "cancellationToken", new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.CancellationToken)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests).GetMethod("AfterAllCleanUpWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::TUnit.Core.TestContext), typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[1]) + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.AfterTests.GlobalCleanUpTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests)), + Name = "GlobalCleanUpTests", + Namespace = "TUnit.TestProject.AfterTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_AfterTests_GlobalCleanUpTests_AfterAllCleanUpWithContext__TestContext_CancellationToken_AfterEvery_Test_Body, + FilePath = "", + LineNumber = 68 + } + ); + private static ValueTask TUnit_TestProject_AfterTests_GlobalCleanUpTests_AfterAllCleanUpWithContext__TestContext_CancellationToken_AfterEvery_Test_Body(TestContext context, CancellationToken cancellationToken) { - Type = typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests)), - Name = "AfterAllCleanUpWithContext", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = new global::TUnit.Core.ParameterMetadata[] - { - global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::TUnit.Core.TestContext), "context", new global::TUnit.Core.ConcreteType(typeof(global::TUnit.Core.TestContext)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests).GetMethod("AfterAllCleanUpWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::TUnit.Core.TestContext), typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[0]), - global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::System.Threading.CancellationToken), "cancellationToken", new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.CancellationToken)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests).GetMethod("AfterAllCleanUpWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::TUnit.Core.TestContext), typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[1]) - }, - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.AfterTests.GlobalCleanUpTests", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests)), - Name = "GlobalCleanUpTests", - Namespace = "TUnit.TestProject.AfterTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_AfterTests_GlobalCleanUpTests_AfterAllCleanUpWithContext__TestContext_CancellationToken_AfterEvery_Test.TUnit_TestProject_AfterTests_GlobalCleanUpTests_AfterAllCleanUpWithContext__TestContext_CancellationToken_AfterEvery_TestInitializer.global_TUnit_TestProject_AfterTests_GlobalCleanUpTests_AfterAllCleanUpWithContext_2Params_Body, - FilePath = "", - LineNumber = 68 - } -); + try + { + return new ValueTask(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests.AfterAllCleanUpWithContext(context, cancellationToken)); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } + } } } diff --git a/tests/TUnit.Core.SourceGenerator.Tests/GlobalStaticBeforeEachTests.Test.verified.txt b/tests/TUnit.Core.SourceGenerator.Tests/GlobalStaticBeforeEachTests.Test.verified.txt index e7f3657d972..d33bc25ef63 100644 --- a/tests/TUnit.Core.SourceGenerator.Tests/GlobalStaticBeforeEachTests.Test.verified.txt +++ b/tests/TUnit.Core.SourceGenerator.Tests/GlobalStaticBeforeEachTests.Test.verified.txt @@ -4,206 +4,108 @@ #nullable enable #pragma warning disable CS9113 // Parameter is unread. using System; -using System.Collections.Generic; -using System.Linq; using System.Reflection; -using System.Runtime.CompilerServices; using System.Threading; using System.Threading.Tasks; using global::TUnit.Core; using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_GlobalBase1_BeforeEach1_Before_Test -{ - internal static class TUnit_TestProject_BeforeTests_GlobalBase1_BeforeEach1_Before_TestInitializer - { - internal static async ValueTask global_TUnit_TestProject_BeforeTests_GlobalBase1_BeforeEach1_0Params_Body(object instance, TestContext context, CancellationToken cancellationToken) - { - var typedInstance = (global::TUnit.TestProject.BeforeTests.GlobalBase1)instance; - await AsyncConvert.Convert(() => typedInstance.BeforeEach1()); - } - } -} namespace TUnit.Generated { internal static partial class TUnit_HookRegistration { static readonly int _h_TUnit_TestProject_BeforeTests_GlobalBase1_BeforeEach1_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.GlobalBase1), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), - static __registrationIndex => - new InstanceHookMethod - { - InitClassType = typeof(global::TUnit.TestProject.BeforeTests.GlobalBase1), - MethodInfo = new global::TUnit.Core.MethodMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.GlobalBase1), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.GlobalBase1)), - Name = "BeforeEach1", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = global::System.Array.Empty(), - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.GlobalBase1", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.GlobalBase1), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.GlobalBase1)), - Name = "GlobalBase1", - Namespace = "TUnit.TestProject.BeforeTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_GlobalBase1_BeforeEach1_Before_Test.TUnit_TestProject_BeforeTests_GlobalBase1_BeforeEach1_Before_TestInitializer.global_TUnit_TestProject_BeforeTests_GlobalBase1_BeforeEach1_0Params_Body - } -); - } -} - - -// ===== FILE SEPARATOR ===== - -// -#pragma warning disable - -#nullable enable -#pragma warning disable CS9113 // Parameter is unread. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Threading; -using System.Threading.Tasks; -using global::TUnit.Core; -using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_GlobalBase2_BeforeEach2_Before_Test -{ - internal static class TUnit_TestProject_BeforeTests_GlobalBase2_BeforeEach2_Before_TestInitializer - { - internal static async ValueTask global_TUnit_TestProject_BeforeTests_GlobalBase2_BeforeEach2_0Params_Body(object instance, TestContext context, CancellationToken cancellationToken) + static __registrationIndex => + new InstanceHookMethod + { + InitClassType = typeof(global::TUnit.TestProject.BeforeTests.GlobalBase1), + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.GlobalBase1), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.GlobalBase1)), + Name = "BeforeEach1", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = global::System.Array.Empty(), + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.GlobalBase1", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.GlobalBase1), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.GlobalBase1)), + Name = "GlobalBase1", + Namespace = "TUnit.TestProject.BeforeTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_BeforeTests_GlobalBase1_BeforeEach1_Before_Test_Body + } + ); + private static ValueTask TUnit_TestProject_BeforeTests_GlobalBase1_BeforeEach1_Before_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) { - var typedInstance = (global::TUnit.TestProject.BeforeTests.GlobalBase2)instance; - await AsyncConvert.Convert(() => typedInstance.BeforeEach2()); + try + { + var typedInstance = (global::TUnit.TestProject.BeforeTests.GlobalBase1)instance; + return new ValueTask(typedInstance.BeforeEach1()); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } } - } -} -namespace TUnit.Generated -{ - internal static partial class TUnit_HookRegistration - { - static readonly int _h_TUnit_TestProject_BeforeTests_GlobalBase2_BeforeEach2_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.GlobalBase2), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), - static __registrationIndex => - new InstanceHookMethod - { - InitClassType = typeof(global::TUnit.TestProject.BeforeTests.GlobalBase2), - MethodInfo = new global::TUnit.Core.MethodMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.GlobalBase2), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.GlobalBase2)), - Name = "BeforeEach2", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = global::System.Array.Empty(), - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.GlobalBase2", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.GlobalBase2), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.GlobalBase2)), - Name = "GlobalBase2", - Namespace = "TUnit.TestProject.BeforeTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_GlobalBase2_BeforeEach2_Before_Test.TUnit_TestProject_BeforeTests_GlobalBase2_BeforeEach2_Before_TestInitializer.global_TUnit_TestProject_BeforeTests_GlobalBase2_BeforeEach2_0Params_Body - } -); - } -} - - -// ===== FILE SEPARATOR ===== - -// -#pragma warning disable - -#nullable enable -#pragma warning disable CS9113 // Parameter is unread. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Threading; -using System.Threading.Tasks; -using global::TUnit.Core; -using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_GlobalBase3_BeforeEach3_Before_Test -{ - internal static class TUnit_TestProject_BeforeTests_GlobalBase3_BeforeEach3_Before_TestInitializer - { - internal static async ValueTask global_TUnit_TestProject_BeforeTests_GlobalBase3_BeforeEach3_0Params_Body(object instance, TestContext context, CancellationToken cancellationToken) + static readonly int _h_TUnit_TestProject_BeforeTests_GlobalBase1_BeforeAll1__TestContext_BeforeEvery_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeEveryTestHooks, global::TUnit.Core.HookRegistrationIndices.GetNextBeforeEveryTestHookIndex(), + static __registrationIndex => + new BeforeTestHookMethod + { + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.GlobalBase1), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.GlobalBase1)), + Name = "BeforeAll1", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = new global::TUnit.Core.ParameterMetadata[] + { + global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::TUnit.Core.TestContext), "context", new global::TUnit.Core.ConcreteType(typeof(global::TUnit.Core.TestContext)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.GlobalBase1).GetMethod("BeforeAll1", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::TUnit.Core.TestContext) }, null)!.GetParameters()[0]) + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.GlobalBase1", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.GlobalBase1), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.GlobalBase1)), + Name = "GlobalBase1", + Namespace = "TUnit.TestProject.BeforeTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_BeforeTests_GlobalBase1_BeforeAll1__TestContext_BeforeEvery_Test_Body, + FilePath = "", + LineNumber = 5 + } + ); + private static ValueTask TUnit_TestProject_BeforeTests_GlobalBase1_BeforeAll1__TestContext_BeforeEvery_Test_Body(TestContext context, CancellationToken cancellationToken) { - var typedInstance = (global::TUnit.TestProject.BeforeTests.GlobalBase3)instance; - await AsyncConvert.Convert(() => typedInstance.BeforeEach3()); + try + { + return new ValueTask(global::TUnit.TestProject.BeforeTests.GlobalBase1.BeforeAll1(context)); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } } } } -namespace TUnit.Generated -{ - internal static partial class TUnit_HookRegistration - { - static readonly int _h_TUnit_TestProject_BeforeTests_GlobalBase3_BeforeEach3_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.GlobalBase3), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), - static __registrationIndex => - new InstanceHookMethod - { - InitClassType = typeof(global::TUnit.TestProject.BeforeTests.GlobalBase3), - MethodInfo = new global::TUnit.Core.MethodMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.GlobalBase3), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.GlobalBase3)), - Name = "BeforeEach3", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = global::System.Array.Empty(), - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.GlobalBase3", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.GlobalBase3), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.GlobalBase3)), - Name = "GlobalBase3", - Namespace = "TUnit.TestProject.BeforeTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_GlobalBase3_BeforeEach3_Before_Test.TUnit_TestProject_BeforeTests_GlobalBase3_BeforeEach3_Before_TestInitializer.global_TUnit_TestProject_BeforeTests_GlobalBase3_BeforeEach3_0Params_Body - } -); - } -} // ===== FILE SEPARATOR ===== @@ -214,212 +116,108 @@ namespace TUnit.Generated #nullable enable #pragma warning disable CS9113 // Parameter is unread. using System; -using System.Collections.Generic; -using System.Linq; using System.Reflection; -using System.Runtime.CompilerServices; using System.Threading; using System.Threading.Tasks; using global::TUnit.Core; using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_GlobalSetUpTests_SetUp_Before_Test -{ - internal static class TUnit_TestProject_BeforeTests_GlobalSetUpTests_SetUp_Before_TestInitializer - { - internal static async ValueTask global_TUnit_TestProject_BeforeTests_GlobalSetUpTests_SetUp_0Params_Body(object instance, TestContext context, CancellationToken cancellationToken) - { - var typedInstance = (global::TUnit.TestProject.BeforeTests.GlobalSetUpTests)instance; - await AsyncConvert.Convert(() => typedInstance.SetUp()); - } - } -} namespace TUnit.Generated { internal static partial class TUnit_HookRegistration { - static readonly int _h_TUnit_TestProject_BeforeTests_GlobalSetUpTests_SetUp_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), - static __registrationIndex => - new InstanceHookMethod - { - InitClassType = typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests), - MethodInfo = new global::TUnit.Core.MethodMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests)), - Name = "SetUp", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = global::System.Array.Empty(), - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.GlobalSetUpTests", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests)), - Name = "GlobalSetUpTests", - Namespace = "TUnit.TestProject.BeforeTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_GlobalSetUpTests_SetUp_Before_Test.TUnit_TestProject_BeforeTests_GlobalSetUpTests_SetUp_Before_TestInitializer.global_TUnit_TestProject_BeforeTests_GlobalSetUpTests_SetUp_0Params_Body - } -); - } -} - - -// ===== FILE SEPARATOR ===== - -// -#pragma warning disable - -#nullable enable -#pragma warning disable CS9113 // Parameter is unread. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Threading; -using System.Threading.Tasks; -using global::TUnit.Core; -using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_GlobalSetUpTests_SetUp__CancellationToken_Before_Test -{ - internal static class TUnit_TestProject_BeforeTests_GlobalSetUpTests_SetUp__CancellationToken_Before_TestInitializer - { - internal static async ValueTask global_TUnit_TestProject_BeforeTests_GlobalSetUpTests_SetUp_1Params_Body(object instance, TestContext context, CancellationToken cancellationToken) + static readonly int _h_TUnit_TestProject_BeforeTests_GlobalBase2_BeforeEach2_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.GlobalBase2), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), + static __registrationIndex => + new InstanceHookMethod + { + InitClassType = typeof(global::TUnit.TestProject.BeforeTests.GlobalBase2), + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.GlobalBase2), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.GlobalBase2)), + Name = "BeforeEach2", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = global::System.Array.Empty(), + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.GlobalBase2", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.GlobalBase2), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.GlobalBase2)), + Name = "GlobalBase2", + Namespace = "TUnit.TestProject.BeforeTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_BeforeTests_GlobalBase2_BeforeEach2_Before_Test_Body + } + ); + private static ValueTask TUnit_TestProject_BeforeTests_GlobalBase2_BeforeEach2_Before_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) { - var typedInstance = (global::TUnit.TestProject.BeforeTests.GlobalSetUpTests)instance; - await AsyncConvert.Convert(() => typedInstance.SetUp(cancellationToken)); + try + { + var typedInstance = (global::TUnit.TestProject.BeforeTests.GlobalBase2)instance; + return new ValueTask(typedInstance.BeforeEach2()); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } } - } -} -namespace TUnit.Generated -{ - internal static partial class TUnit_HookRegistration - { - static readonly int _h_TUnit_TestProject_BeforeTests_GlobalSetUpTests_SetUp__CancellationToken_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), - static __registrationIndex => - new InstanceHookMethod - { - InitClassType = typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests), - MethodInfo = new global::TUnit.Core.MethodMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests)), - Name = "SetUp", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = new global::TUnit.Core.ParameterMetadata[] - { - global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::System.Threading.CancellationToken), "cancellationToken", new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.CancellationToken)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests).GetMethod("SetUp", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[0]) - }, - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.GlobalSetUpTests", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests)), - Name = "GlobalSetUpTests", - Namespace = "TUnit.TestProject.BeforeTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_GlobalSetUpTests_SetUp__CancellationToken_Before_Test.TUnit_TestProject_BeforeTests_GlobalSetUpTests_SetUp__CancellationToken_Before_TestInitializer.global_TUnit_TestProject_BeforeTests_GlobalSetUpTests_SetUp_1Params_Body - } -); - } -} - - -// ===== FILE SEPARATOR ===== - -// -#pragma warning disable - -#nullable enable -#pragma warning disable CS9113 // Parameter is unread. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Threading; -using System.Threading.Tasks; -using global::TUnit.Core; -using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_GlobalSetUpTests_SetUpWithContext__TestContext_Before_Test -{ - internal static class TUnit_TestProject_BeforeTests_GlobalSetUpTests_SetUpWithContext__TestContext_Before_TestInitializer - { - internal static async ValueTask global_TUnit_TestProject_BeforeTests_GlobalSetUpTests_SetUpWithContext_1Params_Body(object instance, TestContext context, CancellationToken cancellationToken) + static readonly int _h_TUnit_TestProject_BeforeTests_GlobalBase2_BeforeAll2__TestContext_BeforeEvery_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeEveryTestHooks, global::TUnit.Core.HookRegistrationIndices.GetNextBeforeEveryTestHookIndex(), + static __registrationIndex => + new BeforeTestHookMethod + { + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.GlobalBase2), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.GlobalBase2)), + Name = "BeforeAll2", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = new global::TUnit.Core.ParameterMetadata[] + { + global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::TUnit.Core.TestContext), "context", new global::TUnit.Core.ConcreteType(typeof(global::TUnit.Core.TestContext)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.GlobalBase2).GetMethod("BeforeAll2", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::TUnit.Core.TestContext) }, null)!.GetParameters()[0]) + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.GlobalBase2", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.GlobalBase2), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.GlobalBase2)), + Name = "GlobalBase2", + Namespace = "TUnit.TestProject.BeforeTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_BeforeTests_GlobalBase2_BeforeAll2__TestContext_BeforeEvery_Test_Body, + FilePath = "", + LineNumber = 20 + } + ); + private static ValueTask TUnit_TestProject_BeforeTests_GlobalBase2_BeforeAll2__TestContext_BeforeEvery_Test_Body(TestContext context, CancellationToken cancellationToken) { - var typedInstance = (global::TUnit.TestProject.BeforeTests.GlobalSetUpTests)instance; - await AsyncConvert.Convert(() => typedInstance.SetUpWithContext(context)); + try + { + return new ValueTask(global::TUnit.TestProject.BeforeTests.GlobalBase2.BeforeAll2(context)); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } } } } -namespace TUnit.Generated -{ - internal static partial class TUnit_HookRegistration - { - static readonly int _h_TUnit_TestProject_BeforeTests_GlobalSetUpTests_SetUpWithContext__TestContext_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), - static __registrationIndex => - new InstanceHookMethod - { - InitClassType = typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests), - MethodInfo = new global::TUnit.Core.MethodMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests)), - Name = "SetUpWithContext", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = new global::TUnit.Core.ParameterMetadata[] - { - global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::TUnit.Core.TestContext), "testContext", new global::TUnit.Core.ConcreteType(typeof(global::TUnit.Core.TestContext)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests).GetMethod("SetUpWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(global::TUnit.Core.TestContext) }, null)!.GetParameters()[0]) - }, - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.GlobalSetUpTests", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests)), - Name = "GlobalSetUpTests", - Namespace = "TUnit.TestProject.BeforeTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_GlobalSetUpTests_SetUpWithContext__TestContext_Before_Test.TUnit_TestProject_BeforeTests_GlobalSetUpTests_SetUpWithContext__TestContext_Before_TestInitializer.global_TUnit_TestProject_BeforeTests_GlobalSetUpTests_SetUpWithContext_1Params_Body - } -); - } -} // ===== FILE SEPARATOR ===== @@ -430,141 +228,106 @@ namespace TUnit.Generated #nullable enable #pragma warning disable CS9113 // Parameter is unread. using System; -using System.Collections.Generic; -using System.Linq; using System.Reflection; -using System.Runtime.CompilerServices; using System.Threading; using System.Threading.Tasks; using global::TUnit.Core; using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_GlobalSetUpTests_SetUpWithContext__TestContext_CancellationToken_Before_Test -{ - internal static class TUnit_TestProject_BeforeTests_GlobalSetUpTests_SetUpWithContext__TestContext_CancellationToken_Before_TestInitializer - { - internal static async ValueTask global_TUnit_TestProject_BeforeTests_GlobalSetUpTests_SetUpWithContext_2Params_Body(object instance, TestContext context, CancellationToken cancellationToken) - { - var typedInstance = (global::TUnit.TestProject.BeforeTests.GlobalSetUpTests)instance; - await AsyncConvert.Convert(() => typedInstance.SetUpWithContext(context, cancellationToken)); - } - } -} namespace TUnit.Generated { internal static partial class TUnit_HookRegistration { - static readonly int _h_TUnit_TestProject_BeforeTests_GlobalSetUpTests_SetUpWithContext__TestContext_CancellationToken_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), - static __registrationIndex => - new InstanceHookMethod - { - InitClassType = typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests), - MethodInfo = new global::TUnit.Core.MethodMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests)), - Name = "SetUpWithContext", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = new global::TUnit.Core.ParameterMetadata[] - { - global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::TUnit.Core.TestContext), "testContext", new global::TUnit.Core.ConcreteType(typeof(global::TUnit.Core.TestContext)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests).GetMethod("SetUpWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(global::TUnit.Core.TestContext), typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[0]), - global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::System.Threading.CancellationToken), "cancellationToken", new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.CancellationToken)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests).GetMethod("SetUpWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(global::TUnit.Core.TestContext), typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[1]) - }, - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.GlobalSetUpTests", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests)), - Name = "GlobalSetUpTests", - Namespace = "TUnit.TestProject.BeforeTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_GlobalSetUpTests_SetUpWithContext__TestContext_CancellationToken_Before_Test.TUnit_TestProject_BeforeTests_GlobalSetUpTests_SetUpWithContext__TestContext_CancellationToken_Before_TestInitializer.global_TUnit_TestProject_BeforeTests_GlobalSetUpTests_SetUpWithContext_2Params_Body - } -); - } -} - - -// ===== FILE SEPARATOR ===== - -// -#pragma warning disable - -#nullable enable -#pragma warning disable CS9113 // Parameter is unread. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Threading; -using System.Threading.Tasks; -using global::TUnit.Core; -using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_GlobalBase1_BeforeAll1__TestContext_BeforeEvery_Test -{ - internal static class TUnit_TestProject_BeforeTests_GlobalBase1_BeforeAll1__TestContext_BeforeEvery_TestInitializer - { - internal static async ValueTask global_TUnit_TestProject_BeforeTests_GlobalBase1_BeforeAll1_1Params_Body(TestContext context, CancellationToken cancellationToken) + static readonly int _h_TUnit_TestProject_BeforeTests_GlobalBase3_BeforeEach3_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.GlobalBase3), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), + static __registrationIndex => + new InstanceHookMethod + { + InitClassType = typeof(global::TUnit.TestProject.BeforeTests.GlobalBase3), + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.GlobalBase3), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.GlobalBase3)), + Name = "BeforeEach3", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = global::System.Array.Empty(), + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.GlobalBase3", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.GlobalBase3), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.GlobalBase3)), + Name = "GlobalBase3", + Namespace = "TUnit.TestProject.BeforeTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_BeforeTests_GlobalBase3_BeforeEach3_Before_Test_Body + } + ); + private static ValueTask TUnit_TestProject_BeforeTests_GlobalBase3_BeforeEach3_Before_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) { - await AsyncConvert.Convert(() => global::TUnit.TestProject.BeforeTests.GlobalBase1.BeforeAll1(context)); + try + { + var typedInstance = (global::TUnit.TestProject.BeforeTests.GlobalBase3)instance; + return new ValueTask(typedInstance.BeforeEach3()); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } } - } -} -namespace TUnit.Generated -{ - internal static partial class TUnit_HookRegistration - { - static readonly int _h_TUnit_TestProject_BeforeTests_GlobalBase1_BeforeAll1__TestContext_BeforeEvery_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeEveryTestHooks, global::TUnit.Core.HookRegistrationIndices.GetNextBeforeEveryTestHookIndex(), - static __registrationIndex => - new BeforeTestHookMethod - { - MethodInfo = new global::TUnit.Core.MethodMetadata + static readonly int _h_TUnit_TestProject_BeforeTests_GlobalBase3_BeforeAll3__TestContext_BeforeEvery_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeEveryTestHooks, global::TUnit.Core.HookRegistrationIndices.GetNextBeforeEveryTestHookIndex(), + static __registrationIndex => + new BeforeTestHookMethod + { + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.GlobalBase3), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.GlobalBase3)), + Name = "BeforeAll3", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = new global::TUnit.Core.ParameterMetadata[] + { + global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::TUnit.Core.TestContext), "context", new global::TUnit.Core.ConcreteType(typeof(global::TUnit.Core.TestContext)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.GlobalBase3).GetMethod("BeforeAll3", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::TUnit.Core.TestContext) }, null)!.GetParameters()[0]) + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.GlobalBase3", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.GlobalBase3), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.GlobalBase3)), + Name = "GlobalBase3", + Namespace = "TUnit.TestProject.BeforeTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_BeforeTests_GlobalBase3_BeforeAll3__TestContext_BeforeEvery_Test_Body, + FilePath = "", + LineNumber = 35 + } + ); + private static ValueTask TUnit_TestProject_BeforeTests_GlobalBase3_BeforeAll3__TestContext_BeforeEvery_Test_Body(TestContext context, CancellationToken cancellationToken) { - Type = typeof(global::TUnit.TestProject.BeforeTests.GlobalBase1), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.GlobalBase1)), - Name = "BeforeAll1", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = new global::TUnit.Core.ParameterMetadata[] - { - global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::TUnit.Core.TestContext), "context", new global::TUnit.Core.ConcreteType(typeof(global::TUnit.Core.TestContext)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.GlobalBase1).GetMethod("BeforeAll1", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::TUnit.Core.TestContext) }, null)!.GetParameters()[0]) - }, - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.GlobalBase1", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.GlobalBase1), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.GlobalBase1)), - Name = "GlobalBase1", - Namespace = "TUnit.TestProject.BeforeTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_GlobalBase1_BeforeAll1__TestContext_BeforeEvery_Test.TUnit_TestProject_BeforeTests_GlobalBase1_BeforeAll1__TestContext_BeforeEvery_TestInitializer.global_TUnit_TestProject_BeforeTests_GlobalBase1_BeforeAll1_1Params_Body, - FilePath = "", - LineNumber = 5 - } -); + try + { + return new ValueTask(global::TUnit.TestProject.BeforeTests.GlobalBase3.BeforeAll3(context)); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } + } } } @@ -577,433 +340,390 @@ namespace TUnit.Generated #nullable enable #pragma warning disable CS9113 // Parameter is unread. using System; -using System.Collections.Generic; -using System.Linq; using System.Reflection; -using System.Runtime.CompilerServices; using System.Threading; using System.Threading.Tasks; using global::TUnit.Core; using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_GlobalBase2_BeforeAll2__TestContext_BeforeEvery_Test -{ - internal static class TUnit_TestProject_BeforeTests_GlobalBase2_BeforeAll2__TestContext_BeforeEvery_TestInitializer - { - internal static async ValueTask global_TUnit_TestProject_BeforeTests_GlobalBase2_BeforeAll2_1Params_Body(TestContext context, CancellationToken cancellationToken) - { - await AsyncConvert.Convert(() => global::TUnit.TestProject.BeforeTests.GlobalBase2.BeforeAll2(context)); - } - } -} namespace TUnit.Generated { internal static partial class TUnit_HookRegistration { - static readonly int _h_TUnit_TestProject_BeforeTests_GlobalBase2_BeforeAll2__TestContext_BeforeEvery_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeEveryTestHooks, global::TUnit.Core.HookRegistrationIndices.GetNextBeforeEveryTestHookIndex(), - static __registrationIndex => - new BeforeTestHookMethod - { - MethodInfo = new global::TUnit.Core.MethodMetadata + static readonly int _h_TUnit_TestProject_BeforeTests_GlobalSetUpTests_SetUp_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), + static __registrationIndex => + new InstanceHookMethod + { + InitClassType = typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests), + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests)), + Name = "SetUp", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = global::System.Array.Empty(), + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.GlobalSetUpTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests)), + Name = "GlobalSetUpTests", + Namespace = "TUnit.TestProject.BeforeTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_BeforeTests_GlobalSetUpTests_SetUp_Before_Test_Body + } + ); + private static ValueTask TUnit_TestProject_BeforeTests_GlobalSetUpTests_SetUp_Before_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) { - Type = typeof(global::TUnit.TestProject.BeforeTests.GlobalBase2), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.GlobalBase2)), - Name = "BeforeAll2", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = new global::TUnit.Core.ParameterMetadata[] - { - global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::TUnit.Core.TestContext), "context", new global::TUnit.Core.ConcreteType(typeof(global::TUnit.Core.TestContext)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.GlobalBase2).GetMethod("BeforeAll2", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::TUnit.Core.TestContext) }, null)!.GetParameters()[0]) - }, - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.GlobalBase2", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.GlobalBase2), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.GlobalBase2)), - Name = "GlobalBase2", - Namespace = "TUnit.TestProject.BeforeTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_GlobalBase2_BeforeAll2__TestContext_BeforeEvery_Test.TUnit_TestProject_BeforeTests_GlobalBase2_BeforeAll2__TestContext_BeforeEvery_TestInitializer.global_TUnit_TestProject_BeforeTests_GlobalBase2_BeforeAll2_1Params_Body, - FilePath = "", - LineNumber = 20 - } -); - } -} - - -// ===== FILE SEPARATOR ===== - -// -#pragma warning disable - -#nullable enable -#pragma warning disable CS9113 // Parameter is unread. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Threading; -using System.Threading.Tasks; -using global::TUnit.Core; -using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_GlobalBase3_BeforeAll3__TestContext_BeforeEvery_Test -{ - internal static class TUnit_TestProject_BeforeTests_GlobalBase3_BeforeAll3__TestContext_BeforeEvery_TestInitializer - { - internal static async ValueTask global_TUnit_TestProject_BeforeTests_GlobalBase3_BeforeAll3_1Params_Body(TestContext context, CancellationToken cancellationToken) + try + { + var typedInstance = (global::TUnit.TestProject.BeforeTests.GlobalSetUpTests)instance; + return new ValueTask(typedInstance.SetUp()); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } + } + static readonly int _h_TUnit_TestProject_BeforeTests_GlobalSetUpTests_SetUp__CancellationToken_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), + static __registrationIndex => + new InstanceHookMethod + { + InitClassType = typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests), + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests)), + Name = "SetUp", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = new global::TUnit.Core.ParameterMetadata[] + { + global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::System.Threading.CancellationToken), "cancellationToken", new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.CancellationToken)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests).GetMethod("SetUp", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[0]) + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.GlobalSetUpTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests)), + Name = "GlobalSetUpTests", + Namespace = "TUnit.TestProject.BeforeTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_BeforeTests_GlobalSetUpTests_SetUp__CancellationToken_Before_Test_Body + } + ); + private static ValueTask TUnit_TestProject_BeforeTests_GlobalSetUpTests_SetUp__CancellationToken_Before_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) { - await AsyncConvert.Convert(() => global::TUnit.TestProject.BeforeTests.GlobalBase3.BeforeAll3(context)); + try + { + var typedInstance = (global::TUnit.TestProject.BeforeTests.GlobalSetUpTests)instance; + return new ValueTask(typedInstance.SetUp(cancellationToken)); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } } - } -} -namespace TUnit.Generated -{ - internal static partial class TUnit_HookRegistration - { - static readonly int _h_TUnit_TestProject_BeforeTests_GlobalBase3_BeforeAll3__TestContext_BeforeEvery_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeEveryTestHooks, global::TUnit.Core.HookRegistrationIndices.GetNextBeforeEveryTestHookIndex(), - static __registrationIndex => - new BeforeTestHookMethod - { - MethodInfo = new global::TUnit.Core.MethodMetadata + static readonly int _h_TUnit_TestProject_BeforeTests_GlobalSetUpTests_SetUpWithContext__TestContext_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), + static __registrationIndex => + new InstanceHookMethod + { + InitClassType = typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests), + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests)), + Name = "SetUpWithContext", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = new global::TUnit.Core.ParameterMetadata[] + { + global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::TUnit.Core.TestContext), "testContext", new global::TUnit.Core.ConcreteType(typeof(global::TUnit.Core.TestContext)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests).GetMethod("SetUpWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(global::TUnit.Core.TestContext) }, null)!.GetParameters()[0]) + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.GlobalSetUpTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests)), + Name = "GlobalSetUpTests", + Namespace = "TUnit.TestProject.BeforeTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_BeforeTests_GlobalSetUpTests_SetUpWithContext__TestContext_Before_Test_Body + } + ); + private static ValueTask TUnit_TestProject_BeforeTests_GlobalSetUpTests_SetUpWithContext__TestContext_Before_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) { - Type = typeof(global::TUnit.TestProject.BeforeTests.GlobalBase3), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.GlobalBase3)), - Name = "BeforeAll3", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = new global::TUnit.Core.ParameterMetadata[] - { - global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::TUnit.Core.TestContext), "context", new global::TUnit.Core.ConcreteType(typeof(global::TUnit.Core.TestContext)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.GlobalBase3).GetMethod("BeforeAll3", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::TUnit.Core.TestContext) }, null)!.GetParameters()[0]) - }, - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.GlobalBase3", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.GlobalBase3), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.GlobalBase3)), - Name = "GlobalBase3", - Namespace = "TUnit.TestProject.BeforeTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_GlobalBase3_BeforeAll3__TestContext_BeforeEvery_Test.TUnit_TestProject_BeforeTests_GlobalBase3_BeforeAll3__TestContext_BeforeEvery_TestInitializer.global_TUnit_TestProject_BeforeTests_GlobalBase3_BeforeAll3_1Params_Body, - FilePath = "", - LineNumber = 35 - } -); - } -} - - -// ===== FILE SEPARATOR ===== - -// -#pragma warning disable - -#nullable enable -#pragma warning disable CS9113 // Parameter is unread. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Threading; -using System.Threading.Tasks; -using global::TUnit.Core; -using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_GlobalSetUpTests_BeforeAllSetUp__TestContext_BeforeEvery_Test -{ - internal static class TUnit_TestProject_BeforeTests_GlobalSetUpTests_BeforeAllSetUp__TestContext_BeforeEvery_TestInitializer - { - internal static async ValueTask global_TUnit_TestProject_BeforeTests_GlobalSetUpTests_BeforeAllSetUp_1Params_Body(TestContext context, CancellationToken cancellationToken) + try + { + var typedInstance = (global::TUnit.TestProject.BeforeTests.GlobalSetUpTests)instance; + return new ValueTask(typedInstance.SetUpWithContext(context)); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } + } + static readonly int _h_TUnit_TestProject_BeforeTests_GlobalSetUpTests_SetUpWithContext__TestContext_CancellationToken_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), + static __registrationIndex => + new InstanceHookMethod + { + InitClassType = typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests), + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests)), + Name = "SetUpWithContext", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = new global::TUnit.Core.ParameterMetadata[] + { + global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::TUnit.Core.TestContext), "testContext", new global::TUnit.Core.ConcreteType(typeof(global::TUnit.Core.TestContext)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests).GetMethod("SetUpWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(global::TUnit.Core.TestContext), typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[0]), + global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::System.Threading.CancellationToken), "cancellationToken", new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.CancellationToken)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests).GetMethod("SetUpWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(global::TUnit.Core.TestContext), typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[1]) + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.GlobalSetUpTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests)), + Name = "GlobalSetUpTests", + Namespace = "TUnit.TestProject.BeforeTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_BeforeTests_GlobalSetUpTests_SetUpWithContext__TestContext_CancellationToken_Before_Test_Body + } + ); + private static ValueTask TUnit_TestProject_BeforeTests_GlobalSetUpTests_SetUpWithContext__TestContext_CancellationToken_Before_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) { - await AsyncConvert.Convert(() => global::TUnit.TestProject.BeforeTests.GlobalSetUpTests.BeforeAllSetUp(context)); + try + { + var typedInstance = (global::TUnit.TestProject.BeforeTests.GlobalSetUpTests)instance; + return new ValueTask(typedInstance.SetUpWithContext(context, cancellationToken)); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } } - } -} -namespace TUnit.Generated -{ - internal static partial class TUnit_HookRegistration - { static readonly int _h_TUnit_TestProject_BeforeTests_GlobalSetUpTests_BeforeAllSetUp__TestContext_BeforeEvery_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeEveryTestHooks, global::TUnit.Core.HookRegistrationIndices.GetNextBeforeEveryTestHookIndex(), - static __registrationIndex => - new BeforeTestHookMethod - { - MethodInfo = new global::TUnit.Core.MethodMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests)), - Name = "BeforeAllSetUp", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = new global::TUnit.Core.ParameterMetadata[] - { - global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::TUnit.Core.TestContext), "context", new global::TUnit.Core.ConcreteType(typeof(global::TUnit.Core.TestContext)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests).GetMethod("BeforeAllSetUp", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::TUnit.Core.TestContext) }, null)!.GetParameters()[0]) - }, - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.GlobalSetUpTests", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests)), - Name = "GlobalSetUpTests", - Namespace = "TUnit.TestProject.BeforeTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_GlobalSetUpTests_BeforeAllSetUp__TestContext_BeforeEvery_Test.TUnit_TestProject_BeforeTests_GlobalSetUpTests_BeforeAllSetUp__TestContext_BeforeEvery_TestInitializer.global_TUnit_TestProject_BeforeTests_GlobalSetUpTests_BeforeAllSetUp_1Params_Body, - FilePath = "", - LineNumber = 50 - } -); - } -} - - -// ===== FILE SEPARATOR ===== - -// -#pragma warning disable - -#nullable enable -#pragma warning disable CS9113 // Parameter is unread. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Threading; -using System.Threading.Tasks; -using global::TUnit.Core; -using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_GlobalSetUpTests_BeforeAllSetUp__TestContext_CancellationToken_BeforeEvery_Test -{ - internal static class TUnit_TestProject_BeforeTests_GlobalSetUpTests_BeforeAllSetUp__TestContext_CancellationToken_BeforeEvery_TestInitializer - { - internal static async ValueTask global_TUnit_TestProject_BeforeTests_GlobalSetUpTests_BeforeAllSetUp_2Params_Body(TestContext context, CancellationToken cancellationToken) + static __registrationIndex => + new BeforeTestHookMethod + { + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests)), + Name = "BeforeAllSetUp", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = new global::TUnit.Core.ParameterMetadata[] + { + global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::TUnit.Core.TestContext), "context", new global::TUnit.Core.ConcreteType(typeof(global::TUnit.Core.TestContext)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests).GetMethod("BeforeAllSetUp", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::TUnit.Core.TestContext) }, null)!.GetParameters()[0]) + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.GlobalSetUpTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests)), + Name = "GlobalSetUpTests", + Namespace = "TUnit.TestProject.BeforeTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_BeforeTests_GlobalSetUpTests_BeforeAllSetUp__TestContext_BeforeEvery_Test_Body, + FilePath = "", + LineNumber = 50 + } + ); + private static ValueTask TUnit_TestProject_BeforeTests_GlobalSetUpTests_BeforeAllSetUp__TestContext_BeforeEvery_Test_Body(TestContext context, CancellationToken cancellationToken) { - await AsyncConvert.Convert(() => global::TUnit.TestProject.BeforeTests.GlobalSetUpTests.BeforeAllSetUp(context, cancellationToken)); + try + { + return new ValueTask(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests.BeforeAllSetUp(context)); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } } - } -} -namespace TUnit.Generated -{ - internal static partial class TUnit_HookRegistration - { static readonly int _h_TUnit_TestProject_BeforeTests_GlobalSetUpTests_BeforeAllSetUp__TestContext_CancellationToken_BeforeEvery_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeEveryTestHooks, global::TUnit.Core.HookRegistrationIndices.GetNextBeforeEveryTestHookIndex(), - static __registrationIndex => - new BeforeTestHookMethod - { - MethodInfo = new global::TUnit.Core.MethodMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests)), - Name = "BeforeAllSetUp", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = new global::TUnit.Core.ParameterMetadata[] - { - global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::TUnit.Core.TestContext), "context", new global::TUnit.Core.ConcreteType(typeof(global::TUnit.Core.TestContext)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests).GetMethod("BeforeAllSetUp", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::TUnit.Core.TestContext), typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[0]), - global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::System.Threading.CancellationToken), "cancellationToken", new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.CancellationToken)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests).GetMethod("BeforeAllSetUp", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::TUnit.Core.TestContext), typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[1]) - }, - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.GlobalSetUpTests", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests)), - Name = "GlobalSetUpTests", - Namespace = "TUnit.TestProject.BeforeTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_GlobalSetUpTests_BeforeAllSetUp__TestContext_CancellationToken_BeforeEvery_Test.TUnit_TestProject_BeforeTests_GlobalSetUpTests_BeforeAllSetUp__TestContext_CancellationToken_BeforeEvery_TestInitializer.global_TUnit_TestProject_BeforeTests_GlobalSetUpTests_BeforeAllSetUp_2Params_Body, - FilePath = "", - LineNumber = 56 - } -); - } -} - - -// ===== FILE SEPARATOR ===== - -// -#pragma warning disable - -#nullable enable -#pragma warning disable CS9113 // Parameter is unread. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Threading; -using System.Threading.Tasks; -using global::TUnit.Core; -using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_GlobalSetUpTests_BeforeAllSetUpWithContext__TestContext_BeforeEvery_Test -{ - internal static class TUnit_TestProject_BeforeTests_GlobalSetUpTests_BeforeAllSetUpWithContext__TestContext_BeforeEvery_TestInitializer - { - internal static async ValueTask global_TUnit_TestProject_BeforeTests_GlobalSetUpTests_BeforeAllSetUpWithContext_1Params_Body(TestContext context, CancellationToken cancellationToken) + static __registrationIndex => + new BeforeTestHookMethod + { + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests)), + Name = "BeforeAllSetUp", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = new global::TUnit.Core.ParameterMetadata[] + { + global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::TUnit.Core.TestContext), "context", new global::TUnit.Core.ConcreteType(typeof(global::TUnit.Core.TestContext)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests).GetMethod("BeforeAllSetUp", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::TUnit.Core.TestContext), typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[0]), + global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::System.Threading.CancellationToken), "cancellationToken", new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.CancellationToken)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests).GetMethod("BeforeAllSetUp", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::TUnit.Core.TestContext), typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[1]) + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.GlobalSetUpTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests)), + Name = "GlobalSetUpTests", + Namespace = "TUnit.TestProject.BeforeTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_BeforeTests_GlobalSetUpTests_BeforeAllSetUp__TestContext_CancellationToken_BeforeEvery_Test_Body, + FilePath = "", + LineNumber = 56 + } + ); + private static ValueTask TUnit_TestProject_BeforeTests_GlobalSetUpTests_BeforeAllSetUp__TestContext_CancellationToken_BeforeEvery_Test_Body(TestContext context, CancellationToken cancellationToken) { - await AsyncConvert.Convert(() => global::TUnit.TestProject.BeforeTests.GlobalSetUpTests.BeforeAllSetUpWithContext(context)); + try + { + return new ValueTask(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests.BeforeAllSetUp(context, cancellationToken)); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } } - } -} -namespace TUnit.Generated -{ - internal static partial class TUnit_HookRegistration - { static readonly int _h_TUnit_TestProject_BeforeTests_GlobalSetUpTests_BeforeAllSetUpWithContext__TestContext_BeforeEvery_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeEveryTestHooks, global::TUnit.Core.HookRegistrationIndices.GetNextBeforeEveryTestHookIndex(), - static __registrationIndex => - new BeforeTestHookMethod - { - MethodInfo = new global::TUnit.Core.MethodMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests)), - Name = "BeforeAllSetUpWithContext", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = new global::TUnit.Core.ParameterMetadata[] - { - global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::TUnit.Core.TestContext), "context", new global::TUnit.Core.ConcreteType(typeof(global::TUnit.Core.TestContext)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests).GetMethod("BeforeAllSetUpWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::TUnit.Core.TestContext) }, null)!.GetParameters()[0]) - }, - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.GlobalSetUpTests", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests)), - Name = "GlobalSetUpTests", - Namespace = "TUnit.TestProject.BeforeTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_GlobalSetUpTests_BeforeAllSetUpWithContext__TestContext_BeforeEvery_Test.TUnit_TestProject_BeforeTests_GlobalSetUpTests_BeforeAllSetUpWithContext__TestContext_BeforeEvery_TestInitializer.global_TUnit_TestProject_BeforeTests_GlobalSetUpTests_BeforeAllSetUpWithContext_1Params_Body, - FilePath = "", - LineNumber = 62 - } -); - } -} - - -// ===== FILE SEPARATOR ===== - -// -#pragma warning disable - -#nullable enable -#pragma warning disable CS9113 // Parameter is unread. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Threading; -using System.Threading.Tasks; -using global::TUnit.Core; -using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_GlobalSetUpTests_BeforeAllSetUpWithContext__TestContext_CancellationToken_BeforeEvery_Test -{ - internal static class TUnit_TestProject_BeforeTests_GlobalSetUpTests_BeforeAllSetUpWithContext__TestContext_CancellationToken_BeforeEvery_TestInitializer - { - internal static async ValueTask global_TUnit_TestProject_BeforeTests_GlobalSetUpTests_BeforeAllSetUpWithContext_2Params_Body(TestContext context, CancellationToken cancellationToken) + static __registrationIndex => + new BeforeTestHookMethod + { + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests)), + Name = "BeforeAllSetUpWithContext", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = new global::TUnit.Core.ParameterMetadata[] + { + global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::TUnit.Core.TestContext), "context", new global::TUnit.Core.ConcreteType(typeof(global::TUnit.Core.TestContext)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests).GetMethod("BeforeAllSetUpWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::TUnit.Core.TestContext) }, null)!.GetParameters()[0]) + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.GlobalSetUpTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests)), + Name = "GlobalSetUpTests", + Namespace = "TUnit.TestProject.BeforeTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_BeforeTests_GlobalSetUpTests_BeforeAllSetUpWithContext__TestContext_BeforeEvery_Test_Body, + FilePath = "", + LineNumber = 62 + } + ); + private static ValueTask TUnit_TestProject_BeforeTests_GlobalSetUpTests_BeforeAllSetUpWithContext__TestContext_BeforeEvery_Test_Body(TestContext context, CancellationToken cancellationToken) { - await AsyncConvert.Convert(() => global::TUnit.TestProject.BeforeTests.GlobalSetUpTests.BeforeAllSetUpWithContext(context, cancellationToken)); + try + { + return new ValueTask(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests.BeforeAllSetUpWithContext(context)); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } } - } -} -namespace TUnit.Generated -{ - internal static partial class TUnit_HookRegistration - { static readonly int _h_TUnit_TestProject_BeforeTests_GlobalSetUpTests_BeforeAllSetUpWithContext__TestContext_CancellationToken_BeforeEvery_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeEveryTestHooks, global::TUnit.Core.HookRegistrationIndices.GetNextBeforeEveryTestHookIndex(), - static __registrationIndex => - new BeforeTestHookMethod - { - MethodInfo = new global::TUnit.Core.MethodMetadata + static __registrationIndex => + new BeforeTestHookMethod + { + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests)), + Name = "BeforeAllSetUpWithContext", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), + Parameters = new global::TUnit.Core.ParameterMetadata[] + { + global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::TUnit.Core.TestContext), "context", new global::TUnit.Core.ConcreteType(typeof(global::TUnit.Core.TestContext)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests).GetMethod("BeforeAllSetUpWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::TUnit.Core.TestContext), typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[0]), + global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::System.Threading.CancellationToken), "cancellationToken", new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.CancellationToken)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests).GetMethod("BeforeAllSetUpWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::TUnit.Core.TestContext), typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[1]) + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.GlobalSetUpTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests)), + Name = "GlobalSetUpTests", + Namespace = "TUnit.TestProject.BeforeTests", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_BeforeTests_GlobalSetUpTests_BeforeAllSetUpWithContext__TestContext_CancellationToken_BeforeEvery_Test_Body, + FilePath = "", + LineNumber = 68 + } + ); + private static ValueTask TUnit_TestProject_BeforeTests_GlobalSetUpTests_BeforeAllSetUpWithContext__TestContext_CancellationToken_BeforeEvery_Test_Body(TestContext context, CancellationToken cancellationToken) { - Type = typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests)), - Name = "BeforeAllSetUpWithContext", - GenericTypeCount = 0, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), - Parameters = new global::TUnit.Core.ParameterMetadata[] - { - global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::TUnit.Core.TestContext), "context", new global::TUnit.Core.ConcreteType(typeof(global::TUnit.Core.TestContext)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests).GetMethod("BeforeAllSetUpWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::TUnit.Core.TestContext), typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[0]), - global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::System.Threading.CancellationToken), "cancellationToken", new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.CancellationToken)), false, reflectionInfoFactory: static () => typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests).GetMethod("BeforeAllSetUpWithContext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::TUnit.Core.TestContext), typeof(global::System.Threading.CancellationToken) }, null)!.GetParameters()[1]) - }, - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BeforeTests.GlobalSetUpTests", new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests)), - Name = "GlobalSetUpTests", - Namespace = "TUnit.TestProject.BeforeTests", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_BeforeTests_GlobalSetUpTests_BeforeAllSetUpWithContext__TestContext_CancellationToken_BeforeEvery_Test.TUnit_TestProject_BeforeTests_GlobalSetUpTests_BeforeAllSetUpWithContext__TestContext_CancellationToken_BeforeEvery_TestInitializer.global_TUnit_TestProject_BeforeTests_GlobalSetUpTests_BeforeAllSetUpWithContext_2Params_Body, - FilePath = "", - LineNumber = 68 - } -); + try + { + return new ValueTask(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests.BeforeAllSetUpWithContext(context, cancellationToken)); + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } + } } } diff --git a/tests/TUnit.Core.SourceGenerator.Tests/HooksTests.DisposableFieldTests.verified.txt b/tests/TUnit.Core.SourceGenerator.Tests/HooksTests.DisposableFieldTests.verified.txt index 5f70da39470..6c4ca633431 100644 --- a/tests/TUnit.Core.SourceGenerator.Tests/HooksTests.DisposableFieldTests.verified.txt +++ b/tests/TUnit.Core.SourceGenerator.Tests/HooksTests.DisposableFieldTests.verified.txt @@ -4,133 +4,104 @@ #nullable enable #pragma warning disable CS9113 // Parameter is unread. using System; -using System.Collections.Generic; -using System.Linq; using System.Reflection; -using System.Runtime.CompilerServices; using System.Threading; using System.Threading.Tasks; using global::TUnit.Core; using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_DisposableFieldTests_Setup_Before_Test -{ - internal static class TUnit_TestProject_DisposableFieldTests_Setup_Before_TestInitializer - { - internal static async ValueTask global_TUnit_TestProject_DisposableFieldTests_Setup_0Params_Body(object instance, TestContext context, CancellationToken cancellationToken) - { - var typedInstance = (global::TUnit.TestProject.DisposableFieldTests)instance; - await AsyncConvert.Convert(() => typedInstance.Setup()); - } - } -} namespace TUnit.Generated { internal static partial class TUnit_HookRegistration { static readonly int _h_TUnit_TestProject_DisposableFieldTests_Setup_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.DisposableFieldTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), - static __registrationIndex => - new InstanceHookMethod - { - InitClassType = typeof(global::TUnit.TestProject.DisposableFieldTests), - MethodInfo = new global::TUnit.Core.MethodMetadata - { - Type = typeof(global::TUnit.TestProject.DisposableFieldTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.DisposableFieldTests)), - Name = "Setup", - GenericTypeCount = 0, - ReturnType = typeof(void), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(void)), - Parameters = global::System.Array.Empty(), - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.DisposableFieldTests", new global::TUnit.Core.ClassMetadata + static __registrationIndex => + new InstanceHookMethod { - Type = typeof(global::TUnit.TestProject.DisposableFieldTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.DisposableFieldTests)), - Name = "DisposableFieldTests", - Namespace = "TUnit.TestProject", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_DisposableFieldTests_Setup_Before_Test.TUnit_TestProject_DisposableFieldTests_Setup_Before_TestInitializer.global_TUnit_TestProject_DisposableFieldTests_Setup_0Params_Body - } -); - } -} - - -// ===== FILE SEPARATOR ===== - -// -#pragma warning disable - -#nullable enable -#pragma warning disable CS9113 // Parameter is unread. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Threading; -using System.Threading.Tasks; -using global::TUnit.Core; -using global::TUnit.Core.Hooks; -using global::TUnit.Core.Interfaces.SourceGenerator; -using global::TUnit.Core.Models; -using HookType = global::TUnit.Core.HookType; -namespace TUnit.Generated.Hooks.TUnit_TestProject_DisposableFieldTests_Blah_After_Test -{ - internal static class TUnit_TestProject_DisposableFieldTests_Blah_After_TestInitializer - { - internal static async ValueTask global_TUnit_TestProject_DisposableFieldTests_Blah_0Params_Body(object instance, TestContext context, CancellationToken cancellationToken) + InitClassType = typeof(global::TUnit.TestProject.DisposableFieldTests), + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.DisposableFieldTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.DisposableFieldTests)), + Name = "Setup", + GenericTypeCount = 0, + ReturnType = typeof(void), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(void)), + Parameters = global::System.Array.Empty(), + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.DisposableFieldTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.DisposableFieldTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.DisposableFieldTests)), + Name = "DisposableFieldTests", + Namespace = "TUnit.TestProject", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_DisposableFieldTests_Setup_Before_Test_Body + } + ); + private static ValueTask TUnit_TestProject_DisposableFieldTests_Setup_Before_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) { - var typedInstance = (global::TUnit.TestProject.DisposableFieldTests)instance; - await AsyncConvert.Convert(() => typedInstance.Blah()); + try + { + var typedInstance = (global::TUnit.TestProject.DisposableFieldTests)instance; + typedInstance.Setup(); + return default; + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } } - } -} -namespace TUnit.Generated -{ - internal static partial class TUnit_HookRegistration - { static readonly int _h_TUnit_TestProject_DisposableFieldTests_Blah_After_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterTestHooks, typeof(global::TUnit.TestProject.DisposableFieldTests), global::TUnit.Core.HookRegistrationIndices.GetNextAfterTestHookIndex(), - static __registrationIndex => - new InstanceHookMethod - { - InitClassType = typeof(global::TUnit.TestProject.DisposableFieldTests), - MethodInfo = new global::TUnit.Core.MethodMetadata + static __registrationIndex => + new InstanceHookMethod + { + InitClassType = typeof(global::TUnit.TestProject.DisposableFieldTests), + MethodInfo = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.DisposableFieldTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.DisposableFieldTests)), + Name = "Blah", + GenericTypeCount = 0, + ReturnType = typeof(void), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(void)), + Parameters = global::System.Array.Empty(), + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.DisposableFieldTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.DisposableFieldTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.DisposableFieldTests)), + Name = "DisposableFieldTests", + Namespace = "TUnit.TestProject", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = __registrationIndex, + Body = TUnit_TestProject_DisposableFieldTests_Blah_After_Test_Body + } + ); + private static ValueTask TUnit_TestProject_DisposableFieldTests_Blah_After_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) { - Type = typeof(global::TUnit.TestProject.DisposableFieldTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.DisposableFieldTests)), - Name = "Blah", - GenericTypeCount = 0, - ReturnType = typeof(void), - ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(void)), - Parameters = global::System.Array.Empty(), - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.DisposableFieldTests", new global::TUnit.Core.ClassMetadata + try { - Type = typeof(global::TUnit.TestProject.DisposableFieldTests), - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.DisposableFieldTests)), - Name = "DisposableFieldTests", - Namespace = "TUnit.TestProject", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }) - }, - HookExecutor = DefaultExecutor.Instance, - Order = 0, - RegistrationIndex = __registrationIndex, - Body = global::TUnit.Generated.Hooks.TUnit_TestProject_DisposableFieldTests_Blah_After_Test.TUnit_TestProject_DisposableFieldTests_Blah_After_TestInitializer.global_TUnit_TestProject_DisposableFieldTests_Blah_0Params_Body - } -); + var typedInstance = (global::TUnit.TestProject.DisposableFieldTests)instance; + typedInstance.Blah(); + return default; + } + catch (Exception ex) + { + return new ValueTask(Task.FromException(ex)); + } + } } } diff --git a/tests/TUnit.SourceGenerator.IncrementalTests/HookMetadataGeneratorIncrementalTests.cs b/tests/TUnit.SourceGenerator.IncrementalTests/HookMetadataGeneratorIncrementalTests.cs index 20fb7c53fd1..ea858683119 100644 --- a/tests/TUnit.SourceGenerator.IncrementalTests/HookMetadataGeneratorIncrementalTests.cs +++ b/tests/TUnit.SourceGenerator.IncrementalTests/HookMetadataGeneratorIncrementalTests.cs @@ -31,6 +31,52 @@ public void AddUnrelatedType_ShouldNotRegenerate() var compilation2 = compilation1.AddSyntaxTrees(CSharpSyntaxTree.ParseText("struct MyValue {}")); var driver2 = driver1.RunGenerators(compilation2); AssertRunReason(driver2, IncrementalStepRunReason.Cached); + TestHelper.AssertRunReason(driver2.GetRunResult().Results[0], HookMetadataGenerator.HookClassGroups, IncrementalStepRunReason.Cached, 0); + } + + [Fact] + public void ChangeHookInOneClass_ShouldOnlyModifyThatClassGroup() + { + const string source = + """ + using System.Threading.Tasks; + using TUnit.Core; + + public class FirstHookTests + { + [Before(HookType.Test)] + public void Setup() + { + } + } + + public class SecondHookTests + { + [Before(HookType.Test)] + public void OtherSetup() + { + } + } + """; + + var compilation1 = Fixture.CreateLibrary(CSharpSyntaxTree.ParseText(source, CSharpParseOptions.Default)); + + var driver1 = TestHelper.GenerateTracked(compilation1); + + var compilation2 = TestHelper.ReplaceMethodDeclaration(compilation1, "OtherSetup", + """ + [Before(HookType.Test)] + public async Task OtherSetup() + { + await Task.Yield(); + } + """); + + var driver2 = driver1.RunGenerators(compilation2); + var runResult = driver2.GetRunResult().Results[0]; + + TestHelper.AssertRunReason(runResult, HookMetadataGenerator.HookClassGroups, IncrementalStepRunReason.Unchanged, 0); + TestHelper.AssertRunReason(runResult, HookMetadataGenerator.HookClassGroups, IncrementalStepRunReason.Modified, 1); } [Fact] From 0dd31cd979b7d17ace369cbe6e58d3ea54abd47f Mon Sep 17 00:00:00 2001 From: Tom Longhurst <30480171+thomhurst@users.noreply.github.com> Date: Tue, 29 Sep 2026 09:45:06 +0100 Subject: [PATCH 2/7] fix(source-gen): unique hook names and async semantics for direct hook bodies - Append a stable hash of the exact type/hook identity to per-class hint names and TUnit_HookRegistration member names. Sanitizing is not injective (A_B.C and A.B_C both became A_B_C), which produced duplicate AddSource hint names and duplicate members. - Invoke hook Body delegates through an internal async HookBodyInvoker in TUnit.Core. Direct (non-async) generated bodies again get async-method semantics: a synchronous OperationCanceledException becomes a canceled task, other synchronous exceptions a faulted task, and ExecutionContext changes (AsyncLocal, culture) made by a synchronous hook no longer leak into the hook executor. Generated bodies drop their per-hook try/catch. - Tests: incremental generator test for sanitized-name collisions and a TestProject engine test covering AsyncLocal isolation and cancellation status seen by a custom hook executor. --- .../Generators/HookMetadataGenerator.cs | 44 ++-- .../Hooks/AfterAssemblyHookMethod.cs | 2 +- src/TUnit.Core/Hooks/AfterClassHookMethod.cs | 2 +- .../Hooks/AfterTestDiscoveryHookMethod.cs | 2 +- src/TUnit.Core/Hooks/AfterTestHookMethod.cs | 2 +- .../Hooks/AfterTestSessionHookMethod.cs | 2 +- .../Hooks/BeforeAssemblyHookMethod.cs | 2 +- src/TUnit.Core/Hooks/BeforeClassHookMethod.cs | 2 +- .../Hooks/BeforeTestDiscoveryHookMethod.cs | 2 +- src/TUnit.Core/Hooks/BeforeTestHookMethod.cs | 2 +- .../Hooks/BeforeTestSessionHookMethod.cs | 2 +- src/TUnit.Core/Hooks/HookBodyInvoker.cs | 28 +++ src/TUnit.Core/Hooks/InstanceHookMethod.cs | 2 +- .../AssemblyAfterTests.Test.verified.txt | 224 +++++------------ .../AssemblyBeforeTests.Test.verified.txt | 224 +++++------------ ...nflictingNamespace.DotNet10_0.verified.txt | 226 +++++------------- ...onflictingNamespace.DotNet8_0.verified.txt | 226 +++++------------- ...onflictingNamespace.DotNet9_0.verified.txt | 226 +++++------------- ...thConflictingNamespace.Net4_7.verified.txt | 224 +++++------------ ...obalStaticAfterEachTests.Test.verified.txt | 224 +++++------------ ...balStaticBeforeEachTests.Test.verified.txt | 224 +++++------------ ...oksTests.DisposableFieldTests.verified.txt | 38 +-- .../HookMetadataGeneratorIncrementalTests.cs | 47 ++++ .../SyncHookBodySemanticsTests.cs | 88 +++++++ 24 files changed, 715 insertions(+), 1350 deletions(-) create mode 100644 src/TUnit.Core/Hooks/HookBodyInvoker.cs create mode 100644 tests/TUnit.TestProject/SyncHookBodySemanticsTests.cs diff --git a/src/TUnit.Core.SourceGenerator/Generators/HookMetadataGenerator.cs b/src/TUnit.Core.SourceGenerator/Generators/HookMetadataGenerator.cs index 300a59223ca..44b85fca3f1 100644 --- a/src/TUnit.Core.SourceGenerator/Generators/HookMetadataGenerator.cs +++ b/src/TUnit.Core.SourceGenerator/Generators/HookMetadataGenerator.cs @@ -4,6 +4,7 @@ using Microsoft.CodeAnalysis.CSharp.Syntax; using TUnit.Core.SourceGenerator.CodeGenerators.Helpers; using TUnit.Core.SourceGenerator.Extensions; +using TUnit.Core.SourceGenerator.Helpers; using TUnit.Core.SourceGenerator.Models; using TUnit.Core.SourceGenerator.Models.Extracted; using TUnit.Core.SourceGenerator.Utilities; @@ -116,7 +117,7 @@ private static void GenerateHookClassFile(SourceProductionContext context, HookC WriteHookClassFileFooter(writer); - context.AddSource($"{SanitizeForFileName(group.FullyQualifiedTypeName)}.Hooks.g.cs", writer.ToString()); + context.AddSource($"{GetUniqueName(group.FullyQualifiedTypeName, group.FullyQualifiedTypeName)}.Hooks.g.cs", writer.ToString()); } catch (Exception ex) { @@ -444,22 +445,32 @@ private static void GenerateHookMembers(CodeWriter writer, HookModel hook) private static string GetSafeFileName(HookModel hook) { - // Create deterministic filename from full type name and method name - // Use fully qualified type name to ensure uniqueness across namespaces + // Readable name from full type name, method name, simple parameter type names and hook kind/type. var baseName = $"{hook.FullyQualifiedTypeName}_{hook.MethodName}"; - // Add parameter types to ensure uniqueness for overloaded methods - // Only add if there are parameters (matches main branch behavior - no _0_ suffix for empty params) if (hook.Parameters.Length > 0) { var paramTypes = string.Join('_', hook.Parameters.Select(p => SanitizeForFileName(GetSimpleTypeName(p.TypeName)))); baseName += $"__{paramTypes}"; } - // Add hook kind and type baseName += $"_{hook.HookKind}_{hook.HookType}"; - return SanitizeForFileName(baseName); + // Sanitizing is not injective (A_B.C and A.B_C both become A_B_C, and parameter types are + // shortened), so a stable hash of the exact hook identity keeps member names unique within the + // shared TUnit_HookRegistration partial class. + var identity = $"{hook.FullyQualifiedTypeName}.{hook.MethodName}({string.Join(",", hook.Parameters.Select(static p => p.TypeName))})|{hook.HookKind}|{hook.HookType}"; + + return GetUniqueName(baseName, identity); + } + + /// + /// Returns a readable, sanitized name with a stable hash of appended, + /// so distinct identities that sanitize to the same text still get distinct names. + /// + private static string GetUniqueName(string readableName, string identity) + { + return $"{SanitizeForFileName(readableName)}_{FileNameHelper.GetStableHashCode(identity):x8}"; } private static string SanitizeForFileName(string input) @@ -596,14 +607,12 @@ private static void GenerateHookDelegate(CodeWriter writer, HookModel hook, stri return; } - // Direct call with no async state machine. Synchronous exceptions are returned as a faulted - // ValueTask, matching what the previous async body produced. + // Direct call with no async state machine or lambda. The hook classes in TUnit.Core invoke + // Body through HookBodyInvoker, an async wrapper that gives these bodies async-method + // semantics: synchronous exceptions become a faulted (or, for OperationCanceledException, + // canceled) task, and ExecutionContext changes made by the hook do not leak to the caller. using (writer.BeginBlock($"private static ValueTask {bodyName}({parameters})")) { - writer.AppendLine("try"); - writer.AppendLine("{"); - writer.Indent(); - if (isInstanceHook) { writer.AppendLine($"var typedInstance = ({className})instance;"); @@ -622,15 +631,6 @@ private static void GenerateHookDelegate(CodeWriter writer, HookModel hook, stri writer.AppendLine($"return {methodCall};"); break; } - - writer.Unindent(); - writer.AppendLine("}"); - writer.AppendLine("catch (Exception ex)"); - writer.AppendLine("{"); - writer.Indent(); - writer.AppendLine("return new ValueTask(Task.FromException(ex));"); - writer.Unindent(); - writer.AppendLine("}"); } writer.AppendLine(); diff --git a/src/TUnit.Core/Hooks/AfterAssemblyHookMethod.cs b/src/TUnit.Core/Hooks/AfterAssemblyHookMethod.cs index 20636a85d4e..33acb8c8735 100644 --- a/src/TUnit.Core/Hooks/AfterAssemblyHookMethod.cs +++ b/src/TUnit.Core/Hooks/AfterAssemblyHookMethod.cs @@ -5,7 +5,7 @@ public record AfterAssemblyHookMethod : StaticHookMethod public override ValueTask ExecuteAsync(AssemblyHookContext context, CancellationToken cancellationToken) { return HookExecutor.ExecuteAfterAssemblyHook(MethodInfo, context, - () => Body!.Invoke(context, cancellationToken) + () => HookBodyInvoker.InvokeAsync(Body!, context, cancellationToken) ); } } diff --git a/src/TUnit.Core/Hooks/AfterClassHookMethod.cs b/src/TUnit.Core/Hooks/AfterClassHookMethod.cs index 3b1c6378720..93b2ddef3c3 100644 --- a/src/TUnit.Core/Hooks/AfterClassHookMethod.cs +++ b/src/TUnit.Core/Hooks/AfterClassHookMethod.cs @@ -5,7 +5,7 @@ public record AfterClassHookMethod : StaticHookMethod public override ValueTask ExecuteAsync(ClassHookContext context, CancellationToken cancellationToken) { return HookExecutor.ExecuteAfterClassHook(MethodInfo, context, - () => Body!.Invoke(context, cancellationToken) + () => HookBodyInvoker.InvokeAsync(Body!, context, cancellationToken) ); } } diff --git a/src/TUnit.Core/Hooks/AfterTestDiscoveryHookMethod.cs b/src/TUnit.Core/Hooks/AfterTestDiscoveryHookMethod.cs index 655c15b6a14..fba6b71f5e8 100644 --- a/src/TUnit.Core/Hooks/AfterTestDiscoveryHookMethod.cs +++ b/src/TUnit.Core/Hooks/AfterTestDiscoveryHookMethod.cs @@ -5,7 +5,7 @@ public record AfterTestDiscoveryHookMethod : StaticHookMethod Body!.Invoke(context, cancellationToken) + () => HookBodyInvoker.InvokeAsync(Body!, context, cancellationToken) ); } } diff --git a/src/TUnit.Core/Hooks/AfterTestHookMethod.cs b/src/TUnit.Core/Hooks/AfterTestHookMethod.cs index 97a88fdc9dc..dfe0d80b4c4 100644 --- a/src/TUnit.Core/Hooks/AfterTestHookMethod.cs +++ b/src/TUnit.Core/Hooks/AfterTestHookMethod.cs @@ -5,7 +5,7 @@ public record AfterTestHookMethod : StaticHookMethod public override ValueTask ExecuteAsync(TestContext context, CancellationToken cancellationToken) { return ResolveEffectiveExecutor(context).ExecuteAfterTestHook(MethodInfo, context, - () => Body!.Invoke(context, cancellationToken) + () => HookBodyInvoker.InvokeAsync(Body!, context, cancellationToken) ); } } diff --git a/src/TUnit.Core/Hooks/AfterTestSessionHookMethod.cs b/src/TUnit.Core/Hooks/AfterTestSessionHookMethod.cs index c8fbd14ef83..0432f5216af 100644 --- a/src/TUnit.Core/Hooks/AfterTestSessionHookMethod.cs +++ b/src/TUnit.Core/Hooks/AfterTestSessionHookMethod.cs @@ -5,7 +5,7 @@ public record AfterTestSessionHookMethod : StaticHookMethod public override ValueTask ExecuteAsync(TestSessionContext context, CancellationToken cancellationToken) { return HookExecutor.ExecuteAfterTestSessionHook(MethodInfo, context, - () => Body!.Invoke(context, cancellationToken) + () => HookBodyInvoker.InvokeAsync(Body!, context, cancellationToken) ); } } diff --git a/src/TUnit.Core/Hooks/BeforeAssemblyHookMethod.cs b/src/TUnit.Core/Hooks/BeforeAssemblyHookMethod.cs index 4d9c2605a39..d1956033dc2 100644 --- a/src/TUnit.Core/Hooks/BeforeAssemblyHookMethod.cs +++ b/src/TUnit.Core/Hooks/BeforeAssemblyHookMethod.cs @@ -5,7 +5,7 @@ public record BeforeAssemblyHookMethod : StaticHookMethod public override ValueTask ExecuteAsync(AssemblyHookContext context, CancellationToken cancellationToken) { return HookExecutor.ExecuteBeforeAssemblyHook(MethodInfo, context, - () => Body!.Invoke(context, cancellationToken) + () => HookBodyInvoker.InvokeAsync(Body!, context, cancellationToken) ); } } diff --git a/src/TUnit.Core/Hooks/BeforeClassHookMethod.cs b/src/TUnit.Core/Hooks/BeforeClassHookMethod.cs index c877681905b..b810485370e 100644 --- a/src/TUnit.Core/Hooks/BeforeClassHookMethod.cs +++ b/src/TUnit.Core/Hooks/BeforeClassHookMethod.cs @@ -5,7 +5,7 @@ public record BeforeClassHookMethod : StaticHookMethod public override ValueTask ExecuteAsync(ClassHookContext context, CancellationToken cancellationToken) { return HookExecutor.ExecuteBeforeClassHook(MethodInfo, context, - () => Body!.Invoke(context, cancellationToken) + () => HookBodyInvoker.InvokeAsync(Body!, context, cancellationToken) ); } } diff --git a/src/TUnit.Core/Hooks/BeforeTestDiscoveryHookMethod.cs b/src/TUnit.Core/Hooks/BeforeTestDiscoveryHookMethod.cs index eca6c919448..8ff3a78fc49 100644 --- a/src/TUnit.Core/Hooks/BeforeTestDiscoveryHookMethod.cs +++ b/src/TUnit.Core/Hooks/BeforeTestDiscoveryHookMethod.cs @@ -5,7 +5,7 @@ public record BeforeTestDiscoveryHookMethod : StaticHookMethod Body!.Invoke(context, cancellationToken) + () => HookBodyInvoker.InvokeAsync(Body!, context, cancellationToken) ); } } diff --git a/src/TUnit.Core/Hooks/BeforeTestHookMethod.cs b/src/TUnit.Core/Hooks/BeforeTestHookMethod.cs index 3ce59d3f35e..6edb600df74 100644 --- a/src/TUnit.Core/Hooks/BeforeTestHookMethod.cs +++ b/src/TUnit.Core/Hooks/BeforeTestHookMethod.cs @@ -5,7 +5,7 @@ public record BeforeTestHookMethod : StaticHookMethod public override ValueTask ExecuteAsync(TestContext context, CancellationToken cancellationToken) { return ResolveEffectiveExecutor(context).ExecuteBeforeTestHook(MethodInfo, context, - () => Body!.Invoke(context, cancellationToken) + () => HookBodyInvoker.InvokeAsync(Body!, context, cancellationToken) ); } } diff --git a/src/TUnit.Core/Hooks/BeforeTestSessionHookMethod.cs b/src/TUnit.Core/Hooks/BeforeTestSessionHookMethod.cs index 4a5c9823aeb..7c5f74e9f9a 100644 --- a/src/TUnit.Core/Hooks/BeforeTestSessionHookMethod.cs +++ b/src/TUnit.Core/Hooks/BeforeTestSessionHookMethod.cs @@ -5,7 +5,7 @@ public record BeforeTestSessionHookMethod : StaticHookMethod public override ValueTask ExecuteAsync(TestSessionContext context, CancellationToken cancellationToken) { return HookExecutor.ExecuteBeforeTestSessionHook(MethodInfo, context, - () => Body!.Invoke(context, cancellationToken) + () => HookBodyInvoker.InvokeAsync(Body!, context, cancellationToken) ); } } diff --git a/src/TUnit.Core/Hooks/HookBodyInvoker.cs b/src/TUnit.Core/Hooks/HookBodyInvoker.cs new file mode 100644 index 00000000000..f081c0923e3 --- /dev/null +++ b/src/TUnit.Core/Hooks/HookBodyInvoker.cs @@ -0,0 +1,28 @@ +namespace TUnit.Core.Hooks; + +/// +/// Invokes a hook Body delegate with async-method semantics. +/// +/// +/// Source-generated hook bodies call the hook method directly, without an async state machine of their +/// own. Invoking them through this async wrapper keeps the behaviour of an async body: +/// +/// A synchronous exception becomes a faulted task, and an +/// becomes a canceled task, instead of throwing out of the executor's action() call. +/// ExecutionContext changes (AsyncLocal values, culture) made synchronously by the hook do not leak +/// into the caller. Hooks opt in to flowing them with . +/// +/// The wrapper completes without allocating when the hook completes synchronously. +/// +internal static class HookBodyInvoker +{ + public static async ValueTask InvokeAsync(Func body, T context, CancellationToken cancellationToken) + { + await body(context, cancellationToken); + } + + public static async ValueTask InvokeAsync(Func body, object instance, TestContext context, CancellationToken cancellationToken) + { + await body(instance, context, cancellationToken); + } +} diff --git a/src/TUnit.Core/Hooks/InstanceHookMethod.cs b/src/TUnit.Core/Hooks/InstanceHookMethod.cs index 9e55d8d10da..ff19d239a15 100644 --- a/src/TUnit.Core/Hooks/InstanceHookMethod.cs +++ b/src/TUnit.Core/Hooks/InstanceHookMethod.cs @@ -36,7 +36,7 @@ public ValueTask ExecuteAsync(TestContext context, CancellationToken cancellatio } return ResolveEffectiveExecutor(context).ExecuteBeforeTestHook(MethodInfo, context, - () => Body!.Invoke(context.Metadata.TestDetails.ClassInstance, context, cancellationToken) + () => HookBodyInvoker.InvokeAsync(Body!, context.Metadata.TestDetails.ClassInstance, context, cancellationToken) ); } } diff --git a/tests/TUnit.Core.SourceGenerator.Tests/AssemblyAfterTests.Test.verified.txt b/tests/TUnit.Core.SourceGenerator.Tests/AssemblyAfterTests.Test.verified.txt index 475f66713fa..e1039b46840 100644 --- a/tests/TUnit.Core.SourceGenerator.Tests/AssemblyAfterTests.Test.verified.txt +++ b/tests/TUnit.Core.SourceGenerator.Tests/AssemblyAfterTests.Test.verified.txt @@ -13,7 +13,7 @@ namespace TUnit.Generated { internal static partial class TUnit_HookRegistration { - static readonly int _h_TUnit_TestProject_AfterTests_AssemblyBase1_AfterAll1_After_Assembly = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterAssemblyHooks, typeof(global::TUnit.TestProject.AfterTests.AssemblyBase1).Assembly, global::TUnit.Core.HookRegistrationIndices.GetNextAfterAssemblyHookIndex(), + static readonly int _h_TUnit_TestProject_AfterTests_AssemblyBase1_AfterAll1_After_Assembly_b3176303 = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterAssemblyHooks, typeof(global::TUnit.TestProject.AfterTests.AssemblyBase1).Assembly, global::TUnit.Core.HookRegistrationIndices.GetNextAfterAssemblyHookIndex(), static __registrationIndex => new AfterAssemblyHookMethod { @@ -41,23 +41,16 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_AfterTests_AssemblyBase1_AfterAll1_After_Assembly_Body, + Body = TUnit_TestProject_AfterTests_AssemblyBase1_AfterAll1_After_Assembly_b3176303_Body, FilePath = "", LineNumber = 5 } ); - private static ValueTask TUnit_TestProject_AfterTests_AssemblyBase1_AfterAll1_After_Assembly_Body(AssemblyHookContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_AfterTests_AssemblyBase1_AfterAll1_After_Assembly_b3176303_Body(AssemblyHookContext context, CancellationToken cancellationToken) { - try - { - return new ValueTask(global::TUnit.TestProject.AfterTests.AssemblyBase1.AfterAll1()); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + return new ValueTask(global::TUnit.TestProject.AfterTests.AssemblyBase1.AfterAll1()); } - static readonly int _h_TUnit_TestProject_AfterTests_AssemblyBase1_AfterEach1_After_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterTestHooks, typeof(global::TUnit.TestProject.AfterTests.AssemblyBase1), global::TUnit.Core.HookRegistrationIndices.GetNextAfterTestHookIndex(), + static readonly int _h_TUnit_TestProject_AfterTests_AssemblyBase1_AfterEach1_After_Test_68cea615 = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterTestHooks, typeof(global::TUnit.TestProject.AfterTests.AssemblyBase1), global::TUnit.Core.HookRegistrationIndices.GetNextAfterTestHookIndex(), static __registrationIndex => new InstanceHookMethod { @@ -86,20 +79,13 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_AfterTests_AssemblyBase1_AfterEach1_After_Test_Body + Body = TUnit_TestProject_AfterTests_AssemblyBase1_AfterEach1_After_Test_68cea615_Body } ); - private static ValueTask TUnit_TestProject_AfterTests_AssemblyBase1_AfterEach1_After_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_AfterTests_AssemblyBase1_AfterEach1_After_Test_68cea615_Body(object instance, TestContext context, CancellationToken cancellationToken) { - try - { - var typedInstance = (global::TUnit.TestProject.AfterTests.AssemblyBase1)instance; - return new ValueTask(typedInstance.AfterEach1()); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + var typedInstance = (global::TUnit.TestProject.AfterTests.AssemblyBase1)instance; + return new ValueTask(typedInstance.AfterEach1()); } } } @@ -122,7 +108,7 @@ namespace TUnit.Generated { internal static partial class TUnit_HookRegistration { - static readonly int _h_TUnit_TestProject_AfterTests_AssemblyBase2_AfterAll2_After_Assembly = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterAssemblyHooks, typeof(global::TUnit.TestProject.AfterTests.AssemblyBase2).Assembly, global::TUnit.Core.HookRegistrationIndices.GetNextAfterAssemblyHookIndex(), + static readonly int _h_TUnit_TestProject_AfterTests_AssemblyBase2_AfterAll2_After_Assembly_46bcab23 = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterAssemblyHooks, typeof(global::TUnit.TestProject.AfterTests.AssemblyBase2).Assembly, global::TUnit.Core.HookRegistrationIndices.GetNextAfterAssemblyHookIndex(), static __registrationIndex => new AfterAssemblyHookMethod { @@ -150,23 +136,16 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_AfterTests_AssemblyBase2_AfterAll2_After_Assembly_Body, + Body = TUnit_TestProject_AfterTests_AssemblyBase2_AfterAll2_After_Assembly_46bcab23_Body, FilePath = "", LineNumber = 20 } ); - private static ValueTask TUnit_TestProject_AfterTests_AssemblyBase2_AfterAll2_After_Assembly_Body(AssemblyHookContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_AfterTests_AssemblyBase2_AfterAll2_After_Assembly_46bcab23_Body(AssemblyHookContext context, CancellationToken cancellationToken) { - try - { - return new ValueTask(global::TUnit.TestProject.AfterTests.AssemblyBase2.AfterAll2()); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + return new ValueTask(global::TUnit.TestProject.AfterTests.AssemblyBase2.AfterAll2()); } - static readonly int _h_TUnit_TestProject_AfterTests_AssemblyBase2_AfterEach2_After_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterTestHooks, typeof(global::TUnit.TestProject.AfterTests.AssemblyBase2), global::TUnit.Core.HookRegistrationIndices.GetNextAfterTestHookIndex(), + static readonly int _h_TUnit_TestProject_AfterTests_AssemblyBase2_AfterEach2_After_Test_2f458047 = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterTestHooks, typeof(global::TUnit.TestProject.AfterTests.AssemblyBase2), global::TUnit.Core.HookRegistrationIndices.GetNextAfterTestHookIndex(), static __registrationIndex => new InstanceHookMethod { @@ -195,20 +174,13 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_AfterTests_AssemblyBase2_AfterEach2_After_Test_Body + Body = TUnit_TestProject_AfterTests_AssemblyBase2_AfterEach2_After_Test_2f458047_Body } ); - private static ValueTask TUnit_TestProject_AfterTests_AssemblyBase2_AfterEach2_After_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_AfterTests_AssemblyBase2_AfterEach2_After_Test_2f458047_Body(object instance, TestContext context, CancellationToken cancellationToken) { - try - { - var typedInstance = (global::TUnit.TestProject.AfterTests.AssemblyBase2)instance; - return new ValueTask(typedInstance.AfterEach2()); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + var typedInstance = (global::TUnit.TestProject.AfterTests.AssemblyBase2)instance; + return new ValueTask(typedInstance.AfterEach2()); } } } @@ -231,7 +203,7 @@ namespace TUnit.Generated { internal static partial class TUnit_HookRegistration { - static readonly int _h_TUnit_TestProject_AfterTests_AssemblyBase3_AfterAll3_After_Assembly = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterAssemblyHooks, typeof(global::TUnit.TestProject.AfterTests.AssemblyBase3).Assembly, global::TUnit.Core.HookRegistrationIndices.GetNextAfterAssemblyHookIndex(), + static readonly int _h_TUnit_TestProject_AfterTests_AssemblyBase3_AfterAll3_After_Assembly_9bc49d3b = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterAssemblyHooks, typeof(global::TUnit.TestProject.AfterTests.AssemblyBase3).Assembly, global::TUnit.Core.HookRegistrationIndices.GetNextAfterAssemblyHookIndex(), static __registrationIndex => new AfterAssemblyHookMethod { @@ -259,23 +231,16 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_AfterTests_AssemblyBase3_AfterAll3_After_Assembly_Body, + Body = TUnit_TestProject_AfterTests_AssemblyBase3_AfterAll3_After_Assembly_9bc49d3b_Body, FilePath = "", LineNumber = 35 } ); - private static ValueTask TUnit_TestProject_AfterTests_AssemblyBase3_AfterAll3_After_Assembly_Body(AssemblyHookContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_AfterTests_AssemblyBase3_AfterAll3_After_Assembly_9bc49d3b_Body(AssemblyHookContext context, CancellationToken cancellationToken) { - try - { - return new ValueTask(global::TUnit.TestProject.AfterTests.AssemblyBase3.AfterAll3()); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + return new ValueTask(global::TUnit.TestProject.AfterTests.AssemblyBase3.AfterAll3()); } - static readonly int _h_TUnit_TestProject_AfterTests_AssemblyBase3_AfterEach3_After_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterTestHooks, typeof(global::TUnit.TestProject.AfterTests.AssemblyBase3), global::TUnit.Core.HookRegistrationIndices.GetNextAfterTestHookIndex(), + static readonly int _h_TUnit_TestProject_AfterTests_AssemblyBase3_AfterEach3_After_Test_65c82d51 = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterTestHooks, typeof(global::TUnit.TestProject.AfterTests.AssemblyBase3), global::TUnit.Core.HookRegistrationIndices.GetNextAfterTestHookIndex(), static __registrationIndex => new InstanceHookMethod { @@ -304,20 +269,13 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_AfterTests_AssemblyBase3_AfterEach3_After_Test_Body + Body = TUnit_TestProject_AfterTests_AssemblyBase3_AfterEach3_After_Test_65c82d51_Body } ); - private static ValueTask TUnit_TestProject_AfterTests_AssemblyBase3_AfterEach3_After_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_AfterTests_AssemblyBase3_AfterEach3_After_Test_65c82d51_Body(object instance, TestContext context, CancellationToken cancellationToken) { - try - { - var typedInstance = (global::TUnit.TestProject.AfterTests.AssemblyBase3)instance; - return new ValueTask(typedInstance.AfterEach3()); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + var typedInstance = (global::TUnit.TestProject.AfterTests.AssemblyBase3)instance; + return new ValueTask(typedInstance.AfterEach3()); } } } @@ -340,7 +298,7 @@ namespace TUnit.Generated { internal static partial class TUnit_HookRegistration { - static readonly int _h_TUnit_TestProject_AfterTests_AssemblyCleanupTests_AfterAllCleanUp_After_Assembly = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterAssemblyHooks, typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests).Assembly, global::TUnit.Core.HookRegistrationIndices.GetNextAfterAssemblyHookIndex(), + static readonly int _h_TUnit_TestProject_AfterTests_AssemblyCleanupTests_AfterAllCleanUp_After_Assembly_dc850121 = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterAssemblyHooks, typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests).Assembly, global::TUnit.Core.HookRegistrationIndices.GetNextAfterAssemblyHookIndex(), static __registrationIndex => new AfterAssemblyHookMethod { @@ -368,23 +326,16 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_AfterTests_AssemblyCleanupTests_AfterAllCleanUp_After_Assembly_Body, + Body = TUnit_TestProject_AfterTests_AssemblyCleanupTests_AfterAllCleanUp_After_Assembly_dc850121_Body, FilePath = "", LineNumber = 50 } ); - private static ValueTask TUnit_TestProject_AfterTests_AssemblyCleanupTests_AfterAllCleanUp_After_Assembly_Body(AssemblyHookContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_AfterTests_AssemblyCleanupTests_AfterAllCleanUp_After_Assembly_dc850121_Body(AssemblyHookContext context, CancellationToken cancellationToken) { - try - { - return new ValueTask(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests.AfterAllCleanUp()); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + return new ValueTask(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests.AfterAllCleanUp()); } - static readonly int _h_TUnit_TestProject_AfterTests_AssemblyCleanupTests_AfterAllCleanUpWithContext__AssemblyHookContext_After_Assembly = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterAssemblyHooks, typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests).Assembly, global::TUnit.Core.HookRegistrationIndices.GetNextAfterAssemblyHookIndex(), + static readonly int _h_TUnit_TestProject_AfterTests_AssemblyCleanupTests_AfterAllCleanUpWithContext__AssemblyHookContext_After_Assembly_27506340 = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterAssemblyHooks, typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests).Assembly, global::TUnit.Core.HookRegistrationIndices.GetNextAfterAssemblyHookIndex(), static __registrationIndex => new AfterAssemblyHookMethod { @@ -415,23 +366,16 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_AfterTests_AssemblyCleanupTests_AfterAllCleanUpWithContext__AssemblyHookContext_After_Assembly_Body, + Body = TUnit_TestProject_AfterTests_AssemblyCleanupTests_AfterAllCleanUpWithContext__AssemblyHookContext_After_Assembly_27506340_Body, FilePath = "", LineNumber = 56 } ); - private static ValueTask TUnit_TestProject_AfterTests_AssemblyCleanupTests_AfterAllCleanUpWithContext__AssemblyHookContext_After_Assembly_Body(AssemblyHookContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_AfterTests_AssemblyCleanupTests_AfterAllCleanUpWithContext__AssemblyHookContext_After_Assembly_27506340_Body(AssemblyHookContext context, CancellationToken cancellationToken) { - try - { - return new ValueTask(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests.AfterAllCleanUpWithContext(context)); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + return new ValueTask(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests.AfterAllCleanUpWithContext(context)); } - static readonly int _h_TUnit_TestProject_AfterTests_AssemblyCleanupTests_AfterAllCleanUp2_After_Assembly = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterAssemblyHooks, typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests).Assembly, global::TUnit.Core.HookRegistrationIndices.GetNextAfterAssemblyHookIndex(), + static readonly int _h_TUnit_TestProject_AfterTests_AssemblyCleanupTests_AfterAllCleanUp2_After_Assembly_13b5ebe7 = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterAssemblyHooks, typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests).Assembly, global::TUnit.Core.HookRegistrationIndices.GetNextAfterAssemblyHookIndex(), static __registrationIndex => new AfterAssemblyHookMethod { @@ -459,23 +403,16 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_AfterTests_AssemblyCleanupTests_AfterAllCleanUp2_After_Assembly_Body, + Body = TUnit_TestProject_AfterTests_AssemblyCleanupTests_AfterAllCleanUp2_After_Assembly_13b5ebe7_Body, FilePath = "", LineNumber = 62 } ); - private static ValueTask TUnit_TestProject_AfterTests_AssemblyCleanupTests_AfterAllCleanUp2_After_Assembly_Body(AssemblyHookContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_AfterTests_AssemblyCleanupTests_AfterAllCleanUp2_After_Assembly_13b5ebe7_Body(AssemblyHookContext context, CancellationToken cancellationToken) { - try - { - return new ValueTask(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests.AfterAllCleanUp2()); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + return new ValueTask(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests.AfterAllCleanUp2()); } - static readonly int _h_TUnit_TestProject_AfterTests_AssemblyCleanupTests_AfterAllCleanUpWithContextAndToken__AssemblyHookContext_CancellationToken_After_Assembly = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterAssemblyHooks, typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests).Assembly, global::TUnit.Core.HookRegistrationIndices.GetNextAfterAssemblyHookIndex(), + static readonly int _h_TUnit_TestProject_AfterTests_AssemblyCleanupTests_AfterAllCleanUpWithContextAndToken__AssemblyHookContext_CancellationToken_After_Assembly_7d3c1b52 = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterAssemblyHooks, typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests).Assembly, global::TUnit.Core.HookRegistrationIndices.GetNextAfterAssemblyHookIndex(), static __registrationIndex => new AfterAssemblyHookMethod { @@ -507,23 +444,16 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_AfterTests_AssemblyCleanupTests_AfterAllCleanUpWithContextAndToken__AssemblyHookContext_CancellationToken_After_Assembly_Body, + Body = TUnit_TestProject_AfterTests_AssemblyCleanupTests_AfterAllCleanUpWithContextAndToken__AssemblyHookContext_CancellationToken_After_Assembly_7d3c1b52_Body, FilePath = "", LineNumber = 68 } ); - private static ValueTask TUnit_TestProject_AfterTests_AssemblyCleanupTests_AfterAllCleanUpWithContextAndToken__AssemblyHookContext_CancellationToken_After_Assembly_Body(AssemblyHookContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_AfterTests_AssemblyCleanupTests_AfterAllCleanUpWithContextAndToken__AssemblyHookContext_CancellationToken_After_Assembly_7d3c1b52_Body(AssemblyHookContext context, CancellationToken cancellationToken) { - try - { - return new ValueTask(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests.AfterAllCleanUpWithContextAndToken(context, cancellationToken)); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + return new ValueTask(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests.AfterAllCleanUpWithContextAndToken(context, cancellationToken)); } - static readonly int _h_TUnit_TestProject_AfterTests_AssemblyCleanupTests_Cleanup_After_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterTestHooks, typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests), global::TUnit.Core.HookRegistrationIndices.GetNextAfterTestHookIndex(), + static readonly int _h_TUnit_TestProject_AfterTests_AssemblyCleanupTests_Cleanup_After_Test_0dc46368 = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterTestHooks, typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests), global::TUnit.Core.HookRegistrationIndices.GetNextAfterTestHookIndex(), static __registrationIndex => new InstanceHookMethod { @@ -552,22 +482,15 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_AfterTests_AssemblyCleanupTests_Cleanup_After_Test_Body + Body = TUnit_TestProject_AfterTests_AssemblyCleanupTests_Cleanup_After_Test_0dc46368_Body } ); - private static ValueTask TUnit_TestProject_AfterTests_AssemblyCleanupTests_Cleanup_After_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_AfterTests_AssemblyCleanupTests_Cleanup_After_Test_0dc46368_Body(object instance, TestContext context, CancellationToken cancellationToken) { - try - { - var typedInstance = (global::TUnit.TestProject.AfterTests.AssemblyCleanupTests)instance; - return new ValueTask(typedInstance.Cleanup()); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + var typedInstance = (global::TUnit.TestProject.AfterTests.AssemblyCleanupTests)instance; + return new ValueTask(typedInstance.Cleanup()); } - static readonly int _h_TUnit_TestProject_AfterTests_AssemblyCleanupTests_Cleanup__CancellationToken_After_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterTestHooks, typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests), global::TUnit.Core.HookRegistrationIndices.GetNextAfterTestHookIndex(), + static readonly int _h_TUnit_TestProject_AfterTests_AssemblyCleanupTests_Cleanup__CancellationToken_After_Test_cf45b0ba = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterTestHooks, typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests), global::TUnit.Core.HookRegistrationIndices.GetNextAfterTestHookIndex(), static __registrationIndex => new InstanceHookMethod { @@ -599,22 +522,15 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_AfterTests_AssemblyCleanupTests_Cleanup__CancellationToken_After_Test_Body + Body = TUnit_TestProject_AfterTests_AssemblyCleanupTests_Cleanup__CancellationToken_After_Test_cf45b0ba_Body } ); - private static ValueTask TUnit_TestProject_AfterTests_AssemblyCleanupTests_Cleanup__CancellationToken_After_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_AfterTests_AssemblyCleanupTests_Cleanup__CancellationToken_After_Test_cf45b0ba_Body(object instance, TestContext context, CancellationToken cancellationToken) { - try - { - var typedInstance = (global::TUnit.TestProject.AfterTests.AssemblyCleanupTests)instance; - return new ValueTask(typedInstance.Cleanup(cancellationToken)); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + var typedInstance = (global::TUnit.TestProject.AfterTests.AssemblyCleanupTests)instance; + return new ValueTask(typedInstance.Cleanup(cancellationToken)); } - static readonly int _h_TUnit_TestProject_AfterTests_AssemblyCleanupTests_CleanupWithContext__TestContext_After_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterTestHooks, typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests), global::TUnit.Core.HookRegistrationIndices.GetNextAfterTestHookIndex(), + static readonly int _h_TUnit_TestProject_AfterTests_AssemblyCleanupTests_CleanupWithContext__TestContext_After_Test_e4d71436 = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterTestHooks, typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests), global::TUnit.Core.HookRegistrationIndices.GetNextAfterTestHookIndex(), static __registrationIndex => new InstanceHookMethod { @@ -646,22 +562,15 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_AfterTests_AssemblyCleanupTests_CleanupWithContext__TestContext_After_Test_Body + Body = TUnit_TestProject_AfterTests_AssemblyCleanupTests_CleanupWithContext__TestContext_After_Test_e4d71436_Body } ); - private static ValueTask TUnit_TestProject_AfterTests_AssemblyCleanupTests_CleanupWithContext__TestContext_After_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_AfterTests_AssemblyCleanupTests_CleanupWithContext__TestContext_After_Test_e4d71436_Body(object instance, TestContext context, CancellationToken cancellationToken) { - try - { - var typedInstance = (global::TUnit.TestProject.AfterTests.AssemblyCleanupTests)instance; - return new ValueTask(typedInstance.CleanupWithContext(context)); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + var typedInstance = (global::TUnit.TestProject.AfterTests.AssemblyCleanupTests)instance; + return new ValueTask(typedInstance.CleanupWithContext(context)); } - static readonly int _h_TUnit_TestProject_AfterTests_AssemblyCleanupTests_CleanupWithContext__TestContext_CancellationToken_After_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterTestHooks, typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests), global::TUnit.Core.HookRegistrationIndices.GetNextAfterTestHookIndex(), + static readonly int _h_TUnit_TestProject_AfterTests_AssemblyCleanupTests_CleanupWithContext__TestContext_CancellationToken_After_Test_3ffc8dca = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterTestHooks, typeof(global::TUnit.TestProject.AfterTests.AssemblyCleanupTests), global::TUnit.Core.HookRegistrationIndices.GetNextAfterTestHookIndex(), static __registrationIndex => new InstanceHookMethod { @@ -694,20 +603,13 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_AfterTests_AssemblyCleanupTests_CleanupWithContext__TestContext_CancellationToken_After_Test_Body + Body = TUnit_TestProject_AfterTests_AssemblyCleanupTests_CleanupWithContext__TestContext_CancellationToken_After_Test_3ffc8dca_Body } ); - private static ValueTask TUnit_TestProject_AfterTests_AssemblyCleanupTests_CleanupWithContext__TestContext_CancellationToken_After_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_AfterTests_AssemblyCleanupTests_CleanupWithContext__TestContext_CancellationToken_After_Test_3ffc8dca_Body(object instance, TestContext context, CancellationToken cancellationToken) { - try - { - var typedInstance = (global::TUnit.TestProject.AfterTests.AssemblyCleanupTests)instance; - return new ValueTask(typedInstance.CleanupWithContext(context, cancellationToken)); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + var typedInstance = (global::TUnit.TestProject.AfterTests.AssemblyCleanupTests)instance; + return new ValueTask(typedInstance.CleanupWithContext(context, cancellationToken)); } } } diff --git a/tests/TUnit.Core.SourceGenerator.Tests/AssemblyBeforeTests.Test.verified.txt b/tests/TUnit.Core.SourceGenerator.Tests/AssemblyBeforeTests.Test.verified.txt index 92af8766e1e..ef318e50b2d 100644 --- a/tests/TUnit.Core.SourceGenerator.Tests/AssemblyBeforeTests.Test.verified.txt +++ b/tests/TUnit.Core.SourceGenerator.Tests/AssemblyBeforeTests.Test.verified.txt @@ -13,7 +13,7 @@ namespace TUnit.Generated { internal static partial class TUnit_HookRegistration { - static readonly int _h_TUnit_TestProject_BeforeTests_AssemblyBase1_BeforeAll1_Before_Assembly = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeAssemblyHooks, typeof(global::TUnit.TestProject.BeforeTests.AssemblyBase1).Assembly, global::TUnit.Core.HookRegistrationIndices.GetNextBeforeAssemblyHookIndex(), + static readonly int _h_TUnit_TestProject_BeforeTests_AssemblyBase1_BeforeAll1_Before_Assembly_1bdba050 = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeAssemblyHooks, typeof(global::TUnit.TestProject.BeforeTests.AssemblyBase1).Assembly, global::TUnit.Core.HookRegistrationIndices.GetNextBeforeAssemblyHookIndex(), static __registrationIndex => new BeforeAssemblyHookMethod { @@ -41,23 +41,16 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_BeforeTests_AssemblyBase1_BeforeAll1_Before_Assembly_Body, + Body = TUnit_TestProject_BeforeTests_AssemblyBase1_BeforeAll1_Before_Assembly_1bdba050_Body, FilePath = "", LineNumber = 5 } ); - private static ValueTask TUnit_TestProject_BeforeTests_AssemblyBase1_BeforeAll1_Before_Assembly_Body(AssemblyHookContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_BeforeTests_AssemblyBase1_BeforeAll1_Before_Assembly_1bdba050_Body(AssemblyHookContext context, CancellationToken cancellationToken) { - try - { - return new ValueTask(global::TUnit.TestProject.BeforeTests.AssemblyBase1.BeforeAll1()); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + return new ValueTask(global::TUnit.TestProject.BeforeTests.AssemblyBase1.BeforeAll1()); } - static readonly int _h_TUnit_TestProject_BeforeTests_AssemblyBase1_BeforeEach1_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.AssemblyBase1), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), + static readonly int _h_TUnit_TestProject_BeforeTests_AssemblyBase1_BeforeEach1_Before_Test_8b6c7366 = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.AssemblyBase1), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), static __registrationIndex => new InstanceHookMethod { @@ -86,20 +79,13 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_BeforeTests_AssemblyBase1_BeforeEach1_Before_Test_Body + Body = TUnit_TestProject_BeforeTests_AssemblyBase1_BeforeEach1_Before_Test_8b6c7366_Body } ); - private static ValueTask TUnit_TestProject_BeforeTests_AssemblyBase1_BeforeEach1_Before_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_BeforeTests_AssemblyBase1_BeforeEach1_Before_Test_8b6c7366_Body(object instance, TestContext context, CancellationToken cancellationToken) { - try - { - var typedInstance = (global::TUnit.TestProject.BeforeTests.AssemblyBase1)instance; - return new ValueTask(typedInstance.BeforeEach1()); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + var typedInstance = (global::TUnit.TestProject.BeforeTests.AssemblyBase1)instance; + return new ValueTask(typedInstance.BeforeEach1()); } } } @@ -122,7 +108,7 @@ namespace TUnit.Generated { internal static partial class TUnit_HookRegistration { - static readonly int _h_TUnit_TestProject_BeforeTests_AssemblyBase2_BeforeAll2_Before_Assembly = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeAssemblyHooks, typeof(global::TUnit.TestProject.BeforeTests.AssemblyBase2).Assembly, global::TUnit.Core.HookRegistrationIndices.GetNextBeforeAssemblyHookIndex(), + static readonly int _h_TUnit_TestProject_BeforeTests_AssemblyBase2_BeforeAll2_Before_Assembly_414b5632 = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeAssemblyHooks, typeof(global::TUnit.TestProject.BeforeTests.AssemblyBase2).Assembly, global::TUnit.Core.HookRegistrationIndices.GetNextBeforeAssemblyHookIndex(), static __registrationIndex => new BeforeAssemblyHookMethod { @@ -150,23 +136,16 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_BeforeTests_AssemblyBase2_BeforeAll2_Before_Assembly_Body, + Body = TUnit_TestProject_BeforeTests_AssemblyBase2_BeforeAll2_Before_Assembly_414b5632_Body, FilePath = "", LineNumber = 20 } ); - private static ValueTask TUnit_TestProject_BeforeTests_AssemblyBase2_BeforeAll2_Before_Assembly_Body(AssemblyHookContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_BeforeTests_AssemblyBase2_BeforeAll2_Before_Assembly_414b5632_Body(AssemblyHookContext context, CancellationToken cancellationToken) { - try - { - return new ValueTask(global::TUnit.TestProject.BeforeTests.AssemblyBase2.BeforeAll2()); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + return new ValueTask(global::TUnit.TestProject.BeforeTests.AssemblyBase2.BeforeAll2()); } - static readonly int _h_TUnit_TestProject_BeforeTests_AssemblyBase2_BeforeEach2_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.AssemblyBase2), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), + static readonly int _h_TUnit_TestProject_BeforeTests_AssemblyBase2_BeforeEach2_Before_Test_729d7bfe = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.AssemblyBase2), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), static __registrationIndex => new InstanceHookMethod { @@ -195,20 +174,13 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_BeforeTests_AssemblyBase2_BeforeEach2_Before_Test_Body + Body = TUnit_TestProject_BeforeTests_AssemblyBase2_BeforeEach2_Before_Test_729d7bfe_Body } ); - private static ValueTask TUnit_TestProject_BeforeTests_AssemblyBase2_BeforeEach2_Before_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_BeforeTests_AssemblyBase2_BeforeEach2_Before_Test_729d7bfe_Body(object instance, TestContext context, CancellationToken cancellationToken) { - try - { - var typedInstance = (global::TUnit.TestProject.BeforeTests.AssemblyBase2)instance; - return new ValueTask(typedInstance.BeforeEach2()); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + var typedInstance = (global::TUnit.TestProject.BeforeTests.AssemblyBase2)instance; + return new ValueTask(typedInstance.BeforeEach2()); } } } @@ -231,7 +203,7 @@ namespace TUnit.Generated { internal static partial class TUnit_HookRegistration { - static readonly int _h_TUnit_TestProject_BeforeTests_AssemblyBase3_BeforeAll3_Before_Assembly = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeAssemblyHooks, typeof(global::TUnit.TestProject.BeforeTests.AssemblyBase3).Assembly, global::TUnit.Core.HookRegistrationIndices.GetNextBeforeAssemblyHookIndex(), + static readonly int _h_TUnit_TestProject_BeforeTests_AssemblyBase3_BeforeAll3_Before_Assembly_fd6aaffc = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeAssemblyHooks, typeof(global::TUnit.TestProject.BeforeTests.AssemblyBase3).Assembly, global::TUnit.Core.HookRegistrationIndices.GetNextBeforeAssemblyHookIndex(), static __registrationIndex => new BeforeAssemblyHookMethod { @@ -259,23 +231,16 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_BeforeTests_AssemblyBase3_BeforeAll3_Before_Assembly_Body, + Body = TUnit_TestProject_BeforeTests_AssemblyBase3_BeforeAll3_Before_Assembly_fd6aaffc_Body, FilePath = "", LineNumber = 35 } ); - private static ValueTask TUnit_TestProject_BeforeTests_AssemblyBase3_BeforeAll3_Before_Assembly_Body(AssemblyHookContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_BeforeTests_AssemblyBase3_BeforeAll3_Before_Assembly_fd6aaffc_Body(AssemblyHookContext context, CancellationToken cancellationToken) { - try - { - return new ValueTask(global::TUnit.TestProject.BeforeTests.AssemblyBase3.BeforeAll3()); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + return new ValueTask(global::TUnit.TestProject.BeforeTests.AssemblyBase3.BeforeAll3()); } - static readonly int _h_TUnit_TestProject_BeforeTests_AssemblyBase3_BeforeEach3_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.AssemblyBase3), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), + static readonly int _h_TUnit_TestProject_BeforeTests_AssemblyBase3_BeforeEach3_Before_Test_fa464f6e = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.AssemblyBase3), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), static __registrationIndex => new InstanceHookMethod { @@ -304,20 +269,13 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_BeforeTests_AssemblyBase3_BeforeEach3_Before_Test_Body + Body = TUnit_TestProject_BeforeTests_AssemblyBase3_BeforeEach3_Before_Test_fa464f6e_Body } ); - private static ValueTask TUnit_TestProject_BeforeTests_AssemblyBase3_BeforeEach3_Before_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_BeforeTests_AssemblyBase3_BeforeEach3_Before_Test_fa464f6e_Body(object instance, TestContext context, CancellationToken cancellationToken) { - try - { - var typedInstance = (global::TUnit.TestProject.BeforeTests.AssemblyBase3)instance; - return new ValueTask(typedInstance.BeforeEach3()); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + var typedInstance = (global::TUnit.TestProject.BeforeTests.AssemblyBase3)instance; + return new ValueTask(typedInstance.BeforeEach3()); } } } @@ -340,7 +298,7 @@ namespace TUnit.Generated { internal static partial class TUnit_HookRegistration { - static readonly int _h_TUnit_TestProject_BeforeTests_AssemblySetupTests_BeforeAllSetUp_Before_Assembly = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeAssemblyHooks, typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests).Assembly, global::TUnit.Core.HookRegistrationIndices.GetNextBeforeAssemblyHookIndex(), + static readonly int _h_TUnit_TestProject_BeforeTests_AssemblySetupTests_BeforeAllSetUp_Before_Assembly_8a7d4fe6 = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeAssemblyHooks, typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests).Assembly, global::TUnit.Core.HookRegistrationIndices.GetNextBeforeAssemblyHookIndex(), static __registrationIndex => new BeforeAssemblyHookMethod { @@ -368,23 +326,16 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_BeforeTests_AssemblySetupTests_BeforeAllSetUp_Before_Assembly_Body, + Body = TUnit_TestProject_BeforeTests_AssemblySetupTests_BeforeAllSetUp_Before_Assembly_8a7d4fe6_Body, FilePath = "", LineNumber = 50 } ); - private static ValueTask TUnit_TestProject_BeforeTests_AssemblySetupTests_BeforeAllSetUp_Before_Assembly_Body(AssemblyHookContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_BeforeTests_AssemblySetupTests_BeforeAllSetUp_Before_Assembly_8a7d4fe6_Body(AssemblyHookContext context, CancellationToken cancellationToken) { - try - { - return new ValueTask(global::TUnit.TestProject.BeforeTests.AssemblySetupTests.BeforeAllSetUp()); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + return new ValueTask(global::TUnit.TestProject.BeforeTests.AssemblySetupTests.BeforeAllSetUp()); } - static readonly int _h_TUnit_TestProject_BeforeTests_AssemblySetupTests_BeforeAllSetUpWithContext__AssemblyHookContext_Before_Assembly = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeAssemblyHooks, typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests).Assembly, global::TUnit.Core.HookRegistrationIndices.GetNextBeforeAssemblyHookIndex(), + static readonly int _h_TUnit_TestProject_BeforeTests_AssemblySetupTests_BeforeAllSetUpWithContext__AssemblyHookContext_Before_Assembly_ba4752b9 = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeAssemblyHooks, typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests).Assembly, global::TUnit.Core.HookRegistrationIndices.GetNextBeforeAssemblyHookIndex(), static __registrationIndex => new BeforeAssemblyHookMethod { @@ -415,23 +366,16 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_BeforeTests_AssemblySetupTests_BeforeAllSetUpWithContext__AssemblyHookContext_Before_Assembly_Body, + Body = TUnit_TestProject_BeforeTests_AssemblySetupTests_BeforeAllSetUpWithContext__AssemblyHookContext_Before_Assembly_ba4752b9_Body, FilePath = "", LineNumber = 56 } ); - private static ValueTask TUnit_TestProject_BeforeTests_AssemblySetupTests_BeforeAllSetUpWithContext__AssemblyHookContext_Before_Assembly_Body(AssemblyHookContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_BeforeTests_AssemblySetupTests_BeforeAllSetUpWithContext__AssemblyHookContext_Before_Assembly_ba4752b9_Body(AssemblyHookContext context, CancellationToken cancellationToken) { - try - { - return new ValueTask(global::TUnit.TestProject.BeforeTests.AssemblySetupTests.BeforeAllSetUpWithContext(context)); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + return new ValueTask(global::TUnit.TestProject.BeforeTests.AssemblySetupTests.BeforeAllSetUpWithContext(context)); } - static readonly int _h_TUnit_TestProject_BeforeTests_AssemblySetupTests_BeforeAllSetUp2_Before_Assembly = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeAssemblyHooks, typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests).Assembly, global::TUnit.Core.HookRegistrationIndices.GetNextBeforeAssemblyHookIndex(), + static readonly int _h_TUnit_TestProject_BeforeTests_AssemblySetupTests_BeforeAllSetUp2_Before_Assembly_31163798 = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeAssemblyHooks, typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests).Assembly, global::TUnit.Core.HookRegistrationIndices.GetNextBeforeAssemblyHookIndex(), static __registrationIndex => new BeforeAssemblyHookMethod { @@ -459,23 +403,16 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_BeforeTests_AssemblySetupTests_BeforeAllSetUp2_Before_Assembly_Body, + Body = TUnit_TestProject_BeforeTests_AssemblySetupTests_BeforeAllSetUp2_Before_Assembly_31163798_Body, FilePath = "", LineNumber = 62 } ); - private static ValueTask TUnit_TestProject_BeforeTests_AssemblySetupTests_BeforeAllSetUp2_Before_Assembly_Body(AssemblyHookContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_BeforeTests_AssemblySetupTests_BeforeAllSetUp2_Before_Assembly_31163798_Body(AssemblyHookContext context, CancellationToken cancellationToken) { - try - { - return new ValueTask(global::TUnit.TestProject.BeforeTests.AssemblySetupTests.BeforeAllSetUp2()); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + return new ValueTask(global::TUnit.TestProject.BeforeTests.AssemblySetupTests.BeforeAllSetUp2()); } - static readonly int _h_TUnit_TestProject_BeforeTests_AssemblySetupTests_BeforeAllSetUpWithContext__AssemblyHookContext_CancellationToken_Before_Assembly = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeAssemblyHooks, typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests).Assembly, global::TUnit.Core.HookRegistrationIndices.GetNextBeforeAssemblyHookIndex(), + static readonly int _h_TUnit_TestProject_BeforeTests_AssemblySetupTests_BeforeAllSetUpWithContext__AssemblyHookContext_CancellationToken_Before_Assembly_ba124fad = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeAssemblyHooks, typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests).Assembly, global::TUnit.Core.HookRegistrationIndices.GetNextBeforeAssemblyHookIndex(), static __registrationIndex => new BeforeAssemblyHookMethod { @@ -507,23 +444,16 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_BeforeTests_AssemblySetupTests_BeforeAllSetUpWithContext__AssemblyHookContext_CancellationToken_Before_Assembly_Body, + Body = TUnit_TestProject_BeforeTests_AssemblySetupTests_BeforeAllSetUpWithContext__AssemblyHookContext_CancellationToken_Before_Assembly_ba124fad_Body, FilePath = "", LineNumber = 68 } ); - private static ValueTask TUnit_TestProject_BeforeTests_AssemblySetupTests_BeforeAllSetUpWithContext__AssemblyHookContext_CancellationToken_Before_Assembly_Body(AssemblyHookContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_BeforeTests_AssemblySetupTests_BeforeAllSetUpWithContext__AssemblyHookContext_CancellationToken_Before_Assembly_ba124fad_Body(AssemblyHookContext context, CancellationToken cancellationToken) { - try - { - return new ValueTask(global::TUnit.TestProject.BeforeTests.AssemblySetupTests.BeforeAllSetUpWithContext(context, cancellationToken)); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + return new ValueTask(global::TUnit.TestProject.BeforeTests.AssemblySetupTests.BeforeAllSetUpWithContext(context, cancellationToken)); } - static readonly int _h_TUnit_TestProject_BeforeTests_AssemblySetupTests_Setup_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), + static readonly int _h_TUnit_TestProject_BeforeTests_AssemblySetupTests_Setup_Before_Test_d378585a = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), static __registrationIndex => new InstanceHookMethod { @@ -552,22 +482,15 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_BeforeTests_AssemblySetupTests_Setup_Before_Test_Body + Body = TUnit_TestProject_BeforeTests_AssemblySetupTests_Setup_Before_Test_d378585a_Body } ); - private static ValueTask TUnit_TestProject_BeforeTests_AssemblySetupTests_Setup_Before_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_BeforeTests_AssemblySetupTests_Setup_Before_Test_d378585a_Body(object instance, TestContext context, CancellationToken cancellationToken) { - try - { - var typedInstance = (global::TUnit.TestProject.BeforeTests.AssemblySetupTests)instance; - return new ValueTask(typedInstance.Setup()); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + var typedInstance = (global::TUnit.TestProject.BeforeTests.AssemblySetupTests)instance; + return new ValueTask(typedInstance.Setup()); } - static readonly int _h_TUnit_TestProject_BeforeTests_AssemblySetupTests_Setup__CancellationToken_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), + static readonly int _h_TUnit_TestProject_BeforeTests_AssemblySetupTests_Setup__CancellationToken_Before_Test_45c177c0 = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), static __registrationIndex => new InstanceHookMethod { @@ -599,22 +522,15 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_BeforeTests_AssemblySetupTests_Setup__CancellationToken_Before_Test_Body + Body = TUnit_TestProject_BeforeTests_AssemblySetupTests_Setup__CancellationToken_Before_Test_45c177c0_Body } ); - private static ValueTask TUnit_TestProject_BeforeTests_AssemblySetupTests_Setup__CancellationToken_Before_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_BeforeTests_AssemblySetupTests_Setup__CancellationToken_Before_Test_45c177c0_Body(object instance, TestContext context, CancellationToken cancellationToken) { - try - { - var typedInstance = (global::TUnit.TestProject.BeforeTests.AssemblySetupTests)instance; - return new ValueTask(typedInstance.Setup(cancellationToken)); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + var typedInstance = (global::TUnit.TestProject.BeforeTests.AssemblySetupTests)instance; + return new ValueTask(typedInstance.Setup(cancellationToken)); } - static readonly int _h_TUnit_TestProject_BeforeTests_AssemblySetupTests_SetupWithContext__TestContext_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), + static readonly int _h_TUnit_TestProject_BeforeTests_AssemblySetupTests_SetupWithContext__TestContext_Before_Test_565c5b5a = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), static __registrationIndex => new InstanceHookMethod { @@ -646,22 +562,15 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_BeforeTests_AssemblySetupTests_SetupWithContext__TestContext_Before_Test_Body + Body = TUnit_TestProject_BeforeTests_AssemblySetupTests_SetupWithContext__TestContext_Before_Test_565c5b5a_Body } ); - private static ValueTask TUnit_TestProject_BeforeTests_AssemblySetupTests_SetupWithContext__TestContext_Before_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_BeforeTests_AssemblySetupTests_SetupWithContext__TestContext_Before_Test_565c5b5a_Body(object instance, TestContext context, CancellationToken cancellationToken) { - try - { - var typedInstance = (global::TUnit.TestProject.BeforeTests.AssemblySetupTests)instance; - return new ValueTask(typedInstance.SetupWithContext(context)); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + var typedInstance = (global::TUnit.TestProject.BeforeTests.AssemblySetupTests)instance; + return new ValueTask(typedInstance.SetupWithContext(context)); } - static readonly int _h_TUnit_TestProject_BeforeTests_AssemblySetupTests_SetupWithContext__TestContext_CancellationToken_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), + static readonly int _h_TUnit_TestProject_BeforeTests_AssemblySetupTests_SetupWithContext__TestContext_CancellationToken_Before_Test_41aba49c = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.AssemblySetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), static __registrationIndex => new InstanceHookMethod { @@ -694,20 +603,13 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_BeforeTests_AssemblySetupTests_SetupWithContext__TestContext_CancellationToken_Before_Test_Body + Body = TUnit_TestProject_BeforeTests_AssemblySetupTests_SetupWithContext__TestContext_CancellationToken_Before_Test_41aba49c_Body } ); - private static ValueTask TUnit_TestProject_BeforeTests_AssemblySetupTests_SetupWithContext__TestContext_CancellationToken_Before_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_BeforeTests_AssemblySetupTests_SetupWithContext__TestContext_CancellationToken_Before_Test_41aba49c_Body(object instance, TestContext context, CancellationToken cancellationToken) { - try - { - var typedInstance = (global::TUnit.TestProject.BeforeTests.AssemblySetupTests)instance; - return new ValueTask(typedInstance.SetupWithContext(context, cancellationToken)); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + var typedInstance = (global::TUnit.TestProject.BeforeTests.AssemblySetupTests)instance; + return new ValueTask(typedInstance.SetupWithContext(context, cancellationToken)); } } } diff --git a/tests/TUnit.Core.SourceGenerator.Tests/ConflictingNamespaceTests.HooksTest_WithConflictingNamespace.DotNet10_0.verified.txt b/tests/TUnit.Core.SourceGenerator.Tests/ConflictingNamespaceTests.HooksTest_WithConflictingNamespace.DotNet10_0.verified.txt index 2e6a86de97c..b1638131676 100644 --- a/tests/TUnit.Core.SourceGenerator.Tests/ConflictingNamespaceTests.HooksTest_WithConflictingNamespace.DotNet10_0.verified.txt +++ b/tests/TUnit.Core.SourceGenerator.Tests/ConflictingNamespaceTests.HooksTest_WithConflictingNamespace.DotNet10_0.verified.txt @@ -1,4 +1,4 @@ -// +// #pragma warning disable #nullable enable @@ -13,7 +13,7 @@ namespace TUnit.Generated { internal static partial class TUnit_HookRegistration { - static readonly int _h_TUnit_TestProject_BeforeTests_Base1_BeforeAll1_Before_Class = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeClassHooks, typeof(global::TUnit.TestProject.BeforeTests.Base1), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeClassHookIndex(), + static readonly int _h_TUnit_TestProject_BeforeTests_Base1_BeforeAll1_Before_Class_5c51506c = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeClassHooks, typeof(global::TUnit.TestProject.BeforeTests.Base1), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeClassHookIndex(), static __registrationIndex => new BeforeClassHookMethod { @@ -41,23 +41,16 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_BeforeTests_Base1_BeforeAll1_Before_Class_Body, + Body = TUnit_TestProject_BeforeTests_Base1_BeforeAll1_Before_Class_5c51506c_Body, FilePath = "", LineNumber = 5 } ); - private static ValueTask TUnit_TestProject_BeforeTests_Base1_BeforeAll1_Before_Class_Body(ClassHookContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_BeforeTests_Base1_BeforeAll1_Before_Class_5c51506c_Body(ClassHookContext context, CancellationToken cancellationToken) { - try - { - return new ValueTask(global::TUnit.TestProject.BeforeTests.Base1.BeforeAll1()); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + return new ValueTask(global::TUnit.TestProject.BeforeTests.Base1.BeforeAll1()); } - static readonly int _h_TUnit_TestProject_BeforeTests_Base1_BeforeEach1_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.Base1), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), + static readonly int _h_TUnit_TestProject_BeforeTests_Base1_BeforeEach1_Before_Test_0f563ec6 = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.Base1), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), static __registrationIndex => new InstanceHookMethod { @@ -86,20 +79,13 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_BeforeTests_Base1_BeforeEach1_Before_Test_Body + Body = TUnit_TestProject_BeforeTests_Base1_BeforeEach1_Before_Test_0f563ec6_Body } ); - private static ValueTask TUnit_TestProject_BeforeTests_Base1_BeforeEach1_Before_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_BeforeTests_Base1_BeforeEach1_Before_Test_0f563ec6_Body(object instance, TestContext context, CancellationToken cancellationToken) { - try - { - var typedInstance = (global::TUnit.TestProject.BeforeTests.Base1)instance; - return new ValueTask(typedInstance.BeforeEach1()); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + var typedInstance = (global::TUnit.TestProject.BeforeTests.Base1)instance; + return new ValueTask(typedInstance.BeforeEach1()); } } } @@ -122,7 +108,7 @@ namespace TUnit.Generated { internal static partial class TUnit_HookRegistration { - static readonly int _h_TUnit_TestProject_BeforeTests_Base2_BeforeAll2_Before_Class = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeClassHooks, typeof(global::TUnit.TestProject.BeforeTests.Base2), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeClassHookIndex(), + static readonly int _h_TUnit_TestProject_BeforeTests_Base2_BeforeAll2_Before_Class_b497be42 = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeClassHooks, typeof(global::TUnit.TestProject.BeforeTests.Base2), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeClassHookIndex(), static __registrationIndex => new BeforeClassHookMethod { @@ -150,23 +136,16 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_BeforeTests_Base2_BeforeAll2_Before_Class_Body, + Body = TUnit_TestProject_BeforeTests_Base2_BeforeAll2_Before_Class_b497be42_Body, FilePath = "", LineNumber = 20 } ); - private static ValueTask TUnit_TestProject_BeforeTests_Base2_BeforeAll2_Before_Class_Body(ClassHookContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_BeforeTests_Base2_BeforeAll2_Before_Class_b497be42_Body(ClassHookContext context, CancellationToken cancellationToken) { - try - { - return new ValueTask(global::TUnit.TestProject.BeforeTests.Base2.BeforeAll2()); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + return new ValueTask(global::TUnit.TestProject.BeforeTests.Base2.BeforeAll2()); } - static readonly int _h_TUnit_TestProject_BeforeTests_Base2_BeforeEach2_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.Base2), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), + static readonly int _h_TUnit_TestProject_BeforeTests_Base2_BeforeEach2_Before_Test_c12372de = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.Base2), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), static __registrationIndex => new InstanceHookMethod { @@ -195,20 +174,13 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_BeforeTests_Base2_BeforeEach2_Before_Test_Body + Body = TUnit_TestProject_BeforeTests_Base2_BeforeEach2_Before_Test_c12372de_Body } ); - private static ValueTask TUnit_TestProject_BeforeTests_Base2_BeforeEach2_Before_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_BeforeTests_Base2_BeforeEach2_Before_Test_c12372de_Body(object instance, TestContext context, CancellationToken cancellationToken) { - try - { - var typedInstance = (global::TUnit.TestProject.BeforeTests.Base2)instance; - return new ValueTask(typedInstance.BeforeEach2()); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + var typedInstance = (global::TUnit.TestProject.BeforeTests.Base2)instance; + return new ValueTask(typedInstance.BeforeEach2()); } } } @@ -231,7 +203,7 @@ namespace TUnit.Generated { internal static partial class TUnit_HookRegistration { - static readonly int _h_TUnit_TestProject_BeforeTests_Base3_BeforeAll3_Before_Class = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeClassHooks, typeof(global::TUnit.TestProject.BeforeTests.Base3), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeClassHookIndex(), + static readonly int _h_TUnit_TestProject_BeforeTests_Base3_BeforeAll3_Before_Class_45e04490 = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeClassHooks, typeof(global::TUnit.TestProject.BeforeTests.Base3), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeClassHookIndex(), static __registrationIndex => new BeforeClassHookMethod { @@ -259,23 +231,16 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_BeforeTests_Base3_BeforeAll3_Before_Class_Body, + Body = TUnit_TestProject_BeforeTests_Base3_BeforeAll3_Before_Class_45e04490_Body, FilePath = "", LineNumber = 35 } ); - private static ValueTask TUnit_TestProject_BeforeTests_Base3_BeforeAll3_Before_Class_Body(ClassHookContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_BeforeTests_Base3_BeforeAll3_Before_Class_45e04490_Body(ClassHookContext context, CancellationToken cancellationToken) { - try - { - return new ValueTask(global::TUnit.TestProject.BeforeTests.Base3.BeforeAll3()); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + return new ValueTask(global::TUnit.TestProject.BeforeTests.Base3.BeforeAll3()); } - static readonly int _h_TUnit_TestProject_BeforeTests_Base3_BeforeEach3_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.Base3), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), + static readonly int _h_TUnit_TestProject_BeforeTests_Base3_BeforeEach3_Before_Test_5cb123ce = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.Base3), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), static __registrationIndex => new InstanceHookMethod { @@ -304,20 +269,13 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_BeforeTests_Base3_BeforeEach3_Before_Test_Body + Body = TUnit_TestProject_BeforeTests_Base3_BeforeEach3_Before_Test_5cb123ce_Body } ); - private static ValueTask TUnit_TestProject_BeforeTests_Base3_BeforeEach3_Before_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_BeforeTests_Base3_BeforeEach3_Before_Test_5cb123ce_Body(object instance, TestContext context, CancellationToken cancellationToken) { - try - { - var typedInstance = (global::TUnit.TestProject.BeforeTests.Base3)instance; - return new ValueTask(typedInstance.BeforeEach3()); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + var typedInstance = (global::TUnit.TestProject.BeforeTests.Base3)instance; + return new ValueTask(typedInstance.BeforeEach3()); } } } @@ -340,7 +298,7 @@ namespace TUnit.Generated { internal static partial class TUnit_HookRegistration { - static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp_Before_Class = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeClassHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeClassHookIndex(), + static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp_Before_Class_e448884e = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeClassHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeClassHookIndex(), static __registrationIndex => new BeforeClassHookMethod { @@ -368,23 +326,16 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp_Before_Class_Body, + Body = TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp_Before_Class_e448884e_Body, FilePath = "", LineNumber = 50 } ); - private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp_Before_Class_Body(ClassHookContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp_Before_Class_e448884e_Body(ClassHookContext context, CancellationToken cancellationToken) { - try - { - return new ValueTask(global::TUnit.TestProject.BeforeTests.SetupTests.BeforeAllSetUp()); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + return new ValueTask(global::TUnit.TestProject.BeforeTests.SetupTests.BeforeAllSetUp()); } - static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_Before_Class = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeClassHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeClassHookIndex(), + static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_Before_Class_a169a78d = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeClassHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeClassHookIndex(), static __registrationIndex => new BeforeClassHookMethod { @@ -415,23 +366,16 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_Before_Class_Body, + Body = TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_Before_Class_a169a78d_Body, FilePath = "", LineNumber = 56 } ); - private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_Before_Class_Body(ClassHookContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_Before_Class_a169a78d_Body(ClassHookContext context, CancellationToken cancellationToken) { - try - { - return new ValueTask(global::TUnit.TestProject.BeforeTests.SetupTests.BeforeAllSetUpWithContext(context)); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + return new ValueTask(global::TUnit.TestProject.BeforeTests.SetupTests.BeforeAllSetUpWithContext(context)); } - static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp__CancellationToken_Before_Class = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeClassHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeClassHookIndex(), + static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp__CancellationToken_Before_Class_baa8f1e8 = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeClassHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeClassHookIndex(), static __registrationIndex => new BeforeClassHookMethod { @@ -462,23 +406,16 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp__CancellationToken_Before_Class_Body, + Body = TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp__CancellationToken_Before_Class_baa8f1e8_Body, FilePath = "", LineNumber = 62 } ); - private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp__CancellationToken_Before_Class_Body(ClassHookContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp__CancellationToken_Before_Class_baa8f1e8_Body(ClassHookContext context, CancellationToken cancellationToken) { - try - { - return new ValueTask(global::TUnit.TestProject.BeforeTests.SetupTests.BeforeAllSetUp(cancellationToken)); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + return new ValueTask(global::TUnit.TestProject.BeforeTests.SetupTests.BeforeAllSetUp(cancellationToken)); } - static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_CancellationToken_Before_Class = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeClassHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeClassHookIndex(), + static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_CancellationToken_Before_Class_95aea855 = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeClassHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeClassHookIndex(), static __registrationIndex => new BeforeClassHookMethod { @@ -510,23 +447,16 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_CancellationToken_Before_Class_Body, + Body = TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_CancellationToken_Before_Class_95aea855_Body, FilePath = "", LineNumber = 68 } ); - private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_CancellationToken_Before_Class_Body(ClassHookContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_CancellationToken_Before_Class_95aea855_Body(ClassHookContext context, CancellationToken cancellationToken) { - try - { - return new ValueTask(global::TUnit.TestProject.BeforeTests.SetupTests.BeforeAllSetUpWithContext(context, cancellationToken)); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + return new ValueTask(global::TUnit.TestProject.BeforeTests.SetupTests.BeforeAllSetUpWithContext(context, cancellationToken)); } - static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_Setup_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), + static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_Setup_Before_Test_234813ba = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), static __registrationIndex => new InstanceHookMethod { @@ -555,22 +485,15 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_BeforeTests_SetupTests_Setup_Before_Test_Body + Body = TUnit_TestProject_BeforeTests_SetupTests_Setup_Before_Test_234813ba_Body } ); - private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_Setup_Before_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_Setup_Before_Test_234813ba_Body(object instance, TestContext context, CancellationToken cancellationToken) { - try - { - var typedInstance = (global::TUnit.TestProject.BeforeTests.SetupTests)instance; - return new ValueTask(typedInstance.Setup()); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + var typedInstance = (global::TUnit.TestProject.BeforeTests.SetupTests)instance; + return new ValueTask(typedInstance.Setup()); } - static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_Setup__CancellationToken_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), + static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_Setup__CancellationToken_Before_Test_81adbb20 = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), static __registrationIndex => new InstanceHookMethod { @@ -602,22 +525,15 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_BeforeTests_SetupTests_Setup__CancellationToken_Before_Test_Body + Body = TUnit_TestProject_BeforeTests_SetupTests_Setup__CancellationToken_Before_Test_81adbb20_Body } ); - private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_Setup__CancellationToken_Before_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_Setup__CancellationToken_Before_Test_81adbb20_Body(object instance, TestContext context, CancellationToken cancellationToken) { - try - { - var typedInstance = (global::TUnit.TestProject.BeforeTests.SetupTests)instance; - return new ValueTask(typedInstance.Setup(cancellationToken)); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + var typedInstance = (global::TUnit.TestProject.BeforeTests.SetupTests)instance; + return new ValueTask(typedInstance.Setup(cancellationToken)); } - static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), + static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_Before_Test_01c9267a = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), static __registrationIndex => new InstanceHookMethod { @@ -649,22 +565,15 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_Before_Test_Body + Body = TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_Before_Test_01c9267a_Body } ); - private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_Before_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_Before_Test_01c9267a_Body(object instance, TestContext context, CancellationToken cancellationToken) { - try - { - var typedInstance = (global::TUnit.TestProject.BeforeTests.SetupTests)instance; - return new ValueTask(typedInstance.SetupWithContext(context)); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + var typedInstance = (global::TUnit.TestProject.BeforeTests.SetupTests)instance; + return new ValueTask(typedInstance.SetupWithContext(context)); } - static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_CancellationToken_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), + static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_CancellationToken_Before_Test_5aec0dbc = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), static __registrationIndex => new InstanceHookMethod { @@ -697,20 +606,13 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_CancellationToken_Before_Test_Body + Body = TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_CancellationToken_Before_Test_5aec0dbc_Body } ); - private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_CancellationToken_Before_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_CancellationToken_Before_Test_5aec0dbc_Body(object instance, TestContext context, CancellationToken cancellationToken) { - try - { - var typedInstance = (global::TUnit.TestProject.BeforeTests.SetupTests)instance; - return new ValueTask(typedInstance.SetupWithContext(context, cancellationToken)); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + var typedInstance = (global::TUnit.TestProject.BeforeTests.SetupTests)instance; + return new ValueTask(typedInstance.SetupWithContext(context, cancellationToken)); } } } diff --git a/tests/TUnit.Core.SourceGenerator.Tests/ConflictingNamespaceTests.HooksTest_WithConflictingNamespace.DotNet8_0.verified.txt b/tests/TUnit.Core.SourceGenerator.Tests/ConflictingNamespaceTests.HooksTest_WithConflictingNamespace.DotNet8_0.verified.txt index 2e6a86de97c..b1638131676 100644 --- a/tests/TUnit.Core.SourceGenerator.Tests/ConflictingNamespaceTests.HooksTest_WithConflictingNamespace.DotNet8_0.verified.txt +++ b/tests/TUnit.Core.SourceGenerator.Tests/ConflictingNamespaceTests.HooksTest_WithConflictingNamespace.DotNet8_0.verified.txt @@ -1,4 +1,4 @@ -// +// #pragma warning disable #nullable enable @@ -13,7 +13,7 @@ namespace TUnit.Generated { internal static partial class TUnit_HookRegistration { - static readonly int _h_TUnit_TestProject_BeforeTests_Base1_BeforeAll1_Before_Class = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeClassHooks, typeof(global::TUnit.TestProject.BeforeTests.Base1), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeClassHookIndex(), + static readonly int _h_TUnit_TestProject_BeforeTests_Base1_BeforeAll1_Before_Class_5c51506c = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeClassHooks, typeof(global::TUnit.TestProject.BeforeTests.Base1), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeClassHookIndex(), static __registrationIndex => new BeforeClassHookMethod { @@ -41,23 +41,16 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_BeforeTests_Base1_BeforeAll1_Before_Class_Body, + Body = TUnit_TestProject_BeforeTests_Base1_BeforeAll1_Before_Class_5c51506c_Body, FilePath = "", LineNumber = 5 } ); - private static ValueTask TUnit_TestProject_BeforeTests_Base1_BeforeAll1_Before_Class_Body(ClassHookContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_BeforeTests_Base1_BeforeAll1_Before_Class_5c51506c_Body(ClassHookContext context, CancellationToken cancellationToken) { - try - { - return new ValueTask(global::TUnit.TestProject.BeforeTests.Base1.BeforeAll1()); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + return new ValueTask(global::TUnit.TestProject.BeforeTests.Base1.BeforeAll1()); } - static readonly int _h_TUnit_TestProject_BeforeTests_Base1_BeforeEach1_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.Base1), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), + static readonly int _h_TUnit_TestProject_BeforeTests_Base1_BeforeEach1_Before_Test_0f563ec6 = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.Base1), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), static __registrationIndex => new InstanceHookMethod { @@ -86,20 +79,13 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_BeforeTests_Base1_BeforeEach1_Before_Test_Body + Body = TUnit_TestProject_BeforeTests_Base1_BeforeEach1_Before_Test_0f563ec6_Body } ); - private static ValueTask TUnit_TestProject_BeforeTests_Base1_BeforeEach1_Before_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_BeforeTests_Base1_BeforeEach1_Before_Test_0f563ec6_Body(object instance, TestContext context, CancellationToken cancellationToken) { - try - { - var typedInstance = (global::TUnit.TestProject.BeforeTests.Base1)instance; - return new ValueTask(typedInstance.BeforeEach1()); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + var typedInstance = (global::TUnit.TestProject.BeforeTests.Base1)instance; + return new ValueTask(typedInstance.BeforeEach1()); } } } @@ -122,7 +108,7 @@ namespace TUnit.Generated { internal static partial class TUnit_HookRegistration { - static readonly int _h_TUnit_TestProject_BeforeTests_Base2_BeforeAll2_Before_Class = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeClassHooks, typeof(global::TUnit.TestProject.BeforeTests.Base2), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeClassHookIndex(), + static readonly int _h_TUnit_TestProject_BeforeTests_Base2_BeforeAll2_Before_Class_b497be42 = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeClassHooks, typeof(global::TUnit.TestProject.BeforeTests.Base2), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeClassHookIndex(), static __registrationIndex => new BeforeClassHookMethod { @@ -150,23 +136,16 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_BeforeTests_Base2_BeforeAll2_Before_Class_Body, + Body = TUnit_TestProject_BeforeTests_Base2_BeforeAll2_Before_Class_b497be42_Body, FilePath = "", LineNumber = 20 } ); - private static ValueTask TUnit_TestProject_BeforeTests_Base2_BeforeAll2_Before_Class_Body(ClassHookContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_BeforeTests_Base2_BeforeAll2_Before_Class_b497be42_Body(ClassHookContext context, CancellationToken cancellationToken) { - try - { - return new ValueTask(global::TUnit.TestProject.BeforeTests.Base2.BeforeAll2()); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + return new ValueTask(global::TUnit.TestProject.BeforeTests.Base2.BeforeAll2()); } - static readonly int _h_TUnit_TestProject_BeforeTests_Base2_BeforeEach2_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.Base2), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), + static readonly int _h_TUnit_TestProject_BeforeTests_Base2_BeforeEach2_Before_Test_c12372de = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.Base2), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), static __registrationIndex => new InstanceHookMethod { @@ -195,20 +174,13 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_BeforeTests_Base2_BeforeEach2_Before_Test_Body + Body = TUnit_TestProject_BeforeTests_Base2_BeforeEach2_Before_Test_c12372de_Body } ); - private static ValueTask TUnit_TestProject_BeforeTests_Base2_BeforeEach2_Before_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_BeforeTests_Base2_BeforeEach2_Before_Test_c12372de_Body(object instance, TestContext context, CancellationToken cancellationToken) { - try - { - var typedInstance = (global::TUnit.TestProject.BeforeTests.Base2)instance; - return new ValueTask(typedInstance.BeforeEach2()); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + var typedInstance = (global::TUnit.TestProject.BeforeTests.Base2)instance; + return new ValueTask(typedInstance.BeforeEach2()); } } } @@ -231,7 +203,7 @@ namespace TUnit.Generated { internal static partial class TUnit_HookRegistration { - static readonly int _h_TUnit_TestProject_BeforeTests_Base3_BeforeAll3_Before_Class = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeClassHooks, typeof(global::TUnit.TestProject.BeforeTests.Base3), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeClassHookIndex(), + static readonly int _h_TUnit_TestProject_BeforeTests_Base3_BeforeAll3_Before_Class_45e04490 = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeClassHooks, typeof(global::TUnit.TestProject.BeforeTests.Base3), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeClassHookIndex(), static __registrationIndex => new BeforeClassHookMethod { @@ -259,23 +231,16 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_BeforeTests_Base3_BeforeAll3_Before_Class_Body, + Body = TUnit_TestProject_BeforeTests_Base3_BeforeAll3_Before_Class_45e04490_Body, FilePath = "", LineNumber = 35 } ); - private static ValueTask TUnit_TestProject_BeforeTests_Base3_BeforeAll3_Before_Class_Body(ClassHookContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_BeforeTests_Base3_BeforeAll3_Before_Class_45e04490_Body(ClassHookContext context, CancellationToken cancellationToken) { - try - { - return new ValueTask(global::TUnit.TestProject.BeforeTests.Base3.BeforeAll3()); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + return new ValueTask(global::TUnit.TestProject.BeforeTests.Base3.BeforeAll3()); } - static readonly int _h_TUnit_TestProject_BeforeTests_Base3_BeforeEach3_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.Base3), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), + static readonly int _h_TUnit_TestProject_BeforeTests_Base3_BeforeEach3_Before_Test_5cb123ce = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.Base3), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), static __registrationIndex => new InstanceHookMethod { @@ -304,20 +269,13 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_BeforeTests_Base3_BeforeEach3_Before_Test_Body + Body = TUnit_TestProject_BeforeTests_Base3_BeforeEach3_Before_Test_5cb123ce_Body } ); - private static ValueTask TUnit_TestProject_BeforeTests_Base3_BeforeEach3_Before_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_BeforeTests_Base3_BeforeEach3_Before_Test_5cb123ce_Body(object instance, TestContext context, CancellationToken cancellationToken) { - try - { - var typedInstance = (global::TUnit.TestProject.BeforeTests.Base3)instance; - return new ValueTask(typedInstance.BeforeEach3()); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + var typedInstance = (global::TUnit.TestProject.BeforeTests.Base3)instance; + return new ValueTask(typedInstance.BeforeEach3()); } } } @@ -340,7 +298,7 @@ namespace TUnit.Generated { internal static partial class TUnit_HookRegistration { - static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp_Before_Class = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeClassHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeClassHookIndex(), + static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp_Before_Class_e448884e = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeClassHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeClassHookIndex(), static __registrationIndex => new BeforeClassHookMethod { @@ -368,23 +326,16 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp_Before_Class_Body, + Body = TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp_Before_Class_e448884e_Body, FilePath = "", LineNumber = 50 } ); - private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp_Before_Class_Body(ClassHookContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp_Before_Class_e448884e_Body(ClassHookContext context, CancellationToken cancellationToken) { - try - { - return new ValueTask(global::TUnit.TestProject.BeforeTests.SetupTests.BeforeAllSetUp()); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + return new ValueTask(global::TUnit.TestProject.BeforeTests.SetupTests.BeforeAllSetUp()); } - static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_Before_Class = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeClassHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeClassHookIndex(), + static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_Before_Class_a169a78d = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeClassHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeClassHookIndex(), static __registrationIndex => new BeforeClassHookMethod { @@ -415,23 +366,16 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_Before_Class_Body, + Body = TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_Before_Class_a169a78d_Body, FilePath = "", LineNumber = 56 } ); - private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_Before_Class_Body(ClassHookContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_Before_Class_a169a78d_Body(ClassHookContext context, CancellationToken cancellationToken) { - try - { - return new ValueTask(global::TUnit.TestProject.BeforeTests.SetupTests.BeforeAllSetUpWithContext(context)); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + return new ValueTask(global::TUnit.TestProject.BeforeTests.SetupTests.BeforeAllSetUpWithContext(context)); } - static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp__CancellationToken_Before_Class = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeClassHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeClassHookIndex(), + static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp__CancellationToken_Before_Class_baa8f1e8 = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeClassHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeClassHookIndex(), static __registrationIndex => new BeforeClassHookMethod { @@ -462,23 +406,16 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp__CancellationToken_Before_Class_Body, + Body = TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp__CancellationToken_Before_Class_baa8f1e8_Body, FilePath = "", LineNumber = 62 } ); - private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp__CancellationToken_Before_Class_Body(ClassHookContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp__CancellationToken_Before_Class_baa8f1e8_Body(ClassHookContext context, CancellationToken cancellationToken) { - try - { - return new ValueTask(global::TUnit.TestProject.BeforeTests.SetupTests.BeforeAllSetUp(cancellationToken)); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + return new ValueTask(global::TUnit.TestProject.BeforeTests.SetupTests.BeforeAllSetUp(cancellationToken)); } - static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_CancellationToken_Before_Class = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeClassHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeClassHookIndex(), + static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_CancellationToken_Before_Class_95aea855 = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeClassHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeClassHookIndex(), static __registrationIndex => new BeforeClassHookMethod { @@ -510,23 +447,16 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_CancellationToken_Before_Class_Body, + Body = TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_CancellationToken_Before_Class_95aea855_Body, FilePath = "", LineNumber = 68 } ); - private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_CancellationToken_Before_Class_Body(ClassHookContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_CancellationToken_Before_Class_95aea855_Body(ClassHookContext context, CancellationToken cancellationToken) { - try - { - return new ValueTask(global::TUnit.TestProject.BeforeTests.SetupTests.BeforeAllSetUpWithContext(context, cancellationToken)); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + return new ValueTask(global::TUnit.TestProject.BeforeTests.SetupTests.BeforeAllSetUpWithContext(context, cancellationToken)); } - static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_Setup_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), + static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_Setup_Before_Test_234813ba = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), static __registrationIndex => new InstanceHookMethod { @@ -555,22 +485,15 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_BeforeTests_SetupTests_Setup_Before_Test_Body + Body = TUnit_TestProject_BeforeTests_SetupTests_Setup_Before_Test_234813ba_Body } ); - private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_Setup_Before_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_Setup_Before_Test_234813ba_Body(object instance, TestContext context, CancellationToken cancellationToken) { - try - { - var typedInstance = (global::TUnit.TestProject.BeforeTests.SetupTests)instance; - return new ValueTask(typedInstance.Setup()); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + var typedInstance = (global::TUnit.TestProject.BeforeTests.SetupTests)instance; + return new ValueTask(typedInstance.Setup()); } - static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_Setup__CancellationToken_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), + static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_Setup__CancellationToken_Before_Test_81adbb20 = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), static __registrationIndex => new InstanceHookMethod { @@ -602,22 +525,15 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_BeforeTests_SetupTests_Setup__CancellationToken_Before_Test_Body + Body = TUnit_TestProject_BeforeTests_SetupTests_Setup__CancellationToken_Before_Test_81adbb20_Body } ); - private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_Setup__CancellationToken_Before_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_Setup__CancellationToken_Before_Test_81adbb20_Body(object instance, TestContext context, CancellationToken cancellationToken) { - try - { - var typedInstance = (global::TUnit.TestProject.BeforeTests.SetupTests)instance; - return new ValueTask(typedInstance.Setup(cancellationToken)); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + var typedInstance = (global::TUnit.TestProject.BeforeTests.SetupTests)instance; + return new ValueTask(typedInstance.Setup(cancellationToken)); } - static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), + static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_Before_Test_01c9267a = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), static __registrationIndex => new InstanceHookMethod { @@ -649,22 +565,15 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_Before_Test_Body + Body = TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_Before_Test_01c9267a_Body } ); - private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_Before_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_Before_Test_01c9267a_Body(object instance, TestContext context, CancellationToken cancellationToken) { - try - { - var typedInstance = (global::TUnit.TestProject.BeforeTests.SetupTests)instance; - return new ValueTask(typedInstance.SetupWithContext(context)); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + var typedInstance = (global::TUnit.TestProject.BeforeTests.SetupTests)instance; + return new ValueTask(typedInstance.SetupWithContext(context)); } - static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_CancellationToken_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), + static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_CancellationToken_Before_Test_5aec0dbc = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), static __registrationIndex => new InstanceHookMethod { @@ -697,20 +606,13 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_CancellationToken_Before_Test_Body + Body = TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_CancellationToken_Before_Test_5aec0dbc_Body } ); - private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_CancellationToken_Before_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_CancellationToken_Before_Test_5aec0dbc_Body(object instance, TestContext context, CancellationToken cancellationToken) { - try - { - var typedInstance = (global::TUnit.TestProject.BeforeTests.SetupTests)instance; - return new ValueTask(typedInstance.SetupWithContext(context, cancellationToken)); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + var typedInstance = (global::TUnit.TestProject.BeforeTests.SetupTests)instance; + return new ValueTask(typedInstance.SetupWithContext(context, cancellationToken)); } } } diff --git a/tests/TUnit.Core.SourceGenerator.Tests/ConflictingNamespaceTests.HooksTest_WithConflictingNamespace.DotNet9_0.verified.txt b/tests/TUnit.Core.SourceGenerator.Tests/ConflictingNamespaceTests.HooksTest_WithConflictingNamespace.DotNet9_0.verified.txt index 2e6a86de97c..b1638131676 100644 --- a/tests/TUnit.Core.SourceGenerator.Tests/ConflictingNamespaceTests.HooksTest_WithConflictingNamespace.DotNet9_0.verified.txt +++ b/tests/TUnit.Core.SourceGenerator.Tests/ConflictingNamespaceTests.HooksTest_WithConflictingNamespace.DotNet9_0.verified.txt @@ -1,4 +1,4 @@ -// +// #pragma warning disable #nullable enable @@ -13,7 +13,7 @@ namespace TUnit.Generated { internal static partial class TUnit_HookRegistration { - static readonly int _h_TUnit_TestProject_BeforeTests_Base1_BeforeAll1_Before_Class = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeClassHooks, typeof(global::TUnit.TestProject.BeforeTests.Base1), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeClassHookIndex(), + static readonly int _h_TUnit_TestProject_BeforeTests_Base1_BeforeAll1_Before_Class_5c51506c = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeClassHooks, typeof(global::TUnit.TestProject.BeforeTests.Base1), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeClassHookIndex(), static __registrationIndex => new BeforeClassHookMethod { @@ -41,23 +41,16 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_BeforeTests_Base1_BeforeAll1_Before_Class_Body, + Body = TUnit_TestProject_BeforeTests_Base1_BeforeAll1_Before_Class_5c51506c_Body, FilePath = "", LineNumber = 5 } ); - private static ValueTask TUnit_TestProject_BeforeTests_Base1_BeforeAll1_Before_Class_Body(ClassHookContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_BeforeTests_Base1_BeforeAll1_Before_Class_5c51506c_Body(ClassHookContext context, CancellationToken cancellationToken) { - try - { - return new ValueTask(global::TUnit.TestProject.BeforeTests.Base1.BeforeAll1()); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + return new ValueTask(global::TUnit.TestProject.BeforeTests.Base1.BeforeAll1()); } - static readonly int _h_TUnit_TestProject_BeforeTests_Base1_BeforeEach1_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.Base1), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), + static readonly int _h_TUnit_TestProject_BeforeTests_Base1_BeforeEach1_Before_Test_0f563ec6 = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.Base1), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), static __registrationIndex => new InstanceHookMethod { @@ -86,20 +79,13 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_BeforeTests_Base1_BeforeEach1_Before_Test_Body + Body = TUnit_TestProject_BeforeTests_Base1_BeforeEach1_Before_Test_0f563ec6_Body } ); - private static ValueTask TUnit_TestProject_BeforeTests_Base1_BeforeEach1_Before_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_BeforeTests_Base1_BeforeEach1_Before_Test_0f563ec6_Body(object instance, TestContext context, CancellationToken cancellationToken) { - try - { - var typedInstance = (global::TUnit.TestProject.BeforeTests.Base1)instance; - return new ValueTask(typedInstance.BeforeEach1()); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + var typedInstance = (global::TUnit.TestProject.BeforeTests.Base1)instance; + return new ValueTask(typedInstance.BeforeEach1()); } } } @@ -122,7 +108,7 @@ namespace TUnit.Generated { internal static partial class TUnit_HookRegistration { - static readonly int _h_TUnit_TestProject_BeforeTests_Base2_BeforeAll2_Before_Class = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeClassHooks, typeof(global::TUnit.TestProject.BeforeTests.Base2), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeClassHookIndex(), + static readonly int _h_TUnit_TestProject_BeforeTests_Base2_BeforeAll2_Before_Class_b497be42 = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeClassHooks, typeof(global::TUnit.TestProject.BeforeTests.Base2), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeClassHookIndex(), static __registrationIndex => new BeforeClassHookMethod { @@ -150,23 +136,16 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_BeforeTests_Base2_BeforeAll2_Before_Class_Body, + Body = TUnit_TestProject_BeforeTests_Base2_BeforeAll2_Before_Class_b497be42_Body, FilePath = "", LineNumber = 20 } ); - private static ValueTask TUnit_TestProject_BeforeTests_Base2_BeforeAll2_Before_Class_Body(ClassHookContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_BeforeTests_Base2_BeforeAll2_Before_Class_b497be42_Body(ClassHookContext context, CancellationToken cancellationToken) { - try - { - return new ValueTask(global::TUnit.TestProject.BeforeTests.Base2.BeforeAll2()); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + return new ValueTask(global::TUnit.TestProject.BeforeTests.Base2.BeforeAll2()); } - static readonly int _h_TUnit_TestProject_BeforeTests_Base2_BeforeEach2_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.Base2), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), + static readonly int _h_TUnit_TestProject_BeforeTests_Base2_BeforeEach2_Before_Test_c12372de = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.Base2), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), static __registrationIndex => new InstanceHookMethod { @@ -195,20 +174,13 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_BeforeTests_Base2_BeforeEach2_Before_Test_Body + Body = TUnit_TestProject_BeforeTests_Base2_BeforeEach2_Before_Test_c12372de_Body } ); - private static ValueTask TUnit_TestProject_BeforeTests_Base2_BeforeEach2_Before_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_BeforeTests_Base2_BeforeEach2_Before_Test_c12372de_Body(object instance, TestContext context, CancellationToken cancellationToken) { - try - { - var typedInstance = (global::TUnit.TestProject.BeforeTests.Base2)instance; - return new ValueTask(typedInstance.BeforeEach2()); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + var typedInstance = (global::TUnit.TestProject.BeforeTests.Base2)instance; + return new ValueTask(typedInstance.BeforeEach2()); } } } @@ -231,7 +203,7 @@ namespace TUnit.Generated { internal static partial class TUnit_HookRegistration { - static readonly int _h_TUnit_TestProject_BeforeTests_Base3_BeforeAll3_Before_Class = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeClassHooks, typeof(global::TUnit.TestProject.BeforeTests.Base3), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeClassHookIndex(), + static readonly int _h_TUnit_TestProject_BeforeTests_Base3_BeforeAll3_Before_Class_45e04490 = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeClassHooks, typeof(global::TUnit.TestProject.BeforeTests.Base3), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeClassHookIndex(), static __registrationIndex => new BeforeClassHookMethod { @@ -259,23 +231,16 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_BeforeTests_Base3_BeforeAll3_Before_Class_Body, + Body = TUnit_TestProject_BeforeTests_Base3_BeforeAll3_Before_Class_45e04490_Body, FilePath = "", LineNumber = 35 } ); - private static ValueTask TUnit_TestProject_BeforeTests_Base3_BeforeAll3_Before_Class_Body(ClassHookContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_BeforeTests_Base3_BeforeAll3_Before_Class_45e04490_Body(ClassHookContext context, CancellationToken cancellationToken) { - try - { - return new ValueTask(global::TUnit.TestProject.BeforeTests.Base3.BeforeAll3()); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + return new ValueTask(global::TUnit.TestProject.BeforeTests.Base3.BeforeAll3()); } - static readonly int _h_TUnit_TestProject_BeforeTests_Base3_BeforeEach3_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.Base3), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), + static readonly int _h_TUnit_TestProject_BeforeTests_Base3_BeforeEach3_Before_Test_5cb123ce = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.Base3), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), static __registrationIndex => new InstanceHookMethod { @@ -304,20 +269,13 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_BeforeTests_Base3_BeforeEach3_Before_Test_Body + Body = TUnit_TestProject_BeforeTests_Base3_BeforeEach3_Before_Test_5cb123ce_Body } ); - private static ValueTask TUnit_TestProject_BeforeTests_Base3_BeforeEach3_Before_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_BeforeTests_Base3_BeforeEach3_Before_Test_5cb123ce_Body(object instance, TestContext context, CancellationToken cancellationToken) { - try - { - var typedInstance = (global::TUnit.TestProject.BeforeTests.Base3)instance; - return new ValueTask(typedInstance.BeforeEach3()); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + var typedInstance = (global::TUnit.TestProject.BeforeTests.Base3)instance; + return new ValueTask(typedInstance.BeforeEach3()); } } } @@ -340,7 +298,7 @@ namespace TUnit.Generated { internal static partial class TUnit_HookRegistration { - static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp_Before_Class = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeClassHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeClassHookIndex(), + static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp_Before_Class_e448884e = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeClassHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeClassHookIndex(), static __registrationIndex => new BeforeClassHookMethod { @@ -368,23 +326,16 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp_Before_Class_Body, + Body = TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp_Before_Class_e448884e_Body, FilePath = "", LineNumber = 50 } ); - private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp_Before_Class_Body(ClassHookContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp_Before_Class_e448884e_Body(ClassHookContext context, CancellationToken cancellationToken) { - try - { - return new ValueTask(global::TUnit.TestProject.BeforeTests.SetupTests.BeforeAllSetUp()); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + return new ValueTask(global::TUnit.TestProject.BeforeTests.SetupTests.BeforeAllSetUp()); } - static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_Before_Class = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeClassHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeClassHookIndex(), + static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_Before_Class_a169a78d = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeClassHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeClassHookIndex(), static __registrationIndex => new BeforeClassHookMethod { @@ -415,23 +366,16 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_Before_Class_Body, + Body = TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_Before_Class_a169a78d_Body, FilePath = "", LineNumber = 56 } ); - private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_Before_Class_Body(ClassHookContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_Before_Class_a169a78d_Body(ClassHookContext context, CancellationToken cancellationToken) { - try - { - return new ValueTask(global::TUnit.TestProject.BeforeTests.SetupTests.BeforeAllSetUpWithContext(context)); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + return new ValueTask(global::TUnit.TestProject.BeforeTests.SetupTests.BeforeAllSetUpWithContext(context)); } - static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp__CancellationToken_Before_Class = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeClassHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeClassHookIndex(), + static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp__CancellationToken_Before_Class_baa8f1e8 = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeClassHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeClassHookIndex(), static __registrationIndex => new BeforeClassHookMethod { @@ -462,23 +406,16 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp__CancellationToken_Before_Class_Body, + Body = TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp__CancellationToken_Before_Class_baa8f1e8_Body, FilePath = "", LineNumber = 62 } ); - private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp__CancellationToken_Before_Class_Body(ClassHookContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp__CancellationToken_Before_Class_baa8f1e8_Body(ClassHookContext context, CancellationToken cancellationToken) { - try - { - return new ValueTask(global::TUnit.TestProject.BeforeTests.SetupTests.BeforeAllSetUp(cancellationToken)); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + return new ValueTask(global::TUnit.TestProject.BeforeTests.SetupTests.BeforeAllSetUp(cancellationToken)); } - static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_CancellationToken_Before_Class = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeClassHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeClassHookIndex(), + static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_CancellationToken_Before_Class_95aea855 = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeClassHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeClassHookIndex(), static __registrationIndex => new BeforeClassHookMethod { @@ -510,23 +447,16 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_CancellationToken_Before_Class_Body, + Body = TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_CancellationToken_Before_Class_95aea855_Body, FilePath = "", LineNumber = 68 } ); - private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_CancellationToken_Before_Class_Body(ClassHookContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_CancellationToken_Before_Class_95aea855_Body(ClassHookContext context, CancellationToken cancellationToken) { - try - { - return new ValueTask(global::TUnit.TestProject.BeforeTests.SetupTests.BeforeAllSetUpWithContext(context, cancellationToken)); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + return new ValueTask(global::TUnit.TestProject.BeforeTests.SetupTests.BeforeAllSetUpWithContext(context, cancellationToken)); } - static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_Setup_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), + static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_Setup_Before_Test_234813ba = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), static __registrationIndex => new InstanceHookMethod { @@ -555,22 +485,15 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_BeforeTests_SetupTests_Setup_Before_Test_Body + Body = TUnit_TestProject_BeforeTests_SetupTests_Setup_Before_Test_234813ba_Body } ); - private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_Setup_Before_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_Setup_Before_Test_234813ba_Body(object instance, TestContext context, CancellationToken cancellationToken) { - try - { - var typedInstance = (global::TUnit.TestProject.BeforeTests.SetupTests)instance; - return new ValueTask(typedInstance.Setup()); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + var typedInstance = (global::TUnit.TestProject.BeforeTests.SetupTests)instance; + return new ValueTask(typedInstance.Setup()); } - static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_Setup__CancellationToken_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), + static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_Setup__CancellationToken_Before_Test_81adbb20 = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), static __registrationIndex => new InstanceHookMethod { @@ -602,22 +525,15 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_BeforeTests_SetupTests_Setup__CancellationToken_Before_Test_Body + Body = TUnit_TestProject_BeforeTests_SetupTests_Setup__CancellationToken_Before_Test_81adbb20_Body } ); - private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_Setup__CancellationToken_Before_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_Setup__CancellationToken_Before_Test_81adbb20_Body(object instance, TestContext context, CancellationToken cancellationToken) { - try - { - var typedInstance = (global::TUnit.TestProject.BeforeTests.SetupTests)instance; - return new ValueTask(typedInstance.Setup(cancellationToken)); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + var typedInstance = (global::TUnit.TestProject.BeforeTests.SetupTests)instance; + return new ValueTask(typedInstance.Setup(cancellationToken)); } - static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), + static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_Before_Test_01c9267a = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), static __registrationIndex => new InstanceHookMethod { @@ -649,22 +565,15 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_Before_Test_Body + Body = TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_Before_Test_01c9267a_Body } ); - private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_Before_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_Before_Test_01c9267a_Body(object instance, TestContext context, CancellationToken cancellationToken) { - try - { - var typedInstance = (global::TUnit.TestProject.BeforeTests.SetupTests)instance; - return new ValueTask(typedInstance.SetupWithContext(context)); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + var typedInstance = (global::TUnit.TestProject.BeforeTests.SetupTests)instance; + return new ValueTask(typedInstance.SetupWithContext(context)); } - static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_CancellationToken_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), + static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_CancellationToken_Before_Test_5aec0dbc = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), static __registrationIndex => new InstanceHookMethod { @@ -697,20 +606,13 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_CancellationToken_Before_Test_Body + Body = TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_CancellationToken_Before_Test_5aec0dbc_Body } ); - private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_CancellationToken_Before_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_CancellationToken_Before_Test_5aec0dbc_Body(object instance, TestContext context, CancellationToken cancellationToken) { - try - { - var typedInstance = (global::TUnit.TestProject.BeforeTests.SetupTests)instance; - return new ValueTask(typedInstance.SetupWithContext(context, cancellationToken)); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + var typedInstance = (global::TUnit.TestProject.BeforeTests.SetupTests)instance; + return new ValueTask(typedInstance.SetupWithContext(context, cancellationToken)); } } } diff --git a/tests/TUnit.Core.SourceGenerator.Tests/ConflictingNamespaceTests.HooksTest_WithConflictingNamespace.Net4_7.verified.txt b/tests/TUnit.Core.SourceGenerator.Tests/ConflictingNamespaceTests.HooksTest_WithConflictingNamespace.Net4_7.verified.txt index 2e6a86de97c..db366dee962 100644 --- a/tests/TUnit.Core.SourceGenerator.Tests/ConflictingNamespaceTests.HooksTest_WithConflictingNamespace.Net4_7.verified.txt +++ b/tests/TUnit.Core.SourceGenerator.Tests/ConflictingNamespaceTests.HooksTest_WithConflictingNamespace.Net4_7.verified.txt @@ -13,7 +13,7 @@ namespace TUnit.Generated { internal static partial class TUnit_HookRegistration { - static readonly int _h_TUnit_TestProject_BeforeTests_Base1_BeforeAll1_Before_Class = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeClassHooks, typeof(global::TUnit.TestProject.BeforeTests.Base1), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeClassHookIndex(), + static readonly int _h_TUnit_TestProject_BeforeTests_Base1_BeforeAll1_Before_Class_5c51506c = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeClassHooks, typeof(global::TUnit.TestProject.BeforeTests.Base1), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeClassHookIndex(), static __registrationIndex => new BeforeClassHookMethod { @@ -41,23 +41,16 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_BeforeTests_Base1_BeforeAll1_Before_Class_Body, + Body = TUnit_TestProject_BeforeTests_Base1_BeforeAll1_Before_Class_5c51506c_Body, FilePath = "", LineNumber = 5 } ); - private static ValueTask TUnit_TestProject_BeforeTests_Base1_BeforeAll1_Before_Class_Body(ClassHookContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_BeforeTests_Base1_BeforeAll1_Before_Class_5c51506c_Body(ClassHookContext context, CancellationToken cancellationToken) { - try - { - return new ValueTask(global::TUnit.TestProject.BeforeTests.Base1.BeforeAll1()); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + return new ValueTask(global::TUnit.TestProject.BeforeTests.Base1.BeforeAll1()); } - static readonly int _h_TUnit_TestProject_BeforeTests_Base1_BeforeEach1_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.Base1), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), + static readonly int _h_TUnit_TestProject_BeforeTests_Base1_BeforeEach1_Before_Test_0f563ec6 = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.Base1), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), static __registrationIndex => new InstanceHookMethod { @@ -86,20 +79,13 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_BeforeTests_Base1_BeforeEach1_Before_Test_Body + Body = TUnit_TestProject_BeforeTests_Base1_BeforeEach1_Before_Test_0f563ec6_Body } ); - private static ValueTask TUnit_TestProject_BeforeTests_Base1_BeforeEach1_Before_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_BeforeTests_Base1_BeforeEach1_Before_Test_0f563ec6_Body(object instance, TestContext context, CancellationToken cancellationToken) { - try - { - var typedInstance = (global::TUnit.TestProject.BeforeTests.Base1)instance; - return new ValueTask(typedInstance.BeforeEach1()); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + var typedInstance = (global::TUnit.TestProject.BeforeTests.Base1)instance; + return new ValueTask(typedInstance.BeforeEach1()); } } } @@ -122,7 +108,7 @@ namespace TUnit.Generated { internal static partial class TUnit_HookRegistration { - static readonly int _h_TUnit_TestProject_BeforeTests_Base2_BeforeAll2_Before_Class = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeClassHooks, typeof(global::TUnit.TestProject.BeforeTests.Base2), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeClassHookIndex(), + static readonly int _h_TUnit_TestProject_BeforeTests_Base2_BeforeAll2_Before_Class_b497be42 = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeClassHooks, typeof(global::TUnit.TestProject.BeforeTests.Base2), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeClassHookIndex(), static __registrationIndex => new BeforeClassHookMethod { @@ -150,23 +136,16 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_BeforeTests_Base2_BeforeAll2_Before_Class_Body, + Body = TUnit_TestProject_BeforeTests_Base2_BeforeAll2_Before_Class_b497be42_Body, FilePath = "", LineNumber = 20 } ); - private static ValueTask TUnit_TestProject_BeforeTests_Base2_BeforeAll2_Before_Class_Body(ClassHookContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_BeforeTests_Base2_BeforeAll2_Before_Class_b497be42_Body(ClassHookContext context, CancellationToken cancellationToken) { - try - { - return new ValueTask(global::TUnit.TestProject.BeforeTests.Base2.BeforeAll2()); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + return new ValueTask(global::TUnit.TestProject.BeforeTests.Base2.BeforeAll2()); } - static readonly int _h_TUnit_TestProject_BeforeTests_Base2_BeforeEach2_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.Base2), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), + static readonly int _h_TUnit_TestProject_BeforeTests_Base2_BeforeEach2_Before_Test_c12372de = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.Base2), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), static __registrationIndex => new InstanceHookMethod { @@ -195,20 +174,13 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_BeforeTests_Base2_BeforeEach2_Before_Test_Body + Body = TUnit_TestProject_BeforeTests_Base2_BeforeEach2_Before_Test_c12372de_Body } ); - private static ValueTask TUnit_TestProject_BeforeTests_Base2_BeforeEach2_Before_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_BeforeTests_Base2_BeforeEach2_Before_Test_c12372de_Body(object instance, TestContext context, CancellationToken cancellationToken) { - try - { - var typedInstance = (global::TUnit.TestProject.BeforeTests.Base2)instance; - return new ValueTask(typedInstance.BeforeEach2()); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + var typedInstance = (global::TUnit.TestProject.BeforeTests.Base2)instance; + return new ValueTask(typedInstance.BeforeEach2()); } } } @@ -231,7 +203,7 @@ namespace TUnit.Generated { internal static partial class TUnit_HookRegistration { - static readonly int _h_TUnit_TestProject_BeforeTests_Base3_BeforeAll3_Before_Class = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeClassHooks, typeof(global::TUnit.TestProject.BeforeTests.Base3), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeClassHookIndex(), + static readonly int _h_TUnit_TestProject_BeforeTests_Base3_BeforeAll3_Before_Class_45e04490 = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeClassHooks, typeof(global::TUnit.TestProject.BeforeTests.Base3), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeClassHookIndex(), static __registrationIndex => new BeforeClassHookMethod { @@ -259,23 +231,16 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_BeforeTests_Base3_BeforeAll3_Before_Class_Body, + Body = TUnit_TestProject_BeforeTests_Base3_BeforeAll3_Before_Class_45e04490_Body, FilePath = "", LineNumber = 35 } ); - private static ValueTask TUnit_TestProject_BeforeTests_Base3_BeforeAll3_Before_Class_Body(ClassHookContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_BeforeTests_Base3_BeforeAll3_Before_Class_45e04490_Body(ClassHookContext context, CancellationToken cancellationToken) { - try - { - return new ValueTask(global::TUnit.TestProject.BeforeTests.Base3.BeforeAll3()); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + return new ValueTask(global::TUnit.TestProject.BeforeTests.Base3.BeforeAll3()); } - static readonly int _h_TUnit_TestProject_BeforeTests_Base3_BeforeEach3_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.Base3), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), + static readonly int _h_TUnit_TestProject_BeforeTests_Base3_BeforeEach3_Before_Test_5cb123ce = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.Base3), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), static __registrationIndex => new InstanceHookMethod { @@ -304,20 +269,13 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_BeforeTests_Base3_BeforeEach3_Before_Test_Body + Body = TUnit_TestProject_BeforeTests_Base3_BeforeEach3_Before_Test_5cb123ce_Body } ); - private static ValueTask TUnit_TestProject_BeforeTests_Base3_BeforeEach3_Before_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_BeforeTests_Base3_BeforeEach3_Before_Test_5cb123ce_Body(object instance, TestContext context, CancellationToken cancellationToken) { - try - { - var typedInstance = (global::TUnit.TestProject.BeforeTests.Base3)instance; - return new ValueTask(typedInstance.BeforeEach3()); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + var typedInstance = (global::TUnit.TestProject.BeforeTests.Base3)instance; + return new ValueTask(typedInstance.BeforeEach3()); } } } @@ -340,7 +298,7 @@ namespace TUnit.Generated { internal static partial class TUnit_HookRegistration { - static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp_Before_Class = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeClassHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeClassHookIndex(), + static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp_Before_Class_e448884e = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeClassHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeClassHookIndex(), static __registrationIndex => new BeforeClassHookMethod { @@ -368,23 +326,16 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp_Before_Class_Body, + Body = TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp_Before_Class_e448884e_Body, FilePath = "", LineNumber = 50 } ); - private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp_Before_Class_Body(ClassHookContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp_Before_Class_e448884e_Body(ClassHookContext context, CancellationToken cancellationToken) { - try - { - return new ValueTask(global::TUnit.TestProject.BeforeTests.SetupTests.BeforeAllSetUp()); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + return new ValueTask(global::TUnit.TestProject.BeforeTests.SetupTests.BeforeAllSetUp()); } - static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_Before_Class = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeClassHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeClassHookIndex(), + static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_Before_Class_a169a78d = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeClassHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeClassHookIndex(), static __registrationIndex => new BeforeClassHookMethod { @@ -415,23 +366,16 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_Before_Class_Body, + Body = TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_Before_Class_a169a78d_Body, FilePath = "", LineNumber = 56 } ); - private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_Before_Class_Body(ClassHookContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_Before_Class_a169a78d_Body(ClassHookContext context, CancellationToken cancellationToken) { - try - { - return new ValueTask(global::TUnit.TestProject.BeforeTests.SetupTests.BeforeAllSetUpWithContext(context)); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + return new ValueTask(global::TUnit.TestProject.BeforeTests.SetupTests.BeforeAllSetUpWithContext(context)); } - static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp__CancellationToken_Before_Class = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeClassHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeClassHookIndex(), + static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp__CancellationToken_Before_Class_baa8f1e8 = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeClassHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeClassHookIndex(), static __registrationIndex => new BeforeClassHookMethod { @@ -462,23 +406,16 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp__CancellationToken_Before_Class_Body, + Body = TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp__CancellationToken_Before_Class_baa8f1e8_Body, FilePath = "", LineNumber = 62 } ); - private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp__CancellationToken_Before_Class_Body(ClassHookContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp__CancellationToken_Before_Class_baa8f1e8_Body(ClassHookContext context, CancellationToken cancellationToken) { - try - { - return new ValueTask(global::TUnit.TestProject.BeforeTests.SetupTests.BeforeAllSetUp(cancellationToken)); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + return new ValueTask(global::TUnit.TestProject.BeforeTests.SetupTests.BeforeAllSetUp(cancellationToken)); } - static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_CancellationToken_Before_Class = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeClassHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeClassHookIndex(), + static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_CancellationToken_Before_Class_95aea855 = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeClassHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeClassHookIndex(), static __registrationIndex => new BeforeClassHookMethod { @@ -510,23 +447,16 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_CancellationToken_Before_Class_Body, + Body = TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_CancellationToken_Before_Class_95aea855_Body, FilePath = "", LineNumber = 68 } ); - private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_CancellationToken_Before_Class_Body(ClassHookContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext__ClassHookContext_CancellationToken_Before_Class_95aea855_Body(ClassHookContext context, CancellationToken cancellationToken) { - try - { - return new ValueTask(global::TUnit.TestProject.BeforeTests.SetupTests.BeforeAllSetUpWithContext(context, cancellationToken)); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + return new ValueTask(global::TUnit.TestProject.BeforeTests.SetupTests.BeforeAllSetUpWithContext(context, cancellationToken)); } - static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_Setup_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), + static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_Setup_Before_Test_234813ba = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), static __registrationIndex => new InstanceHookMethod { @@ -555,22 +485,15 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_BeforeTests_SetupTests_Setup_Before_Test_Body + Body = TUnit_TestProject_BeforeTests_SetupTests_Setup_Before_Test_234813ba_Body } ); - private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_Setup_Before_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_Setup_Before_Test_234813ba_Body(object instance, TestContext context, CancellationToken cancellationToken) { - try - { - var typedInstance = (global::TUnit.TestProject.BeforeTests.SetupTests)instance; - return new ValueTask(typedInstance.Setup()); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + var typedInstance = (global::TUnit.TestProject.BeforeTests.SetupTests)instance; + return new ValueTask(typedInstance.Setup()); } - static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_Setup__CancellationToken_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), + static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_Setup__CancellationToken_Before_Test_81adbb20 = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), static __registrationIndex => new InstanceHookMethod { @@ -602,22 +525,15 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_BeforeTests_SetupTests_Setup__CancellationToken_Before_Test_Body + Body = TUnit_TestProject_BeforeTests_SetupTests_Setup__CancellationToken_Before_Test_81adbb20_Body } ); - private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_Setup__CancellationToken_Before_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_Setup__CancellationToken_Before_Test_81adbb20_Body(object instance, TestContext context, CancellationToken cancellationToken) { - try - { - var typedInstance = (global::TUnit.TestProject.BeforeTests.SetupTests)instance; - return new ValueTask(typedInstance.Setup(cancellationToken)); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + var typedInstance = (global::TUnit.TestProject.BeforeTests.SetupTests)instance; + return new ValueTask(typedInstance.Setup(cancellationToken)); } - static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), + static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_Before_Test_01c9267a = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), static __registrationIndex => new InstanceHookMethod { @@ -649,22 +565,15 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_Before_Test_Body + Body = TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_Before_Test_01c9267a_Body } ); - private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_Before_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_Before_Test_01c9267a_Body(object instance, TestContext context, CancellationToken cancellationToken) { - try - { - var typedInstance = (global::TUnit.TestProject.BeforeTests.SetupTests)instance; - return new ValueTask(typedInstance.SetupWithContext(context)); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + var typedInstance = (global::TUnit.TestProject.BeforeTests.SetupTests)instance; + return new ValueTask(typedInstance.SetupWithContext(context)); } - static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_CancellationToken_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), + static readonly int _h_TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_CancellationToken_Before_Test_5aec0dbc = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.SetupTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), static __registrationIndex => new InstanceHookMethod { @@ -697,20 +606,13 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_CancellationToken_Before_Test_Body + Body = TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_CancellationToken_Before_Test_5aec0dbc_Body } ); - private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_CancellationToken_Before_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext__TestContext_CancellationToken_Before_Test_5aec0dbc_Body(object instance, TestContext context, CancellationToken cancellationToken) { - try - { - var typedInstance = (global::TUnit.TestProject.BeforeTests.SetupTests)instance; - return new ValueTask(typedInstance.SetupWithContext(context, cancellationToken)); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + var typedInstance = (global::TUnit.TestProject.BeforeTests.SetupTests)instance; + return new ValueTask(typedInstance.SetupWithContext(context, cancellationToken)); } } } diff --git a/tests/TUnit.Core.SourceGenerator.Tests/GlobalStaticAfterEachTests.Test.verified.txt b/tests/TUnit.Core.SourceGenerator.Tests/GlobalStaticAfterEachTests.Test.verified.txt index d1d05bc1cb6..3c3f4e7608f 100644 --- a/tests/TUnit.Core.SourceGenerator.Tests/GlobalStaticAfterEachTests.Test.verified.txt +++ b/tests/TUnit.Core.SourceGenerator.Tests/GlobalStaticAfterEachTests.Test.verified.txt @@ -13,7 +13,7 @@ namespace TUnit.Generated { internal static partial class TUnit_HookRegistration { - static readonly int _h_TUnit_TestProject_AfterTests_GlobalBase1_AfterEach1_After_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterTestHooks, typeof(global::TUnit.TestProject.AfterTests.GlobalBase1), global::TUnit.Core.HookRegistrationIndices.GetNextAfterTestHookIndex(), + static readonly int _h_TUnit_TestProject_AfterTests_GlobalBase1_AfterEach1_After_Test_904b20c4 = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterTestHooks, typeof(global::TUnit.TestProject.AfterTests.GlobalBase1), global::TUnit.Core.HookRegistrationIndices.GetNextAfterTestHookIndex(), static __registrationIndex => new InstanceHookMethod { @@ -42,22 +42,15 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_AfterTests_GlobalBase1_AfterEach1_After_Test_Body + Body = TUnit_TestProject_AfterTests_GlobalBase1_AfterEach1_After_Test_904b20c4_Body } ); - private static ValueTask TUnit_TestProject_AfterTests_GlobalBase1_AfterEach1_After_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_AfterTests_GlobalBase1_AfterEach1_After_Test_904b20c4_Body(object instance, TestContext context, CancellationToken cancellationToken) { - try - { - var typedInstance = (global::TUnit.TestProject.AfterTests.GlobalBase1)instance; - return new ValueTask(typedInstance.AfterEach1()); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + var typedInstance = (global::TUnit.TestProject.AfterTests.GlobalBase1)instance; + return new ValueTask(typedInstance.AfterEach1()); } - static readonly int _h_TUnit_TestProject_AfterTests_GlobalBase1_AfterAll1__TestContext_AfterEvery_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterEveryTestHooks, global::TUnit.Core.HookRegistrationIndices.GetNextAfterEveryTestHookIndex(), + static readonly int _h_TUnit_TestProject_AfterTests_GlobalBase1_AfterAll1__TestContext_AfterEvery_Test_b567856a = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterEveryTestHooks, global::TUnit.Core.HookRegistrationIndices.GetNextAfterEveryTestHookIndex(), static __registrationIndex => new AfterTestHookMethod { @@ -88,21 +81,14 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_AfterTests_GlobalBase1_AfterAll1__TestContext_AfterEvery_Test_Body, + Body = TUnit_TestProject_AfterTests_GlobalBase1_AfterAll1__TestContext_AfterEvery_Test_b567856a_Body, FilePath = "", LineNumber = 5 } ); - private static ValueTask TUnit_TestProject_AfterTests_GlobalBase1_AfterAll1__TestContext_AfterEvery_Test_Body(TestContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_AfterTests_GlobalBase1_AfterAll1__TestContext_AfterEvery_Test_b567856a_Body(TestContext context, CancellationToken cancellationToken) { - try - { - return new ValueTask(global::TUnit.TestProject.AfterTests.GlobalBase1.AfterAll1(context)); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + return new ValueTask(global::TUnit.TestProject.AfterTests.GlobalBase1.AfterAll1(context)); } } } @@ -125,7 +111,7 @@ namespace TUnit.Generated { internal static partial class TUnit_HookRegistration { - static readonly int _h_TUnit_TestProject_AfterTests_GlobalBase2_AfterEach2_After_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterTestHooks, typeof(global::TUnit.TestProject.AfterTests.GlobalBase2), global::TUnit.Core.HookRegistrationIndices.GetNextAfterTestHookIndex(), + static readonly int _h_TUnit_TestProject_AfterTests_GlobalBase2_AfterEach2_After_Test_ffd77f0e = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterTestHooks, typeof(global::TUnit.TestProject.AfterTests.GlobalBase2), global::TUnit.Core.HookRegistrationIndices.GetNextAfterTestHookIndex(), static __registrationIndex => new InstanceHookMethod { @@ -154,22 +140,15 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_AfterTests_GlobalBase2_AfterEach2_After_Test_Body + Body = TUnit_TestProject_AfterTests_GlobalBase2_AfterEach2_After_Test_ffd77f0e_Body } ); - private static ValueTask TUnit_TestProject_AfterTests_GlobalBase2_AfterEach2_After_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_AfterTests_GlobalBase2_AfterEach2_After_Test_ffd77f0e_Body(object instance, TestContext context, CancellationToken cancellationToken) { - try - { - var typedInstance = (global::TUnit.TestProject.AfterTests.GlobalBase2)instance; - return new ValueTask(typedInstance.AfterEach2()); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + var typedInstance = (global::TUnit.TestProject.AfterTests.GlobalBase2)instance; + return new ValueTask(typedInstance.AfterEach2()); } - static readonly int _h_TUnit_TestProject_AfterTests_GlobalBase2_AfterAll2__TestContext_AfterEvery_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterEveryTestHooks, global::TUnit.Core.HookRegistrationIndices.GetNextAfterEveryTestHookIndex(), + static readonly int _h_TUnit_TestProject_AfterTests_GlobalBase2_AfterAll2__TestContext_AfterEvery_Test_4d8bdc2a = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterEveryTestHooks, global::TUnit.Core.HookRegistrationIndices.GetNextAfterEveryTestHookIndex(), static __registrationIndex => new AfterTestHookMethod { @@ -200,21 +179,14 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_AfterTests_GlobalBase2_AfterAll2__TestContext_AfterEvery_Test_Body, + Body = TUnit_TestProject_AfterTests_GlobalBase2_AfterAll2__TestContext_AfterEvery_Test_4d8bdc2a_Body, FilePath = "", LineNumber = 20 } ); - private static ValueTask TUnit_TestProject_AfterTests_GlobalBase2_AfterAll2__TestContext_AfterEvery_Test_Body(TestContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_AfterTests_GlobalBase2_AfterAll2__TestContext_AfterEvery_Test_4d8bdc2a_Body(TestContext context, CancellationToken cancellationToken) { - try - { - return new ValueTask(global::TUnit.TestProject.AfterTests.GlobalBase2.AfterAll2(context)); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + return new ValueTask(global::TUnit.TestProject.AfterTests.GlobalBase2.AfterAll2(context)); } } } @@ -237,7 +209,7 @@ namespace TUnit.Generated { internal static partial class TUnit_HookRegistration { - static readonly int _h_TUnit_TestProject_AfterTests_GlobalBase3_AfterEach3_After_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterTestHooks, typeof(global::TUnit.TestProject.AfterTests.GlobalBase3), global::TUnit.Core.HookRegistrationIndices.GetNextAfterTestHookIndex(), + static readonly int _h_TUnit_TestProject_AfterTests_GlobalBase3_AfterEach3_After_Test_9afe6ae4 = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterTestHooks, typeof(global::TUnit.TestProject.AfterTests.GlobalBase3), global::TUnit.Core.HookRegistrationIndices.GetNextAfterTestHookIndex(), static __registrationIndex => new InstanceHookMethod { @@ -266,22 +238,15 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_AfterTests_GlobalBase3_AfterEach3_After_Test_Body + Body = TUnit_TestProject_AfterTests_GlobalBase3_AfterEach3_After_Test_9afe6ae4_Body } ); - private static ValueTask TUnit_TestProject_AfterTests_GlobalBase3_AfterEach3_After_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_AfterTests_GlobalBase3_AfterEach3_After_Test_9afe6ae4_Body(object instance, TestContext context, CancellationToken cancellationToken) { - try - { - var typedInstance = (global::TUnit.TestProject.AfterTests.GlobalBase3)instance; - return new ValueTask(typedInstance.AfterEach3()); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + var typedInstance = (global::TUnit.TestProject.AfterTests.GlobalBase3)instance; + return new ValueTask(typedInstance.AfterEach3()); } - static readonly int _h_TUnit_TestProject_AfterTests_GlobalBase3_AfterAll3__TestContext_AfterEvery_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterEveryTestHooks, global::TUnit.Core.HookRegistrationIndices.GetNextAfterEveryTestHookIndex(), + static readonly int _h_TUnit_TestProject_AfterTests_GlobalBase3_AfterAll3__TestContext_AfterEvery_Test_ad2ba782 = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterEveryTestHooks, global::TUnit.Core.HookRegistrationIndices.GetNextAfterEveryTestHookIndex(), static __registrationIndex => new AfterTestHookMethod { @@ -312,21 +277,14 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_AfterTests_GlobalBase3_AfterAll3__TestContext_AfterEvery_Test_Body, + Body = TUnit_TestProject_AfterTests_GlobalBase3_AfterAll3__TestContext_AfterEvery_Test_ad2ba782_Body, FilePath = "", LineNumber = 35 } ); - private static ValueTask TUnit_TestProject_AfterTests_GlobalBase3_AfterAll3__TestContext_AfterEvery_Test_Body(TestContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_AfterTests_GlobalBase3_AfterAll3__TestContext_AfterEvery_Test_ad2ba782_Body(TestContext context, CancellationToken cancellationToken) { - try - { - return new ValueTask(global::TUnit.TestProject.AfterTests.GlobalBase3.AfterAll3(context)); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + return new ValueTask(global::TUnit.TestProject.AfterTests.GlobalBase3.AfterAll3(context)); } } } @@ -349,7 +307,7 @@ namespace TUnit.Generated { internal static partial class TUnit_HookRegistration { - static readonly int _h_TUnit_TestProject_AfterTests_GlobalCleanUpTests_CleanUp_After_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterTestHooks, typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests), global::TUnit.Core.HookRegistrationIndices.GetNextAfterTestHookIndex(), + static readonly int _h_TUnit_TestProject_AfterTests_GlobalCleanUpTests_CleanUp_After_Test_4454235d = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterTestHooks, typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests), global::TUnit.Core.HookRegistrationIndices.GetNextAfterTestHookIndex(), static __registrationIndex => new InstanceHookMethod { @@ -378,22 +336,15 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_AfterTests_GlobalCleanUpTests_CleanUp_After_Test_Body + Body = TUnit_TestProject_AfterTests_GlobalCleanUpTests_CleanUp_After_Test_4454235d_Body } ); - private static ValueTask TUnit_TestProject_AfterTests_GlobalCleanUpTests_CleanUp_After_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_AfterTests_GlobalCleanUpTests_CleanUp_After_Test_4454235d_Body(object instance, TestContext context, CancellationToken cancellationToken) { - try - { - var typedInstance = (global::TUnit.TestProject.AfterTests.GlobalCleanUpTests)instance; - return new ValueTask(typedInstance.CleanUp()); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + var typedInstance = (global::TUnit.TestProject.AfterTests.GlobalCleanUpTests)instance; + return new ValueTask(typedInstance.CleanUp()); } - static readonly int _h_TUnit_TestProject_AfterTests_GlobalCleanUpTests_CleanUp__CancellationToken_After_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterTestHooks, typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests), global::TUnit.Core.HookRegistrationIndices.GetNextAfterTestHookIndex(), + static readonly int _h_TUnit_TestProject_AfterTests_GlobalCleanUpTests_CleanUp__CancellationToken_After_Test_0df6ecc7 = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterTestHooks, typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests), global::TUnit.Core.HookRegistrationIndices.GetNextAfterTestHookIndex(), static __registrationIndex => new InstanceHookMethod { @@ -425,22 +376,15 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_AfterTests_GlobalCleanUpTests_CleanUp__CancellationToken_After_Test_Body + Body = TUnit_TestProject_AfterTests_GlobalCleanUpTests_CleanUp__CancellationToken_After_Test_0df6ecc7_Body } ); - private static ValueTask TUnit_TestProject_AfterTests_GlobalCleanUpTests_CleanUp__CancellationToken_After_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_AfterTests_GlobalCleanUpTests_CleanUp__CancellationToken_After_Test_0df6ecc7_Body(object instance, TestContext context, CancellationToken cancellationToken) { - try - { - var typedInstance = (global::TUnit.TestProject.AfterTests.GlobalCleanUpTests)instance; - return new ValueTask(typedInstance.CleanUp(cancellationToken)); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + var typedInstance = (global::TUnit.TestProject.AfterTests.GlobalCleanUpTests)instance; + return new ValueTask(typedInstance.CleanUp(cancellationToken)); } - static readonly int _h_TUnit_TestProject_AfterTests_GlobalCleanUpTests_CleanUpWithContext__TestContext_After_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterTestHooks, typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests), global::TUnit.Core.HookRegistrationIndices.GetNextAfterTestHookIndex(), + static readonly int _h_TUnit_TestProject_AfterTests_GlobalCleanUpTests_CleanUpWithContext__TestContext_After_Test_304b58ad = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterTestHooks, typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests), global::TUnit.Core.HookRegistrationIndices.GetNextAfterTestHookIndex(), static __registrationIndex => new InstanceHookMethod { @@ -472,22 +416,15 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_AfterTests_GlobalCleanUpTests_CleanUpWithContext__TestContext_After_Test_Body + Body = TUnit_TestProject_AfterTests_GlobalCleanUpTests_CleanUpWithContext__TestContext_After_Test_304b58ad_Body } ); - private static ValueTask TUnit_TestProject_AfterTests_GlobalCleanUpTests_CleanUpWithContext__TestContext_After_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_AfterTests_GlobalCleanUpTests_CleanUpWithContext__TestContext_After_Test_304b58ad_Body(object instance, TestContext context, CancellationToken cancellationToken) { - try - { - var typedInstance = (global::TUnit.TestProject.AfterTests.GlobalCleanUpTests)instance; - return new ValueTask(typedInstance.CleanUpWithContext(context)); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + var typedInstance = (global::TUnit.TestProject.AfterTests.GlobalCleanUpTests)instance; + return new ValueTask(typedInstance.CleanUpWithContext(context)); } - static readonly int _h_TUnit_TestProject_AfterTests_GlobalCleanUpTests_CleanUpWithContext__TestContext_CancellationToken_After_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterTestHooks, typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests), global::TUnit.Core.HookRegistrationIndices.GetNextAfterTestHookIndex(), + static readonly int _h_TUnit_TestProject_AfterTests_GlobalCleanUpTests_CleanUpWithContext__TestContext_CancellationToken_After_Test_1396b9cf = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterTestHooks, typeof(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests), global::TUnit.Core.HookRegistrationIndices.GetNextAfterTestHookIndex(), static __registrationIndex => new InstanceHookMethod { @@ -520,22 +457,15 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_AfterTests_GlobalCleanUpTests_CleanUpWithContext__TestContext_CancellationToken_After_Test_Body + Body = TUnit_TestProject_AfterTests_GlobalCleanUpTests_CleanUpWithContext__TestContext_CancellationToken_After_Test_1396b9cf_Body } ); - private static ValueTask TUnit_TestProject_AfterTests_GlobalCleanUpTests_CleanUpWithContext__TestContext_CancellationToken_After_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_AfterTests_GlobalCleanUpTests_CleanUpWithContext__TestContext_CancellationToken_After_Test_1396b9cf_Body(object instance, TestContext context, CancellationToken cancellationToken) { - try - { - var typedInstance = (global::TUnit.TestProject.AfterTests.GlobalCleanUpTests)instance; - return new ValueTask(typedInstance.CleanUpWithContext(context, cancellationToken)); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + var typedInstance = (global::TUnit.TestProject.AfterTests.GlobalCleanUpTests)instance; + return new ValueTask(typedInstance.CleanUpWithContext(context, cancellationToken)); } - static readonly int _h_TUnit_TestProject_AfterTests_GlobalCleanUpTests_AfterAllCleanUp__TestContext_AfterEvery_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterEveryTestHooks, global::TUnit.Core.HookRegistrationIndices.GetNextAfterEveryTestHookIndex(), + static readonly int _h_TUnit_TestProject_AfterTests_GlobalCleanUpTests_AfterAllCleanUp__TestContext_AfterEvery_Test_0798971a = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterEveryTestHooks, global::TUnit.Core.HookRegistrationIndices.GetNextAfterEveryTestHookIndex(), static __registrationIndex => new AfterTestHookMethod { @@ -566,23 +496,16 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_AfterTests_GlobalCleanUpTests_AfterAllCleanUp__TestContext_AfterEvery_Test_Body, + Body = TUnit_TestProject_AfterTests_GlobalCleanUpTests_AfterAllCleanUp__TestContext_AfterEvery_Test_0798971a_Body, FilePath = "", LineNumber = 50 } ); - private static ValueTask TUnit_TestProject_AfterTests_GlobalCleanUpTests_AfterAllCleanUp__TestContext_AfterEvery_Test_Body(TestContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_AfterTests_GlobalCleanUpTests_AfterAllCleanUp__TestContext_AfterEvery_Test_0798971a_Body(TestContext context, CancellationToken cancellationToken) { - try - { - return new ValueTask(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests.AfterAllCleanUp(context)); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + return new ValueTask(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests.AfterAllCleanUp(context)); } - static readonly int _h_TUnit_TestProject_AfterTests_GlobalCleanUpTests_AfterAllCleanUp__TestContext_CancellationToken_AfterEvery_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterEveryTestHooks, global::TUnit.Core.HookRegistrationIndices.GetNextAfterEveryTestHookIndex(), + static readonly int _h_TUnit_TestProject_AfterTests_GlobalCleanUpTests_AfterAllCleanUp__TestContext_CancellationToken_AfterEvery_Test_3861f668 = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterEveryTestHooks, global::TUnit.Core.HookRegistrationIndices.GetNextAfterEveryTestHookIndex(), static __registrationIndex => new AfterTestHookMethod { @@ -614,23 +537,16 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_AfterTests_GlobalCleanUpTests_AfterAllCleanUp__TestContext_CancellationToken_AfterEvery_Test_Body, + Body = TUnit_TestProject_AfterTests_GlobalCleanUpTests_AfterAllCleanUp__TestContext_CancellationToken_AfterEvery_Test_3861f668_Body, FilePath = "", LineNumber = 56 } ); - private static ValueTask TUnit_TestProject_AfterTests_GlobalCleanUpTests_AfterAllCleanUp__TestContext_CancellationToken_AfterEvery_Test_Body(TestContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_AfterTests_GlobalCleanUpTests_AfterAllCleanUp__TestContext_CancellationToken_AfterEvery_Test_3861f668_Body(TestContext context, CancellationToken cancellationToken) { - try - { - return new ValueTask(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests.AfterAllCleanUp(context, cancellationToken)); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + return new ValueTask(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests.AfterAllCleanUp(context, cancellationToken)); } - static readonly int _h_TUnit_TestProject_AfterTests_GlobalCleanUpTests_AfterAllCleanUpWithContext__TestContext_AfterEvery_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterEveryTestHooks, global::TUnit.Core.HookRegistrationIndices.GetNextAfterEveryTestHookIndex(), + static readonly int _h_TUnit_TestProject_AfterTests_GlobalCleanUpTests_AfterAllCleanUpWithContext__TestContext_AfterEvery_Test_c1daeebf = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterEveryTestHooks, global::TUnit.Core.HookRegistrationIndices.GetNextAfterEveryTestHookIndex(), static __registrationIndex => new AfterTestHookMethod { @@ -661,23 +577,16 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_AfterTests_GlobalCleanUpTests_AfterAllCleanUpWithContext__TestContext_AfterEvery_Test_Body, + Body = TUnit_TestProject_AfterTests_GlobalCleanUpTests_AfterAllCleanUpWithContext__TestContext_AfterEvery_Test_c1daeebf_Body, FilePath = "", LineNumber = 62 } ); - private static ValueTask TUnit_TestProject_AfterTests_GlobalCleanUpTests_AfterAllCleanUpWithContext__TestContext_AfterEvery_Test_Body(TestContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_AfterTests_GlobalCleanUpTests_AfterAllCleanUpWithContext__TestContext_AfterEvery_Test_c1daeebf_Body(TestContext context, CancellationToken cancellationToken) { - try - { - return new ValueTask(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests.AfterAllCleanUpWithContext(context)); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + return new ValueTask(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests.AfterAllCleanUpWithContext(context)); } - static readonly int _h_TUnit_TestProject_AfterTests_GlobalCleanUpTests_AfterAllCleanUpWithContext__TestContext_CancellationToken_AfterEvery_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterEveryTestHooks, global::TUnit.Core.HookRegistrationIndices.GetNextAfterEveryTestHookIndex(), + static readonly int _h_TUnit_TestProject_AfterTests_GlobalCleanUpTests_AfterAllCleanUpWithContext__TestContext_CancellationToken_AfterEvery_Test_8ae97ec3 = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterEveryTestHooks, global::TUnit.Core.HookRegistrationIndices.GetNextAfterEveryTestHookIndex(), static __registrationIndex => new AfterTestHookMethod { @@ -709,21 +618,14 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_AfterTests_GlobalCleanUpTests_AfterAllCleanUpWithContext__TestContext_CancellationToken_AfterEvery_Test_Body, + Body = TUnit_TestProject_AfterTests_GlobalCleanUpTests_AfterAllCleanUpWithContext__TestContext_CancellationToken_AfterEvery_Test_8ae97ec3_Body, FilePath = "", LineNumber = 68 } ); - private static ValueTask TUnit_TestProject_AfterTests_GlobalCleanUpTests_AfterAllCleanUpWithContext__TestContext_CancellationToken_AfterEvery_Test_Body(TestContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_AfterTests_GlobalCleanUpTests_AfterAllCleanUpWithContext__TestContext_CancellationToken_AfterEvery_Test_8ae97ec3_Body(TestContext context, CancellationToken cancellationToken) { - try - { - return new ValueTask(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests.AfterAllCleanUpWithContext(context, cancellationToken)); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + return new ValueTask(global::TUnit.TestProject.AfterTests.GlobalCleanUpTests.AfterAllCleanUpWithContext(context, cancellationToken)); } } } diff --git a/tests/TUnit.Core.SourceGenerator.Tests/GlobalStaticBeforeEachTests.Test.verified.txt b/tests/TUnit.Core.SourceGenerator.Tests/GlobalStaticBeforeEachTests.Test.verified.txt index d33bc25ef63..28b6f50d94a 100644 --- a/tests/TUnit.Core.SourceGenerator.Tests/GlobalStaticBeforeEachTests.Test.verified.txt +++ b/tests/TUnit.Core.SourceGenerator.Tests/GlobalStaticBeforeEachTests.Test.verified.txt @@ -13,7 +13,7 @@ namespace TUnit.Generated { internal static partial class TUnit_HookRegistration { - static readonly int _h_TUnit_TestProject_BeforeTests_GlobalBase1_BeforeEach1_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.GlobalBase1), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), + static readonly int _h_TUnit_TestProject_BeforeTests_GlobalBase1_BeforeEach1_Before_Test_55ed11e3 = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.GlobalBase1), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), static __registrationIndex => new InstanceHookMethod { @@ -42,22 +42,15 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_BeforeTests_GlobalBase1_BeforeEach1_Before_Test_Body + Body = TUnit_TestProject_BeforeTests_GlobalBase1_BeforeEach1_Before_Test_55ed11e3_Body } ); - private static ValueTask TUnit_TestProject_BeforeTests_GlobalBase1_BeforeEach1_Before_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_BeforeTests_GlobalBase1_BeforeEach1_Before_Test_55ed11e3_Body(object instance, TestContext context, CancellationToken cancellationToken) { - try - { - var typedInstance = (global::TUnit.TestProject.BeforeTests.GlobalBase1)instance; - return new ValueTask(typedInstance.BeforeEach1()); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + var typedInstance = (global::TUnit.TestProject.BeforeTests.GlobalBase1)instance; + return new ValueTask(typedInstance.BeforeEach1()); } - static readonly int _h_TUnit_TestProject_BeforeTests_GlobalBase1_BeforeAll1__TestContext_BeforeEvery_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeEveryTestHooks, global::TUnit.Core.HookRegistrationIndices.GetNextBeforeEveryTestHookIndex(), + static readonly int _h_TUnit_TestProject_BeforeTests_GlobalBase1_BeforeAll1__TestContext_BeforeEvery_Test_f9e41b2d = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeEveryTestHooks, global::TUnit.Core.HookRegistrationIndices.GetNextBeforeEveryTestHookIndex(), static __registrationIndex => new BeforeTestHookMethod { @@ -88,21 +81,14 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_BeforeTests_GlobalBase1_BeforeAll1__TestContext_BeforeEvery_Test_Body, + Body = TUnit_TestProject_BeforeTests_GlobalBase1_BeforeAll1__TestContext_BeforeEvery_Test_f9e41b2d_Body, FilePath = "", LineNumber = 5 } ); - private static ValueTask TUnit_TestProject_BeforeTests_GlobalBase1_BeforeAll1__TestContext_BeforeEvery_Test_Body(TestContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_BeforeTests_GlobalBase1_BeforeAll1__TestContext_BeforeEvery_Test_f9e41b2d_Body(TestContext context, CancellationToken cancellationToken) { - try - { - return new ValueTask(global::TUnit.TestProject.BeforeTests.GlobalBase1.BeforeAll1(context)); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + return new ValueTask(global::TUnit.TestProject.BeforeTests.GlobalBase1.BeforeAll1(context)); } } } @@ -125,7 +111,7 @@ namespace TUnit.Generated { internal static partial class TUnit_HookRegistration { - static readonly int _h_TUnit_TestProject_BeforeTests_GlobalBase2_BeforeEach2_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.GlobalBase2), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), + static readonly int _h_TUnit_TestProject_BeforeTests_GlobalBase2_BeforeEach2_Before_Test_b49381cb = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.GlobalBase2), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), static __registrationIndex => new InstanceHookMethod { @@ -154,22 +140,15 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_BeforeTests_GlobalBase2_BeforeEach2_Before_Test_Body + Body = TUnit_TestProject_BeforeTests_GlobalBase2_BeforeEach2_Before_Test_b49381cb_Body } ); - private static ValueTask TUnit_TestProject_BeforeTests_GlobalBase2_BeforeEach2_Before_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_BeforeTests_GlobalBase2_BeforeEach2_Before_Test_b49381cb_Body(object instance, TestContext context, CancellationToken cancellationToken) { - try - { - var typedInstance = (global::TUnit.TestProject.BeforeTests.GlobalBase2)instance; - return new ValueTask(typedInstance.BeforeEach2()); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + var typedInstance = (global::TUnit.TestProject.BeforeTests.GlobalBase2)instance; + return new ValueTask(typedInstance.BeforeEach2()); } - static readonly int _h_TUnit_TestProject_BeforeTests_GlobalBase2_BeforeAll2__TestContext_BeforeEvery_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeEveryTestHooks, global::TUnit.Core.HookRegistrationIndices.GetNextBeforeEveryTestHookIndex(), + static readonly int _h_TUnit_TestProject_BeforeTests_GlobalBase2_BeforeAll2__TestContext_BeforeEvery_Test_268d05c7 = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeEveryTestHooks, global::TUnit.Core.HookRegistrationIndices.GetNextBeforeEveryTestHookIndex(), static __registrationIndex => new BeforeTestHookMethod { @@ -200,21 +179,14 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_BeforeTests_GlobalBase2_BeforeAll2__TestContext_BeforeEvery_Test_Body, + Body = TUnit_TestProject_BeforeTests_GlobalBase2_BeforeAll2__TestContext_BeforeEvery_Test_268d05c7_Body, FilePath = "", LineNumber = 20 } ); - private static ValueTask TUnit_TestProject_BeforeTests_GlobalBase2_BeforeAll2__TestContext_BeforeEvery_Test_Body(TestContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_BeforeTests_GlobalBase2_BeforeAll2__TestContext_BeforeEvery_Test_268d05c7_Body(TestContext context, CancellationToken cancellationToken) { - try - { - return new ValueTask(global::TUnit.TestProject.BeforeTests.GlobalBase2.BeforeAll2(context)); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + return new ValueTask(global::TUnit.TestProject.BeforeTests.GlobalBase2.BeforeAll2(context)); } } } @@ -237,7 +209,7 @@ namespace TUnit.Generated { internal static partial class TUnit_HookRegistration { - static readonly int _h_TUnit_TestProject_BeforeTests_GlobalBase3_BeforeEach3_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.GlobalBase3), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), + static readonly int _h_TUnit_TestProject_BeforeTests_GlobalBase3_BeforeEach3_Before_Test_886f983b = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.GlobalBase3), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), static __registrationIndex => new InstanceHookMethod { @@ -266,22 +238,15 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_BeforeTests_GlobalBase3_BeforeEach3_Before_Test_Body + Body = TUnit_TestProject_BeforeTests_GlobalBase3_BeforeEach3_Before_Test_886f983b_Body } ); - private static ValueTask TUnit_TestProject_BeforeTests_GlobalBase3_BeforeEach3_Before_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_BeforeTests_GlobalBase3_BeforeEach3_Before_Test_886f983b_Body(object instance, TestContext context, CancellationToken cancellationToken) { - try - { - var typedInstance = (global::TUnit.TestProject.BeforeTests.GlobalBase3)instance; - return new ValueTask(typedInstance.BeforeEach3()); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + var typedInstance = (global::TUnit.TestProject.BeforeTests.GlobalBase3)instance; + return new ValueTask(typedInstance.BeforeEach3()); } - static readonly int _h_TUnit_TestProject_BeforeTests_GlobalBase3_BeforeAll3__TestContext_BeforeEvery_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeEveryTestHooks, global::TUnit.Core.HookRegistrationIndices.GetNextBeforeEveryTestHookIndex(), + static readonly int _h_TUnit_TestProject_BeforeTests_GlobalBase3_BeforeAll3__TestContext_BeforeEvery_Test_ffaf480d = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeEveryTestHooks, global::TUnit.Core.HookRegistrationIndices.GetNextBeforeEveryTestHookIndex(), static __registrationIndex => new BeforeTestHookMethod { @@ -312,21 +277,14 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_BeforeTests_GlobalBase3_BeforeAll3__TestContext_BeforeEvery_Test_Body, + Body = TUnit_TestProject_BeforeTests_GlobalBase3_BeforeAll3__TestContext_BeforeEvery_Test_ffaf480d_Body, FilePath = "", LineNumber = 35 } ); - private static ValueTask TUnit_TestProject_BeforeTests_GlobalBase3_BeforeAll3__TestContext_BeforeEvery_Test_Body(TestContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_BeforeTests_GlobalBase3_BeforeAll3__TestContext_BeforeEvery_Test_ffaf480d_Body(TestContext context, CancellationToken cancellationToken) { - try - { - return new ValueTask(global::TUnit.TestProject.BeforeTests.GlobalBase3.BeforeAll3(context)); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + return new ValueTask(global::TUnit.TestProject.BeforeTests.GlobalBase3.BeforeAll3(context)); } } } @@ -349,7 +307,7 @@ namespace TUnit.Generated { internal static partial class TUnit_HookRegistration { - static readonly int _h_TUnit_TestProject_BeforeTests_GlobalSetUpTests_SetUp_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), + static readonly int _h_TUnit_TestProject_BeforeTests_GlobalSetUpTests_SetUp_Before_Test_a848ce91 = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), static __registrationIndex => new InstanceHookMethod { @@ -378,22 +336,15 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_BeforeTests_GlobalSetUpTests_SetUp_Before_Test_Body + Body = TUnit_TestProject_BeforeTests_GlobalSetUpTests_SetUp_Before_Test_a848ce91_Body } ); - private static ValueTask TUnit_TestProject_BeforeTests_GlobalSetUpTests_SetUp_Before_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_BeforeTests_GlobalSetUpTests_SetUp_Before_Test_a848ce91_Body(object instance, TestContext context, CancellationToken cancellationToken) { - try - { - var typedInstance = (global::TUnit.TestProject.BeforeTests.GlobalSetUpTests)instance; - return new ValueTask(typedInstance.SetUp()); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + var typedInstance = (global::TUnit.TestProject.BeforeTests.GlobalSetUpTests)instance; + return new ValueTask(typedInstance.SetUp()); } - static readonly int _h_TUnit_TestProject_BeforeTests_GlobalSetUpTests_SetUp__CancellationToken_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), + static readonly int _h_TUnit_TestProject_BeforeTests_GlobalSetUpTests_SetUp__CancellationToken_Before_Test_5f0ccde7 = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), static __registrationIndex => new InstanceHookMethod { @@ -425,22 +376,15 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_BeforeTests_GlobalSetUpTests_SetUp__CancellationToken_Before_Test_Body + Body = TUnit_TestProject_BeforeTests_GlobalSetUpTests_SetUp__CancellationToken_Before_Test_5f0ccde7_Body } ); - private static ValueTask TUnit_TestProject_BeforeTests_GlobalSetUpTests_SetUp__CancellationToken_Before_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_BeforeTests_GlobalSetUpTests_SetUp__CancellationToken_Before_Test_5f0ccde7_Body(object instance, TestContext context, CancellationToken cancellationToken) { - try - { - var typedInstance = (global::TUnit.TestProject.BeforeTests.GlobalSetUpTests)instance; - return new ValueTask(typedInstance.SetUp(cancellationToken)); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + var typedInstance = (global::TUnit.TestProject.BeforeTests.GlobalSetUpTests)instance; + return new ValueTask(typedInstance.SetUp(cancellationToken)); } - static readonly int _h_TUnit_TestProject_BeforeTests_GlobalSetUpTests_SetUpWithContext__TestContext_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), + static readonly int _h_TUnit_TestProject_BeforeTests_GlobalSetUpTests_SetUpWithContext__TestContext_Before_Test_e8f81b63 = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), static __registrationIndex => new InstanceHookMethod { @@ -472,22 +416,15 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_BeforeTests_GlobalSetUpTests_SetUpWithContext__TestContext_Before_Test_Body + Body = TUnit_TestProject_BeforeTests_GlobalSetUpTests_SetUpWithContext__TestContext_Before_Test_e8f81b63_Body } ); - private static ValueTask TUnit_TestProject_BeforeTests_GlobalSetUpTests_SetUpWithContext__TestContext_Before_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_BeforeTests_GlobalSetUpTests_SetUpWithContext__TestContext_Before_Test_e8f81b63_Body(object instance, TestContext context, CancellationToken cancellationToken) { - try - { - var typedInstance = (global::TUnit.TestProject.BeforeTests.GlobalSetUpTests)instance; - return new ValueTask(typedInstance.SetUpWithContext(context)); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + var typedInstance = (global::TUnit.TestProject.BeforeTests.GlobalSetUpTests)instance; + return new ValueTask(typedInstance.SetUpWithContext(context)); } - static readonly int _h_TUnit_TestProject_BeforeTests_GlobalSetUpTests_SetUpWithContext__TestContext_CancellationToken_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), + static readonly int _h_TUnit_TestProject_BeforeTests_GlobalSetUpTests_SetUpWithContext__TestContext_CancellationToken_Before_Test_14e8fd63 = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), static __registrationIndex => new InstanceHookMethod { @@ -520,22 +457,15 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_BeforeTests_GlobalSetUpTests_SetUpWithContext__TestContext_CancellationToken_Before_Test_Body + Body = TUnit_TestProject_BeforeTests_GlobalSetUpTests_SetUpWithContext__TestContext_CancellationToken_Before_Test_14e8fd63_Body } ); - private static ValueTask TUnit_TestProject_BeforeTests_GlobalSetUpTests_SetUpWithContext__TestContext_CancellationToken_Before_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_BeforeTests_GlobalSetUpTests_SetUpWithContext__TestContext_CancellationToken_Before_Test_14e8fd63_Body(object instance, TestContext context, CancellationToken cancellationToken) { - try - { - var typedInstance = (global::TUnit.TestProject.BeforeTests.GlobalSetUpTests)instance; - return new ValueTask(typedInstance.SetUpWithContext(context, cancellationToken)); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + var typedInstance = (global::TUnit.TestProject.BeforeTests.GlobalSetUpTests)instance; + return new ValueTask(typedInstance.SetUpWithContext(context, cancellationToken)); } - static readonly int _h_TUnit_TestProject_BeforeTests_GlobalSetUpTests_BeforeAllSetUp__TestContext_BeforeEvery_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeEveryTestHooks, global::TUnit.Core.HookRegistrationIndices.GetNextBeforeEveryTestHookIndex(), + static readonly int _h_TUnit_TestProject_BeforeTests_GlobalSetUpTests_BeforeAllSetUp__TestContext_BeforeEvery_Test_ddba4145 = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeEveryTestHooks, global::TUnit.Core.HookRegistrationIndices.GetNextBeforeEveryTestHookIndex(), static __registrationIndex => new BeforeTestHookMethod { @@ -566,23 +496,16 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_BeforeTests_GlobalSetUpTests_BeforeAllSetUp__TestContext_BeforeEvery_Test_Body, + Body = TUnit_TestProject_BeforeTests_GlobalSetUpTests_BeforeAllSetUp__TestContext_BeforeEvery_Test_ddba4145_Body, FilePath = "", LineNumber = 50 } ); - private static ValueTask TUnit_TestProject_BeforeTests_GlobalSetUpTests_BeforeAllSetUp__TestContext_BeforeEvery_Test_Body(TestContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_BeforeTests_GlobalSetUpTests_BeforeAllSetUp__TestContext_BeforeEvery_Test_ddba4145_Body(TestContext context, CancellationToken cancellationToken) { - try - { - return new ValueTask(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests.BeforeAllSetUp(context)); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + return new ValueTask(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests.BeforeAllSetUp(context)); } - static readonly int _h_TUnit_TestProject_BeforeTests_GlobalSetUpTests_BeforeAllSetUp__TestContext_CancellationToken_BeforeEvery_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeEveryTestHooks, global::TUnit.Core.HookRegistrationIndices.GetNextBeforeEveryTestHookIndex(), + static readonly int _h_TUnit_TestProject_BeforeTests_GlobalSetUpTests_BeforeAllSetUp__TestContext_CancellationToken_BeforeEvery_Test_70af692f = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeEveryTestHooks, global::TUnit.Core.HookRegistrationIndices.GetNextBeforeEveryTestHookIndex(), static __registrationIndex => new BeforeTestHookMethod { @@ -614,23 +537,16 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_BeforeTests_GlobalSetUpTests_BeforeAllSetUp__TestContext_CancellationToken_BeforeEvery_Test_Body, + Body = TUnit_TestProject_BeforeTests_GlobalSetUpTests_BeforeAllSetUp__TestContext_CancellationToken_BeforeEvery_Test_70af692f_Body, FilePath = "", LineNumber = 56 } ); - private static ValueTask TUnit_TestProject_BeforeTests_GlobalSetUpTests_BeforeAllSetUp__TestContext_CancellationToken_BeforeEvery_Test_Body(TestContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_BeforeTests_GlobalSetUpTests_BeforeAllSetUp__TestContext_CancellationToken_BeforeEvery_Test_70af692f_Body(TestContext context, CancellationToken cancellationToken) { - try - { - return new ValueTask(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests.BeforeAllSetUp(context, cancellationToken)); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + return new ValueTask(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests.BeforeAllSetUp(context, cancellationToken)); } - static readonly int _h_TUnit_TestProject_BeforeTests_GlobalSetUpTests_BeforeAllSetUpWithContext__TestContext_BeforeEvery_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeEveryTestHooks, global::TUnit.Core.HookRegistrationIndices.GetNextBeforeEveryTestHookIndex(), + static readonly int _h_TUnit_TestProject_BeforeTests_GlobalSetUpTests_BeforeAllSetUpWithContext__TestContext_BeforeEvery_Test_16a3d03a = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeEveryTestHooks, global::TUnit.Core.HookRegistrationIndices.GetNextBeforeEveryTestHookIndex(), static __registrationIndex => new BeforeTestHookMethod { @@ -661,23 +577,16 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_BeforeTests_GlobalSetUpTests_BeforeAllSetUpWithContext__TestContext_BeforeEvery_Test_Body, + Body = TUnit_TestProject_BeforeTests_GlobalSetUpTests_BeforeAllSetUpWithContext__TestContext_BeforeEvery_Test_16a3d03a_Body, FilePath = "", LineNumber = 62 } ); - private static ValueTask TUnit_TestProject_BeforeTests_GlobalSetUpTests_BeforeAllSetUpWithContext__TestContext_BeforeEvery_Test_Body(TestContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_BeforeTests_GlobalSetUpTests_BeforeAllSetUpWithContext__TestContext_BeforeEvery_Test_16a3d03a_Body(TestContext context, CancellationToken cancellationToken) { - try - { - return new ValueTask(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests.BeforeAllSetUpWithContext(context)); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + return new ValueTask(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests.BeforeAllSetUpWithContext(context)); } - static readonly int _h_TUnit_TestProject_BeforeTests_GlobalSetUpTests_BeforeAllSetUpWithContext__TestContext_CancellationToken_BeforeEvery_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeEveryTestHooks, global::TUnit.Core.HookRegistrationIndices.GetNextBeforeEveryTestHookIndex(), + static readonly int _h_TUnit_TestProject_BeforeTests_GlobalSetUpTests_BeforeAllSetUpWithContext__TestContext_CancellationToken_BeforeEvery_Test_2ee2750e = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeEveryTestHooks, global::TUnit.Core.HookRegistrationIndices.GetNextBeforeEveryTestHookIndex(), static __registrationIndex => new BeforeTestHookMethod { @@ -709,21 +618,14 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_BeforeTests_GlobalSetUpTests_BeforeAllSetUpWithContext__TestContext_CancellationToken_BeforeEvery_Test_Body, + Body = TUnit_TestProject_BeforeTests_GlobalSetUpTests_BeforeAllSetUpWithContext__TestContext_CancellationToken_BeforeEvery_Test_2ee2750e_Body, FilePath = "", LineNumber = 68 } ); - private static ValueTask TUnit_TestProject_BeforeTests_GlobalSetUpTests_BeforeAllSetUpWithContext__TestContext_CancellationToken_BeforeEvery_Test_Body(TestContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_BeforeTests_GlobalSetUpTests_BeforeAllSetUpWithContext__TestContext_CancellationToken_BeforeEvery_Test_2ee2750e_Body(TestContext context, CancellationToken cancellationToken) { - try - { - return new ValueTask(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests.BeforeAllSetUpWithContext(context, cancellationToken)); - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + return new ValueTask(global::TUnit.TestProject.BeforeTests.GlobalSetUpTests.BeforeAllSetUpWithContext(context, cancellationToken)); } } } diff --git a/tests/TUnit.Core.SourceGenerator.Tests/HooksTests.DisposableFieldTests.verified.txt b/tests/TUnit.Core.SourceGenerator.Tests/HooksTests.DisposableFieldTests.verified.txt index 6c4ca633431..19ef6613f98 100644 --- a/tests/TUnit.Core.SourceGenerator.Tests/HooksTests.DisposableFieldTests.verified.txt +++ b/tests/TUnit.Core.SourceGenerator.Tests/HooksTests.DisposableFieldTests.verified.txt @@ -13,7 +13,7 @@ namespace TUnit.Generated { internal static partial class TUnit_HookRegistration { - static readonly int _h_TUnit_TestProject_DisposableFieldTests_Setup_Before_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.DisposableFieldTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), + static readonly int _h_TUnit_TestProject_DisposableFieldTests_Setup_Before_Test_b28f2ec1 = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.BeforeTestHooks, typeof(global::TUnit.TestProject.DisposableFieldTests), global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), static __registrationIndex => new InstanceHookMethod { @@ -42,23 +42,16 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_DisposableFieldTests_Setup_Before_Test_Body + Body = TUnit_TestProject_DisposableFieldTests_Setup_Before_Test_b28f2ec1_Body } ); - private static ValueTask TUnit_TestProject_DisposableFieldTests_Setup_Before_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_DisposableFieldTests_Setup_Before_Test_b28f2ec1_Body(object instance, TestContext context, CancellationToken cancellationToken) { - try - { - var typedInstance = (global::TUnit.TestProject.DisposableFieldTests)instance; - typedInstance.Setup(); - return default; - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + var typedInstance = (global::TUnit.TestProject.DisposableFieldTests)instance; + typedInstance.Setup(); + return default; } - static readonly int _h_TUnit_TestProject_DisposableFieldTests_Blah_After_Test = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterTestHooks, typeof(global::TUnit.TestProject.DisposableFieldTests), global::TUnit.Core.HookRegistrationIndices.GetNextAfterTestHookIndex(), + static readonly int _h_TUnit_TestProject_DisposableFieldTests_Blah_After_Test_7388f534 = global::TUnit.Core.SourceRegistrar.RegisterHook(global::TUnit.Core.Sources.AfterTestHooks, typeof(global::TUnit.TestProject.DisposableFieldTests), global::TUnit.Core.HookRegistrationIndices.GetNextAfterTestHookIndex(), static __registrationIndex => new InstanceHookMethod { @@ -87,21 +80,14 @@ namespace TUnit.Generated HookExecutor = DefaultExecutor.Instance, Order = 0, RegistrationIndex = __registrationIndex, - Body = TUnit_TestProject_DisposableFieldTests_Blah_After_Test_Body + Body = TUnit_TestProject_DisposableFieldTests_Blah_After_Test_7388f534_Body } ); - private static ValueTask TUnit_TestProject_DisposableFieldTests_Blah_After_Test_Body(object instance, TestContext context, CancellationToken cancellationToken) + private static ValueTask TUnit_TestProject_DisposableFieldTests_Blah_After_Test_7388f534_Body(object instance, TestContext context, CancellationToken cancellationToken) { - try - { - var typedInstance = (global::TUnit.TestProject.DisposableFieldTests)instance; - typedInstance.Blah(); - return default; - } - catch (Exception ex) - { - return new ValueTask(Task.FromException(ex)); - } + var typedInstance = (global::TUnit.TestProject.DisposableFieldTests)instance; + typedInstance.Blah(); + return default; } } } diff --git a/tests/TUnit.SourceGenerator.IncrementalTests/HookMetadataGeneratorIncrementalTests.cs b/tests/TUnit.SourceGenerator.IncrementalTests/HookMetadataGeneratorIncrementalTests.cs index ea858683119..88076627356 100644 --- a/tests/TUnit.SourceGenerator.IncrementalTests/HookMetadataGeneratorIncrementalTests.cs +++ b/tests/TUnit.SourceGenerator.IncrementalTests/HookMetadataGeneratorIncrementalTests.cs @@ -34,6 +34,53 @@ public void AddUnrelatedType_ShouldNotRegenerate() TestHelper.AssertRunReason(driver2.GetRunResult().Results[0], HookMetadataGenerator.HookClassGroups, IncrementalStepRunReason.Cached, 0); } + [Fact] + public void TypesWithSameSanitizedName_ShouldGenerateDistinctFilesAndMembers() + { + // A_B.C and A.B_C both sanitize to A_B_C. Hint names and the members emitted into the shared + // TUnit_HookRegistration partial class must still be unique. + const string source = + """ + using TUnit.Core; + + namespace A_B + { + public class C + { + [Before(HookType.Test)] + public void Setup() + { + } + } + } + + namespace A + { + public class B_C + { + [Before(HookType.Test)] + public void Setup() + { + } + } + } + """; + + var compilation = Fixture.CreateLibrary(CSharpSyntaxTree.ParseText(source, CSharpParseOptions.Default)); + + var driver = TestHelper.GenerateTracked(compilation); + var runResult = driver.GetRunResult(); + + Xunit.Assert.Empty(runResult.Diagnostics); + var generatorResult = Xunit.Assert.Single(runResult.Results); + Xunit.Assert.Null(generatorResult.Exception); + Xunit.Assert.Equal(2, generatorResult.GeneratedSources.Length); + Xunit.Assert.Equal(2, generatorResult.GeneratedSources.Select(static s => s.HintName).Distinct().Count()); + + var outputCompilation = compilation.AddSyntaxTrees(generatorResult.GeneratedSources.Select(static s => s.SyntaxTree)); + Xunit.Assert.Empty(outputCompilation.GetDiagnostics().Where(static d => d.Severity == DiagnosticSeverity.Error)); + } + [Fact] public void ChangeHookInOneClass_ShouldOnlyModifyThatClassGroup() { diff --git a/tests/TUnit.TestProject/SyncHookBodySemanticsTests.cs b/tests/TUnit.TestProject/SyncHookBodySemanticsTests.cs new file mode 100644 index 00000000000..f65dd551f1e --- /dev/null +++ b/tests/TUnit.TestProject/SyncHookBodySemanticsTests.cs @@ -0,0 +1,88 @@ +using TUnit.Core.Executors; +using TUnit.TestProject.Attributes; + +namespace TUnit.TestProject; + +/// +/// Synchronous hook bodies must keep async-method semantics when handed to a hook executor: +/// ExecutionContext changes made by the hook do not leak into the executor, and a synchronous +/// OperationCanceledException surfaces as a canceled (not faulted) task rather than a synchronous throw./// +[EngineTest(ExpectedResult.Pass)] +public class SyncHookBodySemanticsTests +{ + internal static readonly AsyncLocal HookLocal = new(); + + internal static bool AsyncLocalHookRan; + internal static string? ValueObservedByExecutor; + + internal static bool CancelingHookThrewSynchronously; + internal static bool? CancelingHookTaskWasCanceled; + + [Before(Test)] + [HookExecutor] + public void SetAsyncLocalSynchronously() + { + AsyncLocalHookRan = true; + HookLocal.Value = "set-by-hook"; + } + + [Before(Test)] + [HookExecutor] + public void ThrowOperationCanceledSynchronously() + { + throw new OperationCanceledException(new CancellationToken(true)); + } + + [Test] + public async Task SyncHook_AsyncLocal_DoesNotLeakIntoExecutor() + { + await Assert.That(AsyncLocalHookRan).IsTrue(); + await Assert.That(ValueObservedByExecutor).IsNull(); + } + + [Test] + public async Task SyncHook_OperationCanceled_SurfacesAsCanceledTask() + { + await Assert.That(CancelingHookThrewSynchronously).IsFalse(); + + // Reflection mode invokes hooks via MethodInfo.Invoke, which wraps the exception in a + // TargetInvocationException, so only source-generated bodies can surface a canceled task. + if (SourceRegistrar.IsEnabled) + { + await Assert.That(CancelingHookTaskWasCanceled).IsEqualTo(true); + } + } +} + +public class AsyncLocalObservingExecutor : GenericAbstractExecutor +{ + protected override async ValueTask ExecuteAsync(Func action) + { + var pending = action(); + SyncHookBodySemanticsTests.ValueObservedByExecutor = SyncHookBodySemanticsTests.HookLocal.Value; + await pending; + } +} + +public class CancellationObservingExecutor : GenericAbstractExecutor +{ + protected override ValueTask ExecuteAsync(Func action) + { + Task task; + try + { + task = action().AsTask(); + } + catch (OperationCanceledException) + { + SyncHookBodySemanticsTests.CancelingHookThrewSynchronously = true; + return default; + } + + SyncHookBodySemanticsTests.CancelingHookTaskWasCanceled = task.IsCanceled; + + // Observe and swallow the outcome so the hook itself does not fail the tests. + _ = task.Exception; + return default; + } +} From 7b2e3c03a94955a02870a0cec56ebe0ee1ad961a Mon Sep 17 00:00:00 2001 From: Tom Longhurst <30480171+thomhurst@users.noreply.github.com> Date: Tue, 29 Sep 2026 11:17:57 +0100 Subject: [PATCH 3/7] fix(source-gen): emit hook class groups in source order Registration indices come from static field initializers, which run in generated-file order. Grouping by first appearance in the concatenated per-kind arrays put a class with a Before hook ahead of an earlier class that only had other hook kinds, so equal-Order hooks sharing a registration counter ran in a different order than in reflection mode. Order groups by the source position of each class's first hook, recovering the compilation file order from the collected arrays. --- .../Generators/HookMetadataGenerator.cs | 68 ++++++++++++++++++- ...HookRegistrationOrderAcrossClassesTests.cs | 48 +++++++++++++ 2 files changed, 113 insertions(+), 3 deletions(-) create mode 100644 tests/TUnit.TestProject/HookRegistrationOrderAcrossClassesTests.cs diff --git a/src/TUnit.Core.SourceGenerator/Generators/HookMetadataGenerator.cs b/src/TUnit.Core.SourceGenerator/Generators/HookMetadataGenerator.cs index 44b85fca3f1..3094eb031ea 100644 --- a/src/TUnit.Core.SourceGenerator/Generators/HookMetadataGenerator.cs +++ b/src/TUnit.Core.SourceGenerator/Generators/HookMetadataGenerator.cs @@ -88,21 +88,83 @@ public void Initialize(IncrementalGeneratorInitializationContext context) private static IEnumerable GroupHooksByClass(params ImmutableArray[] hookArrays) { + var fileRanks = RankFilesBySourceOrder(hookArrays); + // A type's fully qualified name identifies it within a compilation, so grouping by it matches // grouping by symbol while keeping the pipeline free of symbols. + // + // Registration indices come from runtime counters incremented by static field initializers, which + // run in generated-file order. Groups are therefore emitted in the source order of each class's + // first hook. Hooks of one kind in different classes then register in declaration order, as they + // did with per-hook files and as reflection discovery does. Grouping by first appearance in the + // concatenated per-kind arrays would instead move a class ahead just because it has a Before hook. return hookArrays .SelectMany(static hooks => hooks) .Where(static hook => hook is not null) .GroupBy(static hook => hook!.FullyQualifiedTypeName, StringComparer.Ordinal) - .Select(static group => new HookClassGroup + .Select(group => + { + var first = group.OrderBy(hook => fileRanks[hook!.FilePath]).ThenBy(static hook => hook!.LineNumber).First()!; + return (FileRank: fileRanks[first.FilePath], first.LineNumber, Group: group); + }) + .OrderBy(static entry => entry.FileRank) + .ThenBy(static entry => entry.LineNumber) + .ThenBy(static entry => entry.Group.Key, StringComparer.Ordinal) + .Select(static entry => new HookClassGroup { - FullyQualifiedTypeName = group.Key, - Hooks = group.Select(static hook => hook!).ToEquatableArray() + FullyQualifiedTypeName = entry.Group.Key, + Hooks = entry.Group.Select(static hook => hook!).ToEquatableArray() }); } + /// + /// Ranks source files in compilation order. Each collected array is ordered by syntax tree, so each + /// array's sequence of distinct files is a subsequence of the compilation's file order. Merging those + /// sequences recovers that order for every file that declares a hook. + /// + private static Dictionary RankFilesBySourceOrder(ImmutableArray[] hookArrays) + { + var files = new List(); + var seen = new HashSet(StringComparer.Ordinal); + + foreach (var hooks in hookArrays) + { + var cursor = 0; + string? previous = null; + + foreach (var hook in hooks) + { + if (hook is null || string.Equals(hook.FilePath, previous, StringComparison.Ordinal)) + { + continue; + } + + previous = hook.FilePath; + + if (seen.Add(hook.FilePath)) + { + files.Insert(cursor, hook.FilePath); + cursor++; + } + else + { + cursor = files.IndexOf(hook.FilePath) + 1; + } + } + } + + var ranks = new Dictionary(files.Count, StringComparer.Ordinal); + for (var i = 0; i < files.Count; i++) + { + ranks[files[i]] = i; + } + + return ranks; + } + private static void GenerateHookClassFile(SourceProductionContext context, HookClassGroup group) { + // Tracks the hook being generated so a failure names it. var hook = group.Hooks[0]; try { diff --git a/tests/TUnit.TestProject/HookRegistrationOrderAcrossClassesTests.cs b/tests/TUnit.TestProject/HookRegistrationOrderAcrossClassesTests.cs new file mode 100644 index 00000000000..fdbc216c743 --- /dev/null +++ b/tests/TUnit.TestProject/HookRegistrationOrderAcrossClassesTests.cs @@ -0,0 +1,48 @@ +using System.Collections.Concurrent; + +namespace TUnit.TestProject; + +// Hooks with equal Order run in registration order. The first class declares only a BeforeEvery(Assembly) +// hook, while the second also declares a Before(Class) hook. Registration must follow declaration order, +// as it does in reflection mode, and not move the second class ahead because it has a Before hook. +public static class HookRegistrationOrderFirstHooks +{ + [BeforeEvery(Assembly)] + public static void RecordFirst(AssemblyHookContext context) + { + HookRegistrationOrderAcrossClassesTests.Record(context, "First"); + } +} + +public static class HookRegistrationOrderSecondHooks +{ + [Before(Class)] + public static void UnusedClassHook() + { + } + + [BeforeEvery(Assembly)] + public static void RecordSecond(AssemblyHookContext context) + { + HookRegistrationOrderAcrossClassesTests.Record(context, "Second"); + } +} + +public class HookRegistrationOrderAcrossClassesTests +{ + private static readonly ConcurrentQueue Executed = new(); + + internal static void Record(AssemblyHookContext context, string name) + { + if (context.Assembly == typeof(HookRegistrationOrderAcrossClassesTests).Assembly) + { + Executed.Enqueue(name); + } + } + + [Test] + public async Task EqualOrderHooks_InDifferentClasses_RunInDeclarationOrder() + { + await Assert.That(Executed).IsEquivalentTo(["First", "Second"], TUnit.Assertions.Enums.CollectionOrdering.Matching); + } +} From 57c40689610d145cdee09be2ecdf7969b99642b4 Mon Sep 17 00:00:00 2001 From: Tom Longhurst <30480171+thomhurst@users.noreply.github.com> Date: Tue, 29 Sep 2026 11:34:17 +0100 Subject: [PATCH 4/7] fix(source-gen): order hook class groups by compilation file order and column Replace the per-kind file-sequence merge with the files' syntax tree order from the compilation, filtered to files that declare hooks so unrelated edits keep the grouping step cached. Break same-line ties by column so classes declared on one line keep declaration order. --- .../Generators/HookMetadataGenerator.cs | 161 +++++++++++------- .../Models/Extracted/HookModel.cs | 5 + .../HookMetadataGeneratorIncrementalTests.cs | 93 ++++++++++ 3 files changed, 200 insertions(+), 59 deletions(-) diff --git a/src/TUnit.Core.SourceGenerator/Generators/HookMetadataGenerator.cs b/src/TUnit.Core.SourceGenerator/Generators/HookMetadataGenerator.cs index 3094eb031ea..0d1a0c9ab15 100644 --- a/src/TUnit.Core.SourceGenerator/Generators/HookMetadataGenerator.cs +++ b/src/TUnit.Core.SourceGenerator/Generators/HookMetadataGenerator.cs @@ -22,6 +22,7 @@ public class HookMetadataGenerator : IIncrementalGenerator public const string ExtractAfterHooks = "ExtractAfterHooks"; public const string ExtractBeforeEveryHooks = "ExtractBeforeEveryHooks"; public const string ExtractAfterEveryHooks = "ExtractAfterEveryHooks"; + public const string HookFileOrder = "HookFileOrder"; public const string HookClassGroups = "HookClassGroups"; public void Initialize(IncrementalGeneratorInitializationContext context) @@ -65,20 +66,36 @@ public void Initialize(IncrementalGeneratorInitializationContext context) .Where(static m => m is not null) .WithTrackingName(ExtractAfterEveryHooks); + var allHooks = beforeHooks.Collect() + .Combine(afterHooks.Collect()) + .Combine(beforeEveryHooks.Collect()) + .Combine(afterEveryHooks.Collect()) + .Select(static (data, _) => + { + var (((before, after), beforeEvery), afterEvery) = data; + return new[] { before, after, beforeEvery, afterEvery }; + }); + + // The files that declare hooks, in compilation order. Only this small list is compared between + // runs, so edits that add, remove or reorder unrelated files leave the grouping step cached. + var hookFileOrder = allHooks + .Select(static (hookArrays, _) => GetHookFilePaths(hookArrays)) + .Combine(context.CompilationProvider) + .Select(static (data, _) => OrderByCompilation(data.Left, data.Right)) + .WithTrackingName(HookFileOrder); + // Group hooks by declaring class so each class gets one generated file instead of one per hook. // .Collect() is a fan-in, so grouping re-runs when any hook model changes, but it only arranges // already-extracted models. HookClassGroup's value equality means only the changed class's file // is re-emitted. - var hookClassGroups = beforeHooks.Collect() - .Combine(afterHooks.Collect()) - .Combine(beforeEveryHooks.Collect()) - .Combine(afterEveryHooks.Collect()) + var hookClassGroups = allHooks + .Combine(hookFileOrder) .Combine(enabledProvider) .SelectMany(static (data, _) => { - var ((((before, after), beforeEvery), afterEvery), isEnabled) = data; + var ((hookArrays, fileOrder), isEnabled) = data; return isEnabled - ? GroupHooksByClass(before, after, beforeEvery, afterEvery) + ? GroupHooksByClass(hookArrays, fileOrder) : []; }) .WithTrackingName(HookClassGroups); @@ -86,29 +103,98 @@ public void Initialize(IncrementalGeneratorInitializationContext context) context.RegisterSourceOutput(hookClassGroups, GenerateHookClassFile); } - private static IEnumerable GroupHooksByClass(params ImmutableArray[] hookArrays) + private static EquatableArray GetHookFilePaths(ImmutableArray[] hookArrays) + { + var paths = new HashSet(StringComparer.Ordinal); + foreach (var hooks in hookArrays) + { + foreach (var hook in hooks) + { + if (hook is not null) + { + paths.Add(hook.FilePath); + } + } + } + + // Sorted so equal sets compare equal and the compilation-order step stays cached. + var sorted = paths.ToArray(); + Array.Sort(sorted, StringComparer.Ordinal); + return new EquatableArray(sorted); + } + + /// + /// Orders the files that declare hooks as their syntax trees are ordered in the compilation. The compiler + /// emits types in that order, which is the order reflection discovery sees them in. + /// + private static EquatableArray OrderByCompilation(EquatableArray hookFilePaths, Compilation compilation) + { + if (hookFilePaths.Length == 0) + { + return hookFilePaths; + } + + var remaining = new HashSet(hookFilePaths, StringComparer.Ordinal); + var ordered = new List(remaining.Count); + foreach (var tree in compilation.SyntaxTrees) + { + // Removing also lists a path shared by several trees (e.g. empty paths in tests) only once. + if (remaining.Remove(tree.FilePath)) + { + ordered.Add(tree.FilePath); + + if (remaining.Count == 0) + { + break; + } + } + } + + // Defensive: a hook whose path matches no tree still gets a deterministic rank. + foreach (var path in hookFilePaths) + { + if (remaining.Contains(path)) + { + ordered.Add(path); + } + } + + return new EquatableArray(ordered.ToArray()); + } + + private static IEnumerable GroupHooksByClass(ImmutableArray[] hookArrays, EquatableArray fileOrder) { - var fileRanks = RankFilesBySourceOrder(hookArrays); + var fileRanks = new Dictionary(fileOrder.Length, StringComparer.Ordinal); + for (var i = 0; i < fileOrder.Length; i++) + { + fileRanks[fileOrder[i]] = i; + } // A type's fully qualified name identifies it within a compilation, so grouping by it matches // grouping by symbol while keeping the pipeline free of symbols. // // Registration indices come from runtime counters incremented by static field initializers, which // run in generated-file order. Groups are therefore emitted in the source order of each class's - // first hook. Hooks of one kind in different classes then register in declaration order, as they - // did with per-hook files and as reflection discovery does. Grouping by first appearance in the - // concatenated per-kind arrays would instead move a class ahead just because it has a Before hook. + // first hook: file in compilation order, then line, then column. Hooks of one kind in different + // classes then register in declaration order, as they did with per-hook files and as reflection + // discovery does. Grouping by first appearance in the concatenated per-kind arrays would instead + // move a class ahead just because it has a Before hook. return hookArrays .SelectMany(static hooks => hooks) .Where(static hook => hook is not null) .GroupBy(static hook => hook!.FullyQualifiedTypeName, StringComparer.Ordinal) .Select(group => { - var first = group.OrderBy(hook => fileRanks[hook!.FilePath]).ThenBy(static hook => hook!.LineNumber).First()!; - return (FileRank: fileRanks[first.FilePath], first.LineNumber, Group: group); + var first = group + .OrderBy(hook => fileRanks[hook!.FilePath]) + .ThenBy(static hook => hook!.LineNumber) + .ThenBy(static hook => hook!.ColumnNumber) + .First()!; + return (FileRank: fileRanks[first.FilePath], first.LineNumber, first.ColumnNumber, Group: group); }) .OrderBy(static entry => entry.FileRank) .ThenBy(static entry => entry.LineNumber) + .ThenBy(static entry => entry.ColumnNumber) .ThenBy(static entry => entry.Group.Key, StringComparer.Ordinal) .Select(static entry => new HookClassGroup { @@ -117,51 +203,6 @@ private static IEnumerable GroupHooksByClass(params ImmutableArr }); } - /// - /// Ranks source files in compilation order. Each collected array is ordered by syntax tree, so each - /// array's sequence of distinct files is a subsequence of the compilation's file order. Merging those - /// sequences recovers that order for every file that declares a hook. - /// - private static Dictionary RankFilesBySourceOrder(ImmutableArray[] hookArrays) - { - var files = new List(); - var seen = new HashSet(StringComparer.Ordinal); - - foreach (var hooks in hookArrays) - { - var cursor = 0; - string? previous = null; - - foreach (var hook in hooks) - { - if (hook is null || string.Equals(hook.FilePath, previous, StringComparison.Ordinal)) - { - continue; - } - - previous = hook.FilePath; - - if (seen.Add(hook.FilePath)) - { - files.Insert(cursor, hook.FilePath); - cursor++; - } - else - { - cursor = files.IndexOf(hook.FilePath) + 1; - } - } - } - - var ranks = new Dictionary(files.Count, StringComparer.Ordinal); - for (var i = 0; i < files.Count; i++) - { - ranks[files[i]] = i; - } - - return ranks; - } - private static void GenerateHookClassFile(SourceProductionContext context, HookClassGroup group) { // Tracks the hook being generated so a failure names it. @@ -228,7 +269,8 @@ private static void GenerateHookClassFile(SourceProductionContext context, HookC var location = context.TargetNode.GetLocation(); var filePath = location.SourceTree?.FilePath ?? hookAttribute.ConstructorArguments.ElementAtOrDefault(1).Value?.ToString() ?? ""; - var lineNumber = location.GetLineSpan().StartLinePosition.Line + 1; + var startPosition = location.GetLineSpan().StartLinePosition; + var lineNumber = startPosition.Line + 1; var order = GetHookOrder(hookAttribute); var hookExecutor = GetHookExecutorType(methodSymbol); @@ -282,6 +324,7 @@ private static void GenerateHookClassFile(SourceProductionContext context, HookC MethodName = methodSymbol.Name, FilePath = filePath, LineNumber = lineNumber, + ColumnNumber = startPosition.Character, HookKind = hookKind, HookType = hookType, Order = order, diff --git a/src/TUnit.Core.SourceGenerator/Models/Extracted/HookModel.cs b/src/TUnit.Core.SourceGenerator/Models/Extracted/HookModel.cs index f0aeb69e5a4..4134d8598c4 100644 --- a/src/TUnit.Core.SourceGenerator/Models/Extracted/HookModel.cs +++ b/src/TUnit.Core.SourceGenerator/Models/Extracted/HookModel.cs @@ -16,6 +16,10 @@ public sealed class HookModel : IEquatable public required string FilePath { get; init; } public required int LineNumber { get; init; } + // Zero-based column of the hook's declaration. Not emitted; together with LineNumber it orders + // class groups declared on the same line. + public required int ColumnNumber { get; init; } + // Hook configuration (using strings to match existing generator API) public required string HookKind { get; init; } // "Before", "After", "BeforeEvery", "AfterEvery" public required string HookType { get; init; } // "Test", "Class", "Assembly", "TestSession", "TestDiscovery" @@ -69,6 +73,7 @@ public bool Equals(HookModel? other) && MethodName == other.MethodName && FilePath == other.FilePath && LineNumber == other.LineNumber + && ColumnNumber == other.ColumnNumber && HookKind == other.HookKind && HookType == other.HookType && Order == other.Order diff --git a/tests/TUnit.SourceGenerator.IncrementalTests/HookMetadataGeneratorIncrementalTests.cs b/tests/TUnit.SourceGenerator.IncrementalTests/HookMetadataGeneratorIncrementalTests.cs index 88076627356..5d9249599ae 100644 --- a/tests/TUnit.SourceGenerator.IncrementalTests/HookMetadataGeneratorIncrementalTests.cs +++ b/tests/TUnit.SourceGenerator.IncrementalTests/HookMetadataGeneratorIncrementalTests.cs @@ -164,6 +164,99 @@ public async Task Setup() AssertRunReason(driver2, IncrementalStepRunReason.Modified); } + [Fact] + public void ClassGroups_AcrossFilesWithDisjointHookKinds_AreEmittedInCompilationOrder() + { + // The first file's class has only a Before hook besides the shared BeforeEvery hook, and the second + // file's class has only an After hook. No single hook kind orders the two files except BeforeEvery, + // so file order must come from the compilation rather than from merging per-kind sequences. + const string first = + """ + using TUnit.Core; + + public static class FirstFileHooks + { + [Before(HookType.Class)] + public static void BeforeClass() { } + + [BeforeEvery(HookType.Assembly)] + public static void BeforeEveryAssembly(AssemblyHookContext context) { } + } + """; + + const string second = + """ + using TUnit.Core; + + public static class SecondFileHooks + { + [After(HookType.Class)] + public static void AfterClass() { } + + [BeforeEvery(HookType.Assembly)] + public static void BeforeEveryAssembly(AssemblyHookContext context) { } + } + """; + + var compilation = Fixture.CreateLibrary( + CSharpSyntaxTree.ParseText(first, CSharpParseOptions.Default, path: "First.cs"), + CSharpSyntaxTree.ParseText(second, CSharpParseOptions.Default, path: "Second.cs")); + + AssertGeneratedOrder(compilation, "FirstFileHooks", "SecondFileHooks"); + + // Reversing the files in the compilation reverses the emitted order. + var reversed = Fixture.CreateLibrary( + CSharpSyntaxTree.ParseText(second, CSharpParseOptions.Default, path: "Second.cs"), + CSharpSyntaxTree.ParseText(first, CSharpParseOptions.Default, path: "First.cs")); + + AssertGeneratedOrder(reversed, "SecondFileHooks", "FirstFileHooks"); + } + + [Fact] + public void ClassGroups_DeclaredOnOneLine_AreEmittedInDeclarationOrder() + { + const string source = + """ + using TUnit.Core; + + public class ZHooks { [Before(HookType.Test)] public void Setup() { } } public class AHooks { [Before(HookType.Test)] public void Setup() { } } + """; + + var compilation = Fixture.CreateLibrary(CSharpSyntaxTree.ParseText(source, CSharpParseOptions.Default)); + + AssertGeneratedOrder(compilation, "ZHooks", "AHooks"); + } + + [Fact] + public void AddUnrelatedFile_ShouldNotChangeHookFileOrder() + { + var compilation1 = Fixture.CreateLibrary(CSharpSyntaxTree.ParseText(DefaultSource, CSharpParseOptions.Default, path: "Hooks.cs")); + + var driver1 = TestHelper.GenerateTracked(compilation1); + + var compilation2 = compilation1.AddSyntaxTrees(CSharpSyntaxTree.ParseText("struct MyValue {}", CSharpParseOptions.Default, path: "Other.cs")); + var driver2 = driver1.RunGenerators(compilation2); + var runResult = driver2.GetRunResult().Results[0]; + + TestHelper.AssertRunReason(runResult, HookMetadataGenerator.HookFileOrder, IncrementalStepRunReason.Unchanged, 0); + TestHelper.AssertRunReason(runResult, HookMetadataGenerator.HookClassGroups, IncrementalStepRunReason.Cached, 0); + } + + private static void AssertGeneratedOrder(Compilation compilation, params string[] typeNames) + { + var driver = TestHelper.GenerateTracked(compilation); + var generatorResult = Xunit.Assert.Single(driver.GetRunResult().Results); + Xunit.Assert.Null(generatorResult.Exception); + + var hintNames = generatorResult.GeneratedSources.Select(static s => s.HintName).ToArray(); + var indices = typeNames + .Select(typeName => Array.FindIndex(hintNames, hintName => hintName.Contains(typeName))) + .ToArray(); + + Xunit.Assert.DoesNotContain(-1, indices); + Xunit.Assert.Equal(indices.OrderBy(static i => i), indices); + } + private static void AssertRunReason(GeneratorDriver driver, IncrementalStepRunReason reason) { var runResult = driver.GetRunResult().Results[0]; From 57a98884cb31b1901646a0219d6f17f65235baef Mon Sep 17 00:00:00 2001 From: Tom Longhurst <30480171+thomhurst@users.noreply.github.com> Date: Tue, 29 Sep 2026 11:34:17 +0100 Subject: [PATCH 5/7] test: scope recorded hook registration order to the current test session --- .../HookRegistrationOrderAcrossClassesTests.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/TUnit.TestProject/HookRegistrationOrderAcrossClassesTests.cs b/tests/TUnit.TestProject/HookRegistrationOrderAcrossClassesTests.cs index fdbc216c743..98af9a37c05 100644 --- a/tests/TUnit.TestProject/HookRegistrationOrderAcrossClassesTests.cs +++ b/tests/TUnit.TestProject/HookRegistrationOrderAcrossClassesTests.cs @@ -32,6 +32,16 @@ public class HookRegistrationOrderAcrossClassesTests { private static readonly ConcurrentQueue Executed = new(); + // A host can run several test sessions in one process, re-running the assembly hooks each time. + // Session hooks run before assembly hooks, so clearing here scopes the recorded entries to one session. + [Before(TestSession)] + public static void ResetRecordedHooks() + { + while (Executed.TryDequeue(out _)) + { + } + } + internal static void Record(AssemblyHookContext context, string name) { if (context.Assembly == typeof(HookRegistrationOrderAcrossClassesTests).Assembly) From 368c356e9479d9160a807299b4abc27df9c4e337 Mon Sep 17 00:00:00 2001 From: Tom Longhurst <30480171+thomhurst@users.noreply.github.com> Date: Tue, 29 Sep 2026 11:34:17 +0100 Subject: [PATCH 6/7] test: drop accidental UTF-8 BOM from hook snapshot files --- .../AssemblyAfterTests.Test.verified.txt | 2 +- .../AssemblyBeforeTests.Test.verified.txt | 2 +- ...s.HooksTest_WithConflictingNamespace.DotNet10_0.verified.txt | 2 +- ...ts.HooksTest_WithConflictingNamespace.DotNet8_0.verified.txt | 2 +- ...ts.HooksTest_WithConflictingNamespace.DotNet9_0.verified.txt | 2 +- .../GlobalStaticAfterEachTests.Test.verified.txt | 2 +- .../GlobalStaticBeforeEachTests.Test.verified.txt | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/TUnit.Core.SourceGenerator.Tests/AssemblyAfterTests.Test.verified.txt b/tests/TUnit.Core.SourceGenerator.Tests/AssemblyAfterTests.Test.verified.txt index a209721be43..a9920bb226f 100644 --- a/tests/TUnit.Core.SourceGenerator.Tests/AssemblyAfterTests.Test.verified.txt +++ b/tests/TUnit.Core.SourceGenerator.Tests/AssemblyAfterTests.Test.verified.txt @@ -1,4 +1,4 @@ -// +// #pragma warning disable #nullable enable diff --git a/tests/TUnit.Core.SourceGenerator.Tests/AssemblyBeforeTests.Test.verified.txt b/tests/TUnit.Core.SourceGenerator.Tests/AssemblyBeforeTests.Test.verified.txt index 48d19ab4623..fac4e2f1477 100644 --- a/tests/TUnit.Core.SourceGenerator.Tests/AssemblyBeforeTests.Test.verified.txt +++ b/tests/TUnit.Core.SourceGenerator.Tests/AssemblyBeforeTests.Test.verified.txt @@ -1,4 +1,4 @@ -// +// #pragma warning disable #nullable enable diff --git a/tests/TUnit.Core.SourceGenerator.Tests/ConflictingNamespaceTests.HooksTest_WithConflictingNamespace.DotNet10_0.verified.txt b/tests/TUnit.Core.SourceGenerator.Tests/ConflictingNamespaceTests.HooksTest_WithConflictingNamespace.DotNet10_0.verified.txt index 637e7a17fbe..650b5779bf6 100644 --- a/tests/TUnit.Core.SourceGenerator.Tests/ConflictingNamespaceTests.HooksTest_WithConflictingNamespace.DotNet10_0.verified.txt +++ b/tests/TUnit.Core.SourceGenerator.Tests/ConflictingNamespaceTests.HooksTest_WithConflictingNamespace.DotNet10_0.verified.txt @@ -1,4 +1,4 @@ -// +// #pragma warning disable #nullable enable diff --git a/tests/TUnit.Core.SourceGenerator.Tests/ConflictingNamespaceTests.HooksTest_WithConflictingNamespace.DotNet8_0.verified.txt b/tests/TUnit.Core.SourceGenerator.Tests/ConflictingNamespaceTests.HooksTest_WithConflictingNamespace.DotNet8_0.verified.txt index 637e7a17fbe..650b5779bf6 100644 --- a/tests/TUnit.Core.SourceGenerator.Tests/ConflictingNamespaceTests.HooksTest_WithConflictingNamespace.DotNet8_0.verified.txt +++ b/tests/TUnit.Core.SourceGenerator.Tests/ConflictingNamespaceTests.HooksTest_WithConflictingNamespace.DotNet8_0.verified.txt @@ -1,4 +1,4 @@ -// +// #pragma warning disable #nullable enable diff --git a/tests/TUnit.Core.SourceGenerator.Tests/ConflictingNamespaceTests.HooksTest_WithConflictingNamespace.DotNet9_0.verified.txt b/tests/TUnit.Core.SourceGenerator.Tests/ConflictingNamespaceTests.HooksTest_WithConflictingNamespace.DotNet9_0.verified.txt index 637e7a17fbe..650b5779bf6 100644 --- a/tests/TUnit.Core.SourceGenerator.Tests/ConflictingNamespaceTests.HooksTest_WithConflictingNamespace.DotNet9_0.verified.txt +++ b/tests/TUnit.Core.SourceGenerator.Tests/ConflictingNamespaceTests.HooksTest_WithConflictingNamespace.DotNet9_0.verified.txt @@ -1,4 +1,4 @@ -// +// #pragma warning disable #nullable enable diff --git a/tests/TUnit.Core.SourceGenerator.Tests/GlobalStaticAfterEachTests.Test.verified.txt b/tests/TUnit.Core.SourceGenerator.Tests/GlobalStaticAfterEachTests.Test.verified.txt index 61cd16ff18a..c6f64791267 100644 --- a/tests/TUnit.Core.SourceGenerator.Tests/GlobalStaticAfterEachTests.Test.verified.txt +++ b/tests/TUnit.Core.SourceGenerator.Tests/GlobalStaticAfterEachTests.Test.verified.txt @@ -1,4 +1,4 @@ -// +// #pragma warning disable #nullable enable diff --git a/tests/TUnit.Core.SourceGenerator.Tests/GlobalStaticBeforeEachTests.Test.verified.txt b/tests/TUnit.Core.SourceGenerator.Tests/GlobalStaticBeforeEachTests.Test.verified.txt index 7f9310913c2..97d33aab657 100644 --- a/tests/TUnit.Core.SourceGenerator.Tests/GlobalStaticBeforeEachTests.Test.verified.txt +++ b/tests/TUnit.Core.SourceGenerator.Tests/GlobalStaticBeforeEachTests.Test.verified.txt @@ -1,4 +1,4 @@ -// +// #pragma warning disable #nullable enable From 6430d4dd084a21403c5d3aa35b3a1621f42663b2 Mon Sep 17 00:00:00 2001 From: Tom Longhurst <30480171+thomhurst@users.noreply.github.com> Date: Tue, 29 Sep 2026 15:09:02 +0100 Subject: [PATCH 7/7] refactor(core): route static hook bodies through one InvokeBodyAsync helper Document on the Body properties that generated bodies have no async state machine and must be invoked through HookBodyInvoker, and replace the ten repeated wrapper calls with an internal StaticHookMethod.InvokeBodyAsync. --- src/TUnit.Core/Hooks/AfterAssemblyHookMethod.cs | 2 +- src/TUnit.Core/Hooks/AfterClassHookMethod.cs | 2 +- src/TUnit.Core/Hooks/AfterTestDiscoveryHookMethod.cs | 2 +- src/TUnit.Core/Hooks/AfterTestHookMethod.cs | 2 +- src/TUnit.Core/Hooks/AfterTestSessionHookMethod.cs | 2 +- src/TUnit.Core/Hooks/BeforeAssemblyHookMethod.cs | 2 +- src/TUnit.Core/Hooks/BeforeClassHookMethod.cs | 2 +- src/TUnit.Core/Hooks/BeforeTestDiscoveryHookMethod.cs | 2 +- src/TUnit.Core/Hooks/BeforeTestHookMethod.cs | 2 +- src/TUnit.Core/Hooks/BeforeTestSessionHookMethod.cs | 2 +- src/TUnit.Core/Hooks/InstanceHookMethod.cs | 4 ++++ src/TUnit.Core/Hooks/StaticHookMethod.cs | 7 +++++++ 12 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/TUnit.Core/Hooks/AfterAssemblyHookMethod.cs b/src/TUnit.Core/Hooks/AfterAssemblyHookMethod.cs index 33acb8c8735..6206ea52634 100644 --- a/src/TUnit.Core/Hooks/AfterAssemblyHookMethod.cs +++ b/src/TUnit.Core/Hooks/AfterAssemblyHookMethod.cs @@ -5,7 +5,7 @@ public record AfterAssemblyHookMethod : StaticHookMethod public override ValueTask ExecuteAsync(AssemblyHookContext context, CancellationToken cancellationToken) { return HookExecutor.ExecuteAfterAssemblyHook(MethodInfo, context, - () => HookBodyInvoker.InvokeAsync(Body!, context, cancellationToken) + () => InvokeBodyAsync(context, cancellationToken) ); } } diff --git a/src/TUnit.Core/Hooks/AfterClassHookMethod.cs b/src/TUnit.Core/Hooks/AfterClassHookMethod.cs index 93b2ddef3c3..5f5cd84c31f 100644 --- a/src/TUnit.Core/Hooks/AfterClassHookMethod.cs +++ b/src/TUnit.Core/Hooks/AfterClassHookMethod.cs @@ -5,7 +5,7 @@ public record AfterClassHookMethod : StaticHookMethod public override ValueTask ExecuteAsync(ClassHookContext context, CancellationToken cancellationToken) { return HookExecutor.ExecuteAfterClassHook(MethodInfo, context, - () => HookBodyInvoker.InvokeAsync(Body!, context, cancellationToken) + () => InvokeBodyAsync(context, cancellationToken) ); } } diff --git a/src/TUnit.Core/Hooks/AfterTestDiscoveryHookMethod.cs b/src/TUnit.Core/Hooks/AfterTestDiscoveryHookMethod.cs index fba6b71f5e8..45f08a480c2 100644 --- a/src/TUnit.Core/Hooks/AfterTestDiscoveryHookMethod.cs +++ b/src/TUnit.Core/Hooks/AfterTestDiscoveryHookMethod.cs @@ -5,7 +5,7 @@ public record AfterTestDiscoveryHookMethod : StaticHookMethod HookBodyInvoker.InvokeAsync(Body!, context, cancellationToken) + () => InvokeBodyAsync(context, cancellationToken) ); } } diff --git a/src/TUnit.Core/Hooks/AfterTestHookMethod.cs b/src/TUnit.Core/Hooks/AfterTestHookMethod.cs index dfe0d80b4c4..40bf3cb1b87 100644 --- a/src/TUnit.Core/Hooks/AfterTestHookMethod.cs +++ b/src/TUnit.Core/Hooks/AfterTestHookMethod.cs @@ -5,7 +5,7 @@ public record AfterTestHookMethod : StaticHookMethod public override ValueTask ExecuteAsync(TestContext context, CancellationToken cancellationToken) { return ResolveEffectiveExecutor(context).ExecuteAfterTestHook(MethodInfo, context, - () => HookBodyInvoker.InvokeAsync(Body!, context, cancellationToken) + () => InvokeBodyAsync(context, cancellationToken) ); } } diff --git a/src/TUnit.Core/Hooks/AfterTestSessionHookMethod.cs b/src/TUnit.Core/Hooks/AfterTestSessionHookMethod.cs index 0432f5216af..c3a9e1e3fe7 100644 --- a/src/TUnit.Core/Hooks/AfterTestSessionHookMethod.cs +++ b/src/TUnit.Core/Hooks/AfterTestSessionHookMethod.cs @@ -5,7 +5,7 @@ public record AfterTestSessionHookMethod : StaticHookMethod public override ValueTask ExecuteAsync(TestSessionContext context, CancellationToken cancellationToken) { return HookExecutor.ExecuteAfterTestSessionHook(MethodInfo, context, - () => HookBodyInvoker.InvokeAsync(Body!, context, cancellationToken) + () => InvokeBodyAsync(context, cancellationToken) ); } } diff --git a/src/TUnit.Core/Hooks/BeforeAssemblyHookMethod.cs b/src/TUnit.Core/Hooks/BeforeAssemblyHookMethod.cs index d1956033dc2..baa643027d1 100644 --- a/src/TUnit.Core/Hooks/BeforeAssemblyHookMethod.cs +++ b/src/TUnit.Core/Hooks/BeforeAssemblyHookMethod.cs @@ -5,7 +5,7 @@ public record BeforeAssemblyHookMethod : StaticHookMethod public override ValueTask ExecuteAsync(AssemblyHookContext context, CancellationToken cancellationToken) { return HookExecutor.ExecuteBeforeAssemblyHook(MethodInfo, context, - () => HookBodyInvoker.InvokeAsync(Body!, context, cancellationToken) + () => InvokeBodyAsync(context, cancellationToken) ); } } diff --git a/src/TUnit.Core/Hooks/BeforeClassHookMethod.cs b/src/TUnit.Core/Hooks/BeforeClassHookMethod.cs index b810485370e..c5852b44367 100644 --- a/src/TUnit.Core/Hooks/BeforeClassHookMethod.cs +++ b/src/TUnit.Core/Hooks/BeforeClassHookMethod.cs @@ -5,7 +5,7 @@ public record BeforeClassHookMethod : StaticHookMethod public override ValueTask ExecuteAsync(ClassHookContext context, CancellationToken cancellationToken) { return HookExecutor.ExecuteBeforeClassHook(MethodInfo, context, - () => HookBodyInvoker.InvokeAsync(Body!, context, cancellationToken) + () => InvokeBodyAsync(context, cancellationToken) ); } } diff --git a/src/TUnit.Core/Hooks/BeforeTestDiscoveryHookMethod.cs b/src/TUnit.Core/Hooks/BeforeTestDiscoveryHookMethod.cs index 8ff3a78fc49..98f6f4dbba3 100644 --- a/src/TUnit.Core/Hooks/BeforeTestDiscoveryHookMethod.cs +++ b/src/TUnit.Core/Hooks/BeforeTestDiscoveryHookMethod.cs @@ -5,7 +5,7 @@ public record BeforeTestDiscoveryHookMethod : StaticHookMethod HookBodyInvoker.InvokeAsync(Body!, context, cancellationToken) + () => InvokeBodyAsync(context, cancellationToken) ); } } diff --git a/src/TUnit.Core/Hooks/BeforeTestHookMethod.cs b/src/TUnit.Core/Hooks/BeforeTestHookMethod.cs index 6edb600df74..4228e0ece06 100644 --- a/src/TUnit.Core/Hooks/BeforeTestHookMethod.cs +++ b/src/TUnit.Core/Hooks/BeforeTestHookMethod.cs @@ -5,7 +5,7 @@ public record BeforeTestHookMethod : StaticHookMethod public override ValueTask ExecuteAsync(TestContext context, CancellationToken cancellationToken) { return ResolveEffectiveExecutor(context).ExecuteBeforeTestHook(MethodInfo, context, - () => HookBodyInvoker.InvokeAsync(Body!, context, cancellationToken) + () => InvokeBodyAsync(context, cancellationToken) ); } } diff --git a/src/TUnit.Core/Hooks/BeforeTestSessionHookMethod.cs b/src/TUnit.Core/Hooks/BeforeTestSessionHookMethod.cs index 7c5f74e9f9a..e4c5d24433e 100644 --- a/src/TUnit.Core/Hooks/BeforeTestSessionHookMethod.cs +++ b/src/TUnit.Core/Hooks/BeforeTestSessionHookMethod.cs @@ -5,7 +5,7 @@ public record BeforeTestSessionHookMethod : StaticHookMethod public override ValueTask ExecuteAsync(TestSessionContext context, CancellationToken cancellationToken) { return HookExecutor.ExecuteBeforeTestSessionHook(MethodInfo, context, - () => HookBodyInvoker.InvokeAsync(Body!, context, cancellationToken) + () => InvokeBodyAsync(context, cancellationToken) ); } } diff --git a/src/TUnit.Core/Hooks/InstanceHookMethod.cs b/src/TUnit.Core/Hooks/InstanceHookMethod.cs index ff19d239a15..121378e2da0 100644 --- a/src/TUnit.Core/Hooks/InstanceHookMethod.cs +++ b/src/TUnit.Core/Hooks/InstanceHookMethod.cs @@ -19,6 +19,10 @@ public required Type InitClassType init { _classType = value; } } + /// + /// The hook body. Source-generated bodies call the hook method directly, without an async state machine, + /// so invoke it only through to keep async-method semantics. + /// public Func? Body { get; init; } public ValueTask ExecuteAsync(TestContext context, CancellationToken cancellationToken) diff --git a/src/TUnit.Core/Hooks/StaticHookMethod.cs b/src/TUnit.Core/Hooks/StaticHookMethod.cs index c96614919ec..548865e3c65 100644 --- a/src/TUnit.Core/Hooks/StaticHookMethod.cs +++ b/src/TUnit.Core/Hooks/StaticHookMethod.cs @@ -7,8 +7,15 @@ namespace TUnit.Core.Hooks; #endif public abstract record StaticHookMethod : StaticHookMethod, IExecutableHook { + /// + /// The hook body. Source-generated bodies call the hook method directly, without an async state machine, + /// so invoke it only through to keep async-method semantics. + /// public Func? Body { get; init; } public abstract ValueTask ExecuteAsync(T context, CancellationToken cancellationToken); + + internal ValueTask InvokeBodyAsync(T context, CancellationToken cancellationToken) + => HookBodyInvoker.InvokeAsync(Body!, context, cancellationToken); } #if !DEBUG