From 17bb06ba41ffc4d9948c713a3a09b7fd8d8829b4 Mon Sep 17 00:00:00 2001 From: Tom Longhurst <30480171+thomhurst@users.noreply.github.com> Date: Sat, 31 Jan 2026 21:13:48 +0000 Subject: [PATCH 01/11] fix: force synchronous library module initializer completion Fixes timing issue where hooks were collected before library module initializers completed, resulting in 0 hooks found. **Problem:** Module initializers from different assemblies run asynchronously. When test assembly's module initializer referenced library types via typeof(), the library loaded but its module initializer was queued, not executed synchronously. HookDelegateBuilder.InitializeAsync() then ran before library hooks were registered to Sources.* collections. **Solution:** Use RuntimeHelpers.RunClassConstructor(type.TypeHandle) to force library module initializers to complete synchronously. Static constructors can only run AFTER module initializers, so this blocks until initialization finishes. AOT-compatible (uses statically-known types). **Changes:** - InfrastructureGenerator: Replace typeof() with RunClassConstructor() - Add logging for assembly initialization completion - Update documentation explaining the fix - Enhance Claude Code Review workflow to always comment and suggest architectural improvements **Snapshot Tests:** Updated verified snapshots for fully qualified type names in generated code. --- .github/workflows/claude-code-review.yml | 14 +- ...assDataSourceDrivenTests.Test.verified.txt | 112 +- ...ceDrivenTestsSharedKeyed.Test.verified.txt | 22 +- ...thConflictingNamespace.Net4_7.verified.txt | 294 +++ ...thConflictingNamespace.Net4_7.verified.txt | 1221 ++++++++++++ ...thConflictingNamespace.Net4_7.verified.txt | 1044 +++++++++++ ...thConflictingNamespace.Net4_7.verified.txt | 1650 +++++++++++++++++ ...thConflictingNamespace.Net4_7.verified.txt | 986 ++++++++++ ...thConflictingNamespace.Net4_7.verified.txt | 142 ++ .../Tests1889.Test.Net4_7.verified.txt | 4 +- .../CodeGenerators/InfrastructureGenerator.cs | 17 +- 11 files changed, 5434 insertions(+), 72 deletions(-) create mode 100644 TUnit.Core.SourceGenerator.Tests/ConflictingNamespaceTests.BasicTest_WithConflictingNamespace.Net4_7.verified.txt create mode 100644 TUnit.Core.SourceGenerator.Tests/ConflictingNamespaceTests.DataDrivenTest_WithConflictingNamespace.Net4_7.verified.txt create mode 100644 TUnit.Core.SourceGenerator.Tests/ConflictingNamespaceTests.HooksTest_WithConflictingNamespace.Net4_7.verified.txt create mode 100644 TUnit.Core.SourceGenerator.Tests/ConflictingNamespaceTests.MatrixTest_WithConflictingNamespace.Net4_7.verified.txt create mode 100644 TUnit.Core.SourceGenerator.Tests/ConflictingNamespaceTests.MethodDataSource_WithConflictingNamespace.Net4_7.verified.txt create mode 100644 TUnit.Core.SourceGenerator.Tests/ConflictingNamespaceTests.TupleDataSource_WithConflictingNamespace.Net4_7.verified.txt diff --git a/.github/workflows/claude-code-review.yml b/.github/workflows/claude-code-review.yml index bb4626ae8f..08c3339bda 100644 --- a/.github/workflows/claude-code-review.yml +++ b/.github/workflows/claude-code-review.yml @@ -46,7 +46,19 @@ jobs: claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} plugin_marketplaces: 'https://github.com/anthropics/claude-code.git' plugins: 'code-review@claude-code-plugins' - prompt: '/code-review:code-review ${{ github.repository }}/pull/${{ github.event.pull_request.number || inputs.pr_number }}' + prompt: | + /code-review:code-review ${{ github.repository }}/pull/${{ github.event.pull_request.number || inputs.pr_number }} + + Additional instructions: + - ALWAYS post a review comment, even if no issues are found. If the code is good, acknowledge it. + - When you find issues, ALWAYS suggest better approaches or architectural improvements, not just minor optimizations. + - Focus on: + * Design patterns that could be improved + * Alternative approaches that are more maintainable or scalable + * Architectural concerns or anti-patterns + * Better abstractions or simplifications + - Skip minor style/formatting issues unless they impact readability significantly. + - Always explain WHY the suggested approach is better, not just WHAT to change. # See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md # or https://code.claude.com/docs/en/cli-reference for available options diff --git a/TUnit.Core.SourceGenerator.Tests/ClassDataSourceDrivenTests.Test.verified.txt b/TUnit.Core.SourceGenerator.Tests/ClassDataSourceDrivenTests.Test.verified.txt index d4fdf1ef5e..564386e065 100644 --- a/TUnit.Core.SourceGenerator.Tests/ClassDataSourceDrivenTests.Test.verified.txt +++ b/TUnit.Core.SourceGenerator.Tests/ClassDataSourceDrivenTests.Test.verified.txt @@ -1,4 +1,4 @@ -// +// #pragma warning disable #nullable enable @@ -262,7 +262,7 @@ internal sealed class TUnit_TestProject_ClassDataSourceDrivenTests_IsInitialized ], DataSources = new global::TUnit.Core.IDataSourceAttribute[] { - new global::TUnit.Core.ClassDataSourceAttribute(), + new global::TUnit.Core.ClassDataSourceAttribute(), }, ClassDataSources = global::System.Array.Empty(), PropertyDataSources = global::System.Array.Empty(), @@ -280,12 +280,12 @@ internal sealed class TUnit_TestProject_ClassDataSourceDrivenTests_IsInitialized ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), Parameters = new global::TUnit.Core.ParameterMetadata[] { - new global::TUnit.Core.ParameterMetadata(typeof(InitializableClass)) + new global::TUnit.Core.ParameterMetadata(typeof(global::TUnit.TestProject.Library.Models.InitializableClass)) { Name = "class1", - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(InitializableClass)), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.Library.Models.InitializableClass)), IsNullable = false, - ReflectionInfo = typeof(global::TUnit.TestProject.ClassDataSourceDrivenTests).GetMethod("IsInitialized_With_1_ClassDataSource", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(InitializableClass) }, null)!.GetParameters()[0] + ReflectionInfo = typeof(global::TUnit.TestProject.ClassDataSourceDrivenTests).GetMethod("IsInitialized_With_1_ClassDataSource", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(global::TUnit.TestProject.Library.Models.InitializableClass) }, null)!.GetParameters()[0] } }, Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.ClassDataSourceDrivenTests", static () => @@ -313,7 +313,7 @@ internal sealed class TUnit_TestProject_ClassDataSourceDrivenTests_IsInitialized { case 1: { - return new global::System.Threading.Tasks.ValueTask(instance.IsInitialized_With_1_ClassDataSource(global::TUnit.Core.Helpers.CastHelper.Cast(args[0]))); + return new global::System.Threading.Tasks.ValueTask(instance.IsInitialized_With_1_ClassDataSource(global::TUnit.Core.Helpers.CastHelper.Cast(args[0]))); } default: throw new global::System.ArgumentException($"Expected exactly 1 argument, but got {args.Length}"); @@ -382,7 +382,7 @@ internal sealed class TUnit_TestProject_ClassDataSourceDrivenTests_IsInitialized ], DataSources = new global::TUnit.Core.IDataSourceAttribute[] { - new global::TUnit.Core.ClassDataSourceAttribute(), + new global::TUnit.Core.ClassDataSourceAttribute(), }, ClassDataSources = global::System.Array.Empty(), PropertyDataSources = global::System.Array.Empty(), @@ -400,19 +400,19 @@ internal sealed class TUnit_TestProject_ClassDataSourceDrivenTests_IsInitialized ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), Parameters = new global::TUnit.Core.ParameterMetadata[] { - new global::TUnit.Core.ParameterMetadata(typeof(InitializableClass)) + new global::TUnit.Core.ParameterMetadata(typeof(global::TUnit.TestProject.Library.Models.InitializableClass)) { Name = "class1", - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(InitializableClass)), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.Library.Models.InitializableClass)), IsNullable = false, - ReflectionInfo = typeof(global::TUnit.TestProject.ClassDataSourceDrivenTests).GetMethod("IsInitialized_With_2_ClassDataSources", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(InitializableClass), typeof(InitializableClass) }, null)!.GetParameters()[0] + ReflectionInfo = typeof(global::TUnit.TestProject.ClassDataSourceDrivenTests).GetMethod("IsInitialized_With_2_ClassDataSources", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(global::TUnit.TestProject.Library.Models.InitializableClass), typeof(global::TUnit.TestProject.Library.Models.InitializableClass) }, null)!.GetParameters()[0] }, - new global::TUnit.Core.ParameterMetadata(typeof(InitializableClass)) + new global::TUnit.Core.ParameterMetadata(typeof(global::TUnit.TestProject.Library.Models.InitializableClass)) { Name = "class2", - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(InitializableClass)), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.Library.Models.InitializableClass)), IsNullable = false, - ReflectionInfo = typeof(global::TUnit.TestProject.ClassDataSourceDrivenTests).GetMethod("IsInitialized_With_2_ClassDataSources", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(InitializableClass), typeof(InitializableClass) }, null)!.GetParameters()[1] + ReflectionInfo = typeof(global::TUnit.TestProject.ClassDataSourceDrivenTests).GetMethod("IsInitialized_With_2_ClassDataSources", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(global::TUnit.TestProject.Library.Models.InitializableClass), typeof(global::TUnit.TestProject.Library.Models.InitializableClass) }, null)!.GetParameters()[1] } }, Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.ClassDataSourceDrivenTests", static () => @@ -440,7 +440,7 @@ internal sealed class TUnit_TestProject_ClassDataSourceDrivenTests_IsInitialized { case 2: { - return new global::System.Threading.Tasks.ValueTask(instance.IsInitialized_With_2_ClassDataSources(global::TUnit.Core.Helpers.CastHelper.Cast(args[0]), global::TUnit.Core.Helpers.CastHelper.Cast(args[1]))); + return new global::System.Threading.Tasks.ValueTask(instance.IsInitialized_With_2_ClassDataSources(global::TUnit.Core.Helpers.CastHelper.Cast(args[0]), global::TUnit.Core.Helpers.CastHelper.Cast(args[1]))); } default: throw new global::System.ArgumentException($"Expected exactly 2 arguments, but got {args.Length}"); @@ -509,7 +509,7 @@ internal sealed class TUnit_TestProject_ClassDataSourceDrivenTests_IsInitialized ], DataSources = new global::TUnit.Core.IDataSourceAttribute[] { - new global::TUnit.Core.ClassDataSourceAttribute(), + new global::TUnit.Core.ClassDataSourceAttribute(), }, ClassDataSources = global::System.Array.Empty(), PropertyDataSources = global::System.Array.Empty(), @@ -527,26 +527,26 @@ internal sealed class TUnit_TestProject_ClassDataSourceDrivenTests_IsInitialized ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), Parameters = new global::TUnit.Core.ParameterMetadata[] { - new global::TUnit.Core.ParameterMetadata(typeof(InitializableClass)) + new global::TUnit.Core.ParameterMetadata(typeof(global::TUnit.TestProject.Library.Models.InitializableClass)) { Name = "class1", - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(InitializableClass)), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.Library.Models.InitializableClass)), IsNullable = false, - ReflectionInfo = typeof(global::TUnit.TestProject.ClassDataSourceDrivenTests).GetMethod("IsInitialized_With_3_ClassDataSources", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(InitializableClass), typeof(InitializableClass), typeof(InitializableClass) }, null)!.GetParameters()[0] + ReflectionInfo = typeof(global::TUnit.TestProject.ClassDataSourceDrivenTests).GetMethod("IsInitialized_With_3_ClassDataSources", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(global::TUnit.TestProject.Library.Models.InitializableClass), typeof(global::TUnit.TestProject.Library.Models.InitializableClass), typeof(global::TUnit.TestProject.Library.Models.InitializableClass) }, null)!.GetParameters()[0] }, - new global::TUnit.Core.ParameterMetadata(typeof(InitializableClass)) + new global::TUnit.Core.ParameterMetadata(typeof(global::TUnit.TestProject.Library.Models.InitializableClass)) { Name = "class2", - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(InitializableClass)), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.Library.Models.InitializableClass)), IsNullable = false, - ReflectionInfo = typeof(global::TUnit.TestProject.ClassDataSourceDrivenTests).GetMethod("IsInitialized_With_3_ClassDataSources", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(InitializableClass), typeof(InitializableClass), typeof(InitializableClass) }, null)!.GetParameters()[1] + ReflectionInfo = typeof(global::TUnit.TestProject.ClassDataSourceDrivenTests).GetMethod("IsInitialized_With_3_ClassDataSources", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(global::TUnit.TestProject.Library.Models.InitializableClass), typeof(global::TUnit.TestProject.Library.Models.InitializableClass), typeof(global::TUnit.TestProject.Library.Models.InitializableClass) }, null)!.GetParameters()[1] }, - new global::TUnit.Core.ParameterMetadata(typeof(InitializableClass)) + new global::TUnit.Core.ParameterMetadata(typeof(global::TUnit.TestProject.Library.Models.InitializableClass)) { Name = "class3", - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(InitializableClass)), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.Library.Models.InitializableClass)), IsNullable = false, - ReflectionInfo = typeof(global::TUnit.TestProject.ClassDataSourceDrivenTests).GetMethod("IsInitialized_With_3_ClassDataSources", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(InitializableClass), typeof(InitializableClass), typeof(InitializableClass) }, null)!.GetParameters()[2] + ReflectionInfo = typeof(global::TUnit.TestProject.ClassDataSourceDrivenTests).GetMethod("IsInitialized_With_3_ClassDataSources", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(global::TUnit.TestProject.Library.Models.InitializableClass), typeof(global::TUnit.TestProject.Library.Models.InitializableClass), typeof(global::TUnit.TestProject.Library.Models.InitializableClass) }, null)!.GetParameters()[2] } }, Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.ClassDataSourceDrivenTests", static () => @@ -574,7 +574,7 @@ internal sealed class TUnit_TestProject_ClassDataSourceDrivenTests_IsInitialized { case 3: { - return new global::System.Threading.Tasks.ValueTask(instance.IsInitialized_With_3_ClassDataSources(global::TUnit.Core.Helpers.CastHelper.Cast(args[0]), global::TUnit.Core.Helpers.CastHelper.Cast(args[1]), global::TUnit.Core.Helpers.CastHelper.Cast(args[2]))); + return new global::System.Threading.Tasks.ValueTask(instance.IsInitialized_With_3_ClassDataSources(global::TUnit.Core.Helpers.CastHelper.Cast(args[0]), global::TUnit.Core.Helpers.CastHelper.Cast(args[1]), global::TUnit.Core.Helpers.CastHelper.Cast(args[2]))); } default: throw new global::System.ArgumentException($"Expected exactly 3 arguments, but got {args.Length}"); @@ -643,7 +643,7 @@ internal sealed class TUnit_TestProject_ClassDataSourceDrivenTests_IsInitialized ], DataSources = new global::TUnit.Core.IDataSourceAttribute[] { - new global::TUnit.Core.ClassDataSourceAttribute(), + new global::TUnit.Core.ClassDataSourceAttribute(), }, ClassDataSources = global::System.Array.Empty(), PropertyDataSources = global::System.Array.Empty(), @@ -661,33 +661,33 @@ internal sealed class TUnit_TestProject_ClassDataSourceDrivenTests_IsInitialized ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), Parameters = new global::TUnit.Core.ParameterMetadata[] { - new global::TUnit.Core.ParameterMetadata(typeof(InitializableClass)) + new global::TUnit.Core.ParameterMetadata(typeof(global::TUnit.TestProject.Library.Models.InitializableClass)) { Name = "class1", - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(InitializableClass)), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.Library.Models.InitializableClass)), IsNullable = false, - ReflectionInfo = typeof(global::TUnit.TestProject.ClassDataSourceDrivenTests).GetMethod("IsInitialized_With_4_ClassDataSources", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(InitializableClass), typeof(InitializableClass), typeof(InitializableClass), typeof(InitializableClass) }, null)!.GetParameters()[0] + ReflectionInfo = typeof(global::TUnit.TestProject.ClassDataSourceDrivenTests).GetMethod("IsInitialized_With_4_ClassDataSources", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(global::TUnit.TestProject.Library.Models.InitializableClass), typeof(global::TUnit.TestProject.Library.Models.InitializableClass), typeof(global::TUnit.TestProject.Library.Models.InitializableClass), typeof(global::TUnit.TestProject.Library.Models.InitializableClass) }, null)!.GetParameters()[0] }, - new global::TUnit.Core.ParameterMetadata(typeof(InitializableClass)) + new global::TUnit.Core.ParameterMetadata(typeof(global::TUnit.TestProject.Library.Models.InitializableClass)) { Name = "class2", - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(InitializableClass)), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.Library.Models.InitializableClass)), IsNullable = false, - ReflectionInfo = typeof(global::TUnit.TestProject.ClassDataSourceDrivenTests).GetMethod("IsInitialized_With_4_ClassDataSources", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(InitializableClass), typeof(InitializableClass), typeof(InitializableClass), typeof(InitializableClass) }, null)!.GetParameters()[1] + ReflectionInfo = typeof(global::TUnit.TestProject.ClassDataSourceDrivenTests).GetMethod("IsInitialized_With_4_ClassDataSources", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(global::TUnit.TestProject.Library.Models.InitializableClass), typeof(global::TUnit.TestProject.Library.Models.InitializableClass), typeof(global::TUnit.TestProject.Library.Models.InitializableClass), typeof(global::TUnit.TestProject.Library.Models.InitializableClass) }, null)!.GetParameters()[1] }, - new global::TUnit.Core.ParameterMetadata(typeof(InitializableClass)) + new global::TUnit.Core.ParameterMetadata(typeof(global::TUnit.TestProject.Library.Models.InitializableClass)) { Name = "class3", - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(InitializableClass)), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.Library.Models.InitializableClass)), IsNullable = false, - ReflectionInfo = typeof(global::TUnit.TestProject.ClassDataSourceDrivenTests).GetMethod("IsInitialized_With_4_ClassDataSources", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(InitializableClass), typeof(InitializableClass), typeof(InitializableClass), typeof(InitializableClass) }, null)!.GetParameters()[2] + ReflectionInfo = typeof(global::TUnit.TestProject.ClassDataSourceDrivenTests).GetMethod("IsInitialized_With_4_ClassDataSources", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(global::TUnit.TestProject.Library.Models.InitializableClass), typeof(global::TUnit.TestProject.Library.Models.InitializableClass), typeof(global::TUnit.TestProject.Library.Models.InitializableClass), typeof(global::TUnit.TestProject.Library.Models.InitializableClass) }, null)!.GetParameters()[2] }, - new global::TUnit.Core.ParameterMetadata(typeof(InitializableClass)) + new global::TUnit.Core.ParameterMetadata(typeof(global::TUnit.TestProject.Library.Models.InitializableClass)) { Name = "class4", - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(InitializableClass)), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.Library.Models.InitializableClass)), IsNullable = false, - ReflectionInfo = typeof(global::TUnit.TestProject.ClassDataSourceDrivenTests).GetMethod("IsInitialized_With_4_ClassDataSources", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(InitializableClass), typeof(InitializableClass), typeof(InitializableClass), typeof(InitializableClass) }, null)!.GetParameters()[3] + ReflectionInfo = typeof(global::TUnit.TestProject.ClassDataSourceDrivenTests).GetMethod("IsInitialized_With_4_ClassDataSources", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(global::TUnit.TestProject.Library.Models.InitializableClass), typeof(global::TUnit.TestProject.Library.Models.InitializableClass), typeof(global::TUnit.TestProject.Library.Models.InitializableClass), typeof(global::TUnit.TestProject.Library.Models.InitializableClass) }, null)!.GetParameters()[3] } }, Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.ClassDataSourceDrivenTests", static () => @@ -715,7 +715,7 @@ internal sealed class TUnit_TestProject_ClassDataSourceDrivenTests_IsInitialized { case 4: { - return new global::System.Threading.Tasks.ValueTask(instance.IsInitialized_With_4_ClassDataSources(global::TUnit.Core.Helpers.CastHelper.Cast(args[0]), global::TUnit.Core.Helpers.CastHelper.Cast(args[1]), global::TUnit.Core.Helpers.CastHelper.Cast(args[2]), global::TUnit.Core.Helpers.CastHelper.Cast(args[3]))); + return new global::System.Threading.Tasks.ValueTask(instance.IsInitialized_With_4_ClassDataSources(global::TUnit.Core.Helpers.CastHelper.Cast(args[0]), global::TUnit.Core.Helpers.CastHelper.Cast(args[1]), global::TUnit.Core.Helpers.CastHelper.Cast(args[2]), global::TUnit.Core.Helpers.CastHelper.Cast(args[3]))); } default: throw new global::System.ArgumentException($"Expected exactly 4 arguments, but got {args.Length}"); @@ -784,7 +784,7 @@ internal sealed class TUnit_TestProject_ClassDataSourceDrivenTests_IsInitialized ], DataSources = new global::TUnit.Core.IDataSourceAttribute[] { - new global::TUnit.Core.ClassDataSourceAttribute(), + new global::TUnit.Core.ClassDataSourceAttribute(), }, ClassDataSources = global::System.Array.Empty(), PropertyDataSources = global::System.Array.Empty(), @@ -802,40 +802,40 @@ internal sealed class TUnit_TestProject_ClassDataSourceDrivenTests_IsInitialized ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.Task)), Parameters = new global::TUnit.Core.ParameterMetadata[] { - new global::TUnit.Core.ParameterMetadata(typeof(InitializableClass)) + new global::TUnit.Core.ParameterMetadata(typeof(global::TUnit.TestProject.Library.Models.InitializableClass)) { Name = "class1", - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(InitializableClass)), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.Library.Models.InitializableClass)), IsNullable = false, - ReflectionInfo = typeof(global::TUnit.TestProject.ClassDataSourceDrivenTests).GetMethod("IsInitialized_With_5_ClassDataSources", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(InitializableClass), typeof(InitializableClass), typeof(InitializableClass), typeof(InitializableClass), typeof(InitializableClass) }, null)!.GetParameters()[0] + ReflectionInfo = typeof(global::TUnit.TestProject.ClassDataSourceDrivenTests).GetMethod("IsInitialized_With_5_ClassDataSources", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(global::TUnit.TestProject.Library.Models.InitializableClass), typeof(global::TUnit.TestProject.Library.Models.InitializableClass), typeof(global::TUnit.TestProject.Library.Models.InitializableClass), typeof(global::TUnit.TestProject.Library.Models.InitializableClass), typeof(global::TUnit.TestProject.Library.Models.InitializableClass) }, null)!.GetParameters()[0] }, - new global::TUnit.Core.ParameterMetadata(typeof(InitializableClass)) + new global::TUnit.Core.ParameterMetadata(typeof(global::TUnit.TestProject.Library.Models.InitializableClass)) { Name = "class2", - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(InitializableClass)), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.Library.Models.InitializableClass)), IsNullable = false, - ReflectionInfo = typeof(global::TUnit.TestProject.ClassDataSourceDrivenTests).GetMethod("IsInitialized_With_5_ClassDataSources", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(InitializableClass), typeof(InitializableClass), typeof(InitializableClass), typeof(InitializableClass), typeof(InitializableClass) }, null)!.GetParameters()[1] + ReflectionInfo = typeof(global::TUnit.TestProject.ClassDataSourceDrivenTests).GetMethod("IsInitialized_With_5_ClassDataSources", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(global::TUnit.TestProject.Library.Models.InitializableClass), typeof(global::TUnit.TestProject.Library.Models.InitializableClass), typeof(global::TUnit.TestProject.Library.Models.InitializableClass), typeof(global::TUnit.TestProject.Library.Models.InitializableClass), typeof(global::TUnit.TestProject.Library.Models.InitializableClass) }, null)!.GetParameters()[1] }, - new global::TUnit.Core.ParameterMetadata(typeof(InitializableClass)) + new global::TUnit.Core.ParameterMetadata(typeof(global::TUnit.TestProject.Library.Models.InitializableClass)) { Name = "class3", - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(InitializableClass)), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.Library.Models.InitializableClass)), IsNullable = false, - ReflectionInfo = typeof(global::TUnit.TestProject.ClassDataSourceDrivenTests).GetMethod("IsInitialized_With_5_ClassDataSources", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(InitializableClass), typeof(InitializableClass), typeof(InitializableClass), typeof(InitializableClass), typeof(InitializableClass) }, null)!.GetParameters()[2] + ReflectionInfo = typeof(global::TUnit.TestProject.ClassDataSourceDrivenTests).GetMethod("IsInitialized_With_5_ClassDataSources", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(global::TUnit.TestProject.Library.Models.InitializableClass), typeof(global::TUnit.TestProject.Library.Models.InitializableClass), typeof(global::TUnit.TestProject.Library.Models.InitializableClass), typeof(global::TUnit.TestProject.Library.Models.InitializableClass), typeof(global::TUnit.TestProject.Library.Models.InitializableClass) }, null)!.GetParameters()[2] }, - new global::TUnit.Core.ParameterMetadata(typeof(InitializableClass)) + new global::TUnit.Core.ParameterMetadata(typeof(global::TUnit.TestProject.Library.Models.InitializableClass)) { Name = "class4", - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(InitializableClass)), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.Library.Models.InitializableClass)), IsNullable = false, - ReflectionInfo = typeof(global::TUnit.TestProject.ClassDataSourceDrivenTests).GetMethod("IsInitialized_With_5_ClassDataSources", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(InitializableClass), typeof(InitializableClass), typeof(InitializableClass), typeof(InitializableClass), typeof(InitializableClass) }, null)!.GetParameters()[3] + ReflectionInfo = typeof(global::TUnit.TestProject.ClassDataSourceDrivenTests).GetMethod("IsInitialized_With_5_ClassDataSources", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(global::TUnit.TestProject.Library.Models.InitializableClass), typeof(global::TUnit.TestProject.Library.Models.InitializableClass), typeof(global::TUnit.TestProject.Library.Models.InitializableClass), typeof(global::TUnit.TestProject.Library.Models.InitializableClass), typeof(global::TUnit.TestProject.Library.Models.InitializableClass) }, null)!.GetParameters()[3] }, - new global::TUnit.Core.ParameterMetadata(typeof(InitializableClass)) + new global::TUnit.Core.ParameterMetadata(typeof(global::TUnit.TestProject.Library.Models.InitializableClass)) { Name = "class5", - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(InitializableClass)), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.Library.Models.InitializableClass)), IsNullable = false, - ReflectionInfo = typeof(global::TUnit.TestProject.ClassDataSourceDrivenTests).GetMethod("IsInitialized_With_5_ClassDataSources", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(InitializableClass), typeof(InitializableClass), typeof(InitializableClass), typeof(InitializableClass), typeof(InitializableClass) }, null)!.GetParameters()[4] + ReflectionInfo = typeof(global::TUnit.TestProject.ClassDataSourceDrivenTests).GetMethod("IsInitialized_With_5_ClassDataSources", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(global::TUnit.TestProject.Library.Models.InitializableClass), typeof(global::TUnit.TestProject.Library.Models.InitializableClass), typeof(global::TUnit.TestProject.Library.Models.InitializableClass), typeof(global::TUnit.TestProject.Library.Models.InitializableClass), typeof(global::TUnit.TestProject.Library.Models.InitializableClass) }, null)!.GetParameters()[4] } }, Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.ClassDataSourceDrivenTests", static () => @@ -863,7 +863,7 @@ internal sealed class TUnit_TestProject_ClassDataSourceDrivenTests_IsInitialized { case 5: { - return new global::System.Threading.Tasks.ValueTask(instance.IsInitialized_With_5_ClassDataSources(global::TUnit.Core.Helpers.CastHelper.Cast(args[0]), global::TUnit.Core.Helpers.CastHelper.Cast(args[1]), global::TUnit.Core.Helpers.CastHelper.Cast(args[2]), global::TUnit.Core.Helpers.CastHelper.Cast(args[3]), global::TUnit.Core.Helpers.CastHelper.Cast(args[4]))); + return new global::System.Threading.Tasks.ValueTask(instance.IsInitialized_With_5_ClassDataSources(global::TUnit.Core.Helpers.CastHelper.Cast(args[0]), global::TUnit.Core.Helpers.CastHelper.Cast(args[1]), global::TUnit.Core.Helpers.CastHelper.Cast(args[2]), global::TUnit.Core.Helpers.CastHelper.Cast(args[3]), global::TUnit.Core.Helpers.CastHelper.Cast(args[4]))); } default: throw new global::System.ArgumentException($"Expected exactly 5 arguments, but got {args.Length}"); diff --git a/TUnit.Core.SourceGenerator.Tests/ClassDataSourceDrivenTestsSharedKeyed.Test.verified.txt b/TUnit.Core.SourceGenerator.Tests/ClassDataSourceDrivenTestsSharedKeyed.Test.verified.txt index 4a6184deae..af49d2c290 100644 --- a/TUnit.Core.SourceGenerator.Tests/ClassDataSourceDrivenTestsSharedKeyed.Test.verified.txt +++ b/TUnit.Core.SourceGenerator.Tests/ClassDataSourceDrivenTestsSharedKeyed.Test.verified.txt @@ -1,4 +1,4 @@ -// +// #pragma warning disable #nullable enable @@ -20,7 +20,7 @@ internal sealed class TUnit_TestProject_ClassDataSourceDrivenTestsSharedKeyed_Da ], DataSources = new global::TUnit.Core.IDataSourceAttribute[] { - new global::TUnit.Core.ClassDataSourceAttribute() + new global::TUnit.Core.ClassDataSourceAttribute() {Shared = global::TUnit.Core.SharedType.Keyed,Key = "🔑",}, }, ClassDataSources = global::System.Array.Empty(), @@ -39,12 +39,12 @@ internal sealed class TUnit_TestProject_ClassDataSourceDrivenTestsSharedKeyed_Da ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(void)), Parameters = new global::TUnit.Core.ParameterMetadata[] { - new global::TUnit.Core.ParameterMetadata(typeof(SomeAsyncDisposableClass)) + new global::TUnit.Core.ParameterMetadata(typeof(global::TUnit.TestProject.Library.Models.SomeAsyncDisposableClass)) { Name = "value", - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(SomeAsyncDisposableClass)), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.Library.Models.SomeAsyncDisposableClass)), IsNullable = false, - ReflectionInfo = typeof(global::TUnit.TestProject.ClassDataSourceDrivenTestsSharedKeyed).GetMethod("DataSource_Class", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(SomeAsyncDisposableClass) }, null)!.GetParameters()[0] + ReflectionInfo = typeof(global::TUnit.TestProject.ClassDataSourceDrivenTestsSharedKeyed).GetMethod("DataSource_Class", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(global::TUnit.TestProject.Library.Models.SomeAsyncDisposableClass) }, null)!.GetParameters()[0] } }, Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.ClassDataSourceDrivenTestsSharedKeyed", static () => @@ -72,7 +72,7 @@ internal sealed class TUnit_TestProject_ClassDataSourceDrivenTestsSharedKeyed_Da { case 1: { - instance.DataSource_Class(global::TUnit.Core.Helpers.CastHelper.Cast(args[0])); + instance.DataSource_Class(global::TUnit.Core.Helpers.CastHelper.Cast(args[0])); return default(global::System.Threading.Tasks.ValueTask); } default: @@ -142,7 +142,7 @@ internal sealed class TUnit_TestProject_ClassDataSourceDrivenTestsSharedKeyed_Da ], DataSources = new global::TUnit.Core.IDataSourceAttribute[] { - new global::TUnit.Core.ClassDataSourceAttribute() + new global::TUnit.Core.ClassDataSourceAttribute() {Shared = global::TUnit.Core.SharedType.Keyed,Key = "🔑",}, }, ClassDataSources = global::System.Array.Empty(), @@ -161,12 +161,12 @@ internal sealed class TUnit_TestProject_ClassDataSourceDrivenTestsSharedKeyed_Da ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(void)), Parameters = new global::TUnit.Core.ParameterMetadata[] { - new global::TUnit.Core.ParameterMetadata(typeof(SomeAsyncDisposableClass)) + new global::TUnit.Core.ParameterMetadata(typeof(global::TUnit.TestProject.Library.Models.SomeAsyncDisposableClass)) { Name = "value", - TypeInfo = new global::TUnit.Core.ConcreteType(typeof(SomeAsyncDisposableClass)), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.Library.Models.SomeAsyncDisposableClass)), IsNullable = false, - ReflectionInfo = typeof(global::TUnit.TestProject.ClassDataSourceDrivenTestsSharedKeyed).GetMethod("DataSource_Class_Generic", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(SomeAsyncDisposableClass) }, null)!.GetParameters()[0] + ReflectionInfo = typeof(global::TUnit.TestProject.ClassDataSourceDrivenTestsSharedKeyed).GetMethod("DataSource_Class_Generic", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(global::TUnit.TestProject.Library.Models.SomeAsyncDisposableClass) }, null)!.GetParameters()[0] } }, Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.ClassDataSourceDrivenTestsSharedKeyed", static () => @@ -194,7 +194,7 @@ internal sealed class TUnit_TestProject_ClassDataSourceDrivenTestsSharedKeyed_Da { case 1: { - instance.DataSource_Class_Generic(global::TUnit.Core.Helpers.CastHelper.Cast(args[0])); + instance.DataSource_Class_Generic(global::TUnit.Core.Helpers.CastHelper.Cast(args[0])); return default(global::System.Threading.Tasks.ValueTask); } default: diff --git a/TUnit.Core.SourceGenerator.Tests/ConflictingNamespaceTests.BasicTest_WithConflictingNamespace.Net4_7.verified.txt b/TUnit.Core.SourceGenerator.Tests/ConflictingNamespaceTests.BasicTest_WithConflictingNamespace.Net4_7.verified.txt new file mode 100644 index 0000000000..3d1d68ebf1 --- /dev/null +++ b/TUnit.Core.SourceGenerator.Tests/ConflictingNamespaceTests.BasicTest_WithConflictingNamespace.Net4_7.verified.txt @@ -0,0 +1,294 @@ +// +#pragma warning disable + +#nullable enable +namespace TUnit.Generated; +internal sealed class TUnit_TestProject_BasicTests_SynchronousTest_TestSource : global::TUnit.Core.Interfaces.SourceGenerator.ITestSource, global::TUnit.Core.Interfaces.SourceGenerator.ITestDescriptorSource +{ + public async global::System.Collections.Generic.IAsyncEnumerable GetTestsAsync(string testSessionId, [global::System.Runtime.CompilerServices.EnumeratorCancellation] global::System.Threading.CancellationToken cancellationToken = default) + { + var metadata = new global::TUnit.Core.TestMetadata + { + TestName = "SynchronousTest", + TestClassType = typeof(global::TUnit.TestProject.BasicTests), + TestMethodName = "SynchronousTest", + Dependencies = global::System.Array.Empty(), + AttributeFactory = static () => + [ + new global::TUnit.Core.TestAttribute() + ], + DataSources = global::System.Array.Empty(), + ClassDataSources = global::System.Array.Empty(), + PropertyDataSources = global::System.Array.Empty(), + PropertyInjections = global::System.Array.Empty(), + InheritanceDepth = 0, + FilePath = @"", + LineNumber = 5, + MethodMetadata = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.BasicTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BasicTests)), + Name = "SynchronousTest", + 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.BasicTests", static () => + { + var classMetadata = new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.BasicTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BasicTests)), + Name = "BasicTests", + Namespace = "TUnit.TestProject", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", static () => new global::TUnit.Core.AssemblyMetadata { Name = "TestsBase`1" }), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }; + return classMetadata; + }) + }, + InstanceFactory = (typeArgs, args) => new global::TUnit.TestProject.BasicTests(), + InvokeTypedTest = static (instance, args, cancellationToken) => + { + try + { + instance.SynchronousTest(); + return default(global::System.Threading.Tasks.ValueTask); + } + catch (global::System.Exception ex) + { + return new global::System.Threading.Tasks.ValueTask(global::System.Threading.Tasks.Task.FromException(ex)); + } + }, + }; + metadata.UseRuntimeDataGeneration(testSessionId); + yield return metadata; + yield break; + } + public global::System.Collections.Generic.IEnumerable EnumerateTestDescriptors() + { + yield return new global::TUnit.Core.TestDescriptor + { + TestId = "TUnit.TestProject.BasicTests.SynchronousTest", + ClassName = "BasicTests", + MethodName = "SynchronousTest", + FullyQualifiedName = "TUnit.TestProject.BasicTests.SynchronousTest", + FilePath = @"", + LineNumber = 5, + Categories = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + HasDataSource = false, + RepeatCount = 0, + DependsOn = global::System.Array.Empty(), + Materializer = GetTestsAsync + }; + } +} +internal static class TUnit_TestProject_BasicTests_SynchronousTest_ModuleInitializer +{ + [global::System.Runtime.CompilerServices.ModuleInitializer] + public static void Initialize() + { + global::TUnit.Core.SourceRegistrar.Register(typeof(global::TUnit.TestProject.BasicTests), new TUnit_TestProject_BasicTests_SynchronousTest_TestSource()); + } +} + + +// ===== FILE SEPARATOR ===== + +// +#pragma warning disable + +#nullable enable +namespace TUnit.Generated; +internal sealed class TUnit_TestProject_BasicTests_AsynchronousTest_TestSource : global::TUnit.Core.Interfaces.SourceGenerator.ITestSource, global::TUnit.Core.Interfaces.SourceGenerator.ITestDescriptorSource +{ + public async global::System.Collections.Generic.IAsyncEnumerable GetTestsAsync(string testSessionId, [global::System.Runtime.CompilerServices.EnumeratorCancellation] global::System.Threading.CancellationToken cancellationToken = default) + { + var metadata = new global::TUnit.Core.TestMetadata + { + TestName = "AsynchronousTest", + TestClassType = typeof(global::TUnit.TestProject.BasicTests), + TestMethodName = "AsynchronousTest", + Dependencies = global::System.Array.Empty(), + AttributeFactory = static () => + [ + new global::TUnit.Core.TestAttribute() + ], + DataSources = global::System.Array.Empty(), + ClassDataSources = global::System.Array.Empty(), + PropertyDataSources = global::System.Array.Empty(), + PropertyInjections = global::System.Array.Empty(), + InheritanceDepth = 0, + FilePath = @"", + LineNumber = 11, + MethodMetadata = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.BasicTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BasicTests)), + Name = "AsynchronousTest", + 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.BasicTests", static () => + { + var classMetadata = new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.BasicTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BasicTests)), + Name = "BasicTests", + Namespace = "TUnit.TestProject", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", static () => new global::TUnit.Core.AssemblyMetadata { Name = "TestsBase`1" }), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }; + return classMetadata; + }) + }, + InstanceFactory = (typeArgs, args) => new global::TUnit.TestProject.BasicTests(), + InvokeTypedTest = static (instance, args, cancellationToken) => + { + try + { + return new global::System.Threading.Tasks.ValueTask(instance.AsynchronousTest()); + } + catch (global::System.Exception ex) + { + return new global::System.Threading.Tasks.ValueTask(global::System.Threading.Tasks.Task.FromException(ex)); + } + }, + }; + metadata.UseRuntimeDataGeneration(testSessionId); + yield return metadata; + yield break; + } + public global::System.Collections.Generic.IEnumerable EnumerateTestDescriptors() + { + yield return new global::TUnit.Core.TestDescriptor + { + TestId = "TUnit.TestProject.BasicTests.AsynchronousTest", + ClassName = "BasicTests", + MethodName = "AsynchronousTest", + FullyQualifiedName = "TUnit.TestProject.BasicTests.AsynchronousTest", + FilePath = @"", + LineNumber = 11, + Categories = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + HasDataSource = false, + RepeatCount = 0, + DependsOn = global::System.Array.Empty(), + Materializer = GetTestsAsync + }; + } +} +internal static class TUnit_TestProject_BasicTests_AsynchronousTest_ModuleInitializer +{ + [global::System.Runtime.CompilerServices.ModuleInitializer] + public static void Initialize() + { + global::TUnit.Core.SourceRegistrar.Register(typeof(global::TUnit.TestProject.BasicTests), new TUnit_TestProject_BasicTests_AsynchronousTest_TestSource()); + } +} + + +// ===== FILE SEPARATOR ===== + +// +#pragma warning disable + +#nullable enable +namespace TUnit.Generated; +internal sealed class TUnit_TestProject_BasicTests_ValueTaskAsynchronousTest_TestSource : global::TUnit.Core.Interfaces.SourceGenerator.ITestSource, global::TUnit.Core.Interfaces.SourceGenerator.ITestDescriptorSource +{ + public async global::System.Collections.Generic.IAsyncEnumerable GetTestsAsync(string testSessionId, [global::System.Runtime.CompilerServices.EnumeratorCancellation] global::System.Threading.CancellationToken cancellationToken = default) + { + var metadata = new global::TUnit.Core.TestMetadata + { + TestName = "ValueTaskAsynchronousTest", + TestClassType = typeof(global::TUnit.TestProject.BasicTests), + TestMethodName = "ValueTaskAsynchronousTest", + Dependencies = global::System.Array.Empty(), + AttributeFactory = static () => + [ + new global::TUnit.Core.TestAttribute() + ], + DataSources = global::System.Array.Empty(), + ClassDataSources = global::System.Array.Empty(), + PropertyDataSources = global::System.Array.Empty(), + PropertyInjections = global::System.Array.Empty(), + InheritanceDepth = 0, + FilePath = @"", + LineNumber = 17, + MethodMetadata = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.BasicTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BasicTests)), + Name = "ValueTaskAsynchronousTest", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.ValueTask), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.Tasks.ValueTask)), + Parameters = global::System.Array.Empty(), + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.BasicTests", static () => + { + var classMetadata = new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.BasicTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.BasicTests)), + Name = "BasicTests", + Namespace = "TUnit.TestProject", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", static () => new global::TUnit.Core.AssemblyMetadata { Name = "TestsBase`1" }), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }; + return classMetadata; + }) + }, + InstanceFactory = (typeArgs, args) => new global::TUnit.TestProject.BasicTests(), + InvokeTypedTest = static (instance, args, cancellationToken) => + { + try + { + return instance.ValueTaskAsynchronousTest(); + } + catch (global::System.Exception ex) + { + return new global::System.Threading.Tasks.ValueTask(global::System.Threading.Tasks.Task.FromException(ex)); + } + }, + }; + metadata.UseRuntimeDataGeneration(testSessionId); + yield return metadata; + yield break; + } + public global::System.Collections.Generic.IEnumerable EnumerateTestDescriptors() + { + yield return new global::TUnit.Core.TestDescriptor + { + TestId = "TUnit.TestProject.BasicTests.ValueTaskAsynchronousTest", + ClassName = "BasicTests", + MethodName = "ValueTaskAsynchronousTest", + FullyQualifiedName = "TUnit.TestProject.BasicTests.ValueTaskAsynchronousTest", + FilePath = @"", + LineNumber = 17, + Categories = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + HasDataSource = false, + RepeatCount = 0, + DependsOn = global::System.Array.Empty(), + Materializer = GetTestsAsync + }; + } +} +internal static class TUnit_TestProject_BasicTests_ValueTaskAsynchronousTest_ModuleInitializer +{ + [global::System.Runtime.CompilerServices.ModuleInitializer] + public static void Initialize() + { + global::TUnit.Core.SourceRegistrar.Register(typeof(global::TUnit.TestProject.BasicTests), new TUnit_TestProject_BasicTests_ValueTaskAsynchronousTest_TestSource()); + } +} diff --git a/TUnit.Core.SourceGenerator.Tests/ConflictingNamespaceTests.DataDrivenTest_WithConflictingNamespace.Net4_7.verified.txt b/TUnit.Core.SourceGenerator.Tests/ConflictingNamespaceTests.DataDrivenTest_WithConflictingNamespace.Net4_7.verified.txt new file mode 100644 index 0000000000..a541fe4504 --- /dev/null +++ b/TUnit.Core.SourceGenerator.Tests/ConflictingNamespaceTests.DataDrivenTest_WithConflictingNamespace.Net4_7.verified.txt @@ -0,0 +1,1221 @@ +// +#pragma warning disable + +#nullable enable +namespace TUnit.Generated; +internal sealed class TUnit_TestProject_DataDrivenTests_DataSource_Method__int_TestSource : global::TUnit.Core.Interfaces.SourceGenerator.ITestSource, global::TUnit.Core.Interfaces.SourceGenerator.ITestDescriptorSource +{ + public async global::System.Collections.Generic.IAsyncEnumerable GetTestsAsync(string testSessionId, [global::System.Runtime.CompilerServices.EnumeratorCancellation] global::System.Threading.CancellationToken cancellationToken = default) + { + var metadata = new global::TUnit.Core.TestMetadata + { + TestName = "DataSource_Method", + TestClassType = typeof(global::TUnit.TestProject.DataDrivenTests), + TestMethodName = "DataSource_Method", + Dependencies = global::System.Array.Empty(), + AttributeFactory = static () => + [ + new global::TUnit.Core.TestAttribute(), + new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass) + ], + DataSources = new global::TUnit.Core.IDataSourceAttribute[] + { + new global::TUnit.Core.ArgumentsAttribute(1), + new global::TUnit.Core.ArgumentsAttribute(2), + new global::TUnit.Core.ArgumentsAttribute(3), + }, + ClassDataSources = global::System.Array.Empty(), + PropertyDataSources = global::System.Array.Empty(), + PropertyInjections = global::System.Array.Empty(), + InheritanceDepth = 0, + FilePath = @"", + LineNumber = 8, + MethodMetadata = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.DataDrivenTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.DataDrivenTests)), + Name = "DataSource_Method", + GenericTypeCount = 0, + ReturnType = typeof(void), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(void)), + Parameters = new global::TUnit.Core.ParameterMetadata[] + { + new global::TUnit.Core.ParameterMetadata(typeof(int)) + { + Name = "value", + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(int)), + IsNullable = false, + ReflectionInfo = typeof(global::TUnit.TestProject.DataDrivenTests).GetMethod("DataSource_Method", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(int) }, null)!.GetParameters()[0] + } + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.DataDrivenTests", static () => + { + var classMetadata = new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.DataDrivenTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.DataDrivenTests)), + Name = "DataDrivenTests", + Namespace = "TUnit.TestProject", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", static () => new global::TUnit.Core.AssemblyMetadata { Name = "TestsBase`1" }), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }; + return classMetadata; + }) + }, + InstanceFactory = (typeArgs, args) => new global::TUnit.TestProject.DataDrivenTests(), + InvokeTypedTest = static (instance, args, cancellationToken) => + { + try + { + switch (args.Length) + { + case 1: + { + instance.DataSource_Method(global::TUnit.Core.Helpers.CastHelper.Cast(args[0])); + return default(global::System.Threading.Tasks.ValueTask); + } + default: + throw new global::System.ArgumentException($"Expected exactly 1 argument, but got {args.Length}"); + } + } + catch (global::System.Exception ex) + { + return new global::System.Threading.Tasks.ValueTask(global::System.Threading.Tasks.Task.FromException(ex)); + } + }, + }; + metadata.UseRuntimeDataGeneration(testSessionId); + yield return metadata; + yield break; + } + public global::System.Collections.Generic.IEnumerable EnumerateTestDescriptors() + { + yield return new global::TUnit.Core.TestDescriptor + { + TestId = "TUnit.TestProject.DataDrivenTests.DataSource_Method", + ClassName = "DataDrivenTests", + MethodName = "DataSource_Method", + FullyQualifiedName = "TUnit.TestProject.DataDrivenTests.DataSource_Method", + FilePath = @"", + LineNumber = 8, + Categories = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + HasDataSource = true, + RepeatCount = 0, + DependsOn = global::System.Array.Empty(), + Materializer = GetTestsAsync + }; + } +} +internal static class TUnit_TestProject_DataDrivenTests_DataSource_Method__int_ModuleInitializer +{ + [global::System.Runtime.CompilerServices.ModuleInitializer] + public static void Initialize() + { + global::TUnit.Core.SourceRegistrar.Register(typeof(global::TUnit.TestProject.DataDrivenTests), new TUnit_TestProject_DataDrivenTests_DataSource_Method__int_TestSource()); + } +} + + +// ===== FILE SEPARATOR ===== + +// +#pragma warning disable + +#nullable enable +namespace TUnit.Generated; +internal sealed class TUnit_TestProject_DataDrivenTests_DataSource_Method__int_string_TestSource : global::TUnit.Core.Interfaces.SourceGenerator.ITestSource, global::TUnit.Core.Interfaces.SourceGenerator.ITestDescriptorSource +{ + public async global::System.Collections.Generic.IAsyncEnumerable GetTestsAsync(string testSessionId, [global::System.Runtime.CompilerServices.EnumeratorCancellation] global::System.Threading.CancellationToken cancellationToken = default) + { + var metadata = new global::TUnit.Core.TestMetadata + { + TestName = "DataSource_Method", + TestClassType = typeof(global::TUnit.TestProject.DataDrivenTests), + TestMethodName = "DataSource_Method", + Dependencies = global::System.Array.Empty(), + AttributeFactory = static () => + [ + new global::TUnit.Core.TestAttribute(), + new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass) + ], + DataSources = new global::TUnit.Core.IDataSourceAttribute[] + { + new global::TUnit.Core.ArgumentsAttribute(1, "String"), + new global::TUnit.Core.ArgumentsAttribute(2, "String2"), + new global::TUnit.Core.ArgumentsAttribute(3, "String3"), + }, + ClassDataSources = global::System.Array.Empty(), + PropertyDataSources = global::System.Array.Empty(), + PropertyInjections = global::System.Array.Empty(), + InheritanceDepth = 0, + FilePath = @"", + LineNumber = 17, + MethodMetadata = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.DataDrivenTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.DataDrivenTests)), + Name = "DataSource_Method", + GenericTypeCount = 0, + ReturnType = typeof(void), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(void)), + Parameters = new global::TUnit.Core.ParameterMetadata[] + { + new global::TUnit.Core.ParameterMetadata(typeof(int)) + { + Name = "value", + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(int)), + IsNullable = false, + ReflectionInfo = typeof(global::TUnit.TestProject.DataDrivenTests).GetMethod("DataSource_Method", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(int), typeof(string) }, null)!.GetParameters()[0] + }, + new global::TUnit.Core.ParameterMetadata(typeof(string)) + { + Name = "value2", + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(string)), + IsNullable = false, + ReflectionInfo = typeof(global::TUnit.TestProject.DataDrivenTests).GetMethod("DataSource_Method", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(int), typeof(string) }, null)!.GetParameters()[1] + } + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.DataDrivenTests", static () => + { + var classMetadata = new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.DataDrivenTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.DataDrivenTests)), + Name = "DataDrivenTests", + Namespace = "TUnit.TestProject", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", static () => new global::TUnit.Core.AssemblyMetadata { Name = "TestsBase`1" }), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }; + return classMetadata; + }) + }, + InstanceFactory = (typeArgs, args) => new global::TUnit.TestProject.DataDrivenTests(), + InvokeTypedTest = static (instance, args, cancellationToken) => + { + try + { + switch (args.Length) + { + case 2: + { + instance.DataSource_Method(global::TUnit.Core.Helpers.CastHelper.Cast(args[0]), global::TUnit.Core.Helpers.CastHelper.Cast(args[1])); + return default(global::System.Threading.Tasks.ValueTask); + } + default: + throw new global::System.ArgumentException($"Expected exactly 2 arguments, but got {args.Length}"); + } + } + catch (global::System.Exception ex) + { + return new global::System.Threading.Tasks.ValueTask(global::System.Threading.Tasks.Task.FromException(ex)); + } + }, + }; + metadata.UseRuntimeDataGeneration(testSessionId); + yield return metadata; + yield break; + } + public global::System.Collections.Generic.IEnumerable EnumerateTestDescriptors() + { + yield return new global::TUnit.Core.TestDescriptor + { + TestId = "TUnit.TestProject.DataDrivenTests.DataSource_Method", + ClassName = "DataDrivenTests", + MethodName = "DataSource_Method", + FullyQualifiedName = "TUnit.TestProject.DataDrivenTests.DataSource_Method", + FilePath = @"", + LineNumber = 17, + Categories = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + HasDataSource = true, + RepeatCount = 0, + DependsOn = global::System.Array.Empty(), + Materializer = GetTestsAsync + }; + } +} +internal static class TUnit_TestProject_DataDrivenTests_DataSource_Method__int_string_ModuleInitializer +{ + [global::System.Runtime.CompilerServices.ModuleInitializer] + public static void Initialize() + { + global::TUnit.Core.SourceRegistrar.Register(typeof(global::TUnit.TestProject.DataDrivenTests), new TUnit_TestProject_DataDrivenTests_DataSource_Method__int_string_TestSource()); + } +} + + +// ===== FILE SEPARATOR ===== + +// +#pragma warning disable + +#nullable enable +namespace TUnit.Generated; +internal sealed class TUnit_TestProject_DataDrivenTests_EnumValue__TestEnum_TestSource : global::TUnit.Core.Interfaces.SourceGenerator.ITestSource, global::TUnit.Core.Interfaces.SourceGenerator.ITestDescriptorSource +{ + public async global::System.Collections.Generic.IAsyncEnumerable GetTestsAsync(string testSessionId, [global::System.Runtime.CompilerServices.EnumeratorCancellation] global::System.Threading.CancellationToken cancellationToken = default) + { + var metadata = new global::TUnit.Core.TestMetadata + { + TestName = "EnumValue", + TestClassType = typeof(global::TUnit.TestProject.DataDrivenTests), + TestMethodName = "EnumValue", + Dependencies = global::System.Array.Empty(), + AttributeFactory = static () => + [ + new global::TUnit.Core.TestAttribute(), + new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass) + ], + DataSources = new global::TUnit.Core.IDataSourceAttribute[] + { + new global::TUnit.Core.ArgumentsAttribute(global::TUnit.TestProject.TestEnum.One), + new global::TUnit.Core.ArgumentsAttribute(global::TUnit.TestProject.TestEnum.Two), + new global::TUnit.Core.ArgumentsAttribute(-1), + }, + ClassDataSources = global::System.Array.Empty(), + PropertyDataSources = global::System.Array.Empty(), + PropertyInjections = global::System.Array.Empty(), + InheritanceDepth = 0, + FilePath = @"", + LineNumber = 26, + MethodMetadata = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.DataDrivenTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.DataDrivenTests)), + Name = "EnumValue", + GenericTypeCount = 0, + ReturnType = typeof(void), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(void)), + Parameters = new global::TUnit.Core.ParameterMetadata[] + { + new global::TUnit.Core.ParameterMetadata(typeof(global::TUnit.TestProject.TestEnum)) + { + Name = "testEnum", + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.TestEnum)), + IsNullable = false, + ReflectionInfo = typeof(global::TUnit.TestProject.DataDrivenTests).GetMethod("EnumValue", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(global::TUnit.TestProject.TestEnum) }, null)!.GetParameters()[0] + } + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.DataDrivenTests", static () => + { + var classMetadata = new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.DataDrivenTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.DataDrivenTests)), + Name = "DataDrivenTests", + Namespace = "TUnit.TestProject", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", static () => new global::TUnit.Core.AssemblyMetadata { Name = "TestsBase`1" }), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }; + return classMetadata; + }) + }, + InstanceFactory = (typeArgs, args) => new global::TUnit.TestProject.DataDrivenTests(), + InvokeTypedTest = static (instance, args, cancellationToken) => + { + try + { + switch (args.Length) + { + case 1: + { + instance.EnumValue(global::TUnit.Core.Helpers.CastHelper.Cast(args[0])); + return default(global::System.Threading.Tasks.ValueTask); + } + default: + throw new global::System.ArgumentException($"Expected exactly 1 argument, but got {args.Length}"); + } + } + catch (global::System.Exception ex) + { + return new global::System.Threading.Tasks.ValueTask(global::System.Threading.Tasks.Task.FromException(ex)); + } + }, + }; + metadata.UseRuntimeDataGeneration(testSessionId); + yield return metadata; + yield break; + } + public global::System.Collections.Generic.IEnumerable EnumerateTestDescriptors() + { + yield return new global::TUnit.Core.TestDescriptor + { + TestId = "TUnit.TestProject.DataDrivenTests.EnumValue", + ClassName = "DataDrivenTests", + MethodName = "EnumValue", + FullyQualifiedName = "TUnit.TestProject.DataDrivenTests.EnumValue", + FilePath = @"", + LineNumber = 26, + Categories = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + HasDataSource = true, + RepeatCount = 0, + DependsOn = global::System.Array.Empty(), + Materializer = GetTestsAsync + }; + } +} +internal static class TUnit_TestProject_DataDrivenTests_EnumValue__TestEnum_ModuleInitializer +{ + [global::System.Runtime.CompilerServices.ModuleInitializer] + public static void Initialize() + { + global::TUnit.Core.SourceRegistrar.Register(typeof(global::TUnit.TestProject.DataDrivenTests), new TUnit_TestProject_DataDrivenTests_EnumValue__TestEnum_TestSource()); + } +} + + +// ===== FILE SEPARATOR ===== + +// +#pragma warning disable + +#nullable enable +namespace TUnit.Generated; +internal sealed class TUnit_TestProject_DataDrivenTests_NullValue__string__TestSource : global::TUnit.Core.Interfaces.SourceGenerator.ITestSource, global::TUnit.Core.Interfaces.SourceGenerator.ITestDescriptorSource +{ + public async global::System.Collections.Generic.IAsyncEnumerable GetTestsAsync(string testSessionId, [global::System.Runtime.CompilerServices.EnumeratorCancellation] global::System.Threading.CancellationToken cancellationToken = default) + { + var metadata = new global::TUnit.Core.TestMetadata + { + TestName = "NullValue", + TestClassType = typeof(global::TUnit.TestProject.DataDrivenTests), + TestMethodName = "NullValue", + Dependencies = global::System.Array.Empty(), + AttributeFactory = static () => + [ + new global::TUnit.Core.TestAttribute(), + new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass) + ], + DataSources = new global::TUnit.Core.IDataSourceAttribute[] + { + new global::TUnit.Core.ArgumentsAttribute(null), + }, + ClassDataSources = global::System.Array.Empty(), + PropertyDataSources = global::System.Array.Empty(), + PropertyInjections = global::System.Array.Empty(), + InheritanceDepth = 0, + FilePath = @"", + LineNumber = 35, + MethodMetadata = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.DataDrivenTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.DataDrivenTests)), + Name = "NullValue", + GenericTypeCount = 0, + ReturnType = typeof(void), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(void)), + Parameters = new global::TUnit.Core.ParameterMetadata[] + { + new global::TUnit.Core.ParameterMetadata(typeof(string)) + { + Name = "value", + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(string)), + IsNullable = true, + ReflectionInfo = typeof(global::TUnit.TestProject.DataDrivenTests).GetMethod("NullValue", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(string) }, null)!.GetParameters()[0] + } + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.DataDrivenTests", static () => + { + var classMetadata = new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.DataDrivenTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.DataDrivenTests)), + Name = "DataDrivenTests", + Namespace = "TUnit.TestProject", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", static () => new global::TUnit.Core.AssemblyMetadata { Name = "TestsBase`1" }), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }; + return classMetadata; + }) + }, + InstanceFactory = (typeArgs, args) => new global::TUnit.TestProject.DataDrivenTests(), + InvokeTypedTest = static (instance, args, cancellationToken) => + { + try + { + switch (args.Length) + { + case 1: + { + instance.NullValue(global::TUnit.Core.Helpers.CastHelper.Cast(args[0])); + return default(global::System.Threading.Tasks.ValueTask); + } + default: + throw new global::System.ArgumentException($"Expected exactly 1 argument, but got {args.Length}"); + } + } + catch (global::System.Exception ex) + { + return new global::System.Threading.Tasks.ValueTask(global::System.Threading.Tasks.Task.FromException(ex)); + } + }, + }; + metadata.UseRuntimeDataGeneration(testSessionId); + yield return metadata; + yield break; + } + public global::System.Collections.Generic.IEnumerable EnumerateTestDescriptors() + { + yield return new global::TUnit.Core.TestDescriptor + { + TestId = "TUnit.TestProject.DataDrivenTests.NullValue", + ClassName = "DataDrivenTests", + MethodName = "NullValue", + FullyQualifiedName = "TUnit.TestProject.DataDrivenTests.NullValue", + FilePath = @"", + LineNumber = 35, + Categories = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + HasDataSource = true, + RepeatCount = 0, + DependsOn = global::System.Array.Empty(), + Materializer = GetTestsAsync + }; + } +} +internal static class TUnit_TestProject_DataDrivenTests_NullValue__string__ModuleInitializer +{ + [global::System.Runtime.CompilerServices.ModuleInitializer] + public static void Initialize() + { + global::TUnit.Core.SourceRegistrar.Register(typeof(global::TUnit.TestProject.DataDrivenTests), new TUnit_TestProject_DataDrivenTests_NullValue__string__TestSource()); + } +} + + +// ===== FILE SEPARATOR ===== + +// +#pragma warning disable + +#nullable enable +namespace TUnit.Generated; +internal sealed class TUnit_TestProject_DataDrivenTests_EmptyString__string__TestSource : global::TUnit.Core.Interfaces.SourceGenerator.ITestSource, global::TUnit.Core.Interfaces.SourceGenerator.ITestDescriptorSource +{ + public async global::System.Collections.Generic.IAsyncEnumerable GetTestsAsync(string testSessionId, [global::System.Runtime.CompilerServices.EnumeratorCancellation] global::System.Threading.CancellationToken cancellationToken = default) + { + var metadata = new global::TUnit.Core.TestMetadata + { + TestName = "EmptyString", + TestClassType = typeof(global::TUnit.TestProject.DataDrivenTests), + TestMethodName = "EmptyString", + Dependencies = global::System.Array.Empty(), + AttributeFactory = static () => + [ + new global::TUnit.Core.TestAttribute(), + new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass) + ], + DataSources = new global::TUnit.Core.IDataSourceAttribute[] + { + new global::TUnit.Core.ArgumentsAttribute(""), + }, + ClassDataSources = global::System.Array.Empty(), + PropertyDataSources = global::System.Array.Empty(), + PropertyInjections = global::System.Array.Empty(), + InheritanceDepth = 0, + FilePath = @"", + LineNumber = 42, + MethodMetadata = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.DataDrivenTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.DataDrivenTests)), + Name = "EmptyString", + GenericTypeCount = 0, + ReturnType = typeof(void), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(void)), + Parameters = new global::TUnit.Core.ParameterMetadata[] + { + new global::TUnit.Core.ParameterMetadata(typeof(string)) + { + Name = "value", + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(string)), + IsNullable = true, + ReflectionInfo = typeof(global::TUnit.TestProject.DataDrivenTests).GetMethod("EmptyString", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(string) }, null)!.GetParameters()[0] + } + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.DataDrivenTests", static () => + { + var classMetadata = new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.DataDrivenTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.DataDrivenTests)), + Name = "DataDrivenTests", + Namespace = "TUnit.TestProject", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", static () => new global::TUnit.Core.AssemblyMetadata { Name = "TestsBase`1" }), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }; + return classMetadata; + }) + }, + InstanceFactory = (typeArgs, args) => new global::TUnit.TestProject.DataDrivenTests(), + InvokeTypedTest = static (instance, args, cancellationToken) => + { + try + { + switch (args.Length) + { + case 1: + { + instance.EmptyString(global::TUnit.Core.Helpers.CastHelper.Cast(args[0])); + return default(global::System.Threading.Tasks.ValueTask); + } + default: + throw new global::System.ArgumentException($"Expected exactly 1 argument, but got {args.Length}"); + } + } + catch (global::System.Exception ex) + { + return new global::System.Threading.Tasks.ValueTask(global::System.Threading.Tasks.Task.FromException(ex)); + } + }, + }; + metadata.UseRuntimeDataGeneration(testSessionId); + yield return metadata; + yield break; + } + public global::System.Collections.Generic.IEnumerable EnumerateTestDescriptors() + { + yield return new global::TUnit.Core.TestDescriptor + { + TestId = "TUnit.TestProject.DataDrivenTests.EmptyString", + ClassName = "DataDrivenTests", + MethodName = "EmptyString", + FullyQualifiedName = "TUnit.TestProject.DataDrivenTests.EmptyString", + FilePath = @"", + LineNumber = 42, + Categories = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + HasDataSource = true, + RepeatCount = 0, + DependsOn = global::System.Array.Empty(), + Materializer = GetTestsAsync + }; + } +} +internal static class TUnit_TestProject_DataDrivenTests_EmptyString__string__ModuleInitializer +{ + [global::System.Runtime.CompilerServices.ModuleInitializer] + public static void Initialize() + { + global::TUnit.Core.SourceRegistrar.Register(typeof(global::TUnit.TestProject.DataDrivenTests), new TUnit_TestProject_DataDrivenTests_EmptyString__string__TestSource()); + } +} + + +// ===== FILE SEPARATOR ===== + +// +#pragma warning disable + +#nullable enable +namespace TUnit.Generated; +internal sealed class TUnit_TestProject_DataDrivenTests_NonEmptyString__string__TestSource : global::TUnit.Core.Interfaces.SourceGenerator.ITestSource, global::TUnit.Core.Interfaces.SourceGenerator.ITestDescriptorSource +{ + public async global::System.Collections.Generic.IAsyncEnumerable GetTestsAsync(string testSessionId, [global::System.Runtime.CompilerServices.EnumeratorCancellation] global::System.Threading.CancellationToken cancellationToken = default) + { + var metadata = new global::TUnit.Core.TestMetadata + { + TestName = "NonEmptyString", + TestClassType = typeof(global::TUnit.TestProject.DataDrivenTests), + TestMethodName = "NonEmptyString", + Dependencies = global::System.Array.Empty(), + AttributeFactory = static () => + [ + new global::TUnit.Core.TestAttribute(), + new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass) + ], + DataSources = new global::TUnit.Core.IDataSourceAttribute[] + { + new global::TUnit.Core.ArgumentsAttribute("Foo bar!"), + }, + ClassDataSources = global::System.Array.Empty(), + PropertyDataSources = global::System.Array.Empty(), + PropertyInjections = global::System.Array.Empty(), + InheritanceDepth = 0, + FilePath = @"", + LineNumber = 49, + MethodMetadata = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.DataDrivenTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.DataDrivenTests)), + Name = "NonEmptyString", + GenericTypeCount = 0, + ReturnType = typeof(void), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(void)), + Parameters = new global::TUnit.Core.ParameterMetadata[] + { + new global::TUnit.Core.ParameterMetadata(typeof(string)) + { + Name = "value", + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(string)), + IsNullable = true, + ReflectionInfo = typeof(global::TUnit.TestProject.DataDrivenTests).GetMethod("NonEmptyString", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(string) }, null)!.GetParameters()[0] + } + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.DataDrivenTests", static () => + { + var classMetadata = new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.DataDrivenTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.DataDrivenTests)), + Name = "DataDrivenTests", + Namespace = "TUnit.TestProject", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", static () => new global::TUnit.Core.AssemblyMetadata { Name = "TestsBase`1" }), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }; + return classMetadata; + }) + }, + InstanceFactory = (typeArgs, args) => new global::TUnit.TestProject.DataDrivenTests(), + InvokeTypedTest = static (instance, args, cancellationToken) => + { + try + { + switch (args.Length) + { + case 1: + { + instance.NonEmptyString(global::TUnit.Core.Helpers.CastHelper.Cast(args[0])); + return default(global::System.Threading.Tasks.ValueTask); + } + default: + throw new global::System.ArgumentException($"Expected exactly 1 argument, but got {args.Length}"); + } + } + catch (global::System.Exception ex) + { + return new global::System.Threading.Tasks.ValueTask(global::System.Threading.Tasks.Task.FromException(ex)); + } + }, + }; + metadata.UseRuntimeDataGeneration(testSessionId); + yield return metadata; + yield break; + } + public global::System.Collections.Generic.IEnumerable EnumerateTestDescriptors() + { + yield return new global::TUnit.Core.TestDescriptor + { + TestId = "TUnit.TestProject.DataDrivenTests.NonEmptyString", + ClassName = "DataDrivenTests", + MethodName = "NonEmptyString", + FullyQualifiedName = "TUnit.TestProject.DataDrivenTests.NonEmptyString", + FilePath = @"", + LineNumber = 49, + Categories = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + HasDataSource = true, + RepeatCount = 0, + DependsOn = global::System.Array.Empty(), + Materializer = GetTestsAsync + }; + } +} +internal static class TUnit_TestProject_DataDrivenTests_NonEmptyString__string__ModuleInitializer +{ + [global::System.Runtime.CompilerServices.ModuleInitializer] + public static void Initialize() + { + global::TUnit.Core.SourceRegistrar.Register(typeof(global::TUnit.TestProject.DataDrivenTests), new TUnit_TestProject_DataDrivenTests_NonEmptyString__string__TestSource()); + } +} + + +// ===== FILE SEPARATOR ===== + +// +#pragma warning disable + +#nullable enable +namespace TUnit.Generated; +internal sealed class TUnit_TestProject_DataDrivenTests_BooleanString__bool__TestSource : global::TUnit.Core.Interfaces.SourceGenerator.ITestSource, global::TUnit.Core.Interfaces.SourceGenerator.ITestDescriptorSource +{ + public async global::System.Collections.Generic.IAsyncEnumerable GetTestsAsync(string testSessionId, [global::System.Runtime.CompilerServices.EnumeratorCancellation] global::System.Threading.CancellationToken cancellationToken = default) + { + var metadata = new global::TUnit.Core.TestMetadata + { + TestName = "BooleanString", + TestClassType = typeof(global::TUnit.TestProject.DataDrivenTests), + TestMethodName = "BooleanString", + Dependencies = global::System.Array.Empty(), + AttributeFactory = static () => + [ + new global::TUnit.Core.TestAttribute(), + new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass) + ], + DataSources = new global::TUnit.Core.IDataSourceAttribute[] + { + new global::TUnit.Core.ArgumentsAttribute(null), + new global::TUnit.Core.ArgumentsAttribute(false), + new global::TUnit.Core.ArgumentsAttribute(true), + }, + ClassDataSources = global::System.Array.Empty(), + PropertyDataSources = global::System.Array.Empty(), + PropertyInjections = global::System.Array.Empty(), + InheritanceDepth = 0, + FilePath = @"", + LineNumber = 56, + MethodMetadata = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.DataDrivenTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.DataDrivenTests)), + Name = "BooleanString", + GenericTypeCount = 0, + ReturnType = typeof(void), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(void)), + Parameters = new global::TUnit.Core.ParameterMetadata[] + { + new global::TUnit.Core.ParameterMetadata(typeof(bool?)) + { + Name = "value", + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(bool?)), + IsNullable = true, + ReflectionInfo = typeof(global::TUnit.TestProject.DataDrivenTests).GetMethod("BooleanString", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(bool?) }, null)!.GetParameters()[0] + } + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.DataDrivenTests", static () => + { + var classMetadata = new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.DataDrivenTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.DataDrivenTests)), + Name = "DataDrivenTests", + Namespace = "TUnit.TestProject", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", static () => new global::TUnit.Core.AssemblyMetadata { Name = "TestsBase`1" }), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }; + return classMetadata; + }) + }, + InstanceFactory = (typeArgs, args) => new global::TUnit.TestProject.DataDrivenTests(), + InvokeTypedTest = static (instance, args, cancellationToken) => + { + try + { + switch (args.Length) + { + case 1: + { + instance.BooleanString(global::TUnit.Core.Helpers.CastHelper.Cast(args[0])); + return default(global::System.Threading.Tasks.ValueTask); + } + default: + throw new global::System.ArgumentException($"Expected exactly 1 argument, but got {args.Length}"); + } + } + catch (global::System.Exception ex) + { + return new global::System.Threading.Tasks.ValueTask(global::System.Threading.Tasks.Task.FromException(ex)); + } + }, + }; + metadata.UseRuntimeDataGeneration(testSessionId); + yield return metadata; + yield break; + } + public global::System.Collections.Generic.IEnumerable EnumerateTestDescriptors() + { + yield return new global::TUnit.Core.TestDescriptor + { + TestId = "TUnit.TestProject.DataDrivenTests.BooleanString", + ClassName = "DataDrivenTests", + MethodName = "BooleanString", + FullyQualifiedName = "TUnit.TestProject.DataDrivenTests.BooleanString", + FilePath = @"", + LineNumber = 56, + Categories = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + HasDataSource = true, + RepeatCount = 0, + DependsOn = global::System.Array.Empty(), + Materializer = GetTestsAsync + }; + } +} +internal static class TUnit_TestProject_DataDrivenTests_BooleanString__bool__ModuleInitializer +{ + [global::System.Runtime.CompilerServices.ModuleInitializer] + public static void Initialize() + { + global::TUnit.Core.SourceRegistrar.Register(typeof(global::TUnit.TestProject.DataDrivenTests), new TUnit_TestProject_DataDrivenTests_BooleanString__bool__TestSource()); + } +} + + +// ===== FILE SEPARATOR ===== + +// +#pragma warning disable + +#nullable enable +namespace TUnit.Generated; +internal sealed class TUnit_TestProject_DataDrivenTests_Type__Type_TestSource : global::TUnit.Core.Interfaces.SourceGenerator.ITestSource, global::TUnit.Core.Interfaces.SourceGenerator.ITestDescriptorSource +{ + public async global::System.Collections.Generic.IAsyncEnumerable GetTestsAsync(string testSessionId, [global::System.Runtime.CompilerServices.EnumeratorCancellation] global::System.Threading.CancellationToken cancellationToken = default) + { + var metadata = new global::TUnit.Core.TestMetadata + { + TestName = "Type", + TestClassType = typeof(global::TUnit.TestProject.DataDrivenTests), + TestMethodName = "Type", + Dependencies = global::System.Array.Empty(), + AttributeFactory = static () => + [ + new global::TUnit.Core.TestAttribute(), + new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass) + ], + DataSources = new global::TUnit.Core.IDataSourceAttribute[] + { + new global::TUnit.Core.ArgumentsAttribute(typeof(object)), + }, + ClassDataSources = global::System.Array.Empty(), + PropertyDataSources = global::System.Array.Empty(), + PropertyInjections = global::System.Array.Empty(), + InheritanceDepth = 0, + FilePath = @"", + LineNumber = 65, + MethodMetadata = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.DataDrivenTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.DataDrivenTests)), + Name = "Type", + GenericTypeCount = 0, + ReturnType = typeof(void), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(void)), + Parameters = new global::TUnit.Core.ParameterMetadata[] + { + new global::TUnit.Core.ParameterMetadata(typeof(global::System.Type)) + { + Name = "value", + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Type)), + IsNullable = false, + ReflectionInfo = typeof(global::TUnit.TestProject.DataDrivenTests).GetMethod("Type", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(global::System.Type) }, null)!.GetParameters()[0] + } + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.DataDrivenTests", static () => + { + var classMetadata = new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.DataDrivenTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.DataDrivenTests)), + Name = "DataDrivenTests", + Namespace = "TUnit.TestProject", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", static () => new global::TUnit.Core.AssemblyMetadata { Name = "TestsBase`1" }), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }; + return classMetadata; + }) + }, + InstanceFactory = (typeArgs, args) => new global::TUnit.TestProject.DataDrivenTests(), + InvokeTypedTest = static (instance, args, cancellationToken) => + { + try + { + switch (args.Length) + { + case 1: + { + instance.Type(global::TUnit.Core.Helpers.CastHelper.Cast(args[0])); + return default(global::System.Threading.Tasks.ValueTask); + } + default: + throw new global::System.ArgumentException($"Expected exactly 1 argument, but got {args.Length}"); + } + } + catch (global::System.Exception ex) + { + return new global::System.Threading.Tasks.ValueTask(global::System.Threading.Tasks.Task.FromException(ex)); + } + }, + }; + metadata.UseRuntimeDataGeneration(testSessionId); + yield return metadata; + yield break; + } + public global::System.Collections.Generic.IEnumerable EnumerateTestDescriptors() + { + yield return new global::TUnit.Core.TestDescriptor + { + TestId = "TUnit.TestProject.DataDrivenTests.Type", + ClassName = "DataDrivenTests", + MethodName = "Type", + FullyQualifiedName = "TUnit.TestProject.DataDrivenTests.Type", + FilePath = @"", + LineNumber = 65, + Categories = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + HasDataSource = true, + RepeatCount = 0, + DependsOn = global::System.Array.Empty(), + Materializer = GetTestsAsync + }; + } +} +internal static class TUnit_TestProject_DataDrivenTests_Type__Type_ModuleInitializer +{ + [global::System.Runtime.CompilerServices.ModuleInitializer] + public static void Initialize() + { + global::TUnit.Core.SourceRegistrar.Register(typeof(global::TUnit.TestProject.DataDrivenTests), new TUnit_TestProject_DataDrivenTests_Type__Type_TestSource()); + } +} + + +// ===== FILE SEPARATOR ===== + +// +#pragma warning disable + +#nullable enable +namespace TUnit.Generated; +internal sealed class TUnit_TestProject_DataDrivenTests_IntegerArray__int___TestSource : global::TUnit.Core.Interfaces.SourceGenerator.ITestSource, global::TUnit.Core.Interfaces.SourceGenerator.ITestDescriptorSource +{ + public async global::System.Collections.Generic.IAsyncEnumerable GetTestsAsync(string testSessionId, [global::System.Runtime.CompilerServices.EnumeratorCancellation] global::System.Threading.CancellationToken cancellationToken = default) + { + var metadata = new global::TUnit.Core.TestMetadata + { + TestName = "IntegerArray", + TestClassType = typeof(global::TUnit.TestProject.DataDrivenTests), + TestMethodName = "IntegerArray", + Dependencies = global::System.Array.Empty(), + AttributeFactory = static () => + [ + new global::TUnit.Core.TestAttribute(), + new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass) + ], + DataSources = new global::TUnit.Core.IDataSourceAttribute[] + { + new global::TUnit.Core.ArgumentsAttribute(new[] { 1, 2, 3 }), + }, + ClassDataSources = global::System.Array.Empty(), + PropertyDataSources = global::System.Array.Empty(), + PropertyInjections = global::System.Array.Empty(), + InheritanceDepth = 0, + FilePath = @"", + LineNumber = 72, + MethodMetadata = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.DataDrivenTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.DataDrivenTests)), + Name = "IntegerArray", + GenericTypeCount = 0, + ReturnType = typeof(void), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(void)), + Parameters = new global::TUnit.Core.ParameterMetadata[] + { + new global::TUnit.Core.ParameterMetadata(typeof(int[])) + { + Name = "values", + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(int[])), + IsNullable = false, + ReflectionInfo = typeof(global::TUnit.TestProject.DataDrivenTests).GetMethod("IntegerArray", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(int[]) }, null)!.GetParameters()[0] + } + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.DataDrivenTests", static () => + { + var classMetadata = new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.DataDrivenTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.DataDrivenTests)), + Name = "DataDrivenTests", + Namespace = "TUnit.TestProject", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", static () => new global::TUnit.Core.AssemblyMetadata { Name = "TestsBase`1" }), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }; + return classMetadata; + }) + }, + InstanceFactory = (typeArgs, args) => new global::TUnit.TestProject.DataDrivenTests(), + InvokeTypedTest = static (instance, args, cancellationToken) => + { + try + { + switch (args.Length) + { + case 1: + { + instance.IntegerArray(global::TUnit.Core.Helpers.CastHelper.Cast(args[0])); + return default(global::System.Threading.Tasks.ValueTask); + } + default: + throw new global::System.ArgumentException($"Expected exactly 1 argument, but got {args.Length}"); + } + } + catch (global::System.Exception ex) + { + return new global::System.Threading.Tasks.ValueTask(global::System.Threading.Tasks.Task.FromException(ex)); + } + }, + }; + metadata.UseRuntimeDataGeneration(testSessionId); + yield return metadata; + yield break; + } + public global::System.Collections.Generic.IEnumerable EnumerateTestDescriptors() + { + yield return new global::TUnit.Core.TestDescriptor + { + TestId = "TUnit.TestProject.DataDrivenTests.IntegerArray", + ClassName = "DataDrivenTests", + MethodName = "IntegerArray", + FullyQualifiedName = "TUnit.TestProject.DataDrivenTests.IntegerArray", + FilePath = @"", + LineNumber = 72, + Categories = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + HasDataSource = true, + RepeatCount = 0, + DependsOn = global::System.Array.Empty(), + Materializer = GetTestsAsync + }; + } +} +internal static class TUnit_TestProject_DataDrivenTests_IntegerArray__int___ModuleInitializer +{ + [global::System.Runtime.CompilerServices.ModuleInitializer] + public static void Initialize() + { + global::TUnit.Core.SourceRegistrar.Register(typeof(global::TUnit.TestProject.DataDrivenTests), new TUnit_TestProject_DataDrivenTests_IntegerArray__int___TestSource()); + } +} + + +// ===== FILE SEPARATOR ===== + +// +#pragma warning disable + +#nullable enable +namespace TUnit.Generated; +internal sealed class TUnit_TestProject_DataDrivenTests_IntMaxValue__int_TestSource : global::TUnit.Core.Interfaces.SourceGenerator.ITestSource, global::TUnit.Core.Interfaces.SourceGenerator.ITestDescriptorSource +{ + public async global::System.Collections.Generic.IAsyncEnumerable GetTestsAsync(string testSessionId, [global::System.Runtime.CompilerServices.EnumeratorCancellation] global::System.Threading.CancellationToken cancellationToken = default) + { + var metadata = new global::TUnit.Core.TestMetadata + { + TestName = "IntMaxValue", + TestClassType = typeof(global::TUnit.TestProject.DataDrivenTests), + TestMethodName = "IntMaxValue", + Dependencies = global::System.Array.Empty(), + AttributeFactory = static () => + [ + new global::TUnit.Core.TestAttribute(), + new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass) + ], + DataSources = new global::TUnit.Core.IDataSourceAttribute[] + { + new global::TUnit.Core.ArgumentsAttribute(2147483647), + }, + ClassDataSources = global::System.Array.Empty(), + PropertyDataSources = global::System.Array.Empty(), + PropertyInjections = global::System.Array.Empty(), + InheritanceDepth = 0, + FilePath = @"", + LineNumber = 79, + MethodMetadata = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.DataDrivenTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.DataDrivenTests)), + Name = "IntMaxValue", + GenericTypeCount = 0, + ReturnType = typeof(void), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(void)), + Parameters = new global::TUnit.Core.ParameterMetadata[] + { + new global::TUnit.Core.ParameterMetadata(typeof(int)) + { + Name = "value", + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(int)), + IsNullable = false, + ReflectionInfo = typeof(global::TUnit.TestProject.DataDrivenTests).GetMethod("IntMaxValue", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(int) }, null)!.GetParameters()[0] + } + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.DataDrivenTests", static () => + { + var classMetadata = new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.DataDrivenTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.DataDrivenTests)), + Name = "DataDrivenTests", + Namespace = "TUnit.TestProject", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", static () => new global::TUnit.Core.AssemblyMetadata { Name = "TestsBase`1" }), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }; + return classMetadata; + }) + }, + InstanceFactory = (typeArgs, args) => new global::TUnit.TestProject.DataDrivenTests(), + InvokeTypedTest = static (instance, args, cancellationToken) => + { + try + { + switch (args.Length) + { + case 1: + { + instance.IntMaxValue(global::TUnit.Core.Helpers.CastHelper.Cast(args[0])); + return default(global::System.Threading.Tasks.ValueTask); + } + default: + throw new global::System.ArgumentException($"Expected exactly 1 argument, but got {args.Length}"); + } + } + catch (global::System.Exception ex) + { + return new global::System.Threading.Tasks.ValueTask(global::System.Threading.Tasks.Task.FromException(ex)); + } + }, + }; + metadata.UseRuntimeDataGeneration(testSessionId); + yield return metadata; + yield break; + } + public global::System.Collections.Generic.IEnumerable EnumerateTestDescriptors() + { + yield return new global::TUnit.Core.TestDescriptor + { + TestId = "TUnit.TestProject.DataDrivenTests.IntMaxValue", + ClassName = "DataDrivenTests", + MethodName = "IntMaxValue", + FullyQualifiedName = "TUnit.TestProject.DataDrivenTests.IntMaxValue", + FilePath = @"", + LineNumber = 79, + Categories = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + HasDataSource = true, + RepeatCount = 0, + DependsOn = global::System.Array.Empty(), + Materializer = GetTestsAsync + }; + } +} +internal static class TUnit_TestProject_DataDrivenTests_IntMaxValue__int_ModuleInitializer +{ + [global::System.Runtime.CompilerServices.ModuleInitializer] + public static void Initialize() + { + global::TUnit.Core.SourceRegistrar.Register(typeof(global::TUnit.TestProject.DataDrivenTests), new TUnit_TestProject_DataDrivenTests_IntMaxValue__int_TestSource()); + } +} diff --git a/TUnit.Core.SourceGenerator.Tests/ConflictingNamespaceTests.HooksTest_WithConflictingNamespace.Net4_7.verified.txt b/TUnit.Core.SourceGenerator.Tests/ConflictingNamespaceTests.HooksTest_WithConflictingNamespace.Net4_7.verified.txt new file mode 100644 index 0000000000..5be7810cdf --- /dev/null +++ b/TUnit.Core.SourceGenerator.Tests/ConflictingNamespaceTests.HooksTest_WithConflictingNamespace.Net4_7.verified.txt @@ -0,0 +1,1044 @@ +// +#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 +{ + [global::System.Runtime.CompilerServices.ModuleInitializer] + public static void Initialize() + { + global::TUnit.Core.Sources.BeforeClassHooks.GetOrAdd(typeof(global::TUnit.TestProject.BeforeTests.Base1), static _ => new global::System.Collections.Concurrent.ConcurrentBag()); + global::TUnit.Core.Sources.BeforeClassHooks[typeof(global::TUnit.TestProject.BeforeTests.Base1)].Add( + 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", static () => + { + var classMetadata = 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", static () => new global::TUnit.Core.AssemblyMetadata { Name = "TestsBase`1" }), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }; + return classMetadata; + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = global::TUnit.Core.HookRegistrationIndices.GetNextBeforeClassHookIndex(), + Body = global_TUnit_TestProject_BeforeTests_Base1_BeforeAll1_0Params_Body, + FilePath = @"", + LineNumber = 5 + } + ); + } + private static async ValueTask global_TUnit_TestProject_BeforeTests_Base1_BeforeAll1_0Params_Body(ClassHookContext context, CancellationToken cancellationToken) + { + await AsyncConvert.Convert(() => global::TUnit.TestProject.BeforeTests.Base1.BeforeAll1()); + } +} + + +// ===== 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 +{ + [global::System.Runtime.CompilerServices.ModuleInitializer] + public static void Initialize() + { + global::TUnit.Core.Sources.BeforeTestHooks.GetOrAdd(typeof(global::TUnit.TestProject.BeforeTests.Base1), static _ => new global::System.Collections.Concurrent.ConcurrentBag()); + global::TUnit.Core.Sources.BeforeTestHooks[typeof(global::TUnit.TestProject.BeforeTests.Base1)].Add( + 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", static () => + { + var classMetadata = 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", static () => new global::TUnit.Core.AssemblyMetadata { Name = "TestsBase`1" }), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }; + return classMetadata; + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), + Body = global_TUnit_TestProject_BeforeTests_Base1_BeforeEach1_0Params_Body + } + ); + } + private static async ValueTask global_TUnit_TestProject_BeforeTests_Base1_BeforeEach1_0Params_Body(object instance, TestContext context, CancellationToken cancellationToken) + { + var typedInstance = (global::TUnit.TestProject.BeforeTests.Base1)instance; + await AsyncConvert.Convert(() => typedInstance.BeforeEach1()); + } +} + + +// ===== 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_BeforeAll2_Before_Class; +internal static class TUnit_TestProject_BeforeTests_Base2_BeforeAll2_Before_ClassInitializer +{ + [global::System.Runtime.CompilerServices.ModuleInitializer] + public static void Initialize() + { + global::TUnit.Core.Sources.BeforeClassHooks.GetOrAdd(typeof(global::TUnit.TestProject.BeforeTests.Base2), static _ => new global::System.Collections.Concurrent.ConcurrentBag()); + global::TUnit.Core.Sources.BeforeClassHooks[typeof(global::TUnit.TestProject.BeforeTests.Base2)].Add( + 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", static () => + { + var classMetadata = 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", static () => new global::TUnit.Core.AssemblyMetadata { Name = "TestsBase`1" }), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }; + return classMetadata; + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = global::TUnit.Core.HookRegistrationIndices.GetNextBeforeClassHookIndex(), + Body = global_TUnit_TestProject_BeforeTests_Base2_BeforeAll2_0Params_Body, + FilePath = @"", + LineNumber = 20 + } + ); + } + private static async ValueTask global_TUnit_TestProject_BeforeTests_Base2_BeforeAll2_0Params_Body(ClassHookContext context, CancellationToken cancellationToken) + { + await AsyncConvert.Convert(() => global::TUnit.TestProject.BeforeTests.Base2.BeforeAll2()); + } +} + + +// ===== 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 +{ + [global::System.Runtime.CompilerServices.ModuleInitializer] + public static void Initialize() + { + global::TUnit.Core.Sources.BeforeTestHooks.GetOrAdd(typeof(global::TUnit.TestProject.BeforeTests.Base2), static _ => new global::System.Collections.Concurrent.ConcurrentBag()); + global::TUnit.Core.Sources.BeforeTestHooks[typeof(global::TUnit.TestProject.BeforeTests.Base2)].Add( + 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", static () => + { + var classMetadata = 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", static () => new global::TUnit.Core.AssemblyMetadata { Name = "TestsBase`1" }), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }; + return classMetadata; + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), + Body = global_TUnit_TestProject_BeforeTests_Base2_BeforeEach2_0Params_Body + } + ); + } + private static async ValueTask global_TUnit_TestProject_BeforeTests_Base2_BeforeEach2_0Params_Body(object instance, TestContext context, CancellationToken cancellationToken) + { + var typedInstance = (global::TUnit.TestProject.BeforeTests.Base2)instance; + await AsyncConvert.Convert(() => typedInstance.BeforeEach2()); + } +} + + +// ===== 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_BeforeAll3_Before_Class; +internal static class TUnit_TestProject_BeforeTests_Base3_BeforeAll3_Before_ClassInitializer +{ + [global::System.Runtime.CompilerServices.ModuleInitializer] + public static void Initialize() + { + global::TUnit.Core.Sources.BeforeClassHooks.GetOrAdd(typeof(global::TUnit.TestProject.BeforeTests.Base3), static _ => new global::System.Collections.Concurrent.ConcurrentBag()); + global::TUnit.Core.Sources.BeforeClassHooks[typeof(global::TUnit.TestProject.BeforeTests.Base3)].Add( + 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", static () => + { + var classMetadata = 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", static () => new global::TUnit.Core.AssemblyMetadata { Name = "TestsBase`1" }), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }; + return classMetadata; + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = global::TUnit.Core.HookRegistrationIndices.GetNextBeforeClassHookIndex(), + Body = global_TUnit_TestProject_BeforeTests_Base3_BeforeAll3_0Params_Body, + FilePath = @"", + LineNumber = 35 + } + ); + } + private static async ValueTask global_TUnit_TestProject_BeforeTests_Base3_BeforeAll3_0Params_Body(ClassHookContext context, CancellationToken cancellationToken) + { + await AsyncConvert.Convert(() => global::TUnit.TestProject.BeforeTests.Base3.BeforeAll3()); + } +} + + +// ===== 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 +{ + [global::System.Runtime.CompilerServices.ModuleInitializer] + public static void Initialize() + { + global::TUnit.Core.Sources.BeforeTestHooks.GetOrAdd(typeof(global::TUnit.TestProject.BeforeTests.Base3), static _ => new global::System.Collections.Concurrent.ConcurrentBag()); + global::TUnit.Core.Sources.BeforeTestHooks[typeof(global::TUnit.TestProject.BeforeTests.Base3)].Add( + 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", static () => + { + var classMetadata = 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", static () => new global::TUnit.Core.AssemblyMetadata { Name = "TestsBase`1" }), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }; + return classMetadata; + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), + Body = global_TUnit_TestProject_BeforeTests_Base3_BeforeEach3_0Params_Body + } + ); + } + private static async ValueTask global_TUnit_TestProject_BeforeTests_Base3_BeforeEach3_0Params_Body(object instance, TestContext context, CancellationToken cancellationToken) + { + var typedInstance = (global::TUnit.TestProject.BeforeTests.Base3)instance; + await AsyncConvert.Convert(() => typedInstance.BeforeEach3()); + } +} + + +// ===== 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_Before_Class; +internal static class TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp_Before_ClassInitializer +{ + [global::System.Runtime.CompilerServices.ModuleInitializer] + public static void Initialize() + { + global::TUnit.Core.Sources.BeforeClassHooks.GetOrAdd(typeof(global::TUnit.TestProject.BeforeTests.SetupTests), static _ => new global::System.Collections.Concurrent.ConcurrentBag()); + global::TUnit.Core.Sources.BeforeClassHooks[typeof(global::TUnit.TestProject.BeforeTests.SetupTests)].Add( + 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", static () => + { + var classMetadata = 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", static () => new global::TUnit.Core.AssemblyMetadata { Name = "TestsBase`1" }), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }; + return classMetadata; + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = global::TUnit.Core.HookRegistrationIndices.GetNextBeforeClassHookIndex(), + Body = global_TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp_0Params_Body, + FilePath = @"", + LineNumber = 50 + } + ); + } + private static async ValueTask global_TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp_0Params_Body(ClassHookContext context, CancellationToken cancellationToken) + { + await AsyncConvert.Convert(() => global::TUnit.TestProject.BeforeTests.SetupTests.BeforeAllSetUp()); + } +} + + +// ===== 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 +{ + [global::System.Runtime.CompilerServices.ModuleInitializer] + public static void Initialize() + { + global::TUnit.Core.Sources.BeforeClassHooks.GetOrAdd(typeof(global::TUnit.TestProject.BeforeTests.SetupTests), static _ => new global::System.Collections.Concurrent.ConcurrentBag()); + global::TUnit.Core.Sources.BeforeClassHooks[typeof(global::TUnit.TestProject.BeforeTests.SetupTests)].Add( + 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[] + { + new global::TUnit.Core.ParameterMetadata(typeof(global::TUnit.Core.ClassHookContext)) + { + Name = "context", + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.Core.ClassHookContext)), + IsNullable = false, + ReflectionInfo = 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", static () => + { + var classMetadata = 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", static () => new global::TUnit.Core.AssemblyMetadata { Name = "TestsBase`1" }), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }; + return classMetadata; + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = global::TUnit.Core.HookRegistrationIndices.GetNextBeforeClassHookIndex(), + Body = global_TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext_1Params_Body, + FilePath = @"", + LineNumber = 56 + } + ); + } + private static async ValueTask global_TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext_1Params_Body(ClassHookContext context, CancellationToken cancellationToken) + { + await AsyncConvert.Convert(() => global::TUnit.TestProject.BeforeTests.SetupTests.BeforeAllSetUpWithContext(context)); + } +} + + +// ===== 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 +{ + [global::System.Runtime.CompilerServices.ModuleInitializer] + public static void Initialize() + { + global::TUnit.Core.Sources.BeforeClassHooks.GetOrAdd(typeof(global::TUnit.TestProject.BeforeTests.SetupTests), static _ => new global::System.Collections.Concurrent.ConcurrentBag()); + global::TUnit.Core.Sources.BeforeClassHooks[typeof(global::TUnit.TestProject.BeforeTests.SetupTests)].Add( + 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[] + { + new global::TUnit.Core.ParameterMetadata(typeof(global::System.Threading.CancellationToken)) + { + Name = "cancellationToken", + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.CancellationToken)), + IsNullable = false, + ReflectionInfo = 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", static () => + { + var classMetadata = 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", static () => new global::TUnit.Core.AssemblyMetadata { Name = "TestsBase`1" }), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }; + return classMetadata; + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = global::TUnit.Core.HookRegistrationIndices.GetNextBeforeClassHookIndex(), + Body = global_TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp_1Params_Body, + FilePath = @"", + LineNumber = 62 + } + ); + } + private static async ValueTask global_TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUp_1Params_Body(ClassHookContext context, CancellationToken cancellationToken) + { + await AsyncConvert.Convert(() => global::TUnit.TestProject.BeforeTests.SetupTests.BeforeAllSetUp(cancellationToken)); + } +} + + +// ===== 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 +{ + [global::System.Runtime.CompilerServices.ModuleInitializer] + public static void Initialize() + { + global::TUnit.Core.Sources.BeforeClassHooks.GetOrAdd(typeof(global::TUnit.TestProject.BeforeTests.SetupTests), static _ => new global::System.Collections.Concurrent.ConcurrentBag()); + global::TUnit.Core.Sources.BeforeClassHooks[typeof(global::TUnit.TestProject.BeforeTests.SetupTests)].Add( + 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[] + { + new global::TUnit.Core.ParameterMetadata(typeof(global::TUnit.Core.ClassHookContext)) + { + Name = "context", + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.Core.ClassHookContext)), + IsNullable = false, + ReflectionInfo = 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] + }, + new global::TUnit.Core.ParameterMetadata(typeof(global::System.Threading.CancellationToken)) + { + Name = "cancellationToken", + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.CancellationToken)), + IsNullable = false, + ReflectionInfo = 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", static () => + { + var classMetadata = 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", static () => new global::TUnit.Core.AssemblyMetadata { Name = "TestsBase`1" }), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }; + return classMetadata; + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = global::TUnit.Core.HookRegistrationIndices.GetNextBeforeClassHookIndex(), + Body = global_TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext_2Params_Body, + FilePath = @"", + LineNumber = 68 + } + ); + } + private static async ValueTask global_TUnit_TestProject_BeforeTests_SetupTests_BeforeAllSetUpWithContext_2Params_Body(ClassHookContext context, CancellationToken cancellationToken) + { + await AsyncConvert.Convert(() => global::TUnit.TestProject.BeforeTests.SetupTests.BeforeAllSetUpWithContext(context, cancellationToken)); + } +} + + +// ===== 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 +{ + [global::System.Runtime.CompilerServices.ModuleInitializer] + public static void Initialize() + { + global::TUnit.Core.Sources.BeforeTestHooks.GetOrAdd(typeof(global::TUnit.TestProject.BeforeTests.SetupTests), static _ => new global::System.Collections.Concurrent.ConcurrentBag()); + global::TUnit.Core.Sources.BeforeTestHooks[typeof(global::TUnit.TestProject.BeforeTests.SetupTests)].Add( + 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", static () => + { + var classMetadata = 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", static () => new global::TUnit.Core.AssemblyMetadata { Name = "TestsBase`1" }), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }; + return classMetadata; + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), + Body = global_TUnit_TestProject_BeforeTests_SetupTests_Setup_0Params_Body + } + ); + } + private static async ValueTask global_TUnit_TestProject_BeforeTests_SetupTests_Setup_0Params_Body(object instance, TestContext context, CancellationToken cancellationToken) + { + var typedInstance = (global::TUnit.TestProject.BeforeTests.SetupTests)instance; + await AsyncConvert.Convert(() => typedInstance.Setup()); + } +} + + +// ===== 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 +{ + [global::System.Runtime.CompilerServices.ModuleInitializer] + public static void Initialize() + { + global::TUnit.Core.Sources.BeforeTestHooks.GetOrAdd(typeof(global::TUnit.TestProject.BeforeTests.SetupTests), static _ => new global::System.Collections.Concurrent.ConcurrentBag()); + global::TUnit.Core.Sources.BeforeTestHooks[typeof(global::TUnit.TestProject.BeforeTests.SetupTests)].Add( + 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[] + { + new global::TUnit.Core.ParameterMetadata(typeof(global::System.Threading.CancellationToken)) + { + Name = "cancellationToken", + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.CancellationToken)), + IsNullable = false, + ReflectionInfo = 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", static () => + { + var classMetadata = 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", static () => new global::TUnit.Core.AssemblyMetadata { Name = "TestsBase`1" }), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }; + return classMetadata; + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), + Body = global_TUnit_TestProject_BeforeTests_SetupTests_Setup_1Params_Body + } + ); + } + private static async ValueTask global_TUnit_TestProject_BeforeTests_SetupTests_Setup_1Params_Body(object instance, TestContext context, CancellationToken cancellationToken) + { + var typedInstance = (global::TUnit.TestProject.BeforeTests.SetupTests)instance; + await AsyncConvert.Convert(() => typedInstance.Setup(cancellationToken)); + } +} + + +// ===== 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 +{ + [global::System.Runtime.CompilerServices.ModuleInitializer] + public static void Initialize() + { + global::TUnit.Core.Sources.BeforeTestHooks.GetOrAdd(typeof(global::TUnit.TestProject.BeforeTests.SetupTests), static _ => new global::System.Collections.Concurrent.ConcurrentBag()); + global::TUnit.Core.Sources.BeforeTestHooks[typeof(global::TUnit.TestProject.BeforeTests.SetupTests)].Add( + 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[] + { + new global::TUnit.Core.ParameterMetadata(typeof(global::TUnit.Core.TestContext)) + { + Name = "testContext", + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.Core.TestContext)), + IsNullable = false, + ReflectionInfo = 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", static () => + { + var classMetadata = 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", static () => new global::TUnit.Core.AssemblyMetadata { Name = "TestsBase`1" }), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }; + return classMetadata; + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), + Body = global_TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext_1Params_Body + } + ); + } + private static async ValueTask global_TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext_1Params_Body(object instance, TestContext context, CancellationToken cancellationToken) + { + var typedInstance = (global::TUnit.TestProject.BeforeTests.SetupTests)instance; + await AsyncConvert.Convert(() => typedInstance.SetupWithContext(context)); + } +} + + +// ===== 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 +{ + [global::System.Runtime.CompilerServices.ModuleInitializer] + public static void Initialize() + { + global::TUnit.Core.Sources.BeforeTestHooks.GetOrAdd(typeof(global::TUnit.TestProject.BeforeTests.SetupTests), static _ => new global::System.Collections.Concurrent.ConcurrentBag()); + global::TUnit.Core.Sources.BeforeTestHooks[typeof(global::TUnit.TestProject.BeforeTests.SetupTests)].Add( + 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[] + { + new global::TUnit.Core.ParameterMetadata(typeof(global::TUnit.Core.TestContext)) + { + Name = "testContext", + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.Core.TestContext)), + IsNullable = false, + ReflectionInfo = 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] + }, + new global::TUnit.Core.ParameterMetadata(typeof(global::System.Threading.CancellationToken)) + { + Name = "cancellationToken", + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.CancellationToken)), + IsNullable = false, + ReflectionInfo = 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", static () => + { + var classMetadata = 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", static () => new global::TUnit.Core.AssemblyMetadata { Name = "TestsBase`1" }), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }; + return classMetadata; + }) + }, + HookExecutor = DefaultExecutor.Instance, + Order = 0, + RegistrationIndex = global::TUnit.Core.HookRegistrationIndices.GetNextBeforeTestHookIndex(), + Body = global_TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext_2Params_Body + } + ); + } + private static async ValueTask global_TUnit_TestProject_BeforeTests_SetupTests_SetupWithContext_2Params_Body(object instance, TestContext context, CancellationToken cancellationToken) + { + var typedInstance = (global::TUnit.TestProject.BeforeTests.SetupTests)instance; + await AsyncConvert.Convert(() => typedInstance.SetupWithContext(context, cancellationToken)); + } +} diff --git a/TUnit.Core.SourceGenerator.Tests/ConflictingNamespaceTests.MatrixTest_WithConflictingNamespace.Net4_7.verified.txt b/TUnit.Core.SourceGenerator.Tests/ConflictingNamespaceTests.MatrixTest_WithConflictingNamespace.Net4_7.verified.txt new file mode 100644 index 0000000000..47f3403a77 --- /dev/null +++ b/TUnit.Core.SourceGenerator.Tests/ConflictingNamespaceTests.MatrixTest_WithConflictingNamespace.Net4_7.verified.txt @@ -0,0 +1,1650 @@ +// +#pragma warning disable + +#nullable enable +namespace TUnit.Generated; +internal sealed class TUnit_TestProject_MatrixTests_MatrixTest_One__string_int_bool_TestSource : global::TUnit.Core.Interfaces.SourceGenerator.ITestSource, global::TUnit.Core.Interfaces.SourceGenerator.ITestDescriptorSource +{ + public async global::System.Collections.Generic.IAsyncEnumerable GetTestsAsync(string testSessionId, [global::System.Runtime.CompilerServices.EnumeratorCancellation] global::System.Threading.CancellationToken cancellationToken = default) + { + var metadata = new global::TUnit.Core.TestMetadata + { + TestName = "MatrixTest_One", + TestClassType = typeof(global::TUnit.TestProject.MatrixTests), + TestMethodName = "MatrixTest_One", + Dependencies = global::System.Array.Empty(), + AttributeFactory = static () => + [ + new global::TUnit.Core.TestAttribute(), + new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass) + ], + DataSources = new global::TUnit.Core.IDataSourceAttribute[] + { + new global::TUnit.Core.MatrixDataSourceAttribute(), + }, + ClassDataSources = global::System.Array.Empty(), + PropertyDataSources = global::System.Array.Empty(), + PropertyInjections = global::System.Array.Empty(), + InheritanceDepth = 0, + FilePath = @"", + LineNumber = 9, + MethodMetadata = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.MatrixTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.MatrixTests)), + Name = "MatrixTest_One", + 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[] + { + new global::TUnit.Core.ParameterMetadata(typeof(string)) + { + Name = "str", + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(string)), + IsNullable = false, + ReflectionInfo = typeof(global::TUnit.TestProject.MatrixTests).GetMethod("MatrixTest_One", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(string), typeof(int), typeof(bool) }, null)!.GetParameters()[0] + }, + new global::TUnit.Core.ParameterMetadata(typeof(int)) + { + Name = "i", + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(int)), + IsNullable = false, + ReflectionInfo = typeof(global::TUnit.TestProject.MatrixTests).GetMethod("MatrixTest_One", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(string), typeof(int), typeof(bool) }, null)!.GetParameters()[1] + }, + new global::TUnit.Core.ParameterMetadata(typeof(bool)) + { + Name = "boolean", + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(bool)), + IsNullable = false, + ReflectionInfo = typeof(global::TUnit.TestProject.MatrixTests).GetMethod("MatrixTest_One", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(string), typeof(int), typeof(bool) }, null)!.GetParameters()[2] + } + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.MatrixTests", static () => + { + var classMetadata = new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.MatrixTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.MatrixTests)), + Name = "MatrixTests", + Namespace = "TUnit.TestProject", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", static () => new global::TUnit.Core.AssemblyMetadata { Name = "TestsBase`1" }), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }; + return classMetadata; + }) + }, + InstanceFactory = (typeArgs, args) => new global::TUnit.TestProject.MatrixTests(), + InvokeTypedTest = static (instance, args, cancellationToken) => + { + try + { + switch (args.Length) + { + case 3: + { + return new global::System.Threading.Tasks.ValueTask(instance.MatrixTest_One(global::TUnit.Core.Helpers.CastHelper.Cast(args[0]), global::TUnit.Core.Helpers.CastHelper.Cast(args[1]), global::TUnit.Core.Helpers.CastHelper.Cast(args[2]))); + } + default: + throw new global::System.ArgumentException($"Expected exactly 3 arguments, but got {args.Length}"); + } + } + catch (global::System.Exception ex) + { + return new global::System.Threading.Tasks.ValueTask(global::System.Threading.Tasks.Task.FromException(ex)); + } + }, + }; + metadata.UseRuntimeDataGeneration(testSessionId); + yield return metadata; + yield break; + } + public global::System.Collections.Generic.IEnumerable EnumerateTestDescriptors() + { + yield return new global::TUnit.Core.TestDescriptor + { + TestId = "TUnit.TestProject.MatrixTests.MatrixTest_One", + ClassName = "MatrixTests", + MethodName = "MatrixTest_One", + FullyQualifiedName = "TUnit.TestProject.MatrixTests.MatrixTest_One", + FilePath = @"", + LineNumber = 9, + Categories = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + HasDataSource = true, + RepeatCount = 0, + DependsOn = global::System.Array.Empty(), + Materializer = GetTestsAsync + }; + } +} +internal static class TUnit_TestProject_MatrixTests_MatrixTest_One__string_int_bool_ModuleInitializer +{ + [global::System.Runtime.CompilerServices.ModuleInitializer] + public static void Initialize() + { + global::TUnit.Core.SourceRegistrar.Register(typeof(global::TUnit.TestProject.MatrixTests), new TUnit_TestProject_MatrixTests_MatrixTest_One__string_int_bool_TestSource()); + } +} + + +// ===== FILE SEPARATOR ===== + +// +#pragma warning disable + +#nullable enable +namespace TUnit.Generated; +internal sealed class TUnit_TestProject_MatrixTests_MatrixTest_Two__int_int_int_bool_TestSource : global::TUnit.Core.Interfaces.SourceGenerator.ITestSource, global::TUnit.Core.Interfaces.SourceGenerator.ITestDescriptorSource +{ + public async global::System.Collections.Generic.IAsyncEnumerable GetTestsAsync(string testSessionId, [global::System.Runtime.CompilerServices.EnumeratorCancellation] global::System.Threading.CancellationToken cancellationToken = default) + { + var metadata = new global::TUnit.Core.TestMetadata + { + TestName = "MatrixTest_Two", + TestClassType = typeof(global::TUnit.TestProject.MatrixTests), + TestMethodName = "MatrixTest_Two", + Dependencies = global::System.Array.Empty(), + AttributeFactory = static () => + [ + new global::TUnit.Core.TestAttribute(), + new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass) + ], + DataSources = new global::TUnit.Core.IDataSourceAttribute[] + { + new global::TUnit.Core.MatrixDataSourceAttribute(), + }, + ClassDataSources = global::System.Array.Empty(), + PropertyDataSources = global::System.Array.Empty(), + PropertyInjections = global::System.Array.Empty(), + InheritanceDepth = 0, + FilePath = @"", + LineNumber = 19, + MethodMetadata = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.MatrixTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.MatrixTests)), + Name = "MatrixTest_Two", + 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[] + { + new global::TUnit.Core.ParameterMetadata(typeof(int)) + { + Name = "i", + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(int)), + IsNullable = false, + ReflectionInfo = typeof(global::TUnit.TestProject.MatrixTests).GetMethod("MatrixTest_Two", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(int), typeof(int), typeof(int), typeof(bool) }, null)!.GetParameters()[0] + }, + new global::TUnit.Core.ParameterMetadata(typeof(int)) + { + Name = "i2", + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(int)), + IsNullable = false, + ReflectionInfo = typeof(global::TUnit.TestProject.MatrixTests).GetMethod("MatrixTest_Two", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(int), typeof(int), typeof(int), typeof(bool) }, null)!.GetParameters()[1] + }, + new global::TUnit.Core.ParameterMetadata(typeof(int)) + { + Name = "i3", + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(int)), + IsNullable = false, + ReflectionInfo = typeof(global::TUnit.TestProject.MatrixTests).GetMethod("MatrixTest_Two", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(int), typeof(int), typeof(int), typeof(bool) }, null)!.GetParameters()[2] + }, + new global::TUnit.Core.ParameterMetadata(typeof(bool)) + { + Name = "boolean", + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(bool)), + IsNullable = false, + ReflectionInfo = typeof(global::TUnit.TestProject.MatrixTests).GetMethod("MatrixTest_Two", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(int), typeof(int), typeof(int), typeof(bool) }, null)!.GetParameters()[3] + } + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.MatrixTests", static () => + { + var classMetadata = new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.MatrixTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.MatrixTests)), + Name = "MatrixTests", + Namespace = "TUnit.TestProject", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", static () => new global::TUnit.Core.AssemblyMetadata { Name = "TestsBase`1" }), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }; + return classMetadata; + }) + }, + InstanceFactory = (typeArgs, args) => new global::TUnit.TestProject.MatrixTests(), + InvokeTypedTest = static (instance, args, cancellationToken) => + { + try + { + switch (args.Length) + { + case 4: + { + return new global::System.Threading.Tasks.ValueTask(instance.MatrixTest_Two(global::TUnit.Core.Helpers.CastHelper.Cast(args[0]), global::TUnit.Core.Helpers.CastHelper.Cast(args[1]), global::TUnit.Core.Helpers.CastHelper.Cast(args[2]), global::TUnit.Core.Helpers.CastHelper.Cast(args[3]))); + } + default: + throw new global::System.ArgumentException($"Expected exactly 4 arguments, but got {args.Length}"); + } + } + catch (global::System.Exception ex) + { + return new global::System.Threading.Tasks.ValueTask(global::System.Threading.Tasks.Task.FromException(ex)); + } + }, + }; + metadata.UseRuntimeDataGeneration(testSessionId); + yield return metadata; + yield break; + } + public global::System.Collections.Generic.IEnumerable EnumerateTestDescriptors() + { + yield return new global::TUnit.Core.TestDescriptor + { + TestId = "TUnit.TestProject.MatrixTests.MatrixTest_Two", + ClassName = "MatrixTests", + MethodName = "MatrixTest_Two", + FullyQualifiedName = "TUnit.TestProject.MatrixTests.MatrixTest_Two", + FilePath = @"", + LineNumber = 19, + Categories = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + HasDataSource = true, + RepeatCount = 0, + DependsOn = global::System.Array.Empty(), + Materializer = GetTestsAsync + }; + } +} +internal static class TUnit_TestProject_MatrixTests_MatrixTest_Two__int_int_int_bool_ModuleInitializer +{ + [global::System.Runtime.CompilerServices.ModuleInitializer] + public static void Initialize() + { + global::TUnit.Core.SourceRegistrar.Register(typeof(global::TUnit.TestProject.MatrixTests), new TUnit_TestProject_MatrixTests_MatrixTest_Two__int_int_int_bool_TestSource()); + } +} + + +// ===== FILE SEPARATOR ===== + +// +#pragma warning disable + +#nullable enable +namespace TUnit.Generated; +internal sealed class TUnit_TestProject_MatrixTests_MatrixTest_Enum__int_TestEnum_TestEnum__TestSource : global::TUnit.Core.Interfaces.SourceGenerator.ITestSource, global::TUnit.Core.Interfaces.SourceGenerator.ITestDescriptorSource +{ + public async global::System.Collections.Generic.IAsyncEnumerable GetTestsAsync(string testSessionId, [global::System.Runtime.CompilerServices.EnumeratorCancellation] global::System.Threading.CancellationToken cancellationToken = default) + { + var metadata = new global::TUnit.Core.TestMetadata + { + TestName = "MatrixTest_Enum", + TestClassType = typeof(global::TUnit.TestProject.MatrixTests), + TestMethodName = "MatrixTest_Enum", + Dependencies = global::System.Array.Empty(), + AttributeFactory = static () => + [ + new global::TUnit.Core.TestAttribute(), + new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass) + ], + DataSources = new global::TUnit.Core.IDataSourceAttribute[] + { + new global::TUnit.Core.MatrixDataSourceAttribute(), + }, + ClassDataSources = global::System.Array.Empty(), + PropertyDataSources = global::System.Array.Empty(), + PropertyInjections = global::System.Array.Empty(), + InheritanceDepth = 0, + FilePath = @"", + LineNumber = 30, + MethodMetadata = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.MatrixTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.MatrixTests)), + Name = "MatrixTest_Enum", + 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[] + { + new global::TUnit.Core.ParameterMetadata(typeof(int)) + { + Name = "i", + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(int)), + IsNullable = false, + ReflectionInfo = typeof(global::TUnit.TestProject.MatrixTests).GetMethod("MatrixTest_Enum", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(int), typeof(TestEnum), typeof(TestEnum?) }, null)!.GetParameters()[0] + }, + new global::TUnit.Core.ParameterMetadata(typeof(TestEnum)) + { + Name = "testEnum", + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(TestEnum)), + IsNullable = false, + ReflectionInfo = typeof(global::TUnit.TestProject.MatrixTests).GetMethod("MatrixTest_Enum", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(int), typeof(TestEnum), typeof(TestEnum?) }, null)!.GetParameters()[1] + }, + new global::TUnit.Core.ParameterMetadata(typeof(TestEnum?)) + { + Name = "testEnum2", + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(TestEnum?)), + IsNullable = true, + ReflectionInfo = typeof(global::TUnit.TestProject.MatrixTests).GetMethod("MatrixTest_Enum", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(int), typeof(TestEnum), typeof(TestEnum?) }, null)!.GetParameters()[2] + } + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.MatrixTests", static () => + { + var classMetadata = new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.MatrixTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.MatrixTests)), + Name = "MatrixTests", + Namespace = "TUnit.TestProject", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", static () => new global::TUnit.Core.AssemblyMetadata { Name = "TestsBase`1" }), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }; + return classMetadata; + }) + }, + InstanceFactory = (typeArgs, args) => new global::TUnit.TestProject.MatrixTests(), + InvokeTypedTest = static (instance, args, cancellationToken) => + { + try + { + switch (args.Length) + { + case 3: + { + return new global::System.Threading.Tasks.ValueTask(instance.MatrixTest_Enum(global::TUnit.Core.Helpers.CastHelper.Cast(args[0]), global::TUnit.Core.Helpers.CastHelper.Cast(args[1]), global::TUnit.Core.Helpers.CastHelper.Cast(args[2]))); + } + default: + throw new global::System.ArgumentException($"Expected exactly 3 arguments, but got {args.Length}"); + } + } + catch (global::System.Exception ex) + { + return new global::System.Threading.Tasks.ValueTask(global::System.Threading.Tasks.Task.FromException(ex)); + } + }, + }; + metadata.UseRuntimeDataGeneration(testSessionId); + yield return metadata; + yield break; + } + public global::System.Collections.Generic.IEnumerable EnumerateTestDescriptors() + { + yield return new global::TUnit.Core.TestDescriptor + { + TestId = "TUnit.TestProject.MatrixTests.MatrixTest_Enum", + ClassName = "MatrixTests", + MethodName = "MatrixTest_Enum", + FullyQualifiedName = "TUnit.TestProject.MatrixTests.MatrixTest_Enum", + FilePath = @"", + LineNumber = 30, + Categories = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + HasDataSource = true, + RepeatCount = 0, + DependsOn = global::System.Array.Empty(), + Materializer = GetTestsAsync + }; + } +} +internal static class TUnit_TestProject_MatrixTests_MatrixTest_Enum__int_TestEnum_TestEnum__ModuleInitializer +{ + [global::System.Runtime.CompilerServices.ModuleInitializer] + public static void Initialize() + { + global::TUnit.Core.SourceRegistrar.Register(typeof(global::TUnit.TestProject.MatrixTests), new TUnit_TestProject_MatrixTests_MatrixTest_Enum__int_TestEnum_TestEnum__TestSource()); + } +} + + +// ===== FILE SEPARATOR ===== + +// +#pragma warning disable + +#nullable enable +namespace TUnit.Generated; +internal sealed class TUnit_TestProject_MatrixTests_AutoGenerateBools__string_bool_TestSource : global::TUnit.Core.Interfaces.SourceGenerator.ITestSource, global::TUnit.Core.Interfaces.SourceGenerator.ITestDescriptorSource +{ + public async global::System.Collections.Generic.IAsyncEnumerable GetTestsAsync(string testSessionId, [global::System.Runtime.CompilerServices.EnumeratorCancellation] global::System.Threading.CancellationToken cancellationToken = default) + { + var metadata = new global::TUnit.Core.TestMetadata + { + TestName = "AutoGenerateBools", + TestClassType = typeof(global::TUnit.TestProject.MatrixTests), + TestMethodName = "AutoGenerateBools", + Dependencies = global::System.Array.Empty(), + AttributeFactory = static () => + [ + new global::TUnit.Core.TestAttribute(), + new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass) + ], + DataSources = new global::TUnit.Core.IDataSourceAttribute[] + { + new global::TUnit.Core.MatrixDataSourceAttribute(), + }, + ClassDataSources = global::System.Array.Empty(), + PropertyDataSources = global::System.Array.Empty(), + PropertyInjections = global::System.Array.Empty(), + InheritanceDepth = 0, + FilePath = @"", + LineNumber = 40, + MethodMetadata = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.MatrixTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.MatrixTests)), + Name = "AutoGenerateBools", + 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[] + { + new global::TUnit.Core.ParameterMetadata(typeof(string)) + { + Name = "str", + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(string)), + IsNullable = false, + ReflectionInfo = typeof(global::TUnit.TestProject.MatrixTests).GetMethod("AutoGenerateBools", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(string), typeof(bool) }, null)!.GetParameters()[0] + }, + new global::TUnit.Core.ParameterMetadata(typeof(bool)) + { + Name = "boolean", + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(bool)), + IsNullable = false, + ReflectionInfo = typeof(global::TUnit.TestProject.MatrixTests).GetMethod("AutoGenerateBools", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(string), typeof(bool) }, null)!.GetParameters()[1] + } + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.MatrixTests", static () => + { + var classMetadata = new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.MatrixTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.MatrixTests)), + Name = "MatrixTests", + Namespace = "TUnit.TestProject", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", static () => new global::TUnit.Core.AssemblyMetadata { Name = "TestsBase`1" }), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }; + return classMetadata; + }) + }, + InstanceFactory = (typeArgs, args) => new global::TUnit.TestProject.MatrixTests(), + InvokeTypedTest = static (instance, args, cancellationToken) => + { + try + { + switch (args.Length) + { + case 2: + { + return new global::System.Threading.Tasks.ValueTask(instance.AutoGenerateBools(global::TUnit.Core.Helpers.CastHelper.Cast(args[0]), global::TUnit.Core.Helpers.CastHelper.Cast(args[1]))); + } + default: + throw new global::System.ArgumentException($"Expected exactly 2 arguments, but got {args.Length}"); + } + } + catch (global::System.Exception ex) + { + return new global::System.Threading.Tasks.ValueTask(global::System.Threading.Tasks.Task.FromException(ex)); + } + }, + }; + metadata.UseRuntimeDataGeneration(testSessionId); + yield return metadata; + yield break; + } + public global::System.Collections.Generic.IEnumerable EnumerateTestDescriptors() + { + yield return new global::TUnit.Core.TestDescriptor + { + TestId = "TUnit.TestProject.MatrixTests.AutoGenerateBools", + ClassName = "MatrixTests", + MethodName = "AutoGenerateBools", + FullyQualifiedName = "TUnit.TestProject.MatrixTests.AutoGenerateBools", + FilePath = @"", + LineNumber = 40, + Categories = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + HasDataSource = true, + RepeatCount = 0, + DependsOn = global::System.Array.Empty(), + Materializer = GetTestsAsync + }; + } +} +internal static class TUnit_TestProject_MatrixTests_AutoGenerateBools__string_bool_ModuleInitializer +{ + [global::System.Runtime.CompilerServices.ModuleInitializer] + public static void Initialize() + { + global::TUnit.Core.SourceRegistrar.Register(typeof(global::TUnit.TestProject.MatrixTests), new TUnit_TestProject_MatrixTests_AutoGenerateBools__string_bool_TestSource()); + } +} + + +// ===== FILE SEPARATOR ===== + +// +#pragma warning disable + +#nullable enable +namespace TUnit.Generated; +internal sealed class TUnit_TestProject_MatrixTests_AutoGenerateBools2__string_bool__TestSource : global::TUnit.Core.Interfaces.SourceGenerator.ITestSource, global::TUnit.Core.Interfaces.SourceGenerator.ITestDescriptorSource +{ + public async global::System.Collections.Generic.IAsyncEnumerable GetTestsAsync(string testSessionId, [global::System.Runtime.CompilerServices.EnumeratorCancellation] global::System.Threading.CancellationToken cancellationToken = default) + { + var metadata = new global::TUnit.Core.TestMetadata + { + TestName = "AutoGenerateBools2", + TestClassType = typeof(global::TUnit.TestProject.MatrixTests), + TestMethodName = "AutoGenerateBools2", + Dependencies = global::System.Array.Empty(), + AttributeFactory = static () => + [ + new global::TUnit.Core.TestAttribute(), + new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass) + ], + DataSources = new global::TUnit.Core.IDataSourceAttribute[] + { + new global::TUnit.Core.MatrixDataSourceAttribute(), + }, + ClassDataSources = global::System.Array.Empty(), + PropertyDataSources = global::System.Array.Empty(), + PropertyInjections = global::System.Array.Empty(), + InheritanceDepth = 0, + FilePath = @"", + LineNumber = 49, + MethodMetadata = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.MatrixTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.MatrixTests)), + Name = "AutoGenerateBools2", + 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[] + { + new global::TUnit.Core.ParameterMetadata(typeof(string)) + { + Name = "str", + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(string)), + IsNullable = false, + ReflectionInfo = typeof(global::TUnit.TestProject.MatrixTests).GetMethod("AutoGenerateBools2", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(string), typeof(bool?) }, null)!.GetParameters()[0] + }, + new global::TUnit.Core.ParameterMetadata(typeof(bool?)) + { + Name = "boolean", + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(bool?)), + IsNullable = true, + ReflectionInfo = typeof(global::TUnit.TestProject.MatrixTests).GetMethod("AutoGenerateBools2", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(string), typeof(bool?) }, null)!.GetParameters()[1] + } + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.MatrixTests", static () => + { + var classMetadata = new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.MatrixTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.MatrixTests)), + Name = "MatrixTests", + Namespace = "TUnit.TestProject", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", static () => new global::TUnit.Core.AssemblyMetadata { Name = "TestsBase`1" }), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }; + return classMetadata; + }) + }, + InstanceFactory = (typeArgs, args) => new global::TUnit.TestProject.MatrixTests(), + InvokeTypedTest = static (instance, args, cancellationToken) => + { + try + { + switch (args.Length) + { + case 2: + { + return new global::System.Threading.Tasks.ValueTask(instance.AutoGenerateBools2(global::TUnit.Core.Helpers.CastHelper.Cast(args[0]), global::TUnit.Core.Helpers.CastHelper.Cast(args[1]))); + } + default: + throw new global::System.ArgumentException($"Expected exactly 2 arguments, but got {args.Length}"); + } + } + catch (global::System.Exception ex) + { + return new global::System.Threading.Tasks.ValueTask(global::System.Threading.Tasks.Task.FromException(ex)); + } + }, + }; + metadata.UseRuntimeDataGeneration(testSessionId); + yield return metadata; + yield break; + } + public global::System.Collections.Generic.IEnumerable EnumerateTestDescriptors() + { + yield return new global::TUnit.Core.TestDescriptor + { + TestId = "TUnit.TestProject.MatrixTests.AutoGenerateBools2", + ClassName = "MatrixTests", + MethodName = "AutoGenerateBools2", + FullyQualifiedName = "TUnit.TestProject.MatrixTests.AutoGenerateBools2", + FilePath = @"", + LineNumber = 49, + Categories = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + HasDataSource = true, + RepeatCount = 0, + DependsOn = global::System.Array.Empty(), + Materializer = GetTestsAsync + }; + } +} +internal static class TUnit_TestProject_MatrixTests_AutoGenerateBools2__string_bool__ModuleInitializer +{ + [global::System.Runtime.CompilerServices.ModuleInitializer] + public static void Initialize() + { + global::TUnit.Core.SourceRegistrar.Register(typeof(global::TUnit.TestProject.MatrixTests), new TUnit_TestProject_MatrixTests_AutoGenerateBools2__string_bool__TestSource()); + } +} + + +// ===== FILE SEPARATOR ===== + +// +#pragma warning disable + +#nullable enable +namespace TUnit.Generated; +internal sealed class TUnit_TestProject_MatrixTests_ImplicitConversion__OneOf_TestEnum__TestEnum2__bool_TestSource : global::TUnit.Core.Interfaces.SourceGenerator.ITestSource, global::TUnit.Core.Interfaces.SourceGenerator.ITestDescriptorSource +{ + public async global::System.Collections.Generic.IAsyncEnumerable GetTestsAsync(string testSessionId, [global::System.Runtime.CompilerServices.EnumeratorCancellation] global::System.Threading.CancellationToken cancellationToken = default) + { + var metadata = new global::TUnit.Core.TestMetadata + { + TestName = "ImplicitConversion", + TestClassType = typeof(global::TUnit.TestProject.MatrixTests), + TestMethodName = "ImplicitConversion", + Dependencies = global::System.Array.Empty(), + AttributeFactory = static () => + [ + new global::TUnit.Core.TestAttribute(), + new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass) + ], + DataSources = new global::TUnit.Core.IDataSourceAttribute[] + { + new global::TUnit.Core.MatrixDataSourceAttribute(), + }, + ClassDataSources = global::System.Array.Empty(), + PropertyDataSources = global::System.Array.Empty(), + PropertyInjections = global::System.Array.Empty(), + InheritanceDepth = 0, + FilePath = @"", + LineNumber = 58, + MethodMetadata = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.MatrixTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.MatrixTests)), + Name = "ImplicitConversion", + 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[] + { + new global::TUnit.Core.ParameterMetadata(typeof(OneOf)) + { + Name = "enum", + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(OneOf)), + IsNullable = false, + ReflectionInfo = typeof(global::TUnit.TestProject.MatrixTests).GetMethod("ImplicitConversion", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(OneOf), typeof(bool) }, null)!.GetParameters()[0] + }, + new global::TUnit.Core.ParameterMetadata(typeof(bool)) + { + Name = "boolean", + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(bool)), + IsNullable = false, + ReflectionInfo = typeof(global::TUnit.TestProject.MatrixTests).GetMethod("ImplicitConversion", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(OneOf), typeof(bool) }, null)!.GetParameters()[1] + } + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.MatrixTests", static () => + { + var classMetadata = new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.MatrixTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.MatrixTests)), + Name = "MatrixTests", + Namespace = "TUnit.TestProject", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", static () => new global::TUnit.Core.AssemblyMetadata { Name = "TestsBase`1" }), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }; + return classMetadata; + }) + }, + InstanceFactory = (typeArgs, args) => new global::TUnit.TestProject.MatrixTests(), + InvokeTypedTest = static (instance, args, cancellationToken) => + { + try + { + switch (args.Length) + { + case 2: + { + return new global::System.Threading.Tasks.ValueTask(instance.ImplicitConversion(global::TUnit.Core.Helpers.CastHelper.Cast>(args[0]), global::TUnit.Core.Helpers.CastHelper.Cast(args[1]))); + } + default: + throw new global::System.ArgumentException($"Expected exactly 2 arguments, but got {args.Length}"); + } + } + catch (global::System.Exception ex) + { + return new global::System.Threading.Tasks.ValueTask(global::System.Threading.Tasks.Task.FromException(ex)); + } + }, + }; + metadata.UseRuntimeDataGeneration(testSessionId); + yield return metadata; + yield break; + } + public global::System.Collections.Generic.IEnumerable EnumerateTestDescriptors() + { + yield return new global::TUnit.Core.TestDescriptor + { + TestId = "TUnit.TestProject.MatrixTests.ImplicitConversion", + ClassName = "MatrixTests", + MethodName = "ImplicitConversion", + FullyQualifiedName = "TUnit.TestProject.MatrixTests.ImplicitConversion", + FilePath = @"", + LineNumber = 58, + Categories = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + HasDataSource = true, + RepeatCount = 0, + DependsOn = global::System.Array.Empty(), + Materializer = GetTestsAsync + }; + } +} +internal static class TUnit_TestProject_MatrixTests_ImplicitConversion__OneOf_TestEnum__TestEnum2__bool_ModuleInitializer +{ + [global::System.Runtime.CompilerServices.ModuleInitializer] + public static void Initialize() + { + global::TUnit.Core.SourceRegistrar.Register(typeof(global::TUnit.TestProject.MatrixTests), new TUnit_TestProject_MatrixTests_ImplicitConversion__OneOf_TestEnum__TestEnum2__bool_TestSource()); + } +} + + +// ===== FILE SEPARATOR ===== + +// +#pragma warning disable + +#nullable enable +namespace TUnit.Generated; +internal sealed class TUnit_TestProject_MatrixTests_ExcludingAutoGeneratedMatrixValues__CountToTenEnum_bool_TestSource : global::TUnit.Core.Interfaces.SourceGenerator.ITestSource, global::TUnit.Core.Interfaces.SourceGenerator.ITestDescriptorSource +{ + public async global::System.Collections.Generic.IAsyncEnumerable GetTestsAsync(string testSessionId, [global::System.Runtime.CompilerServices.EnumeratorCancellation] global::System.Threading.CancellationToken cancellationToken = default) + { + var metadata = new global::TUnit.Core.TestMetadata + { + TestName = "ExcludingAutoGeneratedMatrixValues", + TestClassType = typeof(global::TUnit.TestProject.MatrixTests), + TestMethodName = "ExcludingAutoGeneratedMatrixValues", + Dependencies = global::System.Array.Empty(), + AttributeFactory = static () => + [ + new global::TUnit.Core.TestAttribute(), + new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass) + ], + DataSources = new global::TUnit.Core.IDataSourceAttribute[] + { + new global::TUnit.Core.MatrixDataSourceAttribute(), + }, + ClassDataSources = global::System.Array.Empty(), + PropertyDataSources = global::System.Array.Empty(), + PropertyInjections = global::System.Array.Empty(), + InheritanceDepth = 0, + FilePath = @"", + LineNumber = 67, + MethodMetadata = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.MatrixTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.MatrixTests)), + Name = "ExcludingAutoGeneratedMatrixValues", + 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[] + { + new global::TUnit.Core.ParameterMetadata(typeof(global::TUnit.TestProject.MatrixTests.CountToTenEnum)) + { + Name = "enum", + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.MatrixTests.CountToTenEnum)), + IsNullable = false, + ReflectionInfo = typeof(global::TUnit.TestProject.MatrixTests).GetMethod("ExcludingAutoGeneratedMatrixValues", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(global::TUnit.TestProject.MatrixTests.CountToTenEnum), typeof(bool) }, null)!.GetParameters()[0] + }, + new global::TUnit.Core.ParameterMetadata(typeof(bool)) + { + Name = "boolean", + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(bool)), + IsNullable = false, + ReflectionInfo = typeof(global::TUnit.TestProject.MatrixTests).GetMethod("ExcludingAutoGeneratedMatrixValues", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(global::TUnit.TestProject.MatrixTests.CountToTenEnum), typeof(bool) }, null)!.GetParameters()[1] + } + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.MatrixTests", static () => + { + var classMetadata = new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.MatrixTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.MatrixTests)), + Name = "MatrixTests", + Namespace = "TUnit.TestProject", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", static () => new global::TUnit.Core.AssemblyMetadata { Name = "TestsBase`1" }), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }; + return classMetadata; + }) + }, + InstanceFactory = (typeArgs, args) => new global::TUnit.TestProject.MatrixTests(), + InvokeTypedTest = static (instance, args, cancellationToken) => + { + try + { + switch (args.Length) + { + case 2: + { + return new global::System.Threading.Tasks.ValueTask(instance.ExcludingAutoGeneratedMatrixValues(global::TUnit.Core.Helpers.CastHelper.Cast(args[0]), global::TUnit.Core.Helpers.CastHelper.Cast(args[1]))); + } + default: + throw new global::System.ArgumentException($"Expected exactly 2 arguments, but got {args.Length}"); + } + } + catch (global::System.Exception ex) + { + return new global::System.Threading.Tasks.ValueTask(global::System.Threading.Tasks.Task.FromException(ex)); + } + }, + }; + metadata.UseRuntimeDataGeneration(testSessionId); + yield return metadata; + yield break; + } + public global::System.Collections.Generic.IEnumerable EnumerateTestDescriptors() + { + yield return new global::TUnit.Core.TestDescriptor + { + TestId = "TUnit.TestProject.MatrixTests.ExcludingAutoGeneratedMatrixValues", + ClassName = "MatrixTests", + MethodName = "ExcludingAutoGeneratedMatrixValues", + FullyQualifiedName = "TUnit.TestProject.MatrixTests.ExcludingAutoGeneratedMatrixValues", + FilePath = @"", + LineNumber = 67, + Categories = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + HasDataSource = true, + RepeatCount = 0, + DependsOn = global::System.Array.Empty(), + Materializer = GetTestsAsync + }; + } +} +internal static class TUnit_TestProject_MatrixTests_ExcludingAutoGeneratedMatrixValues__CountToTenEnum_bool_ModuleInitializer +{ + [global::System.Runtime.CompilerServices.ModuleInitializer] + public static void Initialize() + { + global::TUnit.Core.SourceRegistrar.Register(typeof(global::TUnit.TestProject.MatrixTests), new TUnit_TestProject_MatrixTests_ExcludingAutoGeneratedMatrixValues__CountToTenEnum_bool_TestSource()); + } +} + + +// ===== FILE SEPARATOR ===== + +// +#pragma warning disable + +#nullable enable +namespace TUnit.Generated; +internal sealed class TUnit_TestProject_MatrixTests_Method1__int_TestSource : global::TUnit.Core.Interfaces.SourceGenerator.ITestSource, global::TUnit.Core.Interfaces.SourceGenerator.ITestDescriptorSource +{ + public async global::System.Collections.Generic.IAsyncEnumerable GetTestsAsync(string testSessionId, [global::System.Runtime.CompilerServices.EnumeratorCancellation] global::System.Threading.CancellationToken cancellationToken = default) + { + var metadata = new global::TUnit.Core.TestMetadata + { + TestName = "Method1", + TestClassType = typeof(global::TUnit.TestProject.MatrixTests), + TestMethodName = "Method1", + Dependencies = global::System.Array.Empty(), + AttributeFactory = static () => + [ + new global::TUnit.Core.TestAttribute(), + new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass) + ], + DataSources = new global::TUnit.Core.IDataSourceAttribute[] + { + new global::TUnit.Core.MatrixDataSourceAttribute(), + }, + ClassDataSources = global::System.Array.Empty(), + PropertyDataSources = global::System.Array.Empty(), + PropertyInjections = global::System.Array.Empty(), + InheritanceDepth = 0, + FilePath = @"", + LineNumber = 116, + MethodMetadata = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.MatrixTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.MatrixTests)), + Name = "Method1", + 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[] + { + new global::TUnit.Core.ParameterMetadata(typeof(int)) + { + Name = "item", + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(int)), + IsNullable = false, + ReflectionInfo = typeof(global::TUnit.TestProject.MatrixTests).GetMethod("Method1", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(int) }, null)!.GetParameters()[0] + } + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.MatrixTests", static () => + { + var classMetadata = new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.MatrixTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.MatrixTests)), + Name = "MatrixTests", + Namespace = "TUnit.TestProject", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", static () => new global::TUnit.Core.AssemblyMetadata { Name = "TestsBase`1" }), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }; + return classMetadata; + }) + }, + InstanceFactory = (typeArgs, args) => new global::TUnit.TestProject.MatrixTests(), + InvokeTypedTest = static (instance, args, cancellationToken) => + { + try + { + switch (args.Length) + { + case 1: + { + return new global::System.Threading.Tasks.ValueTask(instance.Method1(global::TUnit.Core.Helpers.CastHelper.Cast(args[0]))); + } + default: + throw new global::System.ArgumentException($"Expected exactly 1 argument, but got {args.Length}"); + } + } + catch (global::System.Exception ex) + { + return new global::System.Threading.Tasks.ValueTask(global::System.Threading.Tasks.Task.FromException(ex)); + } + }, + }; + metadata.UseRuntimeDataGeneration(testSessionId); + yield return metadata; + yield break; + } + public global::System.Collections.Generic.IEnumerable EnumerateTestDescriptors() + { + yield return new global::TUnit.Core.TestDescriptor + { + TestId = "TUnit.TestProject.MatrixTests.Method1", + ClassName = "MatrixTests", + MethodName = "Method1", + FullyQualifiedName = "TUnit.TestProject.MatrixTests.Method1", + FilePath = @"", + LineNumber = 116, + Categories = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + HasDataSource = true, + RepeatCount = 0, + DependsOn = global::System.Array.Empty(), + Materializer = GetTestsAsync + }; + } +} +internal static class TUnit_TestProject_MatrixTests_Method1__int_ModuleInitializer +{ + [global::System.Runtime.CompilerServices.ModuleInitializer] + public static void Initialize() + { + global::TUnit.Core.SourceRegistrar.Register(typeof(global::TUnit.TestProject.MatrixTests), new TUnit_TestProject_MatrixTests_Method1__int_TestSource()); + } +} + + +// ===== FILE SEPARATOR ===== + +// +#pragma warning disable + +#nullable enable +namespace TUnit.Generated; +internal sealed class TUnit_TestProject_MatrixTests_Method2__int_TestSource : global::TUnit.Core.Interfaces.SourceGenerator.ITestSource, global::TUnit.Core.Interfaces.SourceGenerator.ITestDescriptorSource +{ + public async global::System.Collections.Generic.IAsyncEnumerable GetTestsAsync(string testSessionId, [global::System.Runtime.CompilerServices.EnumeratorCancellation] global::System.Threading.CancellationToken cancellationToken = default) + { + var metadata = new global::TUnit.Core.TestMetadata + { + TestName = "Method2", + TestClassType = typeof(global::TUnit.TestProject.MatrixTests), + TestMethodName = "Method2", + Dependencies = global::System.Array.Empty(), + AttributeFactory = static () => + [ + new global::TUnit.Core.TestAttribute(), + new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass) + ], + DataSources = new global::TUnit.Core.IDataSourceAttribute[] + { + new global::TUnit.Core.MatrixDataSourceAttribute(), + }, + ClassDataSources = global::System.Array.Empty(), + PropertyDataSources = global::System.Array.Empty(), + PropertyInjections = global::System.Array.Empty(), + InheritanceDepth = 0, + FilePath = @"", + LineNumber = 124, + MethodMetadata = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.MatrixTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.MatrixTests)), + Name = "Method2", + 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[] + { + new global::TUnit.Core.ParameterMetadata(typeof(int)) + { + Name = "item", + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(int)), + IsNullable = false, + ReflectionInfo = typeof(global::TUnit.TestProject.MatrixTests).GetMethod("Method2", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(int) }, null)!.GetParameters()[0] + } + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.MatrixTests", static () => + { + var classMetadata = new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.MatrixTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.MatrixTests)), + Name = "MatrixTests", + Namespace = "TUnit.TestProject", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", static () => new global::TUnit.Core.AssemblyMetadata { Name = "TestsBase`1" }), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }; + return classMetadata; + }) + }, + InstanceFactory = (typeArgs, args) => new global::TUnit.TestProject.MatrixTests(), + InvokeTypedTest = static (instance, args, cancellationToken) => + { + try + { + switch (args.Length) + { + case 1: + { + return new global::System.Threading.Tasks.ValueTask(instance.Method2(global::TUnit.Core.Helpers.CastHelper.Cast(args[0]))); + } + default: + throw new global::System.ArgumentException($"Expected exactly 1 argument, but got {args.Length}"); + } + } + catch (global::System.Exception ex) + { + return new global::System.Threading.Tasks.ValueTask(global::System.Threading.Tasks.Task.FromException(ex)); + } + }, + }; + metadata.UseRuntimeDataGeneration(testSessionId); + yield return metadata; + yield break; + } + public global::System.Collections.Generic.IEnumerable EnumerateTestDescriptors() + { + yield return new global::TUnit.Core.TestDescriptor + { + TestId = "TUnit.TestProject.MatrixTests.Method2", + ClassName = "MatrixTests", + MethodName = "Method2", + FullyQualifiedName = "TUnit.TestProject.MatrixTests.Method2", + FilePath = @"", + LineNumber = 124, + Categories = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + HasDataSource = true, + RepeatCount = 0, + DependsOn = global::System.Array.Empty(), + Materializer = GetTestsAsync + }; + } +} +internal static class TUnit_TestProject_MatrixTests_Method2__int_ModuleInitializer +{ + [global::System.Runtime.CompilerServices.ModuleInitializer] + public static void Initialize() + { + global::TUnit.Core.SourceRegistrar.Register(typeof(global::TUnit.TestProject.MatrixTests), new TUnit_TestProject_MatrixTests_Method2__int_TestSource()); + } +} + + +// ===== FILE SEPARATOR ===== + +// +#pragma warning disable + +#nullable enable +namespace TUnit.Generated; +internal sealed class TUnit_TestProject_MatrixTests_Method3__int_TestSource : global::TUnit.Core.Interfaces.SourceGenerator.ITestSource, global::TUnit.Core.Interfaces.SourceGenerator.ITestDescriptorSource +{ + public async global::System.Collections.Generic.IAsyncEnumerable GetTestsAsync(string testSessionId, [global::System.Runtime.CompilerServices.EnumeratorCancellation] global::System.Threading.CancellationToken cancellationToken = default) + { + var metadata = new global::TUnit.Core.TestMetadata + { + TestName = "Method3", + TestClassType = typeof(global::TUnit.TestProject.MatrixTests), + TestMethodName = "Method3", + Dependencies = global::System.Array.Empty(), + AttributeFactory = static () => + [ + new global::TUnit.Core.TestAttribute(), + new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass) + ], + DataSources = new global::TUnit.Core.IDataSourceAttribute[] + { + new global::TUnit.Core.MatrixDataSourceAttribute(), + }, + ClassDataSources = global::System.Array.Empty(), + PropertyDataSources = global::System.Array.Empty(), + PropertyInjections = global::System.Array.Empty(), + InheritanceDepth = 0, + FilePath = @"", + LineNumber = 132, + MethodMetadata = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.MatrixTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.MatrixTests)), + Name = "Method3", + 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[] + { + new global::TUnit.Core.ParameterMetadata(typeof(int)) + { + Name = "item", + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(int)), + IsNullable = false, + ReflectionInfo = typeof(global::TUnit.TestProject.MatrixTests).GetMethod("Method3", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(int) }, null)!.GetParameters()[0] + } + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.MatrixTests", static () => + { + var classMetadata = new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.MatrixTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.MatrixTests)), + Name = "MatrixTests", + Namespace = "TUnit.TestProject", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", static () => new global::TUnit.Core.AssemblyMetadata { Name = "TestsBase`1" }), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }; + return classMetadata; + }) + }, + InstanceFactory = (typeArgs, args) => new global::TUnit.TestProject.MatrixTests(), + InvokeTypedTest = static (instance, args, cancellationToken) => + { + try + { + switch (args.Length) + { + case 1: + { + return new global::System.Threading.Tasks.ValueTask(instance.Method3(global::TUnit.Core.Helpers.CastHelper.Cast(args[0]))); + } + default: + throw new global::System.ArgumentException($"Expected exactly 1 argument, but got {args.Length}"); + } + } + catch (global::System.Exception ex) + { + return new global::System.Threading.Tasks.ValueTask(global::System.Threading.Tasks.Task.FromException(ex)); + } + }, + }; + metadata.UseRuntimeDataGeneration(testSessionId); + yield return metadata; + yield break; + } + public global::System.Collections.Generic.IEnumerable EnumerateTestDescriptors() + { + yield return new global::TUnit.Core.TestDescriptor + { + TestId = "TUnit.TestProject.MatrixTests.Method3", + ClassName = "MatrixTests", + MethodName = "Method3", + FullyQualifiedName = "TUnit.TestProject.MatrixTests.Method3", + FilePath = @"", + LineNumber = 132, + Categories = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + HasDataSource = true, + RepeatCount = 0, + DependsOn = global::System.Array.Empty(), + Materializer = GetTestsAsync + }; + } +} +internal static class TUnit_TestProject_MatrixTests_Method3__int_ModuleInitializer +{ + [global::System.Runtime.CompilerServices.ModuleInitializer] + public static void Initialize() + { + global::TUnit.Core.SourceRegistrar.Register(typeof(global::TUnit.TestProject.MatrixTests), new TUnit_TestProject_MatrixTests_Method3__int_TestSource()); + } +} + + +// ===== FILE SEPARATOR ===== + +// +#pragma warning disable + +#nullable enable +namespace TUnit.Generated; +internal sealed class TUnit_TestProject_MatrixTests_Method4__int_TestSource : global::TUnit.Core.Interfaces.SourceGenerator.ITestSource, global::TUnit.Core.Interfaces.SourceGenerator.ITestDescriptorSource +{ + public async global::System.Collections.Generic.IAsyncEnumerable GetTestsAsync(string testSessionId, [global::System.Runtime.CompilerServices.EnumeratorCancellation] global::System.Threading.CancellationToken cancellationToken = default) + { + var metadata = new global::TUnit.Core.TestMetadata + { + TestName = "Method4", + TestClassType = typeof(global::TUnit.TestProject.MatrixTests), + TestMethodName = "Method4", + Dependencies = global::System.Array.Empty(), + AttributeFactory = static () => + [ + new global::TUnit.Core.TestAttribute(), + new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass) + ], + DataSources = new global::TUnit.Core.IDataSourceAttribute[] + { + new global::TUnit.Core.MatrixDataSourceAttribute(), + }, + ClassDataSources = global::System.Array.Empty(), + PropertyDataSources = global::System.Array.Empty(), + PropertyInjections = global::System.Array.Empty(), + InheritanceDepth = 0, + FilePath = @"", + LineNumber = 140, + MethodMetadata = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.MatrixTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.MatrixTests)), + Name = "Method4", + 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[] + { + new global::TUnit.Core.ParameterMetadata(typeof(int)) + { + Name = "item", + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(int)), + IsNullable = false, + ReflectionInfo = typeof(global::TUnit.TestProject.MatrixTests).GetMethod("Method4", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(int) }, null)!.GetParameters()[0] + } + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.MatrixTests", static () => + { + var classMetadata = new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.MatrixTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.MatrixTests)), + Name = "MatrixTests", + Namespace = "TUnit.TestProject", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", static () => new global::TUnit.Core.AssemblyMetadata { Name = "TestsBase`1" }), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }; + return classMetadata; + }) + }, + InstanceFactory = (typeArgs, args) => new global::TUnit.TestProject.MatrixTests(), + InvokeTypedTest = static (instance, args, cancellationToken) => + { + try + { + switch (args.Length) + { + case 1: + { + return new global::System.Threading.Tasks.ValueTask(instance.Method4(global::TUnit.Core.Helpers.CastHelper.Cast(args[0]))); + } + default: + throw new global::System.ArgumentException($"Expected exactly 1 argument, but got {args.Length}"); + } + } + catch (global::System.Exception ex) + { + return new global::System.Threading.Tasks.ValueTask(global::System.Threading.Tasks.Task.FromException(ex)); + } + }, + }; + metadata.UseRuntimeDataGeneration(testSessionId); + yield return metadata; + yield break; + } + public global::System.Collections.Generic.IEnumerable EnumerateTestDescriptors() + { + yield return new global::TUnit.Core.TestDescriptor + { + TestId = "TUnit.TestProject.MatrixTests.Method4", + ClassName = "MatrixTests", + MethodName = "Method4", + FullyQualifiedName = "TUnit.TestProject.MatrixTests.Method4", + FilePath = @"", + LineNumber = 140, + Categories = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + HasDataSource = true, + RepeatCount = 0, + DependsOn = global::System.Array.Empty(), + Materializer = GetTestsAsync + }; + } +} +internal static class TUnit_TestProject_MatrixTests_Method4__int_ModuleInitializer +{ + [global::System.Runtime.CompilerServices.ModuleInitializer] + public static void Initialize() + { + global::TUnit.Core.SourceRegistrar.Register(typeof(global::TUnit.TestProject.MatrixTests), new TUnit_TestProject_MatrixTests_Method4__int_TestSource()); + } +} + + +// ===== FILE SEPARATOR ===== + +// +#pragma warning disable + +#nullable enable +namespace TUnit.Generated; +internal sealed class TUnit_TestProject_MatrixTests_Exclusion__int_int_TestSource : global::TUnit.Core.Interfaces.SourceGenerator.ITestSource, global::TUnit.Core.Interfaces.SourceGenerator.ITestDescriptorSource +{ + public async global::System.Collections.Generic.IAsyncEnumerable GetTestsAsync(string testSessionId, [global::System.Runtime.CompilerServices.EnumeratorCancellation] global::System.Threading.CancellationToken cancellationToken = default) + { + var metadata = new global::TUnit.Core.TestMetadata + { + TestName = "Exclusion", + TestClassType = typeof(global::TUnit.TestProject.MatrixTests), + TestMethodName = "Exclusion", + Dependencies = global::System.Array.Empty(), + AttributeFactory = static () => + [ + new global::TUnit.Core.TestAttribute(), + new global::TUnit.Core.MatrixExclusionAttribute(1, 1), + new global::TUnit.Core.MatrixExclusionAttribute(2, 2), + new global::TUnit.Core.MatrixExclusionAttribute(3, 3), + new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass) + ], + DataSources = new global::TUnit.Core.IDataSourceAttribute[] + { + new global::TUnit.Core.MatrixDataSourceAttribute(), + }, + ClassDataSources = global::System.Array.Empty(), + PropertyDataSources = global::System.Array.Empty(), + PropertyInjections = global::System.Array.Empty(), + InheritanceDepth = 0, + FilePath = @"", + LineNumber = 148, + MethodMetadata = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.MatrixTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.MatrixTests)), + Name = "Exclusion", + 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[] + { + new global::TUnit.Core.ParameterMetadata(typeof(int)) + { + Name = "item", + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(int)), + IsNullable = false, + ReflectionInfo = typeof(global::TUnit.TestProject.MatrixTests).GetMethod("Exclusion", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(int), typeof(int) }, null)!.GetParameters()[0] + }, + new global::TUnit.Core.ParameterMetadata(typeof(int)) + { + Name = "item2", + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(int)), + IsNullable = false, + ReflectionInfo = typeof(global::TUnit.TestProject.MatrixTests).GetMethod("Exclusion", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(int), typeof(int) }, null)!.GetParameters()[1] + } + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.MatrixTests", static () => + { + var classMetadata = new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.MatrixTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.MatrixTests)), + Name = "MatrixTests", + Namespace = "TUnit.TestProject", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", static () => new global::TUnit.Core.AssemblyMetadata { Name = "TestsBase`1" }), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }; + return classMetadata; + }) + }, + InstanceFactory = (typeArgs, args) => new global::TUnit.TestProject.MatrixTests(), + InvokeTypedTest = static (instance, args, cancellationToken) => + { + try + { + switch (args.Length) + { + case 2: + { + return new global::System.Threading.Tasks.ValueTask(instance.Exclusion(global::TUnit.Core.Helpers.CastHelper.Cast(args[0]), global::TUnit.Core.Helpers.CastHelper.Cast(args[1]))); + } + default: + throw new global::System.ArgumentException($"Expected exactly 2 arguments, but got {args.Length}"); + } + } + catch (global::System.Exception ex) + { + return new global::System.Threading.Tasks.ValueTask(global::System.Threading.Tasks.Task.FromException(ex)); + } + }, + }; + metadata.UseRuntimeDataGeneration(testSessionId); + yield return metadata; + yield break; + } + public global::System.Collections.Generic.IEnumerable EnumerateTestDescriptors() + { + yield return new global::TUnit.Core.TestDescriptor + { + TestId = "TUnit.TestProject.MatrixTests.Exclusion", + ClassName = "MatrixTests", + MethodName = "Exclusion", + FullyQualifiedName = "TUnit.TestProject.MatrixTests.Exclusion", + FilePath = @"", + LineNumber = 148, + Categories = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + HasDataSource = true, + RepeatCount = 0, + DependsOn = global::System.Array.Empty(), + Materializer = GetTestsAsync + }; + } +} +internal static class TUnit_TestProject_MatrixTests_Exclusion__int_int_ModuleInitializer +{ + [global::System.Runtime.CompilerServices.ModuleInitializer] + public static void Initialize() + { + global::TUnit.Core.SourceRegistrar.Register(typeof(global::TUnit.TestProject.MatrixTests), new TUnit_TestProject_MatrixTests_Exclusion__int_int_TestSource()); + } +} + + +// ===== FILE SEPARATOR ===== + +// +#pragma warning disable + +#nullable enable +namespace TUnit.Generated; +internal sealed class TUnit_TestProject_MatrixTests_MatrixMethod_WithEnumParameter_UsesOnlyMethodValues__bool_CountToTenEnum_TestSource : global::TUnit.Core.Interfaces.SourceGenerator.ITestSource, global::TUnit.Core.Interfaces.SourceGenerator.ITestDescriptorSource +{ + public async global::System.Collections.Generic.IAsyncEnumerable GetTestsAsync(string testSessionId, [global::System.Runtime.CompilerServices.EnumeratorCancellation] global::System.Threading.CancellationToken cancellationToken = default) + { + var metadata = new global::TUnit.Core.TestMetadata + { + TestName = "MatrixMethod_WithEnumParameter_UsesOnlyMethodValues", + TestClassType = typeof(global::TUnit.TestProject.MatrixTests), + TestMethodName = "MatrixMethod_WithEnumParameter_UsesOnlyMethodValues", + Dependencies = global::System.Array.Empty(), + AttributeFactory = static () => + [ + new global::TUnit.Core.TestAttribute(), + new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass) + ], + DataSources = new global::TUnit.Core.IDataSourceAttribute[] + { + new global::TUnit.Core.MatrixDataSourceAttribute(), + }, + ClassDataSources = global::System.Array.Empty(), + PropertyDataSources = global::System.Array.Empty(), + PropertyInjections = global::System.Array.Empty(), + InheritanceDepth = 0, + FilePath = @"", + LineNumber = 197, + MethodMetadata = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.MatrixTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.MatrixTests)), + Name = "MatrixMethod_WithEnumParameter_UsesOnlyMethodValues", + 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[] + { + new global::TUnit.Core.ParameterMetadata(typeof(bool)) + { + Name = "flag", + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(bool)), + IsNullable = false, + ReflectionInfo = typeof(global::TUnit.TestProject.MatrixTests).GetMethod("MatrixMethod_WithEnumParameter_UsesOnlyMethodValues", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(bool), typeof(global::TUnit.TestProject.MatrixTests.CountToTenEnum) }, null)!.GetParameters()[0] + }, + new global::TUnit.Core.ParameterMetadata(typeof(global::TUnit.TestProject.MatrixTests.CountToTenEnum)) + { + Name = "enum", + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.MatrixTests.CountToTenEnum)), + IsNullable = false, + ReflectionInfo = typeof(global::TUnit.TestProject.MatrixTests).GetMethod("MatrixMethod_WithEnumParameter_UsesOnlyMethodValues", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(bool), typeof(global::TUnit.TestProject.MatrixTests.CountToTenEnum) }, null)!.GetParameters()[1] + } + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.MatrixTests", static () => + { + var classMetadata = new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.MatrixTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.MatrixTests)), + Name = "MatrixTests", + Namespace = "TUnit.TestProject", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", static () => new global::TUnit.Core.AssemblyMetadata { Name = "TestsBase`1" }), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }; + return classMetadata; + }) + }, + InstanceFactory = (typeArgs, args) => new global::TUnit.TestProject.MatrixTests(), + InvokeTypedTest = static (instance, args, cancellationToken) => + { + try + { + switch (args.Length) + { + case 2: + { + return new global::System.Threading.Tasks.ValueTask(instance.MatrixMethod_WithEnumParameter_UsesOnlyMethodValues(global::TUnit.Core.Helpers.CastHelper.Cast(args[0]), global::TUnit.Core.Helpers.CastHelper.Cast(args[1]))); + } + default: + throw new global::System.ArgumentException($"Expected exactly 2 arguments, but got {args.Length}"); + } + } + catch (global::System.Exception ex) + { + return new global::System.Threading.Tasks.ValueTask(global::System.Threading.Tasks.Task.FromException(ex)); + } + }, + }; + metadata.UseRuntimeDataGeneration(testSessionId); + yield return metadata; + yield break; + } + public global::System.Collections.Generic.IEnumerable EnumerateTestDescriptors() + { + yield return new global::TUnit.Core.TestDescriptor + { + TestId = "TUnit.TestProject.MatrixTests.MatrixMethod_WithEnumParameter_UsesOnlyMethodValues", + ClassName = "MatrixTests", + MethodName = "MatrixMethod_WithEnumParameter_UsesOnlyMethodValues", + FullyQualifiedName = "TUnit.TestProject.MatrixTests.MatrixMethod_WithEnumParameter_UsesOnlyMethodValues", + FilePath = @"", + LineNumber = 197, + Categories = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + HasDataSource = true, + RepeatCount = 0, + DependsOn = global::System.Array.Empty(), + Materializer = GetTestsAsync + }; + } +} +internal static class TUnit_TestProject_MatrixTests_MatrixMethod_WithEnumParameter_UsesOnlyMethodValues__bool_CountToTenEnum_ModuleInitializer +{ + [global::System.Runtime.CompilerServices.ModuleInitializer] + public static void Initialize() + { + global::TUnit.Core.SourceRegistrar.Register(typeof(global::TUnit.TestProject.MatrixTests), new TUnit_TestProject_MatrixTests_MatrixMethod_WithEnumParameter_UsesOnlyMethodValues__bool_CountToTenEnum_TestSource()); + } +} diff --git a/TUnit.Core.SourceGenerator.Tests/ConflictingNamespaceTests.MethodDataSource_WithConflictingNamespace.Net4_7.verified.txt b/TUnit.Core.SourceGenerator.Tests/ConflictingNamespaceTests.MethodDataSource_WithConflictingNamespace.Net4_7.verified.txt new file mode 100644 index 0000000000..172fa98a4e --- /dev/null +++ b/TUnit.Core.SourceGenerator.Tests/ConflictingNamespaceTests.MethodDataSource_WithConflictingNamespace.Net4_7.verified.txt @@ -0,0 +1,986 @@ +// +#pragma warning disable + +#nullable enable +namespace TUnit.Generated; +internal sealed class TUnit_TestProject_MethodDataSourceDrivenTests_DataSource_Method__int_TestSource : global::TUnit.Core.Interfaces.SourceGenerator.ITestSource, global::TUnit.Core.Interfaces.SourceGenerator.ITestDescriptorSource +{ + public async global::System.Collections.Generic.IAsyncEnumerable GetTestsAsync(string testSessionId, [global::System.Runtime.CompilerServices.EnumeratorCancellation] global::System.Threading.CancellationToken cancellationToken = default) + { + var metadata = new global::TUnit.Core.TestMetadata + { + TestName = "DataSource_Method", + TestClassType = typeof(global::TUnit.TestProject.MethodDataSourceDrivenTests), + TestMethodName = "DataSource_Method", + Dependencies = global::System.Array.Empty(), + AttributeFactory = static () => + [ + new global::TUnit.Core.TestAttribute(), + new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass) + ], + DataSources = new global::TUnit.Core.IDataSourceAttribute[] + { + new global::TUnit.Core.MethodDataSourceAttribute("SomeMethod") + { + Factory = (dataGeneratorMetadata) => + { + async global::System.Collections.Generic.IAsyncEnumerable>> Factory() + { + var result = global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod(); + yield return () => global::System.Threading.Tasks.Task.FromResult(global::TUnit.Core.Helpers.DataSourceHelpers.ToObjectArray(result)); + } + return Factory(); + } + }, + }, + ClassDataSources = global::System.Array.Empty(), + PropertyDataSources = global::System.Array.Empty(), + PropertyInjections = global::System.Array.Empty(), + InheritanceDepth = 0, + FilePath = @"", + LineNumber = 12, + MethodMetadata = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.MethodDataSourceDrivenTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.MethodDataSourceDrivenTests)), + Name = "DataSource_Method", + GenericTypeCount = 0, + ReturnType = typeof(void), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(void)), + Parameters = new global::TUnit.Core.ParameterMetadata[] + { + new global::TUnit.Core.ParameterMetadata(typeof(int)) + { + Name = "value", + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(int)), + IsNullable = false, + ReflectionInfo = typeof(global::TUnit.TestProject.MethodDataSourceDrivenTests).GetMethod("DataSource_Method", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(int) }, null)!.GetParameters()[0] + } + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.MethodDataSourceDrivenTests", static () => + { + var classMetadata = new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.MethodDataSourceDrivenTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.MethodDataSourceDrivenTests)), + Name = "MethodDataSourceDrivenTests", + Namespace = "TUnit.TestProject", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", static () => new global::TUnit.Core.AssemblyMetadata { Name = "TestsBase`1" }), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }; + return classMetadata; + }) + }, + InstanceFactory = (typeArgs, args) => new global::TUnit.TestProject.MethodDataSourceDrivenTests(), + InvokeTypedTest = static (instance, args, cancellationToken) => + { + try + { + switch (args.Length) + { + case 1: + { + instance.DataSource_Method(global::TUnit.Core.Helpers.CastHelper.Cast(args[0])); + return default(global::System.Threading.Tasks.ValueTask); + } + default: + throw new global::System.ArgumentException($"Expected exactly 1 argument, but got {args.Length}"); + } + } + catch (global::System.Exception ex) + { + return new global::System.Threading.Tasks.ValueTask(global::System.Threading.Tasks.Task.FromException(ex)); + } + }, + }; + metadata.UseRuntimeDataGeneration(testSessionId); + yield return metadata; + yield break; + } + public global::System.Collections.Generic.IEnumerable EnumerateTestDescriptors() + { + yield return new global::TUnit.Core.TestDescriptor + { + TestId = "TUnit.TestProject.MethodDataSourceDrivenTests.DataSource_Method", + ClassName = "MethodDataSourceDrivenTests", + MethodName = "DataSource_Method", + FullyQualifiedName = "TUnit.TestProject.MethodDataSourceDrivenTests.DataSource_Method", + FilePath = @"", + LineNumber = 12, + Categories = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + HasDataSource = true, + RepeatCount = 0, + DependsOn = global::System.Array.Empty(), + Materializer = GetTestsAsync + }; + } +} +internal static class TUnit_TestProject_MethodDataSourceDrivenTests_DataSource_Method__int_ModuleInitializer +{ + [global::System.Runtime.CompilerServices.ModuleInitializer] + public static void Initialize() + { + global::TUnit.Core.SourceRegistrar.Register(typeof(global::TUnit.TestProject.MethodDataSourceDrivenTests), new TUnit_TestProject_MethodDataSourceDrivenTests_DataSource_Method__int_TestSource()); + } +} + + +// ===== FILE SEPARATOR ===== + +// +#pragma warning disable + +#nullable enable +namespace TUnit.Generated; +internal sealed class TUnit_TestProject_MethodDataSourceDrivenTests_DataSource_Method2__int_TestSource : global::TUnit.Core.Interfaces.SourceGenerator.ITestSource, global::TUnit.Core.Interfaces.SourceGenerator.ITestDescriptorSource +{ + public async global::System.Collections.Generic.IAsyncEnumerable GetTestsAsync(string testSessionId, [global::System.Runtime.CompilerServices.EnumeratorCancellation] global::System.Threading.CancellationToken cancellationToken = default) + { + var metadata = new global::TUnit.Core.TestMetadata + { + TestName = "DataSource_Method2", + TestClassType = typeof(global::TUnit.TestProject.MethodDataSourceDrivenTests), + TestMethodName = "DataSource_Method2", + Dependencies = global::System.Array.Empty(), + AttributeFactory = static () => + [ + new global::TUnit.Core.TestAttribute(), + new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass) + ], + DataSources = new global::TUnit.Core.IDataSourceAttribute[] + { + new global::TUnit.Core.MethodDataSourceAttribute("SomeMethod") + { + Factory = (dataGeneratorMetadata) => + { + async global::System.Collections.Generic.IAsyncEnumerable>> Factory() + { + var result = global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod(); + yield return () => global::System.Threading.Tasks.Task.FromResult(global::TUnit.Core.Helpers.DataSourceHelpers.ToObjectArray(result)); + } + return Factory(); + } + }, + }, + ClassDataSources = global::System.Array.Empty(), + PropertyDataSources = global::System.Array.Empty(), + PropertyInjections = global::System.Array.Empty(), + InheritanceDepth = 0, + FilePath = @"", + LineNumber = 19, + MethodMetadata = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.MethodDataSourceDrivenTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.MethodDataSourceDrivenTests)), + Name = "DataSource_Method2", + GenericTypeCount = 0, + ReturnType = typeof(void), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(void)), + Parameters = new global::TUnit.Core.ParameterMetadata[] + { + new global::TUnit.Core.ParameterMetadata(typeof(int)) + { + Name = "value", + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(int)), + IsNullable = false, + ReflectionInfo = typeof(global::TUnit.TestProject.MethodDataSourceDrivenTests).GetMethod("DataSource_Method2", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(int) }, null)!.GetParameters()[0] + } + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.MethodDataSourceDrivenTests", static () => + { + var classMetadata = new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.MethodDataSourceDrivenTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.MethodDataSourceDrivenTests)), + Name = "MethodDataSourceDrivenTests", + Namespace = "TUnit.TestProject", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", static () => new global::TUnit.Core.AssemblyMetadata { Name = "TestsBase`1" }), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }; + return classMetadata; + }) + }, + InstanceFactory = (typeArgs, args) => new global::TUnit.TestProject.MethodDataSourceDrivenTests(), + InvokeTypedTest = static (instance, args, cancellationToken) => + { + try + { + switch (args.Length) + { + case 1: + { + instance.DataSource_Method2(global::TUnit.Core.Helpers.CastHelper.Cast(args[0])); + return default(global::System.Threading.Tasks.ValueTask); + } + default: + throw new global::System.ArgumentException($"Expected exactly 1 argument, but got {args.Length}"); + } + } + catch (global::System.Exception ex) + { + return new global::System.Threading.Tasks.ValueTask(global::System.Threading.Tasks.Task.FromException(ex)); + } + }, + }; + metadata.UseRuntimeDataGeneration(testSessionId); + yield return metadata; + yield break; + } + public global::System.Collections.Generic.IEnumerable EnumerateTestDescriptors() + { + yield return new global::TUnit.Core.TestDescriptor + { + TestId = "TUnit.TestProject.MethodDataSourceDrivenTests.DataSource_Method2", + ClassName = "MethodDataSourceDrivenTests", + MethodName = "DataSource_Method2", + FullyQualifiedName = "TUnit.TestProject.MethodDataSourceDrivenTests.DataSource_Method2", + FilePath = @"", + LineNumber = 19, + Categories = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + HasDataSource = true, + RepeatCount = 0, + DependsOn = global::System.Array.Empty(), + Materializer = GetTestsAsync + }; + } +} +internal static class TUnit_TestProject_MethodDataSourceDrivenTests_DataSource_Method2__int_ModuleInitializer +{ + [global::System.Runtime.CompilerServices.ModuleInitializer] + public static void Initialize() + { + global::TUnit.Core.SourceRegistrar.Register(typeof(global::TUnit.TestProject.MethodDataSourceDrivenTests), new TUnit_TestProject_MethodDataSourceDrivenTests_DataSource_Method2__int_TestSource()); + } +} + + +// ===== FILE SEPARATOR ===== + +// +#pragma warning disable + +#nullable enable +namespace TUnit.Generated; +internal sealed class TUnit_TestProject_MethodDataSourceDrivenTests_DataSource_Method_WithAction__Action_TestSource : global::TUnit.Core.Interfaces.SourceGenerator.ITestSource, global::TUnit.Core.Interfaces.SourceGenerator.ITestDescriptorSource +{ + public async global::System.Collections.Generic.IAsyncEnumerable GetTestsAsync(string testSessionId, [global::System.Runtime.CompilerServices.EnumeratorCancellation] global::System.Threading.CancellationToken cancellationToken = default) + { + var metadata = new global::TUnit.Core.TestMetadata + { + TestName = "DataSource_Method_WithAction", + TestClassType = typeof(global::TUnit.TestProject.MethodDataSourceDrivenTests), + TestMethodName = "DataSource_Method_WithAction", + Dependencies = global::System.Array.Empty(), + AttributeFactory = static () => + [ + new global::TUnit.Core.TestAttribute(), + new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass) + ], + DataSources = new global::TUnit.Core.IDataSourceAttribute[] + { + new global::TUnit.Core.MethodDataSourceAttribute("SomeAction") + { + Factory = (dataGeneratorMetadata) => + { + async global::System.Collections.Generic.IAsyncEnumerable>> Factory() + { + var result = global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeAction(); + yield return () => global::System.Threading.Tasks.Task.FromResult(global::TUnit.Core.Helpers.DataSourceHelpers.ToObjectArray(result)); + } + return Factory(); + } + }, + }, + ClassDataSources = global::System.Array.Empty(), + PropertyDataSources = global::System.Array.Empty(), + PropertyInjections = global::System.Array.Empty(), + InheritanceDepth = 0, + FilePath = @"", + LineNumber = 26, + MethodMetadata = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.MethodDataSourceDrivenTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.MethodDataSourceDrivenTests)), + Name = "DataSource_Method_WithAction", + GenericTypeCount = 0, + ReturnType = typeof(void), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(void)), + Parameters = new global::TUnit.Core.ParameterMetadata[] + { + new global::TUnit.Core.ParameterMetadata(typeof(global::System.Action)) + { + Name = "action", + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::System.Action)), + IsNullable = false, + ReflectionInfo = typeof(global::TUnit.TestProject.MethodDataSourceDrivenTests).GetMethod("DataSource_Method_WithAction", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(global::System.Action) }, null)!.GetParameters()[0] + } + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.MethodDataSourceDrivenTests", static () => + { + var classMetadata = new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.MethodDataSourceDrivenTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.MethodDataSourceDrivenTests)), + Name = "MethodDataSourceDrivenTests", + Namespace = "TUnit.TestProject", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", static () => new global::TUnit.Core.AssemblyMetadata { Name = "TestsBase`1" }), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }; + return classMetadata; + }) + }, + InstanceFactory = (typeArgs, args) => new global::TUnit.TestProject.MethodDataSourceDrivenTests(), + InvokeTypedTest = static (instance, args, cancellationToken) => + { + try + { + switch (args.Length) + { + case 1: + { + instance.DataSource_Method_WithAction(global::TUnit.Core.Helpers.CastHelper.Cast(args[0])); + return default(global::System.Threading.Tasks.ValueTask); + } + default: + throw new global::System.ArgumentException($"Expected exactly 1 argument, but got {args.Length}"); + } + } + catch (global::System.Exception ex) + { + return new global::System.Threading.Tasks.ValueTask(global::System.Threading.Tasks.Task.FromException(ex)); + } + }, + }; + metadata.UseRuntimeDataGeneration(testSessionId); + yield return metadata; + yield break; + } + public global::System.Collections.Generic.IEnumerable EnumerateTestDescriptors() + { + yield return new global::TUnit.Core.TestDescriptor + { + TestId = "TUnit.TestProject.MethodDataSourceDrivenTests.DataSource_Method_WithAction", + ClassName = "MethodDataSourceDrivenTests", + MethodName = "DataSource_Method_WithAction", + FullyQualifiedName = "TUnit.TestProject.MethodDataSourceDrivenTests.DataSource_Method_WithAction", + FilePath = @"", + LineNumber = 26, + Categories = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + HasDataSource = true, + RepeatCount = 0, + DependsOn = global::System.Array.Empty(), + Materializer = GetTestsAsync + }; + } +} +internal static class TUnit_TestProject_MethodDataSourceDrivenTests_DataSource_Method_WithAction__Action_ModuleInitializer +{ + [global::System.Runtime.CompilerServices.ModuleInitializer] + public static void Initialize() + { + global::TUnit.Core.SourceRegistrar.Register(typeof(global::TUnit.TestProject.MethodDataSourceDrivenTests), new TUnit_TestProject_MethodDataSourceDrivenTests_DataSource_Method_WithAction__Action_TestSource()); + } +} + + +// ===== FILE SEPARATOR ===== + +// +#pragma warning disable + +#nullable enable +namespace TUnit.Generated; +internal sealed class TUnit_TestProject_MethodDataSourceDrivenTests_DataSource_Method3__int_TestSource : global::TUnit.Core.Interfaces.SourceGenerator.ITestSource, global::TUnit.Core.Interfaces.SourceGenerator.ITestDescriptorSource +{ + public async global::System.Collections.Generic.IAsyncEnumerable GetTestsAsync(string testSessionId, [global::System.Runtime.CompilerServices.EnumeratorCancellation] global::System.Threading.CancellationToken cancellationToken = default) + { + var metadata = new global::TUnit.Core.TestMetadata + { + TestName = "DataSource_Method3", + TestClassType = typeof(global::TUnit.TestProject.MethodDataSourceDrivenTests), + TestMethodName = "DataSource_Method3", + Dependencies = global::System.Array.Empty(), + AttributeFactory = static () => + [ + new global::TUnit.Core.TestAttribute(), + new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass) + ], + DataSources = new global::TUnit.Core.IDataSourceAttribute[] + { + new global::TUnit.Core.MethodDataSourceAttribute("SomeMethod") + { + Factory = (dataGeneratorMetadata) => + { + async global::System.Collections.Generic.IAsyncEnumerable>> Factory() + { + var result = global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod(); + yield return () => global::System.Threading.Tasks.Task.FromResult(global::TUnit.Core.Helpers.DataSourceHelpers.ToObjectArray(result)); + } + return Factory(); + } + }, + new global::TUnit.Core.MethodDataSourceAttribute("SomeMethod") + { + Arguments = new object[] { 5 }, + Factory = (dataGeneratorMetadata) => + { + // Capture Arguments from the attribute + var arguments = new object[] { 5 }; + async global::System.Collections.Generic.IAsyncEnumerable>> Factory() + { + var result = global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod(); + yield return () => global::System.Threading.Tasks.Task.FromResult(global::TUnit.Core.Helpers.DataSourceHelpers.ToObjectArray(result)); + } + return Factory(); + } + }, + }, + ClassDataSources = global::System.Array.Empty(), + PropertyDataSources = global::System.Array.Empty(), + PropertyInjections = global::System.Array.Empty(), + InheritanceDepth = 0, + FilePath = @"", + LineNumber = 33, + MethodMetadata = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.MethodDataSourceDrivenTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.MethodDataSourceDrivenTests)), + Name = "DataSource_Method3", + GenericTypeCount = 0, + ReturnType = typeof(void), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(void)), + Parameters = new global::TUnit.Core.ParameterMetadata[] + { + new global::TUnit.Core.ParameterMetadata(typeof(int)) + { + Name = "value", + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(int)), + IsNullable = false, + ReflectionInfo = typeof(global::TUnit.TestProject.MethodDataSourceDrivenTests).GetMethod("DataSource_Method3", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(int) }, null)!.GetParameters()[0] + } + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.MethodDataSourceDrivenTests", static () => + { + var classMetadata = new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.MethodDataSourceDrivenTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.MethodDataSourceDrivenTests)), + Name = "MethodDataSourceDrivenTests", + Namespace = "TUnit.TestProject", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", static () => new global::TUnit.Core.AssemblyMetadata { Name = "TestsBase`1" }), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }; + return classMetadata; + }) + }, + InstanceFactory = (typeArgs, args) => new global::TUnit.TestProject.MethodDataSourceDrivenTests(), + InvokeTypedTest = static (instance, args, cancellationToken) => + { + try + { + switch (args.Length) + { + case 1: + { + instance.DataSource_Method3(global::TUnit.Core.Helpers.CastHelper.Cast(args[0])); + return default(global::System.Threading.Tasks.ValueTask); + } + default: + throw new global::System.ArgumentException($"Expected exactly 1 argument, but got {args.Length}"); + } + } + catch (global::System.Exception ex) + { + return new global::System.Threading.Tasks.ValueTask(global::System.Threading.Tasks.Task.FromException(ex)); + } + }, + }; + metadata.UseRuntimeDataGeneration(testSessionId); + yield return metadata; + yield break; + } + public global::System.Collections.Generic.IEnumerable EnumerateTestDescriptors() + { + yield return new global::TUnit.Core.TestDescriptor + { + TestId = "TUnit.TestProject.MethodDataSourceDrivenTests.DataSource_Method3", + ClassName = "MethodDataSourceDrivenTests", + MethodName = "DataSource_Method3", + FullyQualifiedName = "TUnit.TestProject.MethodDataSourceDrivenTests.DataSource_Method3", + FilePath = @"", + LineNumber = 33, + Categories = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + HasDataSource = true, + RepeatCount = 0, + DependsOn = global::System.Array.Empty(), + Materializer = GetTestsAsync + }; + } +} +internal static class TUnit_TestProject_MethodDataSourceDrivenTests_DataSource_Method3__int_ModuleInitializer +{ + [global::System.Runtime.CompilerServices.ModuleInitializer] + public static void Initialize() + { + global::TUnit.Core.SourceRegistrar.Register(typeof(global::TUnit.TestProject.MethodDataSourceDrivenTests), new TUnit_TestProject_MethodDataSourceDrivenTests_DataSource_Method3__int_TestSource()); + } +} + + +// ===== FILE SEPARATOR ===== + +// +#pragma warning disable + +#nullable enable +namespace TUnit.Generated; +internal sealed class TUnit_TestProject_MethodDataSourceDrivenTests_DataSource_Method4__int_TestSource : global::TUnit.Core.Interfaces.SourceGenerator.ITestSource, global::TUnit.Core.Interfaces.SourceGenerator.ITestDescriptorSource +{ + public async global::System.Collections.Generic.IAsyncEnumerable GetTestsAsync(string testSessionId, [global::System.Runtime.CompilerServices.EnumeratorCancellation] global::System.Threading.CancellationToken cancellationToken = default) + { + var metadata = new global::TUnit.Core.TestMetadata + { + TestName = "DataSource_Method4", + TestClassType = typeof(global::TUnit.TestProject.MethodDataSourceDrivenTests), + TestMethodName = "DataSource_Method4", + Dependencies = global::System.Array.Empty(), + AttributeFactory = static () => + [ + new global::TUnit.Core.TestAttribute(), + new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass) + ], + DataSources = new global::TUnit.Core.IDataSourceAttribute[] + { + new global::TUnit.Core.MethodDataSourceAttribute("SomeMethod") + { + Factory = (dataGeneratorMetadata) => + { + async global::System.Collections.Generic.IAsyncEnumerable>> Factory() + { + var result = global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod(); + yield return () => global::System.Threading.Tasks.Task.FromResult(global::TUnit.Core.Helpers.DataSourceHelpers.ToObjectArray(result)); + } + return Factory(); + } + }, + new global::TUnit.Core.MethodDataSourceAttribute("SomeMethod") + { + Arguments = new object[] { "Hello World!", 6, true }, + Factory = (dataGeneratorMetadata) => + { + // Capture Arguments from the attribute + var arguments = new object[] { "Hello World!", 6, true }; + async global::System.Collections.Generic.IAsyncEnumerable>> Factory() + { + var result = global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod(); + yield return () => global::System.Threading.Tasks.Task.FromResult(global::TUnit.Core.Helpers.DataSourceHelpers.ToObjectArray(result)); + } + return Factory(); + } + }, + new global::TUnit.Core.MethodDataSourceAttribute("SomeMethod") + { + Factory = (dataGeneratorMetadata) => + { + async global::System.Collections.Generic.IAsyncEnumerable>> Factory() + { + var result = global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod(); + yield return () => global::System.Threading.Tasks.Task.FromResult(global::TUnit.Core.Helpers.DataSourceHelpers.ToObjectArray(result)); + } + return Factory(); + } + }, + new global::TUnit.Core.MethodDataSourceAttribute("SomeMethod") + { + Arguments = new object[] { "Hello World!", 8, true }, + Factory = (dataGeneratorMetadata) => + { + // Capture Arguments from the attribute + var arguments = new object[] { "Hello World!", 8, true }; + async global::System.Collections.Generic.IAsyncEnumerable>> Factory() + { + var result = global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod(); + yield return () => global::System.Threading.Tasks.Task.FromResult(global::TUnit.Core.Helpers.DataSourceHelpers.ToObjectArray(result)); + } + return Factory(); + } + }, + }, + ClassDataSources = global::System.Array.Empty(), + PropertyDataSources = global::System.Array.Empty(), + PropertyInjections = global::System.Array.Empty(), + InheritanceDepth = 0, + FilePath = @"", + LineNumber = 42, + MethodMetadata = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.MethodDataSourceDrivenTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.MethodDataSourceDrivenTests)), + Name = "DataSource_Method4", + GenericTypeCount = 0, + ReturnType = typeof(void), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(void)), + Parameters = new global::TUnit.Core.ParameterMetadata[] + { + new global::TUnit.Core.ParameterMetadata(typeof(int)) + { + Name = "value", + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(int)), + IsNullable = false, + ReflectionInfo = typeof(global::TUnit.TestProject.MethodDataSourceDrivenTests).GetMethod("DataSource_Method4", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(int) }, null)!.GetParameters()[0] + } + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.MethodDataSourceDrivenTests", static () => + { + var classMetadata = new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.MethodDataSourceDrivenTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.MethodDataSourceDrivenTests)), + Name = "MethodDataSourceDrivenTests", + Namespace = "TUnit.TestProject", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", static () => new global::TUnit.Core.AssemblyMetadata { Name = "TestsBase`1" }), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }; + return classMetadata; + }) + }, + InstanceFactory = (typeArgs, args) => new global::TUnit.TestProject.MethodDataSourceDrivenTests(), + InvokeTypedTest = static (instance, args, cancellationToken) => + { + try + { + switch (args.Length) + { + case 1: + { + instance.DataSource_Method4(global::TUnit.Core.Helpers.CastHelper.Cast(args[0])); + return default(global::System.Threading.Tasks.ValueTask); + } + default: + throw new global::System.ArgumentException($"Expected exactly 1 argument, but got {args.Length}"); + } + } + catch (global::System.Exception ex) + { + return new global::System.Threading.Tasks.ValueTask(global::System.Threading.Tasks.Task.FromException(ex)); + } + }, + }; + metadata.UseRuntimeDataGeneration(testSessionId); + yield return metadata; + yield break; + } + public global::System.Collections.Generic.IEnumerable EnumerateTestDescriptors() + { + yield return new global::TUnit.Core.TestDescriptor + { + TestId = "TUnit.TestProject.MethodDataSourceDrivenTests.DataSource_Method4", + ClassName = "MethodDataSourceDrivenTests", + MethodName = "DataSource_Method4", + FullyQualifiedName = "TUnit.TestProject.MethodDataSourceDrivenTests.DataSource_Method4", + FilePath = @"", + LineNumber = 42, + Categories = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + HasDataSource = true, + RepeatCount = 0, + DependsOn = global::System.Array.Empty(), + Materializer = GetTestsAsync + }; + } +} +internal static class TUnit_TestProject_MethodDataSourceDrivenTests_DataSource_Method4__int_ModuleInitializer +{ + [global::System.Runtime.CompilerServices.ModuleInitializer] + public static void Initialize() + { + global::TUnit.Core.SourceRegistrar.Register(typeof(global::TUnit.TestProject.MethodDataSourceDrivenTests), new TUnit_TestProject_MethodDataSourceDrivenTests_DataSource_Method4__int_TestSource()); + } +} + + +// ===== FILE SEPARATOR ===== + +// +#pragma warning disable + +#nullable enable +namespace TUnit.Generated; +internal sealed class TUnit_TestProject_MethodDataSourceDrivenTests_DataSource_WithBaseReturn__BaseValue_TestSource : global::TUnit.Core.Interfaces.SourceGenerator.ITestSource, global::TUnit.Core.Interfaces.SourceGenerator.ITestDescriptorSource +{ + public async global::System.Collections.Generic.IAsyncEnumerable GetTestsAsync(string testSessionId, [global::System.Runtime.CompilerServices.EnumeratorCancellation] global::System.Threading.CancellationToken cancellationToken = default) + { + var metadata = new global::TUnit.Core.TestMetadata + { + TestName = "DataSource_WithBaseReturn", + TestClassType = typeof(global::TUnit.TestProject.MethodDataSourceDrivenTests), + TestMethodName = "DataSource_WithBaseReturn", + Dependencies = global::System.Array.Empty(), + AttributeFactory = static () => + [ + new global::TUnit.Core.TestAttribute(), + new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass) + ], + DataSources = new global::TUnit.Core.IDataSourceAttribute[] + { + new global::TUnit.Core.MethodDataSourceAttribute("MethodWithBaseReturn") + { + Factory = (dataGeneratorMetadata) => + { + async global::System.Collections.Generic.IAsyncEnumerable>> Factory() + { + var result = global::TUnit.TestProject.MethodDataSourceDrivenTests.MethodWithBaseReturn(); + yield return () => global::System.Threading.Tasks.Task.FromResult(global::TUnit.Core.Helpers.DataSourceHelpers.ToObjectArray(result)); + } + return Factory(); + } + }, + }, + ClassDataSources = global::System.Array.Empty(), + PropertyDataSources = global::System.Array.Empty(), + PropertyInjections = global::System.Array.Empty(), + InheritanceDepth = 0, + FilePath = @"", + LineNumber = 53, + MethodMetadata = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.MethodDataSourceDrivenTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.MethodDataSourceDrivenTests)), + Name = "DataSource_WithBaseReturn", + GenericTypeCount = 0, + ReturnType = typeof(void), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(void)), + Parameters = new global::TUnit.Core.ParameterMetadata[] + { + new global::TUnit.Core.ParameterMetadata(typeof(global::TUnit.TestProject.MethodDataSourceDrivenTests.BaseValue)) + { + Name = "value", + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.MethodDataSourceDrivenTests.BaseValue)), + IsNullable = false, + ReflectionInfo = typeof(global::TUnit.TestProject.MethodDataSourceDrivenTests).GetMethod("DataSource_WithBaseReturn", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(global::TUnit.TestProject.MethodDataSourceDrivenTests.BaseValue) }, null)!.GetParameters()[0] + } + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.MethodDataSourceDrivenTests", static () => + { + var classMetadata = new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.MethodDataSourceDrivenTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.MethodDataSourceDrivenTests)), + Name = "MethodDataSourceDrivenTests", + Namespace = "TUnit.TestProject", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", static () => new global::TUnit.Core.AssemblyMetadata { Name = "TestsBase`1" }), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }; + return classMetadata; + }) + }, + InstanceFactory = (typeArgs, args) => new global::TUnit.TestProject.MethodDataSourceDrivenTests(), + InvokeTypedTest = static (instance, args, cancellationToken) => + { + try + { + switch (args.Length) + { + case 1: + { + instance.DataSource_WithBaseReturn(global::TUnit.Core.Helpers.CastHelper.Cast(args[0])); + return default(global::System.Threading.Tasks.ValueTask); + } + default: + throw new global::System.ArgumentException($"Expected exactly 1 argument, but got {args.Length}"); + } + } + catch (global::System.Exception ex) + { + return new global::System.Threading.Tasks.ValueTask(global::System.Threading.Tasks.Task.FromException(ex)); + } + }, + }; + metadata.UseRuntimeDataGeneration(testSessionId); + yield return metadata; + yield break; + } + public global::System.Collections.Generic.IEnumerable EnumerateTestDescriptors() + { + yield return new global::TUnit.Core.TestDescriptor + { + TestId = "TUnit.TestProject.MethodDataSourceDrivenTests.DataSource_WithBaseReturn", + ClassName = "MethodDataSourceDrivenTests", + MethodName = "DataSource_WithBaseReturn", + FullyQualifiedName = "TUnit.TestProject.MethodDataSourceDrivenTests.DataSource_WithBaseReturn", + FilePath = @"", + LineNumber = 53, + Categories = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + HasDataSource = true, + RepeatCount = 0, + DependsOn = global::System.Array.Empty(), + Materializer = GetTestsAsync + }; + } +} +internal static class TUnit_TestProject_MethodDataSourceDrivenTests_DataSource_WithBaseReturn__BaseValue_ModuleInitializer +{ + [global::System.Runtime.CompilerServices.ModuleInitializer] + public static void Initialize() + { + global::TUnit.Core.SourceRegistrar.Register(typeof(global::TUnit.TestProject.MethodDataSourceDrivenTests), new TUnit_TestProject_MethodDataSourceDrivenTests_DataSource_WithBaseReturn__BaseValue_TestSource()); + } +} + + +// ===== FILE SEPARATOR ===== + +// +#pragma warning disable + +#nullable enable +namespace TUnit.Generated; +internal sealed class TUnit_TestProject_MethodDataSourceDrivenTests_EnumerableFuncArrayTest__string___TestSource : global::TUnit.Core.Interfaces.SourceGenerator.ITestSource, global::TUnit.Core.Interfaces.SourceGenerator.ITestDescriptorSource +{ + public async global::System.Collections.Generic.IAsyncEnumerable GetTestsAsync(string testSessionId, [global::System.Runtime.CompilerServices.EnumeratorCancellation] global::System.Threading.CancellationToken cancellationToken = default) + { + var metadata = new global::TUnit.Core.TestMetadata + { + TestName = "EnumerableFuncArrayTest", + TestClassType = typeof(global::TUnit.TestProject.MethodDataSourceDrivenTests), + TestMethodName = "EnumerableFuncArrayTest", + Dependencies = global::System.Array.Empty(), + AttributeFactory = static () => + [ + new global::TUnit.Core.TestAttribute(), + new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass) + ], + DataSources = new global::TUnit.Core.IDataSourceAttribute[] + { + new global::TUnit.Core.MethodDataSourceAttribute("EnumerableFuncArrayTestData") + { + Factory = (dataGeneratorMetadata) => + { + async global::System.Collections.Generic.IAsyncEnumerable>> Factory() + { + var result = global::TUnit.TestProject.MethodDataSourceDrivenTests.EnumerableFuncArrayTestData(); + if (result is global::System.Collections.IEnumerable enumerable && !(result is string)) + { + foreach (var item in enumerable) + { + yield return () => global::System.Threading.Tasks.Task.FromResult(global::TUnit.Core.Helpers.DataSourceHelpers.ToObjectArray(item)); + } + } + else + { + yield return () => global::System.Threading.Tasks.Task.FromResult(global::TUnit.Core.Helpers.DataSourceHelpers.ToObjectArray(result)); + } + } + return Factory(); + } + }, + }, + ClassDataSources = global::System.Array.Empty(), + PropertyDataSources = global::System.Array.Empty(), + PropertyInjections = global::System.Array.Empty(), + InheritanceDepth = 0, + FilePath = @"", + LineNumber = 59, + MethodMetadata = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.MethodDataSourceDrivenTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.MethodDataSourceDrivenTests)), + Name = "EnumerableFuncArrayTest", + 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[] + { + new global::TUnit.Core.ParameterMetadata(typeof(string[])) + { + Name = "strings", + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(string[])), + IsNullable = false, + ReflectionInfo = typeof(global::TUnit.TestProject.MethodDataSourceDrivenTests).GetMethod("EnumerableFuncArrayTest", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(string[]) }, null)!.GetParameters()[0] + } + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.MethodDataSourceDrivenTests", static () => + { + var classMetadata = new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.MethodDataSourceDrivenTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.MethodDataSourceDrivenTests)), + Name = "MethodDataSourceDrivenTests", + Namespace = "TUnit.TestProject", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", static () => new global::TUnit.Core.AssemblyMetadata { Name = "TestsBase`1" }), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }; + return classMetadata; + }) + }, + InstanceFactory = (typeArgs, args) => new global::TUnit.TestProject.MethodDataSourceDrivenTests(), + InvokeTypedTest = static (instance, args, cancellationToken) => + { + try + { + switch (args.Length) + { + case 1: + { + return new global::System.Threading.Tasks.ValueTask(instance.EnumerableFuncArrayTest(global::TUnit.Core.Helpers.CastHelper.Cast(args[0]))); + } + default: + throw new global::System.ArgumentException($"Expected exactly 1 argument, but got {args.Length}"); + } + } + catch (global::System.Exception ex) + { + return new global::System.Threading.Tasks.ValueTask(global::System.Threading.Tasks.Task.FromException(ex)); + } + }, + }; + metadata.UseRuntimeDataGeneration(testSessionId); + yield return metadata; + yield break; + } + public global::System.Collections.Generic.IEnumerable EnumerateTestDescriptors() + { + yield return new global::TUnit.Core.TestDescriptor + { + TestId = "TUnit.TestProject.MethodDataSourceDrivenTests.EnumerableFuncArrayTest", + ClassName = "MethodDataSourceDrivenTests", + MethodName = "EnumerableFuncArrayTest", + FullyQualifiedName = "TUnit.TestProject.MethodDataSourceDrivenTests.EnumerableFuncArrayTest", + FilePath = @"", + LineNumber = 59, + Categories = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + HasDataSource = true, + RepeatCount = 0, + DependsOn = global::System.Array.Empty(), + Materializer = GetTestsAsync + }; + } +} +internal static class TUnit_TestProject_MethodDataSourceDrivenTests_EnumerableFuncArrayTest__string___ModuleInitializer +{ + [global::System.Runtime.CompilerServices.ModuleInitializer] + public static void Initialize() + { + global::TUnit.Core.SourceRegistrar.Register(typeof(global::TUnit.TestProject.MethodDataSourceDrivenTests), new TUnit_TestProject_MethodDataSourceDrivenTests_EnumerableFuncArrayTest__string___TestSource()); + } +} diff --git a/TUnit.Core.SourceGenerator.Tests/ConflictingNamespaceTests.TupleDataSource_WithConflictingNamespace.Net4_7.verified.txt b/TUnit.Core.SourceGenerator.Tests/ConflictingNamespaceTests.TupleDataSource_WithConflictingNamespace.Net4_7.verified.txt new file mode 100644 index 0000000000..384aa5eb20 --- /dev/null +++ b/TUnit.Core.SourceGenerator.Tests/ConflictingNamespaceTests.TupleDataSource_WithConflictingNamespace.Net4_7.verified.txt @@ -0,0 +1,142 @@ +// +#pragma warning disable + +#nullable enable +namespace TUnit.Generated; +internal sealed class TUnit_TestProject_TupleDataSourceDrivenTests_DataSource_TupleMethod__int_string_bool_TestSource : global::TUnit.Core.Interfaces.SourceGenerator.ITestSource, global::TUnit.Core.Interfaces.SourceGenerator.ITestDescriptorSource +{ + public async global::System.Collections.Generic.IAsyncEnumerable GetTestsAsync(string testSessionId, [global::System.Runtime.CompilerServices.EnumeratorCancellation] global::System.Threading.CancellationToken cancellationToken = default) + { + var metadata = new global::TUnit.Core.TestMetadata + { + TestName = "DataSource_TupleMethod", + TestClassType = typeof(global::TUnit.TestProject.TupleDataSourceDrivenTests), + TestMethodName = "DataSource_TupleMethod", + Dependencies = global::System.Array.Empty(), + AttributeFactory = static () => + [ + new global::TUnit.Core.TestAttribute(), + new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass) + ], + DataSources = new global::TUnit.Core.IDataSourceAttribute[] + { + new global::TUnit.Core.MethodDataSourceAttribute("TupleMethod") + { + Factory = (dataGeneratorMetadata) => + { + async global::System.Collections.Generic.IAsyncEnumerable>> Factory() + { + var result = global::TUnit.TestProject.TupleDataSourceDrivenTests.TupleMethod(); + yield return () => global::System.Threading.Tasks.Task.FromResult(global::TUnit.Core.Helpers.DataSourceHelpers.ToObjectArray(result)); + } + return Factory(); + } + }, + }, + ClassDataSources = global::System.Array.Empty(), + PropertyDataSources = global::System.Array.Empty(), + PropertyInjections = global::System.Array.Empty(), + InheritanceDepth = 0, + FilePath = @"", + LineNumber = 8, + MethodMetadata = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.TupleDataSourceDrivenTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.TupleDataSourceDrivenTests)), + Name = "DataSource_TupleMethod", + GenericTypeCount = 0, + ReturnType = typeof(void), + ReturnTypeInfo = new global::TUnit.Core.ConcreteType(typeof(void)), + Parameters = new global::TUnit.Core.ParameterMetadata[] + { + new global::TUnit.Core.ParameterMetadata(typeof(int)) + { + Name = "value", + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(int)), + IsNullable = false, + ReflectionInfo = typeof(global::TUnit.TestProject.TupleDataSourceDrivenTests).GetMethod("DataSource_TupleMethod", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(int), typeof(string), typeof(bool) }, null)!.GetParameters()[0] + }, + new global::TUnit.Core.ParameterMetadata(typeof(string)) + { + Name = "value2", + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(string)), + IsNullable = false, + ReflectionInfo = typeof(global::TUnit.TestProject.TupleDataSourceDrivenTests).GetMethod("DataSource_TupleMethod", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(int), typeof(string), typeof(bool) }, null)!.GetParameters()[1] + }, + new global::TUnit.Core.ParameterMetadata(typeof(bool)) + { + Name = "value3", + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(bool)), + IsNullable = false, + ReflectionInfo = typeof(global::TUnit.TestProject.TupleDataSourceDrivenTests).GetMethod("DataSource_TupleMethod", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(int), typeof(string), typeof(bool) }, null)!.GetParameters()[2] + } + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.TupleDataSourceDrivenTests", static () => + { + var classMetadata = new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.TupleDataSourceDrivenTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.TupleDataSourceDrivenTests)), + Name = "TupleDataSourceDrivenTests", + Namespace = "TUnit.TestProject", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", static () => new global::TUnit.Core.AssemblyMetadata { Name = "TestsBase`1" }), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }; + return classMetadata; + }) + }, + InstanceFactory = (typeArgs, args) => new global::TUnit.TestProject.TupleDataSourceDrivenTests(), + InvokeTypedTest = static (instance, args, cancellationToken) => + { + try + { + switch (args.Length) + { + case 3: + { + instance.DataSource_TupleMethod(global::TUnit.Core.Helpers.CastHelper.Cast(args[0]), global::TUnit.Core.Helpers.CastHelper.Cast(args[1]), global::TUnit.Core.Helpers.CastHelper.Cast(args[2])); + return default(global::System.Threading.Tasks.ValueTask); + } + default: + throw new global::System.ArgumentException($"Expected exactly 3 arguments, but got {args.Length}"); + } + } + catch (global::System.Exception ex) + { + return new global::System.Threading.Tasks.ValueTask(global::System.Threading.Tasks.Task.FromException(ex)); + } + }, + }; + metadata.UseRuntimeDataGeneration(testSessionId); + yield return metadata; + yield break; + } + public global::System.Collections.Generic.IEnumerable EnumerateTestDescriptors() + { + yield return new global::TUnit.Core.TestDescriptor + { + TestId = "TUnit.TestProject.TupleDataSourceDrivenTests.DataSource_TupleMethod", + ClassName = "TupleDataSourceDrivenTests", + MethodName = "DataSource_TupleMethod", + FullyQualifiedName = "TUnit.TestProject.TupleDataSourceDrivenTests.DataSource_TupleMethod", + FilePath = @"", + LineNumber = 8, + Categories = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + HasDataSource = true, + RepeatCount = 0, + DependsOn = global::System.Array.Empty(), + Materializer = GetTestsAsync + }; + } +} +internal static class TUnit_TestProject_TupleDataSourceDrivenTests_DataSource_TupleMethod__int_string_bool_ModuleInitializer +{ + [global::System.Runtime.CompilerServices.ModuleInitializer] + public static void Initialize() + { + global::TUnit.Core.SourceRegistrar.Register(typeof(global::TUnit.TestProject.TupleDataSourceDrivenTests), new TUnit_TestProject_TupleDataSourceDrivenTests_DataSource_TupleMethod__int_string_bool_TestSource()); + } +} diff --git a/TUnit.Core.SourceGenerator.Tests/Tests1889.Test.Net4_7.verified.txt b/TUnit.Core.SourceGenerator.Tests/Tests1889.Test.Net4_7.verified.txt index a3350fb87d..48cf940413 100644 --- a/TUnit.Core.SourceGenerator.Tests/Tests1889.Test.Net4_7.verified.txt +++ b/TUnit.Core.SourceGenerator.Tests/Tests1889.Test.Net4_7.verified.txt @@ -174,7 +174,7 @@ internal sealed class TUnit_TestProject_Bugs__1889_DerivedTest_Test2__bool_TestS { case 1: { - instance.Test2(TUnit.Core.Helpers.CastHelper.Cast(args[0])); + instance.Test2(global::TUnit.Core.Helpers.CastHelper.Cast(args[0])); return default(global::System.Threading.Tasks.ValueTask); } default: @@ -297,7 +297,7 @@ internal sealed class TUnit_TestProject_Bugs__1889_DerivedTest_Test3__bool_TestS { case 1: { - instance.Test3(TUnit.Core.Helpers.CastHelper.Cast(args[0])); + instance.Test3(global::TUnit.Core.Helpers.CastHelper.Cast(args[0])); return default(global::System.Threading.Tasks.ValueTask); } default: diff --git a/TUnit.Core.SourceGenerator/CodeGenerators/InfrastructureGenerator.cs b/TUnit.Core.SourceGenerator/CodeGenerators/InfrastructureGenerator.cs index bb1767cc61..d844abe5c7 100644 --- a/TUnit.Core.SourceGenerator/CodeGenerators/InfrastructureGenerator.cs +++ b/TUnit.Core.SourceGenerator/CodeGenerators/InfrastructureGenerator.cs @@ -9,9 +9,17 @@ namespace TUnit.Core.SourceGenerator.CodeGenerators; /// Consolidated infrastructure generator that handles: /// 1. Disabling reflection scanner (sets SourceRegistrar.IsEnabled = true) /// 2. Pre-loading assemblies that reference TUnit.Core +/// 3. Forcing library module initializers to complete synchronously /// /// This combines DisableReflectionScannerGenerator and AssemblyLoaderGenerator /// into a single generator for efficiency. +/// +/// Assembly Loading Strategy: +/// Uses RuntimeHelpers.RunClassConstructor to force library module initializers +/// to complete before the test assembly's module initializer finishes. This ensures +/// hooks registered by library assemblies are available when HookDelegateBuilder +/// collects them. Static constructors can only run AFTER module initializers complete, +/// so calling RunClassConstructor blocks until initialization is done. /// [Generator] public class InfrastructureGenerator : IIncrementalGenerator @@ -333,13 +341,18 @@ private static void GenerateCode(SourceProductionContext context, AssemblyInfoMo sourceBuilder.AppendLine($"global::TUnit.Core.GlobalContext.Current.GlobalLogger.LogDebug(\"[ModuleInitializer] Loading {model.TypesToReference.Length} assembly reference(s)...\");"); } - foreach (var typeName in model.TypesToReference) + for (var i = 0; i < model.TypesToReference.Length; i++) { + var typeName = model.TypesToReference[i]; sourceBuilder.AppendLine("try"); sourceBuilder.AppendLine("{"); sourceBuilder.Indent(); sourceBuilder.AppendLine($"global::TUnit.Core.GlobalContext.Current.GlobalLogger.LogDebug(\"[ModuleInitializer] Loading assembly containing: {typeName.Replace("\"", "\\\"")}\");"); - sourceBuilder.AppendLine($"_ = typeof({typeName});"); + sourceBuilder.AppendLine($"var type_{i} = typeof({typeName});"); + sourceBuilder.AppendLine("// Force module initializer to complete before proceeding"); + sourceBuilder.AppendLine("// RunClassConstructor triggers static constructor, which can only run AFTER module initializer completes"); + sourceBuilder.AppendLine($"global::System.Runtime.CompilerServices.RuntimeHelpers.RunClassConstructor(type_{i}.TypeHandle);"); + sourceBuilder.AppendLine($"global::TUnit.Core.GlobalContext.Current.GlobalLogger.LogDebug(\"[ModuleInitializer] Assembly initialized: {typeName.Replace("\"", "\\\"")}\");"); sourceBuilder.Unindent(); sourceBuilder.AppendLine("}"); sourceBuilder.AppendLine("catch (global::System.Exception ex)"); From 0c5cee8115513d83c23c5db8371844efa7cc747e Mon Sep 17 00:00:00 2001 From: Tom Longhurst <30480171+thomhurst@users.noreply.github.com> Date: Sat, 31 Jan 2026 21:20:23 +0000 Subject: [PATCH 02/11] feat: add assembly name to module initializer logs for debugging Enhances logging to include the assembly name in all module initializer log messages, making it easy to identify which assembly's module initializer is running and when library assemblies are being loaded. Example output: [ModuleInitializer:TUnit.TestProject] Loading assembly containing: ... [ModuleInitializer:TUnit.TestProject] Assembly initialized: ... [ModuleInitializer:TUnit.TestProject.Library] TUnit infrastructure initializing... This helps debug timing issues between test and library assemblies. --- .../CodeGenerators/InfrastructureGenerator.cs | 15 ++++++++------- .../Models/Extracted/AssemblyInfoModel.cs | 16 ++++++++++++++-- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/TUnit.Core.SourceGenerator/CodeGenerators/InfrastructureGenerator.cs b/TUnit.Core.SourceGenerator/CodeGenerators/InfrastructureGenerator.cs index d844abe5c7..f3cca742a2 100644 --- a/TUnit.Core.SourceGenerator/CodeGenerators/InfrastructureGenerator.cs +++ b/TUnit.Core.SourceGenerator/CodeGenerators/InfrastructureGenerator.cs @@ -116,6 +116,7 @@ private static AssemblyInfoModel ExtractAssemblyInfo(Compilation compilation) return new AssemblyInfoModel { + AssemblyName = compilation.Assembly.Name, TypesToReference = new EquatableArray([.. assembliesToLoad]) }; } @@ -327,18 +328,18 @@ private static void GenerateCode(SourceProductionContext context, AssemblyInfoMo using (sourceBuilder.BeginBlock("public static void Initialize()")) { // Log module initializer start (buffered until logger is ready) - sourceBuilder.AppendLine("global::TUnit.Core.GlobalContext.Current.GlobalLogger.LogDebug(\"[ModuleInitializer] TUnit infrastructure initializing...\");"); + sourceBuilder.AppendLine($"global::TUnit.Core.GlobalContext.Current.GlobalLogger.LogDebug(\"[ModuleInitializer:{model.AssemblyName}] TUnit infrastructure initializing...\");"); sourceBuilder.AppendLine(); // Disable reflection scanner for source-generated assemblies sourceBuilder.AppendLine("global::TUnit.Core.SourceRegistrar.IsEnabled = true;"); - sourceBuilder.AppendLine("global::TUnit.Core.GlobalContext.Current.GlobalLogger.LogDebug(\"[ModuleInitializer] Source generation mode enabled\");"); + sourceBuilder.AppendLine($"global::TUnit.Core.GlobalContext.Current.GlobalLogger.LogDebug(\"[ModuleInitializer:{model.AssemblyName}] Source generation mode enabled\");"); sourceBuilder.AppendLine(); // Reference types from assemblies to trigger their module constructors if (model.TypesToReference.Length > 0) { - sourceBuilder.AppendLine($"global::TUnit.Core.GlobalContext.Current.GlobalLogger.LogDebug(\"[ModuleInitializer] Loading {model.TypesToReference.Length} assembly reference(s)...\");"); + sourceBuilder.AppendLine($"global::TUnit.Core.GlobalContext.Current.GlobalLogger.LogDebug(\"[ModuleInitializer:{model.AssemblyName}] Loading {model.TypesToReference.Length} assembly reference(s)...\");"); } for (var i = 0; i < model.TypesToReference.Length; i++) @@ -347,24 +348,24 @@ private static void GenerateCode(SourceProductionContext context, AssemblyInfoMo sourceBuilder.AppendLine("try"); sourceBuilder.AppendLine("{"); sourceBuilder.Indent(); - sourceBuilder.AppendLine($"global::TUnit.Core.GlobalContext.Current.GlobalLogger.LogDebug(\"[ModuleInitializer] Loading assembly containing: {typeName.Replace("\"", "\\\"")}\");"); + sourceBuilder.AppendLine($"global::TUnit.Core.GlobalContext.Current.GlobalLogger.LogDebug(\"[ModuleInitializer:{model.AssemblyName}] Loading assembly containing: {typeName.Replace("\"", "\\\"")}\");"); sourceBuilder.AppendLine($"var type_{i} = typeof({typeName});"); sourceBuilder.AppendLine("// Force module initializer to complete before proceeding"); sourceBuilder.AppendLine("// RunClassConstructor triggers static constructor, which can only run AFTER module initializer completes"); sourceBuilder.AppendLine($"global::System.Runtime.CompilerServices.RuntimeHelpers.RunClassConstructor(type_{i}.TypeHandle);"); - sourceBuilder.AppendLine($"global::TUnit.Core.GlobalContext.Current.GlobalLogger.LogDebug(\"[ModuleInitializer] Assembly initialized: {typeName.Replace("\"", "\\\"")}\");"); + sourceBuilder.AppendLine($"global::TUnit.Core.GlobalContext.Current.GlobalLogger.LogDebug(\"[ModuleInitializer:{model.AssemblyName}] Assembly initialized: {typeName.Replace("\"", "\\\"")}\");"); sourceBuilder.Unindent(); sourceBuilder.AppendLine("}"); sourceBuilder.AppendLine("catch (global::System.Exception ex)"); sourceBuilder.AppendLine("{"); sourceBuilder.Indent(); - sourceBuilder.AppendLine($"global::TUnit.Core.GlobalContext.Current.GlobalLogger.LogDebug(\"[ModuleInitializer] Failed to load {typeName.Replace("\"", "\\\"")}: \" + ex.Message);"); + sourceBuilder.AppendLine($"global::TUnit.Core.GlobalContext.Current.GlobalLogger.LogDebug(\"[ModuleInitializer:{model.AssemblyName}] Failed to load {typeName.Replace("\"", "\\\"")}: \" + ex.Message);"); sourceBuilder.Unindent(); sourceBuilder.AppendLine("}"); } sourceBuilder.AppendLine(); - sourceBuilder.AppendLine("global::TUnit.Core.GlobalContext.Current.GlobalLogger.LogDebug(\"[ModuleInitializer] TUnit infrastructure initialized\");"); + sourceBuilder.AppendLine($"global::TUnit.Core.GlobalContext.Current.GlobalLogger.LogDebug(\"[ModuleInitializer:{model.AssemblyName}] TUnit infrastructure initialized\");"); } } diff --git a/TUnit.Core.SourceGenerator/Models/Extracted/AssemblyInfoModel.cs b/TUnit.Core.SourceGenerator/Models/Extracted/AssemblyInfoModel.cs index bdd739fd73..b9a707e815 100644 --- a/TUnit.Core.SourceGenerator/Models/Extracted/AssemblyInfoModel.cs +++ b/TUnit.Core.SourceGenerator/Models/Extracted/AssemblyInfoModel.cs @@ -6,6 +6,12 @@ namespace TUnit.Core.SourceGenerator.Models.Extracted; /// public sealed class AssemblyInfoModel : IEquatable { + /// + /// Name of the current assembly being generated for. + /// Used for debugging to identify which assembly's module initializer is running. + /// + public required string AssemblyName { get; init; } + /// /// Fully qualified type names to reference, which loads their assemblies and triggers hook discovery. /// @@ -23,7 +29,7 @@ public bool Equals(AssemblyInfoModel? other) return true; } - return TypesToReference.Equals(other.TypesToReference); + return AssemblyName == other.AssemblyName && TypesToReference.Equals(other.TypesToReference); } public override bool Equals(object? obj) @@ -33,6 +39,12 @@ public override bool Equals(object? obj) public override int GetHashCode() { - return TypesToReference.GetHashCode(); + unchecked + { + var hash = 17; + hash = hash * 31 + (AssemblyName?.GetHashCode() ?? 0); + hash = hash * 31 + TypesToReference.GetHashCode(); + return hash; + } } } From d2cb6da3f66695ae26e384d87459b217e3b8d8aa Mon Sep 17 00:00:00 2001 From: Tom Longhurst <30480171+thomhurst@users.noreply.github.com> Date: Sat, 31 Jan 2026 21:44:28 +0000 Subject: [PATCH 03/11] fix: force TUnit.Core to load before accessing its types Prevents TypeInitializationException in third-party packages that reference TUnit by ensuring TUnit.Core assembly is loaded before the module initializer attempts to access GlobalContext or other TUnit.Core types. This is cleaner than defensive try-catch as it ensures dependencies are properly loaded and logging actually works. --- .../CodeGenerators/InfrastructureGenerator.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/TUnit.Core.SourceGenerator/CodeGenerators/InfrastructureGenerator.cs b/TUnit.Core.SourceGenerator/CodeGenerators/InfrastructureGenerator.cs index f3cca742a2..98e5744582 100644 --- a/TUnit.Core.SourceGenerator/CodeGenerators/InfrastructureGenerator.cs +++ b/TUnit.Core.SourceGenerator/CodeGenerators/InfrastructureGenerator.cs @@ -327,6 +327,11 @@ private static void GenerateCode(SourceProductionContext context, AssemblyInfoMo sourceBuilder.AppendLine("[global::System.Runtime.CompilerServices.ModuleInitializer]"); using (sourceBuilder.BeginBlock("public static void Initialize()")) { + // Force TUnit.Core to load before accessing any of its types + // This prevents TypeInitializationException in third-party packages + sourceBuilder.AppendLine("_ = typeof(global::TUnit.Core.GlobalContext);"); + sourceBuilder.AppendLine(); + // Log module initializer start (buffered until logger is ready) sourceBuilder.AppendLine($"global::TUnit.Core.GlobalContext.Current.GlobalLogger.LogDebug(\"[ModuleInitializer:{model.AssemblyName}] TUnit infrastructure initializing...\");"); sourceBuilder.AppendLine(); From a58af3b134123068aa250473e08b959374fefbbb Mon Sep 17 00:00:00 2001 From: Tom Longhurst <30480171+thomhurst@users.noreply.github.com> Date: Sat, 31 Jan 2026 21:49:22 +0000 Subject: [PATCH 04/11] feat: add defensive logging with try-catch for safety Wraps all logging statements in try-catch blocks for defense in depth. The explicit TUnit.Core loading (typeof) still fails fast if there's a real problem, but logging failures won't crash initialization. This provides: - Fail-fast on real issues (TUnit.Core can't load) - Graceful degradation (logging failures don't crash) - Better debugging (logs when available) - Safety for edge cases and third-party packages --- .../CodeGenerators/InfrastructureGenerator.cs | 46 ++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/TUnit.Core.SourceGenerator/CodeGenerators/InfrastructureGenerator.cs b/TUnit.Core.SourceGenerator/CodeGenerators/InfrastructureGenerator.cs index 98e5744582..083498194a 100644 --- a/TUnit.Core.SourceGenerator/CodeGenerators/InfrastructureGenerator.cs +++ b/TUnit.Core.SourceGenerator/CodeGenerators/InfrastructureGenerator.cs @@ -329,22 +329,42 @@ private static void GenerateCode(SourceProductionContext context, AssemblyInfoMo { // Force TUnit.Core to load before accessing any of its types // This prevents TypeInitializationException in third-party packages + // If this fails, we want to fail fast with a clear error sourceBuilder.AppendLine("_ = typeof(global::TUnit.Core.GlobalContext);"); sourceBuilder.AppendLine(); - // Log module initializer start (buffered until logger is ready) + // Defensive logging - wrap in try-catch for safety + sourceBuilder.AppendLine("try"); + sourceBuilder.AppendLine("{"); + sourceBuilder.Indent(); sourceBuilder.AppendLine($"global::TUnit.Core.GlobalContext.Current.GlobalLogger.LogDebug(\"[ModuleInitializer:{model.AssemblyName}] TUnit infrastructure initializing...\");"); + sourceBuilder.Unindent(); + sourceBuilder.AppendLine("}"); + sourceBuilder.AppendLine("catch { /* Logging failed - continue initialization */ }"); sourceBuilder.AppendLine(); // Disable reflection scanner for source-generated assemblies sourceBuilder.AppendLine("global::TUnit.Core.SourceRegistrar.IsEnabled = true;"); + sourceBuilder.AppendLine(); + sourceBuilder.AppendLine("try"); + sourceBuilder.AppendLine("{"); + sourceBuilder.Indent(); sourceBuilder.AppendLine($"global::TUnit.Core.GlobalContext.Current.GlobalLogger.LogDebug(\"[ModuleInitializer:{model.AssemblyName}] Source generation mode enabled\");"); + sourceBuilder.Unindent(); + sourceBuilder.AppendLine("}"); + sourceBuilder.AppendLine("catch { /* Logging failed - continue initialization */ }"); sourceBuilder.AppendLine(); // Reference types from assemblies to trigger their module constructors if (model.TypesToReference.Length > 0) { + sourceBuilder.AppendLine("try"); + sourceBuilder.AppendLine("{"); + sourceBuilder.Indent(); sourceBuilder.AppendLine($"global::TUnit.Core.GlobalContext.Current.GlobalLogger.LogDebug(\"[ModuleInitializer:{model.AssemblyName}] Loading {model.TypesToReference.Length} assembly reference(s)...\");"); + sourceBuilder.Unindent(); + sourceBuilder.AppendLine("}"); + sourceBuilder.AppendLine("catch { /* Logging failed - continue initialization */ }"); } for (var i = 0; i < model.TypesToReference.Length; i++) @@ -353,24 +373,48 @@ private static void GenerateCode(SourceProductionContext context, AssemblyInfoMo sourceBuilder.AppendLine("try"); sourceBuilder.AppendLine("{"); sourceBuilder.Indent(); + sourceBuilder.AppendLine("try"); + sourceBuilder.AppendLine("{"); + sourceBuilder.Indent(); sourceBuilder.AppendLine($"global::TUnit.Core.GlobalContext.Current.GlobalLogger.LogDebug(\"[ModuleInitializer:{model.AssemblyName}] Loading assembly containing: {typeName.Replace("\"", "\\\"")}\");"); + sourceBuilder.Unindent(); + sourceBuilder.AppendLine("}"); + sourceBuilder.AppendLine("catch { /* Logging failed - continue initialization */ }"); sourceBuilder.AppendLine($"var type_{i} = typeof({typeName});"); sourceBuilder.AppendLine("// Force module initializer to complete before proceeding"); sourceBuilder.AppendLine("// RunClassConstructor triggers static constructor, which can only run AFTER module initializer completes"); sourceBuilder.AppendLine($"global::System.Runtime.CompilerServices.RuntimeHelpers.RunClassConstructor(type_{i}.TypeHandle);"); + sourceBuilder.AppendLine("try"); + sourceBuilder.AppendLine("{"); + sourceBuilder.Indent(); sourceBuilder.AppendLine($"global::TUnit.Core.GlobalContext.Current.GlobalLogger.LogDebug(\"[ModuleInitializer:{model.AssemblyName}] Assembly initialized: {typeName.Replace("\"", "\\\"")}\");"); sourceBuilder.Unindent(); sourceBuilder.AppendLine("}"); + sourceBuilder.AppendLine("catch { /* Logging failed - continue initialization */ }"); + sourceBuilder.Unindent(); + sourceBuilder.AppendLine("}"); sourceBuilder.AppendLine("catch (global::System.Exception ex)"); sourceBuilder.AppendLine("{"); sourceBuilder.Indent(); + sourceBuilder.AppendLine("try"); + sourceBuilder.AppendLine("{"); + sourceBuilder.Indent(); sourceBuilder.AppendLine($"global::TUnit.Core.GlobalContext.Current.GlobalLogger.LogDebug(\"[ModuleInitializer:{model.AssemblyName}] Failed to load {typeName.Replace("\"", "\\\"")}: \" + ex.Message);"); sourceBuilder.Unindent(); sourceBuilder.AppendLine("}"); + sourceBuilder.AppendLine("catch { /* Logging failed - continue initialization */ }"); + sourceBuilder.Unindent(); + sourceBuilder.AppendLine("}"); } sourceBuilder.AppendLine(); + sourceBuilder.AppendLine("try"); + sourceBuilder.AppendLine("{"); + sourceBuilder.Indent(); sourceBuilder.AppendLine($"global::TUnit.Core.GlobalContext.Current.GlobalLogger.LogDebug(\"[ModuleInitializer:{model.AssemblyName}] TUnit infrastructure initialized\");"); + sourceBuilder.Unindent(); + sourceBuilder.AppendLine("}"); + sourceBuilder.AppendLine("catch { /* Logging failed - continue initialization */ }"); } } From fe5dff7bebaa965d1c0a2fc7a51c8ccdd20b20d0 Mon Sep 17 00:00:00 2001 From: Tom Longhurst <30480171+thomhurst@users.noreply.github.com> Date: Sat, 31 Jan 2026 22:05:48 +0000 Subject: [PATCH 05/11] fix: wrap TUnit.Core loading in try-catch to prevent FileNotFoundException The explicit TUnit.Core loading was causing FileNotFoundException in third-party packages (like Verify.TUnit) during their build/test phase when TUnit.Core.dll isn't available yet in the output directory. By wrapping the loading in try-catch, we gracefully handle cases where TUnit.Core is unavailable while still providing the early-loading benefits for normal test execution. --- .../CodeGenerators/InfrastructureGenerator.cs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/TUnit.Core.SourceGenerator/CodeGenerators/InfrastructureGenerator.cs b/TUnit.Core.SourceGenerator/CodeGenerators/InfrastructureGenerator.cs index 083498194a..017098b6b7 100644 --- a/TUnit.Core.SourceGenerator/CodeGenerators/InfrastructureGenerator.cs +++ b/TUnit.Core.SourceGenerator/CodeGenerators/InfrastructureGenerator.cs @@ -327,20 +327,16 @@ private static void GenerateCode(SourceProductionContext context, AssemblyInfoMo sourceBuilder.AppendLine("[global::System.Runtime.CompilerServices.ModuleInitializer]"); using (sourceBuilder.BeginBlock("public static void Initialize()")) { - // Force TUnit.Core to load before accessing any of its types - // This prevents TypeInitializationException in third-party packages - // If this fails, we want to fail fast with a clear error - sourceBuilder.AppendLine("_ = typeof(global::TUnit.Core.GlobalContext);"); - sourceBuilder.AppendLine(); - - // Defensive logging - wrap in try-catch for safety + // Try to load TUnit.Core early, but don't crash if it's not available + // This handles cases like Verify.TUnit build where TUnit.Core DLL might not be present yet sourceBuilder.AppendLine("try"); sourceBuilder.AppendLine("{"); sourceBuilder.Indent(); + sourceBuilder.AppendLine("_ = typeof(global::TUnit.Core.GlobalContext);"); sourceBuilder.AppendLine($"global::TUnit.Core.GlobalContext.Current.GlobalLogger.LogDebug(\"[ModuleInitializer:{model.AssemblyName}] TUnit infrastructure initializing...\");"); sourceBuilder.Unindent(); sourceBuilder.AppendLine("}"); - sourceBuilder.AppendLine("catch { /* Logging failed - continue initialization */ }"); + sourceBuilder.AppendLine("catch { /* TUnit.Core not available or logging failed - continue initialization */ }"); sourceBuilder.AppendLine(); // Disable reflection scanner for source-generated assemblies From 3eb2985c40854f59419f6b6bb1b75c98920b2e36 Mon Sep 17 00:00:00 2001 From: Tom Longhurst <30480171+thomhurst@users.noreply.github.com> Date: Sat, 31 Jan 2026 22:33:51 +0000 Subject: [PATCH 06/11] feat: add MinVer for automatic version calculation from git tags MinVer automatically sets assembly version based on git tags, ensuring that locally built assemblies have matching versions with published packages. This fixes version mismatch issues where third-party packages like Verify.TUnit expect specific TUnit.Core versions (e.g., 1.12.65.0). --- Directory.Packages.props | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Directory.Packages.props b/Directory.Packages.props index 68cf08ffaa..176f0cf3d8 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -4,6 +4,10 @@ + + all + runtime; build; native; contentfiles; analyzers + @@ -46,6 +50,7 @@ + From c1a0df9bc96a1133bb2ab2b48d16e9d8495623d3 Mon Sep 17 00:00:00 2001 From: Tom Longhurst <30480171+thomhurst@users.noreply.github.com> Date: Sat, 31 Jan 2026 22:43:37 +0000 Subject: [PATCH 07/11] fix: remove duplicate MinVer PackageVersion entry MinVer should only be a GlobalPackageReference, not also a PackageVersion. --- Directory.Packages.props | 1 - 1 file changed, 1 deletion(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 176f0cf3d8..6faba0dad9 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -50,7 +50,6 @@ - From 12bfef349d9a0cc8ecb93e23d647d1793b954879 Mon Sep 17 00:00:00 2001 From: Tom Longhurst <30480171+thomhurst@users.noreply.github.com> Date: Sat, 31 Jan 2026 23:21:29 +0000 Subject: [PATCH 08/11] fix: wrap all TUnit.Core references in defensive try-catch The root cause: Third-party NuGet packages (like Verify.TUnit) may be built with older versions of TUnit.Core.SourceGenerator. When they run in CI with newer TUnit.Core versions, any unguarded TUnit.Core type access causes FileNotFoundException or version mismatch errors. The solution: Wrap EVERY TUnit.Core reference (logging, SourceRegistrar) in individual try-catch blocks. This makes the generated code resilient to: - TUnit.Core version mismatches - TUnit.Core not being available (transitive dependencies) - Build order issues (assembly not loaded yet) Critical changes: - SourceRegistrar.IsEnabled set FIRST before any logging (most important) - Each logging call wrapped separately so one failure doesn't block others - Assembly loading (RunClassConstructor) still works even if logging fails - Clear error messages in catch blocks explain why operations were skipped This ensures library assemblies with hooks can still load other assemblies even when TUnit.Core has version mismatches or isn't available. --- .../CodeGenerators/InfrastructureGenerator.cs | 27 +++++++++---------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/TUnit.Core.SourceGenerator/CodeGenerators/InfrastructureGenerator.cs b/TUnit.Core.SourceGenerator/CodeGenerators/InfrastructureGenerator.cs index 017098b6b7..608dbbce69 100644 --- a/TUnit.Core.SourceGenerator/CodeGenerators/InfrastructureGenerator.cs +++ b/TUnit.Core.SourceGenerator/CodeGenerators/InfrastructureGenerator.cs @@ -327,28 +327,25 @@ private static void GenerateCode(SourceProductionContext context, AssemblyInfoMo sourceBuilder.AppendLine("[global::System.Runtime.CompilerServices.ModuleInitializer]"); using (sourceBuilder.BeginBlock("public static void Initialize()")) { - // Try to load TUnit.Core early, but don't crash if it's not available - // This handles cases like Verify.TUnit build where TUnit.Core DLL might not be present yet + // Set source registrar FIRST - this is critical and must run even if logging fails + // Wrap in try-catch to handle cases where TUnit.Core isn't available sourceBuilder.AppendLine("try"); sourceBuilder.AppendLine("{"); sourceBuilder.Indent(); - sourceBuilder.AppendLine("_ = typeof(global::TUnit.Core.GlobalContext);"); - sourceBuilder.AppendLine($"global::TUnit.Core.GlobalContext.Current.GlobalLogger.LogDebug(\"[ModuleInitializer:{model.AssemblyName}] TUnit infrastructure initializing...\");"); + sourceBuilder.AppendLine("global::TUnit.Core.SourceRegistrar.IsEnabled = true;"); sourceBuilder.Unindent(); sourceBuilder.AppendLine("}"); - sourceBuilder.AppendLine("catch { /* TUnit.Core not available or logging failed - continue initialization */ }"); + sourceBuilder.AppendLine("catch { /* TUnit.Core not available - skip source registrar */ }"); sourceBuilder.AppendLine(); - // Disable reflection scanner for source-generated assemblies - sourceBuilder.AppendLine("global::TUnit.Core.SourceRegistrar.IsEnabled = true;"); - sourceBuilder.AppendLine(); + // Logging is optional - wrap separately so it doesn't prevent other work sourceBuilder.AppendLine("try"); sourceBuilder.AppendLine("{"); sourceBuilder.Indent(); - sourceBuilder.AppendLine($"global::TUnit.Core.GlobalContext.Current.GlobalLogger.LogDebug(\"[ModuleInitializer:{model.AssemblyName}] Source generation mode enabled\");"); + sourceBuilder.AppendLine($"global::TUnit.Core.GlobalContext.Current.GlobalLogger.LogDebug(\"[ModuleInitializer:{model.AssemblyName}] TUnit infrastructure initializing...\");"); sourceBuilder.Unindent(); sourceBuilder.AppendLine("}"); - sourceBuilder.AppendLine("catch { /* Logging failed - continue initialization */ }"); + sourceBuilder.AppendLine("catch { /* TUnit.Core not available - skip logging */ }"); sourceBuilder.AppendLine(); // Reference types from assemblies to trigger their module constructors @@ -360,7 +357,7 @@ private static void GenerateCode(SourceProductionContext context, AssemblyInfoMo sourceBuilder.AppendLine($"global::TUnit.Core.GlobalContext.Current.GlobalLogger.LogDebug(\"[ModuleInitializer:{model.AssemblyName}] Loading {model.TypesToReference.Length} assembly reference(s)...\");"); sourceBuilder.Unindent(); sourceBuilder.AppendLine("}"); - sourceBuilder.AppendLine("catch { /* Logging failed - continue initialization */ }"); + sourceBuilder.AppendLine("catch { /* TUnit.Core not available - skip logging */ }"); } for (var i = 0; i < model.TypesToReference.Length; i++) @@ -375,7 +372,7 @@ private static void GenerateCode(SourceProductionContext context, AssemblyInfoMo sourceBuilder.AppendLine($"global::TUnit.Core.GlobalContext.Current.GlobalLogger.LogDebug(\"[ModuleInitializer:{model.AssemblyName}] Loading assembly containing: {typeName.Replace("\"", "\\\"")}\");"); sourceBuilder.Unindent(); sourceBuilder.AppendLine("}"); - sourceBuilder.AppendLine("catch { /* Logging failed - continue initialization */ }"); + sourceBuilder.AppendLine("catch { /* TUnit.Core not available - skip logging */ }"); sourceBuilder.AppendLine($"var type_{i} = typeof({typeName});"); sourceBuilder.AppendLine("// Force module initializer to complete before proceeding"); sourceBuilder.AppendLine("// RunClassConstructor triggers static constructor, which can only run AFTER module initializer completes"); @@ -386,7 +383,7 @@ private static void GenerateCode(SourceProductionContext context, AssemblyInfoMo sourceBuilder.AppendLine($"global::TUnit.Core.GlobalContext.Current.GlobalLogger.LogDebug(\"[ModuleInitializer:{model.AssemblyName}] Assembly initialized: {typeName.Replace("\"", "\\\"")}\");"); sourceBuilder.Unindent(); sourceBuilder.AppendLine("}"); - sourceBuilder.AppendLine("catch { /* Logging failed - continue initialization */ }"); + sourceBuilder.AppendLine("catch { /* TUnit.Core not available - skip logging */ }"); sourceBuilder.Unindent(); sourceBuilder.AppendLine("}"); sourceBuilder.AppendLine("catch (global::System.Exception ex)"); @@ -398,7 +395,7 @@ private static void GenerateCode(SourceProductionContext context, AssemblyInfoMo sourceBuilder.AppendLine($"global::TUnit.Core.GlobalContext.Current.GlobalLogger.LogDebug(\"[ModuleInitializer:{model.AssemblyName}] Failed to load {typeName.Replace("\"", "\\\"")}: \" + ex.Message);"); sourceBuilder.Unindent(); sourceBuilder.AppendLine("}"); - sourceBuilder.AppendLine("catch { /* Logging failed - continue initialization */ }"); + sourceBuilder.AppendLine("catch { /* TUnit.Core not available - skip logging */ }"); sourceBuilder.Unindent(); sourceBuilder.AppendLine("}"); } @@ -410,7 +407,7 @@ private static void GenerateCode(SourceProductionContext context, AssemblyInfoMo sourceBuilder.AppendLine($"global::TUnit.Core.GlobalContext.Current.GlobalLogger.LogDebug(\"[ModuleInitializer:{model.AssemblyName}] TUnit infrastructure initialized\");"); sourceBuilder.Unindent(); sourceBuilder.AppendLine("}"); - sourceBuilder.AppendLine("catch { /* Logging failed - continue initialization */ }"); + sourceBuilder.AppendLine("catch { /* TUnit.Core not available - skip logging */ }"); } } From 0faefbd28b923f96b4656abcf5ec627ce925263c Mon Sep 17 00:00:00 2001 From: Tom Longhurst <30480171+thomhurst@users.noreply.github.com> Date: Sat, 31 Jan 2026 23:37:27 +0000 Subject: [PATCH 09/11] fix: configure MinVer to set AssemblyVersion from git tags MinVer was ignoring tags with 'v' prefix (v1.12.102), causing version calculation to fall back to ancient 0.85.0 tag. This resulted in TypeInitializationException when third-party packages like Verify.TUnit expected specific TUnit.Core versions but found mismatched AssemblyVersion. Changes: - Add MinVerTagPrefix configuration to recognize 'v' prefixed tags - Configure MSBuild target to set AssemblyVersion from MinVer properties - Set FileVersion to match for consistency Result: AssemblyVersion now matches git tag version (1.12.103.0), enabling modern .NET's automatic binding redirection to handle version mismatches. --- Directory.Packages.props | 4 ++++ Library.props | 2 +- Library.targets | 9 +++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 6faba0dad9..4e4d6b58e3 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -2,6 +2,10 @@ true + + + v + diff --git a/Library.props b/Library.props index f05d61c64a..a4f9a83316 100644 --- a/Library.props +++ b/Library.props @@ -8,7 +8,7 @@ true - + true $(MSBuildThisFileDirectory)strongname.snk 0024000004800000940000000602000000240000525341310004000001000100698a70398fa0b2230c5a72e3bd9d56b48f809f6173e49a19fbb942d621be93ad48c5566b47b28faabc359b9ad3ff4e00bbdea88f5bdfa250f391fedd28182b2e37b55d429c0151a42a98ea7a5821818cd15a79fef9903e8607a88304cf3e0317bf86ec96e32e1381535a6582251e5a6eed40b5a3ed82bc444598b1269cce57a7 diff --git a/Library.targets b/Library.targets index 71a1f1dca7..eca124b150 100644 --- a/Library.targets +++ b/Library.targets @@ -1,4 +1,13 @@ + + + + + $(MinVerMajor).$(MinVerMinor).$(MinVerPatch).0 + $(MinVerMajor).$(MinVerMinor).$(MinVerPatch).0 + + + From 25f41976c38a2b1f8004b4de74f5ebcd85bcdc91 Mon Sep 17 00:00:00 2001 From: Tom Longhurst <30480171+thomhurst@users.noreply.github.com> Date: Sat, 31 Jan 2026 23:55:34 +0000 Subject: [PATCH 10/11] fix: skip AssemblyVersion target during pack operations Add condition to prevent SetAssemblyVersionFromMinVer target from running when IsPackTarget=true. Pack operations have their own explicit version settings and this target would interfere with that process. --- Library.targets | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Library.targets b/Library.targets index eca124b150..614129a44c 100644 --- a/Library.targets +++ b/Library.targets @@ -3,7 +3,10 @@ Project="$(MSBuildThisFileDirectory)Polyfill.targets" /> - + + $(MinVerMajor).$(MinVerMinor).$(MinVerPatch).0 $(MinVerMajor).$(MinVerMinor).$(MinVerPatch).0 From 9ea1ec4b6538c7f038ef97c85d5b4ebc7d94233e Mon Sep 17 00:00:00 2001 From: Tom Longhurst <30480171+thomhurst@users.noreply.github.com> Date: Sun, 1 Feb 2026 00:19:23 +0000 Subject: [PATCH 11/11] fix: skip MinVer during pack operations Pack operations provide explicit versioning via properties (Version, PackageVersion, AssemblyFileVersion). MinVer was running during pack and overriding these with calculated versions from git tags, causing version mismatches in the test pipeline. Add MinVerSkip=true condition when IsPackTarget=true to prevent MinVer from interfering with explicit pack versioning. --- Directory.Packages.props | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Directory.Packages.props b/Directory.Packages.props index 4e4d6b58e3..86cd42989b 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -5,6 +5,8 @@ v + + true