diff --git a/.editorconfig b/.editorconfig index 36ded1c6ff..21ecaacff2 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,9 +1,132 @@ root = true +[*] +insert_final_newline = true +indent_style = space +indent_size = 4 +trim_trailing_whitespace = true + +[project.json] +indent_size = 2 + +# Generated code +[*{_AssemblyInfo.cs,.notsupported.cs}] +generated_code = true + +# C# files +[*.cs] +# New line preferences +csharp_new_line_before_open_brace = all +csharp_new_line_before_else = true +csharp_new_line_before_catch = true +csharp_new_line_before_finally = true +csharp_new_line_before_members_in_object_initializers = true +csharp_new_line_before_members_in_anonymous_types = true +csharp_new_line_between_query_expression_clauses = true + +# Indentation preferences +csharp_indent_block_contents = true +csharp_indent_braces = false +csharp_indent_case_contents = true +csharp_indent_case_contents_when_block = true +csharp_indent_switch_labels = true +csharp_indent_labels = one_less_than_current + +# Modifier preferences +csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:suggestion + +# avoid this. unless absolutely necessary +dotnet_style_qualification_for_field = false:suggestion +dotnet_style_qualification_for_property = false:suggestion +dotnet_style_qualification_for_method = false:suggestion +dotnet_style_qualification_for_event = false:suggestion + +# name all constant fields using PascalCase +dotnet_naming_rule.constant_fields_should_be_pascal_case.severity = suggestion +dotnet_naming_rule.constant_fields_should_be_pascal_case.symbols = constant_fields +dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style +dotnet_naming_symbols.constant_fields.applicable_kinds = field +dotnet_naming_symbols.constant_fields.required_modifiers = const +dotnet_naming_style.pascal_case_style.capitalization = pascal_case + +# internal and private fields should be _camelCase +dotnet_naming_rule.camel_case_for_private_internal_fields.severity = suggestion +dotnet_naming_rule.camel_case_for_private_internal_fields.symbols = private_internal_fields +dotnet_naming_rule.camel_case_for_private_internal_fields.style = camel_case_underscore_style +dotnet_naming_symbols.private_internal_fields.applicable_kinds = field +dotnet_naming_symbols.private_internal_fields.applicable_accessibilities = private, internal +dotnet_naming_style.camel_case_underscore_style.required_prefix = _ +dotnet_naming_style.camel_case_underscore_style.capitalization = camel_case + +# Code style defaults +csharp_using_directive_placement = outside_namespace:suggestion +dotnet_sort_system_directives_first = true +csharp_prefer_braces = true:silent +csharp_preserve_single_line_blocks = true:none +csharp_preserve_single_line_statements = false:none +csharp_prefer_static_local_function = true:suggestion +csharp_style_prefer_switch_expression = true:suggestion +dotnet_style_readonly_field = true:suggestion + +# Expression-level preferences +dotnet_style_object_initializer = true:suggestion +dotnet_style_collection_initializer = true:suggestion +dotnet_style_explicit_tuple_names = true:suggestion +dotnet_style_coalesce_expression = true:suggestion +dotnet_style_null_propagation = true:suggestion +dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion +dotnet_style_prefer_inferred_tuple_names = true:suggestion +dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion +dotnet_style_prefer_auto_properties = true:suggestion +dotnet_style_prefer_conditional_expression_over_assignment = true:silent +dotnet_style_prefer_conditional_expression_over_return = true:silent + +# Expression-bodied members +csharp_style_expression_bodied_methods = true:silent +csharp_style_expression_bodied_constructors = true:silent +csharp_style_expression_bodied_operators = true:silent +csharp_style_expression_bodied_properties = true:silent +csharp_style_expression_bodied_indexers = true:silent +csharp_style_expression_bodied_accessors = true:silent +csharp_style_expression_bodied_lambdas = true:silent +csharp_style_expression_bodied_local_functions = true:silent + +# Pattern matching +csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion +csharp_style_pattern_matching_over_as_with_null_check = true:suggestion +csharp_style_inlined_variable_declaration = true:suggestion + +# Null checking preferences +csharp_style_throw_expression = true:suggestion +csharp_style_conditional_delegate_call = true:suggestion + +# Space preferences +csharp_space_after_cast = true +csharp_space_after_colon_in_inheritance_clause = true +csharp_space_after_comma = true +csharp_space_after_dot = false +csharp_space_after_keywords_in_control_flow_statements = true +csharp_space_after_semicolon_in_for_statement = true +csharp_space_around_binary_operators = before_and_after +csharp_space_around_declaration_statements = do_not_ignore +csharp_space_before_colon_in_inheritance_clause = true +csharp_space_before_comma = false +csharp_space_before_dot = false +csharp_space_before_open_square_brackets = false +csharp_space_before_semicolon_in_for_statement = false +csharp_space_between_empty_square_brackets = false +csharp_space_between_method_call_empty_parameter_list_parentheses = false +csharp_space_between_method_call_name_and_opening_parenthesis = false +csharp_space_between_method_call_parameter_list_parentheses = false +csharp_space_between_method_declaration_empty_parameter_list_parentheses = false +csharp_space_between_method_declaration_name_and_open_parenthesis = false +csharp_space_between_method_declaration_parameter_list_parentheses = false +csharp_space_between_parentheses = false +csharp_space_between_square_brackets = false + [*.{cs,vb}] dotnet_diagnostic.TUnitAssertions0003.severity=silent - # Verify [*.{received,verified}.{txt}] charset = "utf-8-bom" @@ -12,4 +135,4 @@ indent_size = unset indent_style = unset insert_final_newline = false tab_width = unset -trim_trailing_whitespace = false \ No newline at end of file +trim_trailing_whitespace = false diff --git a/TUnit.Core.SourceGenerator.Tests/AfterAllTests.Test.verified.txt b/TUnit.Core.SourceGenerator.Tests/AfterAllTests.Test.verified.txt index d96416fb88..7e12a4eb47 100644 --- a/TUnit.Core.SourceGenerator.Tests/AfterAllTests.Test.verified.txt +++ b/TUnit.Core.SourceGenerator.Tests/AfterAllTests.Test.verified.txt @@ -638,6 +638,7 @@ file partial class Hooks_CleanupTests : global::TUnit.Core.Interfaces.SourceGene { Name = "context", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.AfterTests.CleanupTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -728,6 +729,7 @@ file partial class Hooks_CleanupTests : global::TUnit.Core.Interfaces.SourceGene { Name = "cancellationToken", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.AfterTests.CleanupTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -818,11 +820,13 @@ file partial class Hooks_CleanupTests : global::TUnit.Core.Interfaces.SourceGene { Name = "context", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "cancellationToken", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.AfterTests.CleanupTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -997,6 +1001,7 @@ file partial class Hooks_CleanupTests : global::TUnit.Core.Interfaces.SourceGene { Name = "cancellationToken", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.AfterTests.CleanupTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -1086,6 +1091,7 @@ file partial class Hooks_CleanupTests : global::TUnit.Core.Interfaces.SourceGene { Name = "testContext", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.AfterTests.CleanupTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -1176,11 +1182,13 @@ file partial class Hooks_CleanupTests : global::TUnit.Core.Interfaces.SourceGene { Name = "testContext", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "cancellationToken", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.AfterTests.CleanupTests", () => new global::TUnit.Core.SourceGeneratedClassInformation diff --git a/TUnit.Core.SourceGenerator.Tests/AfterTests.Test.verified.txt b/TUnit.Core.SourceGenerator.Tests/AfterTests.Test.verified.txt index d81ab9247c..f0e0d2f393 100644 --- a/TUnit.Core.SourceGenerator.Tests/AfterTests.Test.verified.txt +++ b/TUnit.Core.SourceGenerator.Tests/AfterTests.Test.verified.txt @@ -638,6 +638,7 @@ file partial class Hooks_CleanupTests : global::TUnit.Core.Interfaces.SourceGene { Name = "context", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.AfterTests.CleanupTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -728,6 +729,7 @@ file partial class Hooks_CleanupTests : global::TUnit.Core.Interfaces.SourceGene { Name = "cancellationToken", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.AfterTests.CleanupTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -818,11 +820,13 @@ file partial class Hooks_CleanupTests : global::TUnit.Core.Interfaces.SourceGene { Name = "context", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "cancellationToken", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.AfterTests.CleanupTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -997,6 +1001,7 @@ file partial class Hooks_CleanupTests : global::TUnit.Core.Interfaces.SourceGene { Name = "cancellationToken", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.AfterTests.CleanupTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -1086,6 +1091,7 @@ file partial class Hooks_CleanupTests : global::TUnit.Core.Interfaces.SourceGene { Name = "testContext", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.AfterTests.CleanupTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -1176,11 +1182,13 @@ file partial class Hooks_CleanupTests : global::TUnit.Core.Interfaces.SourceGene { Name = "testContext", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "cancellationToken", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.AfterTests.CleanupTests", () => new global::TUnit.Core.SourceGeneratedClassInformation diff --git a/TUnit.Core.SourceGenerator.Tests/ArgsAsArrayTests.Test.verified.txt b/TUnit.Core.SourceGenerator.Tests/ArgsAsArrayTests.Test.verified.txt index b7d21fefd6..2feb414367 100644 --- a/TUnit.Core.SourceGenerator.Tests/ArgsAsArrayTests.Test.verified.txt +++ b/TUnit.Core.SourceGenerator.Tests/ArgsAsArrayTests.Test.verified.txt @@ -45,6 +45,7 @@ file partial class ArgsAsArrayTests : global::TUnit.Core.Interfaces.SourceGenera { Name = "arguments", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.ArgsAsArrayTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -161,6 +162,7 @@ file partial class ArgsAsArrayTests : global::TUnit.Core.Interfaces.SourceGenera { Name = "arguments", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.ArgsAsArrayTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -277,6 +279,7 @@ file partial class ArgsAsArrayTests : global::TUnit.Core.Interfaces.SourceGenera { Name = "arguments", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.ArgsAsArrayTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -393,6 +396,7 @@ file partial class ArgsAsArrayTests : global::TUnit.Core.Interfaces.SourceGenera { Name = "arguments", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.ArgsAsArrayTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -509,11 +513,13 @@ file partial class ArgsAsArrayTests : global::TUnit.Core.Interfaces.SourceGenera { Name = "i", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation> { Name = "arguments", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.ArgsAsArrayTests", () => new global::TUnit.Core.SourceGeneratedClassInformation diff --git a/TUnit.Core.SourceGenerator.Tests/ArgumentWithImplicitConverterTests.Test.verified.txt b/TUnit.Core.SourceGenerator.Tests/ArgumentWithImplicitConverterTests.Test.verified.txt index 0bffda5c09..aa3a4db38f 100644 --- a/TUnit.Core.SourceGenerator.Tests/ArgumentWithImplicitConverterTests.Test.verified.txt +++ b/TUnit.Core.SourceGenerator.Tests/ArgumentWithImplicitConverterTests.Test.verified.txt @@ -52,6 +52,7 @@ file partial class ArgumentWithImplicitConverterTests : global::TUnit.Core.Inter { Name = "integer", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.ArgumentWithImplicitConverterTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -145,6 +146,7 @@ file partial class ArgumentWithImplicitConverterTests : global::TUnit.Core.Inter { Name = "integer", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.ArgumentWithImplicitConverterTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -238,6 +240,7 @@ file partial class ArgumentWithImplicitConverterTests : global::TUnit.Core.Inter { Name = "integer", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.ArgumentWithImplicitConverterTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -361,6 +364,7 @@ file partial class ArgumentWithImplicitConverterTests : global::TUnit.Core.Inter { Name = "integer", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.ArgumentWithImplicitConverterTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -454,6 +458,7 @@ file partial class ArgumentWithImplicitConverterTests : global::TUnit.Core.Inter { Name = "integer", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.ArgumentWithImplicitConverterTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -547,6 +552,7 @@ file partial class ArgumentWithImplicitConverterTests : global::TUnit.Core.Inter { Name = "integer", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.ArgumentWithImplicitConverterTests", () => new global::TUnit.Core.SourceGeneratedClassInformation diff --git a/TUnit.Core.SourceGenerator.Tests/AssemblyAfterTests.Test.verified.txt b/TUnit.Core.SourceGenerator.Tests/AssemblyAfterTests.Test.verified.txt index fdb68d8a48..b7d05e657e 100644 --- a/TUnit.Core.SourceGenerator.Tests/AssemblyAfterTests.Test.verified.txt +++ b/TUnit.Core.SourceGenerator.Tests/AssemblyAfterTests.Test.verified.txt @@ -638,6 +638,7 @@ file partial class Hooks_AssemblyCleanupTests : global::TUnit.Core.Interfaces.So { Name = "context", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.AfterTests.AssemblyCleanupTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -728,6 +729,7 @@ file partial class Hooks_AssemblyCleanupTests : global::TUnit.Core.Interfaces.So { Name = "cancellationToken", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.AfterTests.AssemblyCleanupTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -818,11 +820,13 @@ file partial class Hooks_AssemblyCleanupTests : global::TUnit.Core.Interfaces.So { Name = "context", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "cancellationToken", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.AfterTests.AssemblyCleanupTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -997,6 +1001,7 @@ file partial class Hooks_AssemblyCleanupTests : global::TUnit.Core.Interfaces.So { Name = "cancellationToken", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.AfterTests.AssemblyCleanupTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -1086,6 +1091,7 @@ file partial class Hooks_AssemblyCleanupTests : global::TUnit.Core.Interfaces.So { Name = "testContext", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.AfterTests.AssemblyCleanupTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -1176,11 +1182,13 @@ file partial class Hooks_AssemblyCleanupTests : global::TUnit.Core.Interfaces.So { Name = "testContext", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "cancellationToken", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.AfterTests.AssemblyCleanupTests", () => new global::TUnit.Core.SourceGeneratedClassInformation diff --git a/TUnit.Core.SourceGenerator.Tests/AssemblyBeforeTests.Test.verified.txt b/TUnit.Core.SourceGenerator.Tests/AssemblyBeforeTests.Test.verified.txt index 570b604505..709b3911f1 100644 --- a/TUnit.Core.SourceGenerator.Tests/AssemblyBeforeTests.Test.verified.txt +++ b/TUnit.Core.SourceGenerator.Tests/AssemblyBeforeTests.Test.verified.txt @@ -632,6 +632,7 @@ file partial class Hooks_AssemblySetupTests : global::TUnit.Core.Interfaces.Sour { Name = "context", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.BeforeTests.AssemblySetupTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -722,6 +723,7 @@ file partial class Hooks_AssemblySetupTests : global::TUnit.Core.Interfaces.Sour { Name = "cancellationToken", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.BeforeTests.AssemblySetupTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -812,11 +814,13 @@ file partial class Hooks_AssemblySetupTests : global::TUnit.Core.Interfaces.Sour { Name = "context", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "cancellationToken", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.BeforeTests.AssemblySetupTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -991,6 +995,7 @@ file partial class Hooks_AssemblySetupTests : global::TUnit.Core.Interfaces.Sour { Name = "cancellationToken", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.BeforeTests.AssemblySetupTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -1080,6 +1085,7 @@ file partial class Hooks_AssemblySetupTests : global::TUnit.Core.Interfaces.Sour { Name = "testContext", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.BeforeTests.AssemblySetupTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -1170,11 +1176,13 @@ file partial class Hooks_AssemblySetupTests : global::TUnit.Core.Interfaces.Sour { Name = "testContext", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "cancellationToken", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.BeforeTests.AssemblySetupTests", () => new global::TUnit.Core.SourceGeneratedClassInformation diff --git a/TUnit.Core.SourceGenerator.Tests/AssemblyLoaderTests.Test.DotNet8_0.verified.txt b/TUnit.Core.SourceGenerator.Tests/AssemblyLoaderTests.Test.DotNet8_0.verified.txt index 0abca50ba8..35a3195163 100644 --- a/TUnit.Core.SourceGenerator.Tests/AssemblyLoaderTests.Test.DotNet8_0.verified.txt +++ b/TUnit.Core.SourceGenerator.Tests/AssemblyLoaderTests.Test.DotNet8_0.verified.txt @@ -6,21 +6,24 @@ file static class AssemblyLoader_Guid [global::System.Runtime.CompilerServices.ModuleInitializer] public static void Initialize() { + global::TUnit.Core.SourceRegistrar.RegisterAssembly(() => global::System.Reflection.Assembly.Load("AssemblyLoaderTests, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")); global::TUnit.Core.SourceRegistrar.RegisterAssembly(() => global::System.Reflection.Assembly.Load("TUnit.Core.SourceGenerator.Tests, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null")); - global::TUnit.Core.SourceRegistrar.RegisterAssembly(() => global::System.Reflection.Assembly.Load("TUnit.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b8d4030011dbd70c")); - global::TUnit.Core.SourceRegistrar.RegisterAssembly(() => global::System.Reflection.Assembly.Load("Verify.TUnit, Version=1.0.0.0, Culture=neutral, PublicKeyToken=c7a34512ecd69090")); - global::TUnit.Core.SourceRegistrar.RegisterAssembly(() => global::System.Reflection.Assembly.Load("Verify, Version=1.0.0.0, Culture=neutral, PublicKeyToken=c7a34512ecd69090")); + global::TUnit.Core.SourceRegistrar.RegisterAssembly(() => global::System.Reflection.Assembly.Load("TUnit.Engine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b8d4030011dbd70c")); global::TUnit.Core.SourceRegistrar.RegisterAssembly(() => global::System.Reflection.Assembly.Load("Argon, Version=1.0.0.0, Culture=neutral, PublicKeyToken=00a55352ff068a54")); global::TUnit.Core.SourceRegistrar.RegisterAssembly(() => global::System.Reflection.Assembly.Load("DiffEngine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=c7a34512ecd69090")); global::TUnit.Core.SourceRegistrar.RegisterAssembly(() => global::System.Reflection.Assembly.Load("EmptyFiles, Version=1.0.0.0, Culture=neutral, PublicKeyToken=c7a34512ecd69090")); - global::TUnit.Core.SourceRegistrar.RegisterAssembly(() => global::System.Reflection.Assembly.Load("SimpleInfoName, Version=1.0.0.0, Culture=neutral, PublicKeyToken=c7a34512ecd69090")); - global::TUnit.Core.SourceRegistrar.RegisterAssembly(() => global::System.Reflection.Assembly.Load("TUnit.Assertions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b8d4030011dbd70c")); - global::TUnit.Core.SourceRegistrar.RegisterAssembly(() => global::System.Reflection.Assembly.Load("TUnit.Core.SourceGenerator, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null")); - global::TUnit.Core.SourceRegistrar.RegisterAssembly(() => global::System.Reflection.Assembly.Load("TUnit.Engine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b8d4030011dbd70c")); global::TUnit.Core.SourceRegistrar.RegisterAssembly(() => global::System.Reflection.Assembly.Load("EnumerableAsyncProcessor, Version=2.1.0.0, Culture=neutral, PublicKeyToken=7a7adb9c614908c9")); global::TUnit.Core.SourceRegistrar.RegisterAssembly(() => global::System.Reflection.Assembly.Load("Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed")); + global::TUnit.Core.SourceRegistrar.RegisterAssembly(() => global::System.Reflection.Assembly.Load("SimpleInfoName, Version=1.0.0.0, Culture=neutral, PublicKeyToken=c7a34512ecd69090")); global::TUnit.Core.SourceRegistrar.RegisterAssembly(() => global::System.Reflection.Assembly.Load("Sourcy.Core, Version=0.7.7.0, Culture=neutral, PublicKeyToken=null")); + global::TUnit.Core.SourceRegistrar.RegisterAssembly(() => global::System.Reflection.Assembly.Load("TUnit.Core.SourceGenerator, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null")); + global::TUnit.Core.SourceRegistrar.RegisterAssembly(() => global::System.Reflection.Assembly.Load("Verify, Version=1.0.0.0, Culture=neutral, PublicKeyToken=c7a34512ecd69090")); + global::TUnit.Core.SourceRegistrar.RegisterAssembly(() => global::System.Reflection.Assembly.Load("Verify.TUnit, Version=1.0.0.0, Culture=neutral, PublicKeyToken=c7a34512ecd69090")); + global::TUnit.Core.SourceRegistrar.RegisterAssembly(() => global::System.Reflection.Assembly.Load("DiffPlex, Version=1.7.2.0, Culture=neutral, PublicKeyToken=1d35e91d1bd7bc0f")); + global::TUnit.Core.SourceRegistrar.RegisterAssembly(() => global::System.Reflection.Assembly.Load("Humanizer, Version=2.14.0.0, Culture=neutral, PublicKeyToken=979442b78dfc278e")); + global::TUnit.Core.SourceRegistrar.RegisterAssembly(() => global::System.Reflection.Assembly.Load("TUnit.Assertions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b8d4030011dbd70c")); global::TUnit.Core.SourceRegistrar.RegisterAssembly(() => global::System.Reflection.Assembly.Load("TUnit.TestProject.Library, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null")); + global::TUnit.Core.SourceRegistrar.RegisterAssembly(() => global::System.Reflection.Assembly.Load("TUnit.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b8d4030011dbd70c")); } } diff --git a/TUnit.Core.SourceGenerator.Tests/AssemblyLoaderTests.Test.DotNet9_0.verified.txt b/TUnit.Core.SourceGenerator.Tests/AssemblyLoaderTests.Test.DotNet9_0.verified.txt index 0abca50ba8..35a3195163 100644 --- a/TUnit.Core.SourceGenerator.Tests/AssemblyLoaderTests.Test.DotNet9_0.verified.txt +++ b/TUnit.Core.SourceGenerator.Tests/AssemblyLoaderTests.Test.DotNet9_0.verified.txt @@ -6,21 +6,24 @@ file static class AssemblyLoader_Guid [global::System.Runtime.CompilerServices.ModuleInitializer] public static void Initialize() { + global::TUnit.Core.SourceRegistrar.RegisterAssembly(() => global::System.Reflection.Assembly.Load("AssemblyLoaderTests, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")); global::TUnit.Core.SourceRegistrar.RegisterAssembly(() => global::System.Reflection.Assembly.Load("TUnit.Core.SourceGenerator.Tests, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null")); - global::TUnit.Core.SourceRegistrar.RegisterAssembly(() => global::System.Reflection.Assembly.Load("TUnit.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b8d4030011dbd70c")); - global::TUnit.Core.SourceRegistrar.RegisterAssembly(() => global::System.Reflection.Assembly.Load("Verify.TUnit, Version=1.0.0.0, Culture=neutral, PublicKeyToken=c7a34512ecd69090")); - global::TUnit.Core.SourceRegistrar.RegisterAssembly(() => global::System.Reflection.Assembly.Load("Verify, Version=1.0.0.0, Culture=neutral, PublicKeyToken=c7a34512ecd69090")); + global::TUnit.Core.SourceRegistrar.RegisterAssembly(() => global::System.Reflection.Assembly.Load("TUnit.Engine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b8d4030011dbd70c")); global::TUnit.Core.SourceRegistrar.RegisterAssembly(() => global::System.Reflection.Assembly.Load("Argon, Version=1.0.0.0, Culture=neutral, PublicKeyToken=00a55352ff068a54")); global::TUnit.Core.SourceRegistrar.RegisterAssembly(() => global::System.Reflection.Assembly.Load("DiffEngine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=c7a34512ecd69090")); global::TUnit.Core.SourceRegistrar.RegisterAssembly(() => global::System.Reflection.Assembly.Load("EmptyFiles, Version=1.0.0.0, Culture=neutral, PublicKeyToken=c7a34512ecd69090")); - global::TUnit.Core.SourceRegistrar.RegisterAssembly(() => global::System.Reflection.Assembly.Load("SimpleInfoName, Version=1.0.0.0, Culture=neutral, PublicKeyToken=c7a34512ecd69090")); - global::TUnit.Core.SourceRegistrar.RegisterAssembly(() => global::System.Reflection.Assembly.Load("TUnit.Assertions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b8d4030011dbd70c")); - global::TUnit.Core.SourceRegistrar.RegisterAssembly(() => global::System.Reflection.Assembly.Load("TUnit.Core.SourceGenerator, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null")); - global::TUnit.Core.SourceRegistrar.RegisterAssembly(() => global::System.Reflection.Assembly.Load("TUnit.Engine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b8d4030011dbd70c")); global::TUnit.Core.SourceRegistrar.RegisterAssembly(() => global::System.Reflection.Assembly.Load("EnumerableAsyncProcessor, Version=2.1.0.0, Culture=neutral, PublicKeyToken=7a7adb9c614908c9")); global::TUnit.Core.SourceRegistrar.RegisterAssembly(() => global::System.Reflection.Assembly.Load("Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed")); + global::TUnit.Core.SourceRegistrar.RegisterAssembly(() => global::System.Reflection.Assembly.Load("SimpleInfoName, Version=1.0.0.0, Culture=neutral, PublicKeyToken=c7a34512ecd69090")); global::TUnit.Core.SourceRegistrar.RegisterAssembly(() => global::System.Reflection.Assembly.Load("Sourcy.Core, Version=0.7.7.0, Culture=neutral, PublicKeyToken=null")); + global::TUnit.Core.SourceRegistrar.RegisterAssembly(() => global::System.Reflection.Assembly.Load("TUnit.Core.SourceGenerator, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null")); + global::TUnit.Core.SourceRegistrar.RegisterAssembly(() => global::System.Reflection.Assembly.Load("Verify, Version=1.0.0.0, Culture=neutral, PublicKeyToken=c7a34512ecd69090")); + global::TUnit.Core.SourceRegistrar.RegisterAssembly(() => global::System.Reflection.Assembly.Load("Verify.TUnit, Version=1.0.0.0, Culture=neutral, PublicKeyToken=c7a34512ecd69090")); + global::TUnit.Core.SourceRegistrar.RegisterAssembly(() => global::System.Reflection.Assembly.Load("DiffPlex, Version=1.7.2.0, Culture=neutral, PublicKeyToken=1d35e91d1bd7bc0f")); + global::TUnit.Core.SourceRegistrar.RegisterAssembly(() => global::System.Reflection.Assembly.Load("Humanizer, Version=2.14.0.0, Culture=neutral, PublicKeyToken=979442b78dfc278e")); + global::TUnit.Core.SourceRegistrar.RegisterAssembly(() => global::System.Reflection.Assembly.Load("TUnit.Assertions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b8d4030011dbd70c")); global::TUnit.Core.SourceRegistrar.RegisterAssembly(() => global::System.Reflection.Assembly.Load("TUnit.TestProject.Library, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null")); + global::TUnit.Core.SourceRegistrar.RegisterAssembly(() => global::System.Reflection.Assembly.Load("TUnit.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b8d4030011dbd70c")); } } diff --git a/TUnit.Core.SourceGenerator.Tests/AssemblyLoaderTests.Test.Net4_7.verified.txt b/TUnit.Core.SourceGenerator.Tests/AssemblyLoaderTests.Test.Net4_7.verified.txt index 0abca50ba8..35a3195163 100644 --- a/TUnit.Core.SourceGenerator.Tests/AssemblyLoaderTests.Test.Net4_7.verified.txt +++ b/TUnit.Core.SourceGenerator.Tests/AssemblyLoaderTests.Test.Net4_7.verified.txt @@ -6,21 +6,24 @@ file static class AssemblyLoader_Guid [global::System.Runtime.CompilerServices.ModuleInitializer] public static void Initialize() { + global::TUnit.Core.SourceRegistrar.RegisterAssembly(() => global::System.Reflection.Assembly.Load("AssemblyLoaderTests, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")); global::TUnit.Core.SourceRegistrar.RegisterAssembly(() => global::System.Reflection.Assembly.Load("TUnit.Core.SourceGenerator.Tests, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null")); - global::TUnit.Core.SourceRegistrar.RegisterAssembly(() => global::System.Reflection.Assembly.Load("TUnit.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b8d4030011dbd70c")); - global::TUnit.Core.SourceRegistrar.RegisterAssembly(() => global::System.Reflection.Assembly.Load("Verify.TUnit, Version=1.0.0.0, Culture=neutral, PublicKeyToken=c7a34512ecd69090")); - global::TUnit.Core.SourceRegistrar.RegisterAssembly(() => global::System.Reflection.Assembly.Load("Verify, Version=1.0.0.0, Culture=neutral, PublicKeyToken=c7a34512ecd69090")); + global::TUnit.Core.SourceRegistrar.RegisterAssembly(() => global::System.Reflection.Assembly.Load("TUnit.Engine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b8d4030011dbd70c")); global::TUnit.Core.SourceRegistrar.RegisterAssembly(() => global::System.Reflection.Assembly.Load("Argon, Version=1.0.0.0, Culture=neutral, PublicKeyToken=00a55352ff068a54")); global::TUnit.Core.SourceRegistrar.RegisterAssembly(() => global::System.Reflection.Assembly.Load("DiffEngine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=c7a34512ecd69090")); global::TUnit.Core.SourceRegistrar.RegisterAssembly(() => global::System.Reflection.Assembly.Load("EmptyFiles, Version=1.0.0.0, Culture=neutral, PublicKeyToken=c7a34512ecd69090")); - global::TUnit.Core.SourceRegistrar.RegisterAssembly(() => global::System.Reflection.Assembly.Load("SimpleInfoName, Version=1.0.0.0, Culture=neutral, PublicKeyToken=c7a34512ecd69090")); - global::TUnit.Core.SourceRegistrar.RegisterAssembly(() => global::System.Reflection.Assembly.Load("TUnit.Assertions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b8d4030011dbd70c")); - global::TUnit.Core.SourceRegistrar.RegisterAssembly(() => global::System.Reflection.Assembly.Load("TUnit.Core.SourceGenerator, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null")); - global::TUnit.Core.SourceRegistrar.RegisterAssembly(() => global::System.Reflection.Assembly.Load("TUnit.Engine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b8d4030011dbd70c")); global::TUnit.Core.SourceRegistrar.RegisterAssembly(() => global::System.Reflection.Assembly.Load("EnumerableAsyncProcessor, Version=2.1.0.0, Culture=neutral, PublicKeyToken=7a7adb9c614908c9")); global::TUnit.Core.SourceRegistrar.RegisterAssembly(() => global::System.Reflection.Assembly.Load("Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed")); + global::TUnit.Core.SourceRegistrar.RegisterAssembly(() => global::System.Reflection.Assembly.Load("SimpleInfoName, Version=1.0.0.0, Culture=neutral, PublicKeyToken=c7a34512ecd69090")); global::TUnit.Core.SourceRegistrar.RegisterAssembly(() => global::System.Reflection.Assembly.Load("Sourcy.Core, Version=0.7.7.0, Culture=neutral, PublicKeyToken=null")); + global::TUnit.Core.SourceRegistrar.RegisterAssembly(() => global::System.Reflection.Assembly.Load("TUnit.Core.SourceGenerator, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null")); + global::TUnit.Core.SourceRegistrar.RegisterAssembly(() => global::System.Reflection.Assembly.Load("Verify, Version=1.0.0.0, Culture=neutral, PublicKeyToken=c7a34512ecd69090")); + global::TUnit.Core.SourceRegistrar.RegisterAssembly(() => global::System.Reflection.Assembly.Load("Verify.TUnit, Version=1.0.0.0, Culture=neutral, PublicKeyToken=c7a34512ecd69090")); + global::TUnit.Core.SourceRegistrar.RegisterAssembly(() => global::System.Reflection.Assembly.Load("DiffPlex, Version=1.7.2.0, Culture=neutral, PublicKeyToken=1d35e91d1bd7bc0f")); + global::TUnit.Core.SourceRegistrar.RegisterAssembly(() => global::System.Reflection.Assembly.Load("Humanizer, Version=2.14.0.0, Culture=neutral, PublicKeyToken=979442b78dfc278e")); + global::TUnit.Core.SourceRegistrar.RegisterAssembly(() => global::System.Reflection.Assembly.Load("TUnit.Assertions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b8d4030011dbd70c")); global::TUnit.Core.SourceRegistrar.RegisterAssembly(() => global::System.Reflection.Assembly.Load("TUnit.TestProject.Library, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null")); + global::TUnit.Core.SourceRegistrar.RegisterAssembly(() => global::System.Reflection.Assembly.Load("TUnit.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b8d4030011dbd70c")); } } diff --git a/TUnit.Core.SourceGenerator.Tests/Basic.Test.verified.txt b/TUnit.Core.SourceGenerator.Tests/Basic.Test.verified.txt index 4ef27be2ad..592571462c 100644 --- a/TUnit.Core.SourceGenerator.Tests/Basic.Test.verified.txt +++ b/TUnit.Core.SourceGenerator.Tests/Basic.Test.verified.txt @@ -21,7 +21,7 @@ file partial class Basic : global::TUnit.Core.Interfaces.SourceGenerator.IDynami { try { - var context = new global::TUnit.Core.DynamicTestBuilderContext(@"", 40); + var context = new global::TUnit.Core.DynamicTestBuilderContext(@"", 43); new global::TUnit.TestProject.DynamicTests.Basic().BuildTests(context); return context.Tests; } @@ -35,7 +35,7 @@ file partial class Basic : global::TUnit.Core.Interfaces.SourceGenerator.IDynami MethodName = $"BuildTests", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("Basic.BuildTests failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 40, + TestLineNumber = 43, } ]; } diff --git a/TUnit.Core.SourceGenerator.Tests/BeforeAllTests.Test.verified.txt b/TUnit.Core.SourceGenerator.Tests/BeforeAllTests.Test.verified.txt index b4bd80f83d..45740e6b60 100644 --- a/TUnit.Core.SourceGenerator.Tests/BeforeAllTests.Test.verified.txt +++ b/TUnit.Core.SourceGenerator.Tests/BeforeAllTests.Test.verified.txt @@ -632,6 +632,7 @@ file partial class Hooks_SetupTests : global::TUnit.Core.Interfaces.SourceGenera { Name = "context", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.BeforeTests.SetupTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -722,6 +723,7 @@ file partial class Hooks_SetupTests : global::TUnit.Core.Interfaces.SourceGenera { Name = "cancellationToken", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.BeforeTests.SetupTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -812,11 +814,13 @@ file partial class Hooks_SetupTests : global::TUnit.Core.Interfaces.SourceGenera { Name = "context", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "cancellationToken", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.BeforeTests.SetupTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -991,6 +995,7 @@ file partial class Hooks_SetupTests : global::TUnit.Core.Interfaces.SourceGenera { Name = "cancellationToken", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.BeforeTests.SetupTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -1080,6 +1085,7 @@ file partial class Hooks_SetupTests : global::TUnit.Core.Interfaces.SourceGenera { Name = "testContext", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.BeforeTests.SetupTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -1170,11 +1176,13 @@ file partial class Hooks_SetupTests : global::TUnit.Core.Interfaces.SourceGenera { Name = "testContext", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "cancellationToken", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.BeforeTests.SetupTests", () => new global::TUnit.Core.SourceGeneratedClassInformation diff --git a/TUnit.Core.SourceGenerator.Tests/BeforeTests.Test.verified.txt b/TUnit.Core.SourceGenerator.Tests/BeforeTests.Test.verified.txt index 34a3ede44a..1876e989c8 100644 --- a/TUnit.Core.SourceGenerator.Tests/BeforeTests.Test.verified.txt +++ b/TUnit.Core.SourceGenerator.Tests/BeforeTests.Test.verified.txt @@ -632,6 +632,7 @@ file partial class Hooks_SetupTests : global::TUnit.Core.Interfaces.SourceGenera { Name = "context", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.BeforeTests.SetupTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -722,6 +723,7 @@ file partial class Hooks_SetupTests : global::TUnit.Core.Interfaces.SourceGenera { Name = "cancellationToken", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.BeforeTests.SetupTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -812,11 +814,13 @@ file partial class Hooks_SetupTests : global::TUnit.Core.Interfaces.SourceGenera { Name = "context", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "cancellationToken", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.BeforeTests.SetupTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -991,6 +995,7 @@ file partial class Hooks_SetupTests : global::TUnit.Core.Interfaces.SourceGenera { Name = "cancellationToken", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.BeforeTests.SetupTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -1080,6 +1085,7 @@ file partial class Hooks_SetupTests : global::TUnit.Core.Interfaces.SourceGenera { Name = "testContext", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.BeforeTests.SetupTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -1170,11 +1176,13 @@ file partial class Hooks_SetupTests : global::TUnit.Core.Interfaces.SourceGenera { Name = "testContext", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "cancellationToken", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.BeforeTests.SetupTests", () => new global::TUnit.Core.SourceGeneratedClassInformation diff --git a/TUnit.Core.SourceGenerator.Tests/ClassAndMethodArgumentsTests.Test.verified.txt b/TUnit.Core.SourceGenerator.Tests/ClassAndMethodArgumentsTests.Test.verified.txt index 5f82a162c9..85f0b25b99 100644 --- a/TUnit.Core.SourceGenerator.Tests/ClassAndMethodArgumentsTests.Test.verified.txt +++ b/TUnit.Core.SourceGenerator.Tests/ClassAndMethodArgumentsTests.Test.verified.txt @@ -65,6 +65,7 @@ file partial class ClassAndMethodArgumentsTests : global::TUnit.Core.Interfaces. { Name = "arg1", Attributes = [], + ReflectionInfo = null!, }, ], Properties = [], @@ -159,6 +160,7 @@ file partial class ClassAndMethodArgumentsTests : global::TUnit.Core.Interfaces. { Name = "arg1", Attributes = [], + ReflectionInfo = null!, }, ], Properties = [], @@ -269,6 +271,7 @@ file partial class ClassAndMethodArgumentsTests : global::TUnit.Core.Interfaces. { Name = "arg2", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.ClassAndMethodArgumentsTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -293,6 +296,7 @@ file partial class ClassAndMethodArgumentsTests : global::TUnit.Core.Interfaces. { Name = "arg1", Attributes = [], + ReflectionInfo = null!, }, ], Properties = [], @@ -374,6 +378,7 @@ file partial class ClassAndMethodArgumentsTests : global::TUnit.Core.Interfaces. { Name = "arg2", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.ClassAndMethodArgumentsTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -398,6 +403,7 @@ file partial class ClassAndMethodArgumentsTests : global::TUnit.Core.Interfaces. { Name = "arg1", Attributes = [], + ReflectionInfo = null!, }, ], Properties = [], @@ -479,6 +485,7 @@ file partial class ClassAndMethodArgumentsTests : global::TUnit.Core.Interfaces. { Name = "arg2", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.ClassAndMethodArgumentsTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -503,6 +510,7 @@ file partial class ClassAndMethodArgumentsTests : global::TUnit.Core.Interfaces. { Name = "arg1", Attributes = [], + ReflectionInfo = null!, }, ], Properties = [], @@ -584,6 +592,7 @@ file partial class ClassAndMethodArgumentsTests : global::TUnit.Core.Interfaces. { Name = "arg2", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.ClassAndMethodArgumentsTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -608,6 +617,7 @@ file partial class ClassAndMethodArgumentsTests : global::TUnit.Core.Interfaces. { Name = "arg1", Attributes = [], + ReflectionInfo = null!, }, ], Properties = [], @@ -720,6 +730,7 @@ file partial class ClassAndMethodArgumentsTests : global::TUnit.Core.Interfaces. { Name = "arg2", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.ClassAndMethodArgumentsTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -744,6 +755,7 @@ file partial class ClassAndMethodArgumentsTests : global::TUnit.Core.Interfaces. { Name = "arg1", Attributes = [], + ReflectionInfo = null!, }, ], Properties = [], @@ -825,6 +837,7 @@ file partial class ClassAndMethodArgumentsTests : global::TUnit.Core.Interfaces. { Name = "arg2", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.ClassAndMethodArgumentsTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -849,6 +862,7 @@ file partial class ClassAndMethodArgumentsTests : global::TUnit.Core.Interfaces. { Name = "arg1", Attributes = [], + ReflectionInfo = null!, }, ], Properties = [], @@ -930,6 +944,7 @@ file partial class ClassAndMethodArgumentsTests : global::TUnit.Core.Interfaces. { Name = "arg2", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.ClassAndMethodArgumentsTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -954,6 +969,7 @@ file partial class ClassAndMethodArgumentsTests : global::TUnit.Core.Interfaces. { Name = "arg1", Attributes = [], + ReflectionInfo = null!, }, ], Properties = [], @@ -1035,6 +1051,7 @@ file partial class ClassAndMethodArgumentsTests : global::TUnit.Core.Interfaces. { Name = "arg2", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.ClassAndMethodArgumentsTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -1059,6 +1076,7 @@ file partial class ClassAndMethodArgumentsTests : global::TUnit.Core.Interfaces. { Name = "arg1", Attributes = [], + ReflectionInfo = null!, }, ], Properties = [], diff --git a/TUnit.Core.SourceGenerator.Tests/ClassConstructorTest.Test.verified.txt b/TUnit.Core.SourceGenerator.Tests/ClassConstructorTest.Test.verified.txt index 8317f12a50..7399ba8065 100644 --- a/TUnit.Core.SourceGenerator.Tests/ClassConstructorTest.Test.verified.txt +++ b/TUnit.Core.SourceGenerator.Tests/ClassConstructorTest.Test.verified.txt @@ -60,6 +60,7 @@ file partial class ClassConstructorTest : global::TUnit.Core.Interfaces.SourceGe { Name = "dummyReferenceTypeClass", Attributes = [], + ReflectionInfo = null!, }, ], Properties = diff --git a/TUnit.Core.SourceGenerator.Tests/ClassDataSourceDrivenTests.Test.verified.txt b/TUnit.Core.SourceGenerator.Tests/ClassDataSourceDrivenTests.Test.verified.txt index fadb34c0d0..727aafdd51 100644 --- a/TUnit.Core.SourceGenerator.Tests/ClassDataSourceDrivenTests.Test.verified.txt +++ b/TUnit.Core.SourceGenerator.Tests/ClassDataSourceDrivenTests.Test.verified.txt @@ -44,6 +44,7 @@ file partial class ClassDataSourceDrivenTests : global::TUnit.Core.Interfaces.So { Name = "value", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.ClassDataSourceDrivenTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -57,7 +58,10 @@ file partial class ClassDataSourceDrivenTests : global::TUnit.Core.Interfaces.So }), Name = "ClassDataSourceDrivenTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -78,6 +82,7 @@ file partial class ClassDataSourceDrivenTests : global::TUnit.Core.Interfaces.So { Name = "value", Attributes = [], + ReflectionInfo = null!, }, ], TestSessionId = sessionId, @@ -115,7 +120,7 @@ file partial class ClassDataSourceDrivenTests : global::TUnit.Core.Interfaces.So ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.DataSource_Class(methodArgGeneratedData)), TestFilePath = @"", - TestLineNumber = 9, + TestLineNumber = 11, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -132,7 +137,7 @@ file partial class ClassDataSourceDrivenTests : global::TUnit.Core.Interfaces.So MethodName = $"DataSource_Class", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("ClassDataSourceDrivenTests.DataSource_Class failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 9, + TestLineNumber = 11, }); } return nodes; @@ -185,6 +190,7 @@ file partial class ClassDataSourceDrivenTests : global::TUnit.Core.Interfaces.So { Name = "value", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.ClassDataSourceDrivenTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -198,7 +204,10 @@ file partial class ClassDataSourceDrivenTests : global::TUnit.Core.Interfaces.So }), Name = "ClassDataSourceDrivenTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -219,6 +228,7 @@ file partial class ClassDataSourceDrivenTests : global::TUnit.Core.Interfaces.So { Name = "value", Attributes = [], + ReflectionInfo = null!, }, ], TestSessionId = sessionId, @@ -256,7 +266,7 @@ file partial class ClassDataSourceDrivenTests : global::TUnit.Core.Interfaces.So ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.DataSource_Class_Generic(methodArgGeneratedData)), TestFilePath = @"", - TestLineNumber = 16, + TestLineNumber = 18, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -273,7 +283,7 @@ file partial class ClassDataSourceDrivenTests : global::TUnit.Core.Interfaces.So MethodName = $"DataSource_Class_Generic", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("ClassDataSourceDrivenTests.DataSource_Class_Generic failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 16, + TestLineNumber = 18, }); } return nodes; @@ -326,6 +336,7 @@ file partial class ClassDataSourceDrivenTests : global::TUnit.Core.Interfaces.So { Name = "class1", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.ClassDataSourceDrivenTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -339,7 +350,10 @@ file partial class ClassDataSourceDrivenTests : global::TUnit.Core.Interfaces.So }), Name = "ClassDataSourceDrivenTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -360,6 +374,7 @@ file partial class ClassDataSourceDrivenTests : global::TUnit.Core.Interfaces.So { Name = "class1", Attributes = [], + ReflectionInfo = null!, }, ], TestSessionId = sessionId, @@ -397,7 +412,7 @@ file partial class ClassDataSourceDrivenTests : global::TUnit.Core.Interfaces.So ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.IsInitialized_With_1_ClassDataSource(methodArgGeneratedData)), TestFilePath = @"", - TestLineNumber = 23, + TestLineNumber = 25, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -414,7 +429,7 @@ file partial class ClassDataSourceDrivenTests : global::TUnit.Core.Interfaces.So MethodName = $"IsInitialized_With_1_ClassDataSource", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("ClassDataSourceDrivenTests.IsInitialized_With_1_ClassDataSource failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 23, + TestLineNumber = 25, }); } return nodes; @@ -467,11 +482,13 @@ file partial class ClassDataSourceDrivenTests : global::TUnit.Core.Interfaces.So { Name = "class1", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "class2", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.ClassDataSourceDrivenTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -485,7 +502,10 @@ file partial class ClassDataSourceDrivenTests : global::TUnit.Core.Interfaces.So }), Name = "ClassDataSourceDrivenTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -506,11 +526,13 @@ file partial class ClassDataSourceDrivenTests : global::TUnit.Core.Interfaces.So { Name = "class1", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "class2", Attributes = [], + ReflectionInfo = null!, }, ], TestSessionId = sessionId, @@ -551,7 +573,7 @@ file partial class ClassDataSourceDrivenTests : global::TUnit.Core.Interfaces.So ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.IsInitialized_With_2_ClassDataSources(methodArg, methodArg1)), TestFilePath = @"", - TestLineNumber = 30, + TestLineNumber = 32, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -568,7 +590,7 @@ file partial class ClassDataSourceDrivenTests : global::TUnit.Core.Interfaces.So MethodName = $"IsInitialized_With_2_ClassDataSources", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("ClassDataSourceDrivenTests.IsInitialized_With_2_ClassDataSources failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 30, + TestLineNumber = 32, }); } return nodes; @@ -621,16 +643,19 @@ file partial class ClassDataSourceDrivenTests : global::TUnit.Core.Interfaces.So { Name = "class1", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "class2", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "class3", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.ClassDataSourceDrivenTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -644,7 +669,10 @@ file partial class ClassDataSourceDrivenTests : global::TUnit.Core.Interfaces.So }), Name = "ClassDataSourceDrivenTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -665,16 +693,19 @@ file partial class ClassDataSourceDrivenTests : global::TUnit.Core.Interfaces.So { Name = "class1", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "class2", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "class3", Attributes = [], + ReflectionInfo = null!, }, ], TestSessionId = sessionId, @@ -716,7 +747,7 @@ file partial class ClassDataSourceDrivenTests : global::TUnit.Core.Interfaces.So ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.IsInitialized_With_3_ClassDataSources(methodArg, methodArg1, methodArg2)), TestFilePath = @"", - TestLineNumber = 38, + TestLineNumber = 40, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -733,7 +764,7 @@ file partial class ClassDataSourceDrivenTests : global::TUnit.Core.Interfaces.So MethodName = $"IsInitialized_With_3_ClassDataSources", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("ClassDataSourceDrivenTests.IsInitialized_With_3_ClassDataSources failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 38, + TestLineNumber = 40, }); } return nodes; @@ -786,21 +817,25 @@ file partial class ClassDataSourceDrivenTests : global::TUnit.Core.Interfaces.So { Name = "class1", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "class2", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "class3", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "class4", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.ClassDataSourceDrivenTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -814,7 +849,10 @@ file partial class ClassDataSourceDrivenTests : global::TUnit.Core.Interfaces.So }), Name = "ClassDataSourceDrivenTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -835,21 +873,25 @@ file partial class ClassDataSourceDrivenTests : global::TUnit.Core.Interfaces.So { Name = "class1", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "class2", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "class3", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "class4", Attributes = [], + ReflectionInfo = null!, }, ], TestSessionId = sessionId, @@ -892,7 +934,7 @@ file partial class ClassDataSourceDrivenTests : global::TUnit.Core.Interfaces.So ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.IsInitialized_With_4_ClassDataSources(methodArg, methodArg1, methodArg2, methodArg3)), TestFilePath = @"", - TestLineNumber = 47, + TestLineNumber = 49, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -909,7 +951,7 @@ file partial class ClassDataSourceDrivenTests : global::TUnit.Core.Interfaces.So MethodName = $"IsInitialized_With_4_ClassDataSources", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("ClassDataSourceDrivenTests.IsInitialized_With_4_ClassDataSources failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 47, + TestLineNumber = 49, }); } return nodes; @@ -962,26 +1004,31 @@ file partial class ClassDataSourceDrivenTests : global::TUnit.Core.Interfaces.So { Name = "class1", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "class2", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "class3", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "class4", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "class5", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.ClassDataSourceDrivenTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -995,7 +1042,10 @@ file partial class ClassDataSourceDrivenTests : global::TUnit.Core.Interfaces.So }), Name = "ClassDataSourceDrivenTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -1016,26 +1066,31 @@ file partial class ClassDataSourceDrivenTests : global::TUnit.Core.Interfaces.So { Name = "class1", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "class2", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "class3", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "class4", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "class5", Attributes = [], + ReflectionInfo = null!, }, ], TestSessionId = sessionId, @@ -1079,7 +1134,7 @@ file partial class ClassDataSourceDrivenTests : global::TUnit.Core.Interfaces.So ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.IsInitialized_With_5_ClassDataSources(methodArg, methodArg1, methodArg2, methodArg3, methodArg4)), TestFilePath = @"", - TestLineNumber = 57, + TestLineNumber = 59, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -1096,7 +1151,7 @@ file partial class ClassDataSourceDrivenTests : global::TUnit.Core.Interfaces.So MethodName = $"IsInitialized_With_5_ClassDataSources", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("ClassDataSourceDrivenTests.IsInitialized_With_5_ClassDataSources failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 57, + TestLineNumber = 59, }); } return nodes; diff --git a/TUnit.Core.SourceGenerator.Tests/ClassDataSourceDrivenTests2.Test.verified.txt b/TUnit.Core.SourceGenerator.Tests/ClassDataSourceDrivenTests2.Test.verified.txt index 5170ba3d9b..6a3bc4b6c6 100644 --- a/TUnit.Core.SourceGenerator.Tests/ClassDataSourceDrivenTests2.Test.verified.txt +++ b/TUnit.Core.SourceGenerator.Tests/ClassDataSourceDrivenTests2.Test.verified.txt @@ -54,13 +54,17 @@ file partial class ClassDataSourceDrivenTests2 : global::TUnit.Core.Interfaces.S }), Name = "ClassDataSourceDrivenTests2", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [ new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "base", Attributes = [], + ReflectionInfo = null!, }, ], Properties = [], @@ -82,6 +86,7 @@ file partial class ClassDataSourceDrivenTests2 : global::TUnit.Core.Interfaces.S { Name = "base", Attributes = [], + ReflectionInfo = null!, }, ], TestSessionId = sessionId, @@ -119,7 +124,7 @@ file partial class ClassDataSourceDrivenTests2 : global::TUnit.Core.Interfaces.S ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.Base_Derived1()), TestFilePath = @"", - TestLineNumber = 9, + TestLineNumber = 12, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -136,7 +141,7 @@ file partial class ClassDataSourceDrivenTests2 : global::TUnit.Core.Interfaces.S MethodName = $"Base_Derived1", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("ClassDataSourceDrivenTests2.Base_Derived1 failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 9, + TestLineNumber = 12, }); } return nodes; @@ -170,13 +175,17 @@ file partial class ClassDataSourceDrivenTests2 : global::TUnit.Core.Interfaces.S }), Name = "ClassDataSourceDrivenTests2", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [ new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "base", Attributes = [], + ReflectionInfo = null!, }, ], Properties = [], @@ -198,6 +207,7 @@ file partial class ClassDataSourceDrivenTests2 : global::TUnit.Core.Interfaces.S { Name = "base", Attributes = [], + ReflectionInfo = null!, }, ], TestSessionId = sessionId, @@ -235,7 +245,7 @@ file partial class ClassDataSourceDrivenTests2 : global::TUnit.Core.Interfaces.S ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.Base_Derived1()), TestFilePath = @"", - TestLineNumber = 9, + TestLineNumber = 12, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -252,7 +262,7 @@ file partial class ClassDataSourceDrivenTests2 : global::TUnit.Core.Interfaces.S MethodName = $"Base_Derived1", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("ClassDataSourceDrivenTests2.Base_Derived1 failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 9, + TestLineNumber = 12, }); } return nodes; @@ -315,13 +325,17 @@ file partial class ClassDataSourceDrivenTests2 : global::TUnit.Core.Interfaces.S }), Name = "ClassDataSourceDrivenTests2", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [ new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "base", Attributes = [], + ReflectionInfo = null!, }, ], Properties = [], @@ -343,6 +357,7 @@ file partial class ClassDataSourceDrivenTests2 : global::TUnit.Core.Interfaces.S { Name = "base", Attributes = [], + ReflectionInfo = null!, }, ], TestSessionId = sessionId, @@ -380,7 +395,7 @@ file partial class ClassDataSourceDrivenTests2 : global::TUnit.Core.Interfaces.S ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.Base_Derived2()), TestFilePath = @"", - TestLineNumber = 15, + TestLineNumber = 18, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -397,7 +412,7 @@ file partial class ClassDataSourceDrivenTests2 : global::TUnit.Core.Interfaces.S MethodName = $"Base_Derived2", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("ClassDataSourceDrivenTests2.Base_Derived2 failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 15, + TestLineNumber = 18, }); } return nodes; @@ -431,13 +446,17 @@ file partial class ClassDataSourceDrivenTests2 : global::TUnit.Core.Interfaces.S }), Name = "ClassDataSourceDrivenTests2", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [ new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "base", Attributes = [], + ReflectionInfo = null!, }, ], Properties = [], @@ -459,6 +478,7 @@ file partial class ClassDataSourceDrivenTests2 : global::TUnit.Core.Interfaces.S { Name = "base", Attributes = [], + ReflectionInfo = null!, }, ], TestSessionId = sessionId, @@ -496,7 +516,7 @@ file partial class ClassDataSourceDrivenTests2 : global::TUnit.Core.Interfaces.S ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.Base_Derived2()), TestFilePath = @"", - TestLineNumber = 15, + TestLineNumber = 18, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -513,7 +533,7 @@ file partial class ClassDataSourceDrivenTests2 : global::TUnit.Core.Interfaces.S MethodName = $"Base_Derived2", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("ClassDataSourceDrivenTests2.Base_Derived2 failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 15, + TestLineNumber = 18, }); } return nodes; diff --git a/TUnit.Core.SourceGenerator.Tests/ClassDataSourceDrivenTestsSharedKeyed.Test.verified.txt b/TUnit.Core.SourceGenerator.Tests/ClassDataSourceDrivenTestsSharedKeyed.Test.verified.txt index 17eb8a6708..d7a0dfbeae 100644 --- a/TUnit.Core.SourceGenerator.Tests/ClassDataSourceDrivenTestsSharedKeyed.Test.verified.txt +++ b/TUnit.Core.SourceGenerator.Tests/ClassDataSourceDrivenTestsSharedKeyed.Test.verified.txt @@ -44,6 +44,7 @@ file partial class ClassDataSourceDrivenTestsSharedKeyed : global::TUnit.Core.In { Name = "value", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.ClassDataSourceDrivenTestsSharedKeyed", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -57,7 +58,10 @@ file partial class ClassDataSourceDrivenTestsSharedKeyed : global::TUnit.Core.In }), Name = "ClassDataSourceDrivenTestsSharedKeyed", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -78,6 +82,7 @@ file partial class ClassDataSourceDrivenTestsSharedKeyed : global::TUnit.Core.In { Name = "value", Attributes = [], + ReflectionInfo = null!, }, ], TestSessionId = sessionId, @@ -119,7 +124,7 @@ file partial class ClassDataSourceDrivenTestsSharedKeyed : global::TUnit.Core.In ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.DataSource_Class(methodArgGeneratedData)), TestFilePath = @"", - TestLineNumber = 7, + TestLineNumber = 9, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -136,7 +141,7 @@ file partial class ClassDataSourceDrivenTestsSharedKeyed : global::TUnit.Core.In MethodName = $"DataSource_Class", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("ClassDataSourceDrivenTestsSharedKeyed.DataSource_Class failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 7, + TestLineNumber = 9, }); } return nodes; @@ -189,6 +194,7 @@ file partial class ClassDataSourceDrivenTestsSharedKeyed : global::TUnit.Core.In { Name = "value", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.ClassDataSourceDrivenTestsSharedKeyed", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -202,7 +208,10 @@ file partial class ClassDataSourceDrivenTestsSharedKeyed : global::TUnit.Core.In }), Name = "ClassDataSourceDrivenTestsSharedKeyed", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -223,6 +232,7 @@ file partial class ClassDataSourceDrivenTestsSharedKeyed : global::TUnit.Core.In { Name = "value", Attributes = [], + ReflectionInfo = null!, }, ], TestSessionId = sessionId, @@ -264,7 +274,7 @@ file partial class ClassDataSourceDrivenTestsSharedKeyed : global::TUnit.Core.In ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.DataSource_Class_Generic(methodArgGeneratedData)), TestFilePath = @"", - TestLineNumber = 14, + TestLineNumber = 16, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -281,7 +291,7 @@ file partial class ClassDataSourceDrivenTestsSharedKeyed : global::TUnit.Core.In MethodName = $"DataSource_Class_Generic", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("ClassDataSourceDrivenTestsSharedKeyed.DataSource_Class_Generic failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 14, + TestLineNumber = 16, }); } return nodes; diff --git a/TUnit.Core.SourceGenerator.Tests/ClassTupleDataSourceDrivenTests.Test.verified.txt b/TUnit.Core.SourceGenerator.Tests/ClassTupleDataSourceDrivenTests.Test.verified.txt index 01b3e8116a..36bce39f70 100644 --- a/TUnit.Core.SourceGenerator.Tests/ClassTupleDataSourceDrivenTests.Test.verified.txt +++ b/TUnit.Core.SourceGenerator.Tests/ClassTupleDataSourceDrivenTests.Test.verified.txt @@ -52,16 +52,19 @@ file partial class ClassTupleDataSourceDrivenTests : global::TUnit.Core.Interfac { Name = "value", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "value2", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "value3", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.ClassTupleDataSourceDrivenTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -77,6 +80,7 @@ file partial class ClassTupleDataSourceDrivenTests : global::TUnit.Core.Interfac Namespace = "TUnit.TestProject", Attributes = [ + new EngineTest(Pass), new global::TUnit.Core.MethodDataSourceAttribute("TupleMethod"), new global::TUnit.Core.MethodDataSourceAttribute("NamedTupleMethod") ], @@ -86,16 +90,19 @@ file partial class ClassTupleDataSourceDrivenTests : global::TUnit.Core.Interfac { Name = "value", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "value2", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "value3", Attributes = [], + ReflectionInfo = null!, }, ], Properties = @@ -191,7 +198,7 @@ new global::TUnit.Core.SourceGeneratedPropertyInformation ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.DataSource_TupleMethod(methodArg, methodArg1, methodArg2)), TestFilePath = @"", - TestLineNumber = 24, + TestLineNumber = 27, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -207,7 +214,7 @@ new global::TUnit.Core.SourceGeneratedPropertyInformation MethodName = $"DataSource_TupleMethod", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("ClassTupleDataSourceDrivenTests.DataSource_TupleMethod failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 24, + TestLineNumber = 27, }); } return nodes; @@ -237,16 +244,19 @@ new global::TUnit.Core.SourceGeneratedPropertyInformation { Name = "value", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "value2", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "value3", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.ClassTupleDataSourceDrivenTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -262,6 +272,7 @@ new global::TUnit.Core.SourceGeneratedPropertyInformation Namespace = "TUnit.TestProject", Attributes = [ + new EngineTest(Pass), new global::TUnit.Core.MethodDataSourceAttribute("TupleMethod"), new global::TUnit.Core.MethodDataSourceAttribute("NamedTupleMethod") ], @@ -271,16 +282,19 @@ new global::TUnit.Core.SourceGeneratedPropertyInformation { Name = "value", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "value2", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "value3", Attributes = [], + ReflectionInfo = null!, }, ], Properties = @@ -376,7 +390,7 @@ new global::TUnit.Core.SourceGeneratedPropertyInformation ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.DataSource_TupleMethod(methodArg, methodArg1, methodArg2)), TestFilePath = @"", - TestLineNumber = 24, + TestLineNumber = 27, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -392,7 +406,7 @@ new global::TUnit.Core.SourceGeneratedPropertyInformation MethodName = $"DataSource_TupleMethod", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("ClassTupleDataSourceDrivenTests.DataSource_TupleMethod failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 24, + TestLineNumber = 27, }); } return nodes; @@ -422,16 +436,19 @@ new global::TUnit.Core.SourceGeneratedPropertyInformation { Name = "value", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "value2", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "value3", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.ClassTupleDataSourceDrivenTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -447,6 +464,7 @@ new global::TUnit.Core.SourceGeneratedPropertyInformation Namespace = "TUnit.TestProject", Attributes = [ + new EngineTest(Pass), new global::TUnit.Core.MethodDataSourceAttribute("TupleMethod"), new global::TUnit.Core.MethodDataSourceAttribute("NamedTupleMethod") ], @@ -456,16 +474,19 @@ new global::TUnit.Core.SourceGeneratedPropertyInformation { Name = "value", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "value2", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "value3", Attributes = [], + ReflectionInfo = null!, }, ], Properties = @@ -561,7 +582,7 @@ new global::TUnit.Core.SourceGeneratedPropertyInformation ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.DataSource_TupleMethod(methodArg, methodArg1, methodArg2)), TestFilePath = @"", - TestLineNumber = 24, + TestLineNumber = 27, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -577,7 +598,7 @@ new global::TUnit.Core.SourceGeneratedPropertyInformation MethodName = $"DataSource_TupleMethod", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("ClassTupleDataSourceDrivenTests.DataSource_TupleMethod failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 24, + TestLineNumber = 27, }); } return nodes; @@ -607,16 +628,19 @@ new global::TUnit.Core.SourceGeneratedPropertyInformation { Name = "value", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "value2", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "value3", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.ClassTupleDataSourceDrivenTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -632,6 +656,7 @@ new global::TUnit.Core.SourceGeneratedPropertyInformation Namespace = "TUnit.TestProject", Attributes = [ + new EngineTest(Pass), new global::TUnit.Core.MethodDataSourceAttribute("TupleMethod"), new global::TUnit.Core.MethodDataSourceAttribute("NamedTupleMethod") ], @@ -641,16 +666,19 @@ new global::TUnit.Core.SourceGeneratedPropertyInformation { Name = "value", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "value2", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "value3", Attributes = [], + ReflectionInfo = null!, }, ], Properties = @@ -746,7 +774,7 @@ new global::TUnit.Core.SourceGeneratedPropertyInformation ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.DataSource_TupleMethod(methodArg, methodArg1, methodArg2)), TestFilePath = @"", - TestLineNumber = 24, + TestLineNumber = 27, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -762,7 +790,7 @@ new global::TUnit.Core.SourceGeneratedPropertyInformation MethodName = $"DataSource_TupleMethod", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("ClassTupleDataSourceDrivenTests.DataSource_TupleMethod failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 24, + TestLineNumber = 27, }); } return nodes; diff --git a/TUnit.Core.SourceGenerator.Tests/ConstantArgumentsTests.Test.verified.txt b/TUnit.Core.SourceGenerator.Tests/ConstantArgumentsTests.Test.verified.txt index 29cae0f602..fd02815551 100644 --- a/TUnit.Core.SourceGenerator.Tests/ConstantArgumentsTests.Test.verified.txt +++ b/TUnit.Core.SourceGenerator.Tests/ConstantArgumentsTests.Test.verified.txt @@ -45,6 +45,7 @@ file partial class ConstantArgumentsTests : global::TUnit.Core.Interfaces.Source { Name = "dummy", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.ConstantArgumentsTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -58,7 +59,10 @@ file partial class ConstantArgumentsTests : global::TUnit.Core.Interfaces.Source }), Name = "ConstantArgumentsTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -91,7 +95,7 @@ file partial class ConstantArgumentsTests : global::TUnit.Core.Interfaces.Source ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.String1(methodArg)), TestFilePath = @"", - TestLineNumber = 16, + TestLineNumber = 18, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -107,7 +111,7 @@ file partial class ConstantArgumentsTests : global::TUnit.Core.Interfaces.Source MethodName = $"String1", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("ConstantArgumentsTests.String1 failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 16, + TestLineNumber = 18, }); } return nodes; @@ -161,6 +165,7 @@ file partial class ConstantArgumentsTests : global::TUnit.Core.Interfaces.Source { Name = "dummy", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.ConstantArgumentsTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -174,7 +179,10 @@ file partial class ConstantArgumentsTests : global::TUnit.Core.Interfaces.Source }), Name = "ConstantArgumentsTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -207,7 +215,7 @@ file partial class ConstantArgumentsTests : global::TUnit.Core.Interfaces.Source ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.Int(methodArg)), TestFilePath = @"", - TestLineNumber = 23, + TestLineNumber = 25, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -223,7 +231,7 @@ file partial class ConstantArgumentsTests : global::TUnit.Core.Interfaces.Source MethodName = $"Int", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("ConstantArgumentsTests.Int failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 23, + TestLineNumber = 25, }); } return nodes; @@ -277,6 +285,7 @@ file partial class ConstantArgumentsTests : global::TUnit.Core.Interfaces.Source { Name = "dummy", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.ConstantArgumentsTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -290,7 +299,10 @@ file partial class ConstantArgumentsTests : global::TUnit.Core.Interfaces.Source }), Name = "ConstantArgumentsTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -323,7 +335,7 @@ file partial class ConstantArgumentsTests : global::TUnit.Core.Interfaces.Source ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.Double(methodArg)), TestFilePath = @"", - TestLineNumber = 30, + TestLineNumber = 32, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -339,7 +351,7 @@ file partial class ConstantArgumentsTests : global::TUnit.Core.Interfaces.Source MethodName = $"Double", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("ConstantArgumentsTests.Double failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 30, + TestLineNumber = 32, }); } return nodes; @@ -393,6 +405,7 @@ file partial class ConstantArgumentsTests : global::TUnit.Core.Interfaces.Source { Name = "dummy", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.ConstantArgumentsTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -406,7 +419,10 @@ file partial class ConstantArgumentsTests : global::TUnit.Core.Interfaces.Source }), Name = "ConstantArgumentsTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -439,7 +455,7 @@ file partial class ConstantArgumentsTests : global::TUnit.Core.Interfaces.Source ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.Float(methodArg)), TestFilePath = @"", - TestLineNumber = 37, + TestLineNumber = 39, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -455,7 +471,7 @@ file partial class ConstantArgumentsTests : global::TUnit.Core.Interfaces.Source MethodName = $"Float", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("ConstantArgumentsTests.Float failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 37, + TestLineNumber = 39, }); } return nodes; @@ -509,6 +525,7 @@ file partial class ConstantArgumentsTests : global::TUnit.Core.Interfaces.Source { Name = "dummy", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.ConstantArgumentsTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -522,7 +539,10 @@ file partial class ConstantArgumentsTests : global::TUnit.Core.Interfaces.Source }), Name = "ConstantArgumentsTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -555,7 +575,7 @@ file partial class ConstantArgumentsTests : global::TUnit.Core.Interfaces.Source ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.Long(methodArg)), TestFilePath = @"", - TestLineNumber = 44, + TestLineNumber = 46, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -571,7 +591,7 @@ file partial class ConstantArgumentsTests : global::TUnit.Core.Interfaces.Source MethodName = $"Long", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("ConstantArgumentsTests.Long failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 44, + TestLineNumber = 46, }); } return nodes; @@ -625,6 +645,7 @@ file partial class ConstantArgumentsTests : global::TUnit.Core.Interfaces.Source { Name = "dummy", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.ConstantArgumentsTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -638,7 +659,10 @@ file partial class ConstantArgumentsTests : global::TUnit.Core.Interfaces.Source }), Name = "ConstantArgumentsTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -671,7 +695,7 @@ file partial class ConstantArgumentsTests : global::TUnit.Core.Interfaces.Source ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.UInt(methodArg)), TestFilePath = @"", - TestLineNumber = 51, + TestLineNumber = 53, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -687,7 +711,7 @@ file partial class ConstantArgumentsTests : global::TUnit.Core.Interfaces.Source MethodName = $"UInt", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("ConstantArgumentsTests.UInt failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 51, + TestLineNumber = 53, }); } return nodes; @@ -741,6 +765,7 @@ file partial class ConstantArgumentsTests : global::TUnit.Core.Interfaces.Source { Name = "dummy", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.ConstantArgumentsTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -754,7 +779,10 @@ file partial class ConstantArgumentsTests : global::TUnit.Core.Interfaces.Source }), Name = "ConstantArgumentsTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -787,7 +815,7 @@ file partial class ConstantArgumentsTests : global::TUnit.Core.Interfaces.Source ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.ULong(methodArg)), TestFilePath = @"", - TestLineNumber = 58, + TestLineNumber = 60, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -803,7 +831,7 @@ file partial class ConstantArgumentsTests : global::TUnit.Core.Interfaces.Source MethodName = $"ULong", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("ConstantArgumentsTests.ULong failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 58, + TestLineNumber = 60, }); } return nodes; diff --git a/TUnit.Core.SourceGenerator.Tests/ConstantInBaseClassTests.Test.verified.txt b/TUnit.Core.SourceGenerator.Tests/ConstantInBaseClassTests.Test.verified.txt index e624a1ff74..3256ab4f03 100644 --- a/TUnit.Core.SourceGenerator.Tests/ConstantInBaseClassTests.Test.verified.txt +++ b/TUnit.Core.SourceGenerator.Tests/ConstantInBaseClassTests.Test.verified.txt @@ -45,6 +45,7 @@ file partial class ConstantInBaseClassTests : global::TUnit.Core.Interfaces.Sour { Name = "value", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.Bugs._1432.ConstantInBaseClassTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -58,7 +59,10 @@ file partial class ConstantInBaseClassTests : global::TUnit.Core.Interfaces.Sour }), Name = "ConstantInBaseClassTests", Namespace = "TUnit.TestProject.Bugs._1432", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -91,7 +95,7 @@ file partial class ConstantInBaseClassTests : global::TUnit.Core.Interfaces.Sour ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.SomeTest(methodArg)), TestFilePath = @"", - TestLineNumber = 13, + TestLineNumber = 15, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -107,7 +111,7 @@ file partial class ConstantInBaseClassTests : global::TUnit.Core.Interfaces.Sour MethodName = $"SomeTest", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("ConstantInBaseClassTests.SomeTest failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 13, + TestLineNumber = 15, }); } return nodes; diff --git a/TUnit.Core.SourceGenerator.Tests/ConstantsInInterpolatedStringsTests.Test.verified.txt b/TUnit.Core.SourceGenerator.Tests/ConstantsInInterpolatedStringsTests.Test.verified.txt index 3b155aabc0..2c3e0196cc 100644 --- a/TUnit.Core.SourceGenerator.Tests/ConstantsInInterpolatedStringsTests.Test.verified.txt +++ b/TUnit.Core.SourceGenerator.Tests/ConstantsInInterpolatedStringsTests.Test.verified.txt @@ -45,6 +45,7 @@ file partial class ConstantsInInterpolatedStringsTests : global::TUnit.Core.Inte { Name = "value", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.Bugs._1432.ConstantsInInterpolatedStringsTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -58,7 +59,10 @@ file partial class ConstantsInInterpolatedStringsTests : global::TUnit.Core.Inte }), Name = "ConstantsInInterpolatedStringsTests", Namespace = "TUnit.TestProject.Bugs._1432", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -91,7 +95,7 @@ file partial class ConstantsInInterpolatedStringsTests : global::TUnit.Core.Inte ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.SomeTest(methodArg)), TestFilePath = @"", - TestLineNumber = 13, + TestLineNumber = 15, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -107,7 +111,7 @@ file partial class ConstantsInInterpolatedStringsTests : global::TUnit.Core.Inte MethodName = $"SomeTest", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("ConstantsInInterpolatedStringsTests.SomeTest failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 13, + TestLineNumber = 15, }); } return nodes; diff --git a/TUnit.Core.SourceGenerator.Tests/CustomDisplayNameTests.Test.verified.txt b/TUnit.Core.SourceGenerator.Tests/CustomDisplayNameTests.Test.verified.txt index 234ba601dd..56991b0bf9 100644 --- a/TUnit.Core.SourceGenerator.Tests/CustomDisplayNameTests.Test.verified.txt +++ b/TUnit.Core.SourceGenerator.Tests/CustomDisplayNameTests.Test.verified.txt @@ -51,7 +51,10 @@ file partial class CustomDisplayNameTests : global::TUnit.Core.Interfaces.Source }), Name = "CustomDisplayNameTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [ @@ -91,7 +94,7 @@ new global::TUnit.Core.SourceGeneratedPropertyInformation ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.Test()), TestFilePath = @"", - TestLineNumber = 12, + TestLineNumber = 14, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -107,7 +110,7 @@ new global::TUnit.Core.SourceGeneratedPropertyInformation MethodName = $"Test", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("CustomDisplayNameTests.Test failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 12, + TestLineNumber = 14, }); } return nodes; @@ -167,7 +170,10 @@ file partial class CustomDisplayNameTests : global::TUnit.Core.Interfaces.Source }), Name = "CustomDisplayNameTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [ @@ -207,7 +213,7 @@ new global::TUnit.Core.SourceGeneratedPropertyInformation ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.Test2()), TestFilePath = @"", - TestLineNumber = 19, + TestLineNumber = 21, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -223,7 +229,7 @@ new global::TUnit.Core.SourceGeneratedPropertyInformation MethodName = $"Test2", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("CustomDisplayNameTests.Test2 failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 19, + TestLineNumber = 21, }); } return nodes; @@ -283,16 +289,19 @@ file partial class CustomDisplayNameTests : global::TUnit.Core.Interfaces.Source { Name = "value1", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "value2", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "value3", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.CustomDisplayNameTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -306,7 +315,10 @@ file partial class CustomDisplayNameTests : global::TUnit.Core.Interfaces.Source }), Name = "CustomDisplayNameTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [ @@ -350,7 +362,7 @@ new global::TUnit.Core.SourceGeneratedPropertyInformation ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.Test3(methodArg, methodArg1, methodArg2)), TestFilePath = @"", - TestLineNumber = 26, + TestLineNumber = 28, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -366,7 +378,7 @@ new global::TUnit.Core.SourceGeneratedPropertyInformation MethodName = $"Test3", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("CustomDisplayNameTests.Test3 failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 26, + TestLineNumber = 28, }); } return nodes; @@ -397,16 +409,19 @@ new global::TUnit.Core.SourceGeneratedPropertyInformation { Name = "value1", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "value2", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "value3", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.CustomDisplayNameTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -420,7 +435,10 @@ new global::TUnit.Core.SourceGeneratedPropertyInformation }), Name = "CustomDisplayNameTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [ @@ -464,7 +482,7 @@ new global::TUnit.Core.SourceGeneratedPropertyInformation ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.Test3(methodArg, methodArg1, methodArg2)), TestFilePath = @"", - TestLineNumber = 26, + TestLineNumber = 28, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -480,7 +498,7 @@ new global::TUnit.Core.SourceGeneratedPropertyInformation MethodName = $"Test3", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("CustomDisplayNameTests.Test3 failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 26, + TestLineNumber = 28, }); } return nodes; @@ -535,6 +553,7 @@ file partial class CustomDisplayNameTests : global::TUnit.Core.Interfaces.Source { Name = "foo", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.CustomDisplayNameTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -548,7 +567,10 @@ file partial class CustomDisplayNameTests : global::TUnit.Core.Interfaces.Source }), Name = "CustomDisplayNameTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [ @@ -589,7 +611,7 @@ new global::TUnit.Core.SourceGeneratedPropertyInformation ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.MethodDataSourceTest(methodArg)), TestFilePath = @"", - TestLineNumber = 36, + TestLineNumber = 38, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -605,7 +627,7 @@ new global::TUnit.Core.SourceGeneratedPropertyInformation MethodName = $"MethodDataSourceTest", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("CustomDisplayNameTests.MethodDataSourceTest failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 36, + TestLineNumber = 38, }); } return nodes; @@ -658,6 +680,7 @@ file partial class CustomDisplayNameTests : global::TUnit.Core.Interfaces.Source { Name = "password", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.CustomDisplayNameTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -671,7 +694,10 @@ file partial class CustomDisplayNameTests : global::TUnit.Core.Interfaces.Source }), Name = "CustomDisplayNameTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [ @@ -701,6 +727,7 @@ new global::TUnit.Core.SourceGeneratedPropertyInformation { Name = "password", Attributes = [], + ReflectionInfo = null!, }, ], TestSessionId = sessionId, @@ -738,7 +765,7 @@ new global::TUnit.Core.SourceGeneratedPropertyInformation ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.PasswordTest(methodArgGeneratedData)), TestFilePath = @"", - TestLineNumber = 44, + TestLineNumber = 46, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -755,7 +782,7 @@ new global::TUnit.Core.SourceGeneratedPropertyInformation MethodName = $"PasswordTest", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("CustomDisplayNameTests.PasswordTest failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 44, + TestLineNumber = 46, }); } return nodes; @@ -815,7 +842,10 @@ file partial class CustomDisplayNameTests : global::TUnit.Core.Interfaces.Source }), Name = "CustomDisplayNameTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [ @@ -855,7 +885,7 @@ new global::TUnit.Core.SourceGeneratedPropertyInformation ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.SameClassConstantTest()), TestFilePath = @"", - TestLineNumber = 51, + TestLineNumber = 53, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -871,7 +901,7 @@ new global::TUnit.Core.SourceGeneratedPropertyInformation MethodName = $"SameClassConstantTest", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("CustomDisplayNameTests.SameClassConstantTest failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 51, + TestLineNumber = 53, }); } return nodes; @@ -931,7 +961,10 @@ file partial class CustomDisplayNameTests : global::TUnit.Core.Interfaces.Source }), Name = "CustomDisplayNameTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [ @@ -971,7 +1004,7 @@ new global::TUnit.Core.SourceGeneratedPropertyInformation ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.DifferentClassConstantTest()), TestFilePath = @"", - TestLineNumber = 58, + TestLineNumber = 60, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -987,7 +1020,7 @@ new global::TUnit.Core.SourceGeneratedPropertyInformation MethodName = $"DifferentClassConstantTest", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("CustomDisplayNameTests.DifferentClassConstantTest failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 58, + TestLineNumber = 60, }); } return nodes; @@ -1047,7 +1080,10 @@ file partial class CustomDisplayNameTests : global::TUnit.Core.Interfaces.Source }), Name = "CustomDisplayNameTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [ @@ -1087,7 +1123,7 @@ new global::TUnit.Core.SourceGeneratedPropertyInformation ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.NestedClassConstantTest()), TestFilePath = @"", - TestLineNumber = 65, + TestLineNumber = 67, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -1103,7 +1139,7 @@ new global::TUnit.Core.SourceGeneratedPropertyInformation MethodName = $"NestedClassConstantTest", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("CustomDisplayNameTests.NestedClassConstantTest failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 65, + TestLineNumber = 67, }); } return nodes; diff --git a/TUnit.Core.SourceGenerator.Tests/DataDrivenTests.Test.verified.txt b/TUnit.Core.SourceGenerator.Tests/DataDrivenTests.Test.verified.txt index 956b8c372a..8a3e36502e 100644 --- a/TUnit.Core.SourceGenerator.Tests/DataDrivenTests.Test.verified.txt +++ b/TUnit.Core.SourceGenerator.Tests/DataDrivenTests.Test.verified.txt @@ -52,6 +52,7 @@ file partial class DataDrivenTests : global::TUnit.Core.Interfaces.SourceGenerat { Name = "value", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.DataDrivenTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -65,7 +66,10 @@ file partial class DataDrivenTests : global::TUnit.Core.Interfaces.SourceGenerat }), Name = "DataDrivenTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -98,7 +102,7 @@ file partial class DataDrivenTests : global::TUnit.Core.Interfaces.SourceGenerat ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.DataSource_Method(methodArg)), TestFilePath = @"", - TestLineNumber = 5, + TestLineNumber = 8, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -114,7 +118,7 @@ file partial class DataDrivenTests : global::TUnit.Core.Interfaces.SourceGenerat MethodName = $"DataSource_Method", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("DataDrivenTests.DataSource_Method failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 5, + TestLineNumber = 8, }); } return nodes; @@ -145,6 +149,7 @@ file partial class DataDrivenTests : global::TUnit.Core.Interfaces.SourceGenerat { Name = "value", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.DataDrivenTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -158,7 +163,10 @@ file partial class DataDrivenTests : global::TUnit.Core.Interfaces.SourceGenerat }), Name = "DataDrivenTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -191,7 +199,7 @@ file partial class DataDrivenTests : global::TUnit.Core.Interfaces.SourceGenerat ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.DataSource_Method(methodArg)), TestFilePath = @"", - TestLineNumber = 5, + TestLineNumber = 8, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -207,7 +215,7 @@ file partial class DataDrivenTests : global::TUnit.Core.Interfaces.SourceGenerat MethodName = $"DataSource_Method", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("DataDrivenTests.DataSource_Method failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 5, + TestLineNumber = 8, }); } return nodes; @@ -238,6 +246,7 @@ file partial class DataDrivenTests : global::TUnit.Core.Interfaces.SourceGenerat { Name = "value", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.DataDrivenTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -251,7 +260,10 @@ file partial class DataDrivenTests : global::TUnit.Core.Interfaces.SourceGenerat }), Name = "DataDrivenTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -284,7 +296,7 @@ file partial class DataDrivenTests : global::TUnit.Core.Interfaces.SourceGenerat ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.DataSource_Method(methodArg)), TestFilePath = @"", - TestLineNumber = 5, + TestLineNumber = 8, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -300,7 +312,7 @@ file partial class DataDrivenTests : global::TUnit.Core.Interfaces.SourceGenerat MethodName = $"DataSource_Method", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("DataDrivenTests.DataSource_Method failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 5, + TestLineNumber = 8, }); } return nodes; @@ -361,11 +373,13 @@ file partial class DataDrivenTests : global::TUnit.Core.Interfaces.SourceGenerat { Name = "value", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "value2", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.DataDrivenTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -379,7 +393,10 @@ file partial class DataDrivenTests : global::TUnit.Core.Interfaces.SourceGenerat }), Name = "DataDrivenTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -413,7 +430,7 @@ file partial class DataDrivenTests : global::TUnit.Core.Interfaces.SourceGenerat ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.DataSource_Method(methodArg, methodArg1)), TestFilePath = @"", - TestLineNumber = 14, + TestLineNumber = 17, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -429,7 +446,7 @@ file partial class DataDrivenTests : global::TUnit.Core.Interfaces.SourceGenerat MethodName = $"DataSource_Method", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("DataDrivenTests.DataSource_Method failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 14, + TestLineNumber = 17, }); } return nodes; @@ -460,11 +477,13 @@ file partial class DataDrivenTests : global::TUnit.Core.Interfaces.SourceGenerat { Name = "value", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "value2", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.DataDrivenTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -478,7 +497,10 @@ file partial class DataDrivenTests : global::TUnit.Core.Interfaces.SourceGenerat }), Name = "DataDrivenTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -512,7 +534,7 @@ file partial class DataDrivenTests : global::TUnit.Core.Interfaces.SourceGenerat ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.DataSource_Method(methodArg, methodArg1)), TestFilePath = @"", - TestLineNumber = 14, + TestLineNumber = 17, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -528,7 +550,7 @@ file partial class DataDrivenTests : global::TUnit.Core.Interfaces.SourceGenerat MethodName = $"DataSource_Method", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("DataDrivenTests.DataSource_Method failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 14, + TestLineNumber = 17, }); } return nodes; @@ -559,11 +581,13 @@ file partial class DataDrivenTests : global::TUnit.Core.Interfaces.SourceGenerat { Name = "value", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "value2", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.DataDrivenTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -577,7 +601,10 @@ file partial class DataDrivenTests : global::TUnit.Core.Interfaces.SourceGenerat }), Name = "DataDrivenTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -611,7 +638,7 @@ file partial class DataDrivenTests : global::TUnit.Core.Interfaces.SourceGenerat ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.DataSource_Method(methodArg, methodArg1)), TestFilePath = @"", - TestLineNumber = 14, + TestLineNumber = 17, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -627,7 +654,7 @@ file partial class DataDrivenTests : global::TUnit.Core.Interfaces.SourceGenerat MethodName = $"DataSource_Method", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("DataDrivenTests.DataSource_Method failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 14, + TestLineNumber = 17, }); } return nodes; @@ -688,6 +715,7 @@ file partial class DataDrivenTests : global::TUnit.Core.Interfaces.SourceGenerat { Name = "testEnum", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.DataDrivenTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -701,7 +729,10 @@ file partial class DataDrivenTests : global::TUnit.Core.Interfaces.SourceGenerat }), Name = "DataDrivenTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -734,7 +765,7 @@ file partial class DataDrivenTests : global::TUnit.Core.Interfaces.SourceGenerat ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.EnumValue(methodArg)), TestFilePath = @"", - TestLineNumber = 23, + TestLineNumber = 26, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -750,7 +781,7 @@ file partial class DataDrivenTests : global::TUnit.Core.Interfaces.SourceGenerat MethodName = $"EnumValue", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("DataDrivenTests.EnumValue failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 23, + TestLineNumber = 26, }); } return nodes; @@ -781,6 +812,7 @@ file partial class DataDrivenTests : global::TUnit.Core.Interfaces.SourceGenerat { Name = "testEnum", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.DataDrivenTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -794,7 +826,10 @@ file partial class DataDrivenTests : global::TUnit.Core.Interfaces.SourceGenerat }), Name = "DataDrivenTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -827,7 +862,7 @@ file partial class DataDrivenTests : global::TUnit.Core.Interfaces.SourceGenerat ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.EnumValue(methodArg)), TestFilePath = @"", - TestLineNumber = 23, + TestLineNumber = 26, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -843,7 +878,7 @@ file partial class DataDrivenTests : global::TUnit.Core.Interfaces.SourceGenerat MethodName = $"EnumValue", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("DataDrivenTests.EnumValue failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 23, + TestLineNumber = 26, }); } return nodes; @@ -874,6 +909,7 @@ file partial class DataDrivenTests : global::TUnit.Core.Interfaces.SourceGenerat { Name = "testEnum", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.DataDrivenTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -887,7 +923,10 @@ file partial class DataDrivenTests : global::TUnit.Core.Interfaces.SourceGenerat }), Name = "DataDrivenTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -920,7 +959,7 @@ file partial class DataDrivenTests : global::TUnit.Core.Interfaces.SourceGenerat ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.EnumValue(methodArg)), TestFilePath = @"", - TestLineNumber = 23, + TestLineNumber = 26, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -936,7 +975,7 @@ file partial class DataDrivenTests : global::TUnit.Core.Interfaces.SourceGenerat MethodName = $"EnumValue", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("DataDrivenTests.EnumValue failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 23, + TestLineNumber = 26, }); } return nodes; @@ -990,6 +1029,7 @@ file partial class DataDrivenTests : global::TUnit.Core.Interfaces.SourceGenerat { Name = "value", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.DataDrivenTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -1003,7 +1043,10 @@ file partial class DataDrivenTests : global::TUnit.Core.Interfaces.SourceGenerat }), Name = "DataDrivenTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -1036,7 +1079,7 @@ file partial class DataDrivenTests : global::TUnit.Core.Interfaces.SourceGenerat ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.NullValue(methodArg)), TestFilePath = @"", - TestLineNumber = 32, + TestLineNumber = 35, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -1052,7 +1095,7 @@ file partial class DataDrivenTests : global::TUnit.Core.Interfaces.SourceGenerat MethodName = $"NullValue", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("DataDrivenTests.NullValue failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 32, + TestLineNumber = 35, }); } return nodes; @@ -1106,6 +1149,7 @@ file partial class DataDrivenTests : global::TUnit.Core.Interfaces.SourceGenerat { Name = "value", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.DataDrivenTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -1119,7 +1163,10 @@ file partial class DataDrivenTests : global::TUnit.Core.Interfaces.SourceGenerat }), Name = "DataDrivenTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -1152,7 +1199,7 @@ file partial class DataDrivenTests : global::TUnit.Core.Interfaces.SourceGenerat ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.EmptyString(methodArg)), TestFilePath = @"", - TestLineNumber = 39, + TestLineNumber = 42, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -1168,7 +1215,7 @@ file partial class DataDrivenTests : global::TUnit.Core.Interfaces.SourceGenerat MethodName = $"EmptyString", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("DataDrivenTests.EmptyString failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 39, + TestLineNumber = 42, }); } return nodes; @@ -1222,6 +1269,7 @@ file partial class DataDrivenTests : global::TUnit.Core.Interfaces.SourceGenerat { Name = "value", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.DataDrivenTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -1235,7 +1283,10 @@ file partial class DataDrivenTests : global::TUnit.Core.Interfaces.SourceGenerat }), Name = "DataDrivenTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -1268,7 +1319,7 @@ file partial class DataDrivenTests : global::TUnit.Core.Interfaces.SourceGenerat ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.NonEmptyString(methodArg)), TestFilePath = @"", - TestLineNumber = 46, + TestLineNumber = 49, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -1284,7 +1335,7 @@ file partial class DataDrivenTests : global::TUnit.Core.Interfaces.SourceGenerat MethodName = $"NonEmptyString", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("DataDrivenTests.NonEmptyString failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 46, + TestLineNumber = 49, }); } return nodes; @@ -1345,6 +1396,7 @@ file partial class DataDrivenTests : global::TUnit.Core.Interfaces.SourceGenerat { Name = "value", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.DataDrivenTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -1358,7 +1410,10 @@ file partial class DataDrivenTests : global::TUnit.Core.Interfaces.SourceGenerat }), Name = "DataDrivenTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -1391,7 +1446,7 @@ file partial class DataDrivenTests : global::TUnit.Core.Interfaces.SourceGenerat ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.BooleanString(methodArg)), TestFilePath = @"", - TestLineNumber = 53, + TestLineNumber = 56, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -1407,7 +1462,7 @@ file partial class DataDrivenTests : global::TUnit.Core.Interfaces.SourceGenerat MethodName = $"BooleanString", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("DataDrivenTests.BooleanString failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 53, + TestLineNumber = 56, }); } return nodes; @@ -1438,6 +1493,7 @@ file partial class DataDrivenTests : global::TUnit.Core.Interfaces.SourceGenerat { Name = "value", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.DataDrivenTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -1451,7 +1507,10 @@ file partial class DataDrivenTests : global::TUnit.Core.Interfaces.SourceGenerat }), Name = "DataDrivenTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -1484,7 +1543,7 @@ file partial class DataDrivenTests : global::TUnit.Core.Interfaces.SourceGenerat ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.BooleanString(methodArg)), TestFilePath = @"", - TestLineNumber = 53, + TestLineNumber = 56, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -1500,7 +1559,7 @@ file partial class DataDrivenTests : global::TUnit.Core.Interfaces.SourceGenerat MethodName = $"BooleanString", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("DataDrivenTests.BooleanString failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 53, + TestLineNumber = 56, }); } return nodes; @@ -1531,6 +1590,7 @@ file partial class DataDrivenTests : global::TUnit.Core.Interfaces.SourceGenerat { Name = "value", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.DataDrivenTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -1544,7 +1604,10 @@ file partial class DataDrivenTests : global::TUnit.Core.Interfaces.SourceGenerat }), Name = "DataDrivenTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -1577,7 +1640,7 @@ file partial class DataDrivenTests : global::TUnit.Core.Interfaces.SourceGenerat ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.BooleanString(methodArg)), TestFilePath = @"", - TestLineNumber = 53, + TestLineNumber = 56, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -1593,7 +1656,7 @@ file partial class DataDrivenTests : global::TUnit.Core.Interfaces.SourceGenerat MethodName = $"BooleanString", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("DataDrivenTests.BooleanString failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 53, + TestLineNumber = 56, }); } return nodes; @@ -1647,6 +1710,7 @@ file partial class DataDrivenTests : global::TUnit.Core.Interfaces.SourceGenerat { Name = "value", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.DataDrivenTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -1660,7 +1724,10 @@ file partial class DataDrivenTests : global::TUnit.Core.Interfaces.SourceGenerat }), Name = "DataDrivenTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -1693,7 +1760,7 @@ file partial class DataDrivenTests : global::TUnit.Core.Interfaces.SourceGenerat ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.Type(methodArg)), TestFilePath = @"", - TestLineNumber = 62, + TestLineNumber = 65, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -1709,7 +1776,7 @@ file partial class DataDrivenTests : global::TUnit.Core.Interfaces.SourceGenerat MethodName = $"Type", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("DataDrivenTests.Type failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 62, + TestLineNumber = 65, }); } return nodes; @@ -1763,6 +1830,7 @@ file partial class DataDrivenTests : global::TUnit.Core.Interfaces.SourceGenerat { Name = "values", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.DataDrivenTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -1776,7 +1844,10 @@ file partial class DataDrivenTests : global::TUnit.Core.Interfaces.SourceGenerat }), Name = "DataDrivenTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -1809,7 +1880,7 @@ file partial class DataDrivenTests : global::TUnit.Core.Interfaces.SourceGenerat ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.IntegerArray(methodArg)), TestFilePath = @"", - TestLineNumber = 69, + TestLineNumber = 72, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -1825,7 +1896,7 @@ file partial class DataDrivenTests : global::TUnit.Core.Interfaces.SourceGenerat MethodName = $"IntegerArray", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("DataDrivenTests.IntegerArray failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 69, + TestLineNumber = 72, }); } return nodes; @@ -1879,6 +1950,7 @@ file partial class DataDrivenTests : global::TUnit.Core.Interfaces.SourceGenerat { Name = "value", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.DataDrivenTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -1892,7 +1964,10 @@ file partial class DataDrivenTests : global::TUnit.Core.Interfaces.SourceGenerat }), Name = "DataDrivenTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -1925,7 +2000,7 @@ file partial class DataDrivenTests : global::TUnit.Core.Interfaces.SourceGenerat ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.IntMaxValue(methodArg)), TestFilePath = @"", - TestLineNumber = 76, + TestLineNumber = 79, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -1941,7 +2016,7 @@ file partial class DataDrivenTests : global::TUnit.Core.Interfaces.SourceGenerat MethodName = $"IntMaxValue", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("DataDrivenTests.IntMaxValue failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 76, + TestLineNumber = 79, }); } return nodes; diff --git a/TUnit.Core.SourceGenerator.Tests/DataSourceClassCombinedWithDataSourceMethodTests.Test.verified.txt b/TUnit.Core.SourceGenerator.Tests/DataSourceClassCombinedWithDataSourceMethodTests.Test.verified.txt index 7dc3cddae4..f4f948832c 100644 --- a/TUnit.Core.SourceGenerator.Tests/DataSourceClassCombinedWithDataSourceMethodTests.Test.verified.txt +++ b/TUnit.Core.SourceGenerator.Tests/DataSourceClassCombinedWithDataSourceMethodTests.Test.verified.txt @@ -58,6 +58,7 @@ file partial class DataSourceClassCombinedWithDataSourceMethod : global::TUnit.C { Name = "i", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.DataSourceClassCombinedWithDataSourceMethod", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -73,6 +74,7 @@ file partial class DataSourceClassCombinedWithDataSourceMethod : global::TUnit.C Namespace = "TUnit.TestProject", Attributes = [ + new EngineTest(Pass), new global::TUnit.Core.MethodDataSourceAttribute(typeof(global::TUnit.TestProject.CommonTestData), "One"), new global::TUnit.Core.MethodDataSourceAttribute(typeof(global::TUnit.TestProject.CommonTestData), "Two"), new global::TUnit.Core.MethodDataSourceAttribute(typeof(global::TUnit.TestProject.CommonTestData), "Three") @@ -83,6 +85,7 @@ file partial class DataSourceClassCombinedWithDataSourceMethod : global::TUnit.C { Name = "i", Attributes = [], + ReflectionInfo = null!, }, ], Properties = [], @@ -116,7 +119,7 @@ file partial class DataSourceClassCombinedWithDataSourceMethod : global::TUnit.C ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.DataSourceClassCombinedWithDataSourceMethodTest(methodArg)), TestFilePath = @"", - TestLineNumber = 10, + TestLineNumber = 13, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -132,7 +135,7 @@ file partial class DataSourceClassCombinedWithDataSourceMethod : global::TUnit.C MethodName = $"DataSourceClassCombinedWithDataSourceMethodTest", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("DataSourceClassCombinedWithDataSourceMethod.DataSourceClassCombinedWithDataSourceMethodTest failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 10, + TestLineNumber = 13, }); } return nodes; @@ -163,6 +166,7 @@ file partial class DataSourceClassCombinedWithDataSourceMethod : global::TUnit.C { Name = "i", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.DataSourceClassCombinedWithDataSourceMethod", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -178,6 +182,7 @@ file partial class DataSourceClassCombinedWithDataSourceMethod : global::TUnit.C Namespace = "TUnit.TestProject", Attributes = [ + new EngineTest(Pass), new global::TUnit.Core.MethodDataSourceAttribute(typeof(global::TUnit.TestProject.CommonTestData), "One"), new global::TUnit.Core.MethodDataSourceAttribute(typeof(global::TUnit.TestProject.CommonTestData), "Two"), new global::TUnit.Core.MethodDataSourceAttribute(typeof(global::TUnit.TestProject.CommonTestData), "Three") @@ -188,6 +193,7 @@ file partial class DataSourceClassCombinedWithDataSourceMethod : global::TUnit.C { Name = "i", Attributes = [], + ReflectionInfo = null!, }, ], Properties = [], @@ -221,7 +227,7 @@ file partial class DataSourceClassCombinedWithDataSourceMethod : global::TUnit.C ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.DataSourceClassCombinedWithDataSourceMethodTest(methodArg)), TestFilePath = @"", - TestLineNumber = 10, + TestLineNumber = 13, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -237,7 +243,7 @@ file partial class DataSourceClassCombinedWithDataSourceMethod : global::TUnit.C MethodName = $"DataSourceClassCombinedWithDataSourceMethodTest", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("DataSourceClassCombinedWithDataSourceMethod.DataSourceClassCombinedWithDataSourceMethodTest failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 10, + TestLineNumber = 13, }); } return nodes; @@ -268,6 +274,7 @@ file partial class DataSourceClassCombinedWithDataSourceMethod : global::TUnit.C { Name = "i", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.DataSourceClassCombinedWithDataSourceMethod", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -283,6 +290,7 @@ file partial class DataSourceClassCombinedWithDataSourceMethod : global::TUnit.C Namespace = "TUnit.TestProject", Attributes = [ + new EngineTest(Pass), new global::TUnit.Core.MethodDataSourceAttribute(typeof(global::TUnit.TestProject.CommonTestData), "One"), new global::TUnit.Core.MethodDataSourceAttribute(typeof(global::TUnit.TestProject.CommonTestData), "Two"), new global::TUnit.Core.MethodDataSourceAttribute(typeof(global::TUnit.TestProject.CommonTestData), "Three") @@ -293,6 +301,7 @@ file partial class DataSourceClassCombinedWithDataSourceMethod : global::TUnit.C { Name = "i", Attributes = [], + ReflectionInfo = null!, }, ], Properties = [], @@ -326,7 +335,7 @@ file partial class DataSourceClassCombinedWithDataSourceMethod : global::TUnit.C ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.DataSourceClassCombinedWithDataSourceMethodTest(methodArg)), TestFilePath = @"", - TestLineNumber = 10, + TestLineNumber = 13, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -342,7 +351,7 @@ file partial class DataSourceClassCombinedWithDataSourceMethod : global::TUnit.C MethodName = $"DataSourceClassCombinedWithDataSourceMethodTest", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("DataSourceClassCombinedWithDataSourceMethod.DataSourceClassCombinedWithDataSourceMethodTest failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 10, + TestLineNumber = 13, }); } return nodes; @@ -373,6 +382,7 @@ file partial class DataSourceClassCombinedWithDataSourceMethod : global::TUnit.C { Name = "i", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.DataSourceClassCombinedWithDataSourceMethod", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -388,6 +398,7 @@ file partial class DataSourceClassCombinedWithDataSourceMethod : global::TUnit.C Namespace = "TUnit.TestProject", Attributes = [ + new EngineTest(Pass), new global::TUnit.Core.MethodDataSourceAttribute(typeof(global::TUnit.TestProject.CommonTestData), "One"), new global::TUnit.Core.MethodDataSourceAttribute(typeof(global::TUnit.TestProject.CommonTestData), "Two"), new global::TUnit.Core.MethodDataSourceAttribute(typeof(global::TUnit.TestProject.CommonTestData), "Three") @@ -398,6 +409,7 @@ file partial class DataSourceClassCombinedWithDataSourceMethod : global::TUnit.C { Name = "i", Attributes = [], + ReflectionInfo = null!, }, ], Properties = [], @@ -431,7 +443,7 @@ file partial class DataSourceClassCombinedWithDataSourceMethod : global::TUnit.C ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.DataSourceClassCombinedWithDataSourceMethodTest(methodArg)), TestFilePath = @"", - TestLineNumber = 10, + TestLineNumber = 13, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -447,7 +459,7 @@ file partial class DataSourceClassCombinedWithDataSourceMethod : global::TUnit.C MethodName = $"DataSourceClassCombinedWithDataSourceMethodTest", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("DataSourceClassCombinedWithDataSourceMethod.DataSourceClassCombinedWithDataSourceMethodTest failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 10, + TestLineNumber = 13, }); } return nodes; @@ -478,6 +490,7 @@ file partial class DataSourceClassCombinedWithDataSourceMethod : global::TUnit.C { Name = "i", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.DataSourceClassCombinedWithDataSourceMethod", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -493,6 +506,7 @@ file partial class DataSourceClassCombinedWithDataSourceMethod : global::TUnit.C Namespace = "TUnit.TestProject", Attributes = [ + new EngineTest(Pass), new global::TUnit.Core.MethodDataSourceAttribute(typeof(global::TUnit.TestProject.CommonTestData), "One"), new global::TUnit.Core.MethodDataSourceAttribute(typeof(global::TUnit.TestProject.CommonTestData), "Two"), new global::TUnit.Core.MethodDataSourceAttribute(typeof(global::TUnit.TestProject.CommonTestData), "Three") @@ -503,6 +517,7 @@ file partial class DataSourceClassCombinedWithDataSourceMethod : global::TUnit.C { Name = "i", Attributes = [], + ReflectionInfo = null!, }, ], Properties = [], @@ -536,7 +551,7 @@ file partial class DataSourceClassCombinedWithDataSourceMethod : global::TUnit.C ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.DataSourceClassCombinedWithDataSourceMethodTest(methodArg)), TestFilePath = @"", - TestLineNumber = 10, + TestLineNumber = 13, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -552,7 +567,7 @@ file partial class DataSourceClassCombinedWithDataSourceMethod : global::TUnit.C MethodName = $"DataSourceClassCombinedWithDataSourceMethodTest", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("DataSourceClassCombinedWithDataSourceMethod.DataSourceClassCombinedWithDataSourceMethodTest failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 10, + TestLineNumber = 13, }); } return nodes; @@ -583,6 +598,7 @@ file partial class DataSourceClassCombinedWithDataSourceMethod : global::TUnit.C { Name = "i", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.DataSourceClassCombinedWithDataSourceMethod", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -598,6 +614,7 @@ file partial class DataSourceClassCombinedWithDataSourceMethod : global::TUnit.C Namespace = "TUnit.TestProject", Attributes = [ + new EngineTest(Pass), new global::TUnit.Core.MethodDataSourceAttribute(typeof(global::TUnit.TestProject.CommonTestData), "One"), new global::TUnit.Core.MethodDataSourceAttribute(typeof(global::TUnit.TestProject.CommonTestData), "Two"), new global::TUnit.Core.MethodDataSourceAttribute(typeof(global::TUnit.TestProject.CommonTestData), "Three") @@ -608,6 +625,7 @@ file partial class DataSourceClassCombinedWithDataSourceMethod : global::TUnit.C { Name = "i", Attributes = [], + ReflectionInfo = null!, }, ], Properties = [], @@ -641,7 +659,7 @@ file partial class DataSourceClassCombinedWithDataSourceMethod : global::TUnit.C ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.DataSourceClassCombinedWithDataSourceMethodTest(methodArg)), TestFilePath = @"", - TestLineNumber = 10, + TestLineNumber = 13, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -657,7 +675,7 @@ file partial class DataSourceClassCombinedWithDataSourceMethod : global::TUnit.C MethodName = $"DataSourceClassCombinedWithDataSourceMethodTest", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("DataSourceClassCombinedWithDataSourceMethod.DataSourceClassCombinedWithDataSourceMethodTest failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 10, + TestLineNumber = 13, }); } return nodes; @@ -688,6 +706,7 @@ file partial class DataSourceClassCombinedWithDataSourceMethod : global::TUnit.C { Name = "i", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.DataSourceClassCombinedWithDataSourceMethod", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -703,6 +722,7 @@ file partial class DataSourceClassCombinedWithDataSourceMethod : global::TUnit.C Namespace = "TUnit.TestProject", Attributes = [ + new EngineTest(Pass), new global::TUnit.Core.MethodDataSourceAttribute(typeof(global::TUnit.TestProject.CommonTestData), "One"), new global::TUnit.Core.MethodDataSourceAttribute(typeof(global::TUnit.TestProject.CommonTestData), "Two"), new global::TUnit.Core.MethodDataSourceAttribute(typeof(global::TUnit.TestProject.CommonTestData), "Three") @@ -713,6 +733,7 @@ file partial class DataSourceClassCombinedWithDataSourceMethod : global::TUnit.C { Name = "i", Attributes = [], + ReflectionInfo = null!, }, ], Properties = [], @@ -746,7 +767,7 @@ file partial class DataSourceClassCombinedWithDataSourceMethod : global::TUnit.C ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.DataSourceClassCombinedWithDataSourceMethodTest(methodArg)), TestFilePath = @"", - TestLineNumber = 10, + TestLineNumber = 13, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -762,7 +783,7 @@ file partial class DataSourceClassCombinedWithDataSourceMethod : global::TUnit.C MethodName = $"DataSourceClassCombinedWithDataSourceMethodTest", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("DataSourceClassCombinedWithDataSourceMethod.DataSourceClassCombinedWithDataSourceMethodTest failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 10, + TestLineNumber = 13, }); } return nodes; @@ -793,6 +814,7 @@ file partial class DataSourceClassCombinedWithDataSourceMethod : global::TUnit.C { Name = "i", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.DataSourceClassCombinedWithDataSourceMethod", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -808,6 +830,7 @@ file partial class DataSourceClassCombinedWithDataSourceMethod : global::TUnit.C Namespace = "TUnit.TestProject", Attributes = [ + new EngineTest(Pass), new global::TUnit.Core.MethodDataSourceAttribute(typeof(global::TUnit.TestProject.CommonTestData), "One"), new global::TUnit.Core.MethodDataSourceAttribute(typeof(global::TUnit.TestProject.CommonTestData), "Two"), new global::TUnit.Core.MethodDataSourceAttribute(typeof(global::TUnit.TestProject.CommonTestData), "Three") @@ -818,6 +841,7 @@ file partial class DataSourceClassCombinedWithDataSourceMethod : global::TUnit.C { Name = "i", Attributes = [], + ReflectionInfo = null!, }, ], Properties = [], @@ -851,7 +875,7 @@ file partial class DataSourceClassCombinedWithDataSourceMethod : global::TUnit.C ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.DataSourceClassCombinedWithDataSourceMethodTest(methodArg)), TestFilePath = @"", - TestLineNumber = 10, + TestLineNumber = 13, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -867,7 +891,7 @@ file partial class DataSourceClassCombinedWithDataSourceMethod : global::TUnit.C MethodName = $"DataSourceClassCombinedWithDataSourceMethodTest", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("DataSourceClassCombinedWithDataSourceMethod.DataSourceClassCombinedWithDataSourceMethodTest failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 10, + TestLineNumber = 13, }); } return nodes; @@ -898,6 +922,7 @@ file partial class DataSourceClassCombinedWithDataSourceMethod : global::TUnit.C { Name = "i", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.DataSourceClassCombinedWithDataSourceMethod", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -913,6 +938,7 @@ file partial class DataSourceClassCombinedWithDataSourceMethod : global::TUnit.C Namespace = "TUnit.TestProject", Attributes = [ + new EngineTest(Pass), new global::TUnit.Core.MethodDataSourceAttribute(typeof(global::TUnit.TestProject.CommonTestData), "One"), new global::TUnit.Core.MethodDataSourceAttribute(typeof(global::TUnit.TestProject.CommonTestData), "Two"), new global::TUnit.Core.MethodDataSourceAttribute(typeof(global::TUnit.TestProject.CommonTestData), "Three") @@ -923,6 +949,7 @@ file partial class DataSourceClassCombinedWithDataSourceMethod : global::TUnit.C { Name = "i", Attributes = [], + ReflectionInfo = null!, }, ], Properties = [], @@ -956,7 +983,7 @@ file partial class DataSourceClassCombinedWithDataSourceMethod : global::TUnit.C ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.DataSourceClassCombinedWithDataSourceMethodTest(methodArg)), TestFilePath = @"", - TestLineNumber = 10, + TestLineNumber = 13, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -972,7 +999,7 @@ file partial class DataSourceClassCombinedWithDataSourceMethod : global::TUnit.C MethodName = $"DataSourceClassCombinedWithDataSourceMethodTest", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("DataSourceClassCombinedWithDataSourceMethod.DataSourceClassCombinedWithDataSourceMethodTest failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 10, + TestLineNumber = 13, }); } return nodes; diff --git a/TUnit.Core.SourceGenerator.Tests/DataSourceGeneratorTests.NonTyped.verified.txt b/TUnit.Core.SourceGenerator.Tests/DataSourceGeneratorTests.NonTyped.verified.txt index 485077cf3e..4e18f92a0c 100644 --- a/TUnit.Core.SourceGenerator.Tests/DataSourceGeneratorTests.NonTyped.verified.txt +++ b/TUnit.Core.SourceGenerator.Tests/DataSourceGeneratorTests.NonTyped.verified.txt @@ -44,21 +44,25 @@ file partial class AutoDataTests : global::TUnit.Core.Interfaces.SourceGenerator { Name = "value1", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "value2", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "value3", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "value4", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.AutoDataTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -93,21 +97,25 @@ file partial class AutoDataTests : global::TUnit.Core.Interfaces.SourceGenerator { Name = "value1", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "value2", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "value3", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "value4", Attributes = [], + ReflectionInfo = null!, }, ], TestSessionId = sessionId, diff --git a/TUnit.Core.SourceGenerator.Tests/DataSourceGeneratorTests.Typed.verified.txt b/TUnit.Core.SourceGenerator.Tests/DataSourceGeneratorTests.Typed.verified.txt index f59274ccce..5b7a22128e 100644 --- a/TUnit.Core.SourceGenerator.Tests/DataSourceGeneratorTests.Typed.verified.txt +++ b/TUnit.Core.SourceGenerator.Tests/DataSourceGeneratorTests.Typed.verified.txt @@ -48,6 +48,7 @@ file partial class DataSourceGeneratorTests : global::TUnit.Core.Interfaces.Sour { Name = "value", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.DataSourceGeneratorTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -61,23 +62,29 @@ file partial class DataSourceGeneratorTests : global::TUnit.Core.Interfaces.Sour }), Name = "DataSourceGeneratorTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [ new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "value", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "value2", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "value3", Attributes = [], + ReflectionInfo = null!, }, ], Properties = [], @@ -99,16 +106,19 @@ file partial class DataSourceGeneratorTests : global::TUnit.Core.Interfaces.Sour { Name = "value", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "value2", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "value3", Attributes = [], + ReflectionInfo = null!, }, ], TestSessionId = sessionId, @@ -135,6 +145,7 @@ file partial class DataSourceGeneratorTests : global::TUnit.Core.Interfaces.Sour { Name = "value", Attributes = [], + ReflectionInfo = null!, }, ], TestSessionId = sessionId, @@ -177,7 +188,7 @@ file partial class DataSourceGeneratorTests : global::TUnit.Core.Interfaces.Sour ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.GeneratedData_Method(methodArgGeneratedData)), TestFilePath = @"", - TestLineNumber = 9, + TestLineNumber = 12, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -195,7 +206,7 @@ file partial class DataSourceGeneratorTests : global::TUnit.Core.Interfaces.Sour MethodName = $"GeneratedData_Method", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("DataSourceGeneratorTests.GeneratedData_Method failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 9, + TestLineNumber = 12, }); } return nodes; @@ -223,6 +234,7 @@ file partial class DataSourceGeneratorTests : global::TUnit.Core.Interfaces.Sour { Name = "value", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.DataSourceGeneratorTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -236,23 +248,29 @@ file partial class DataSourceGeneratorTests : global::TUnit.Core.Interfaces.Sour }), Name = "DataSourceGeneratorTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [ new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "value", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "value2", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "value3", Attributes = [], + ReflectionInfo = null!, }, ], Properties = [], @@ -274,16 +292,19 @@ file partial class DataSourceGeneratorTests : global::TUnit.Core.Interfaces.Sour { Name = "value", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "value2", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "value3", Attributes = [], + ReflectionInfo = null!, }, ], TestSessionId = sessionId, @@ -310,6 +331,7 @@ file partial class DataSourceGeneratorTests : global::TUnit.Core.Interfaces.Sour { Name = "value", Attributes = [], + ReflectionInfo = null!, }, ], TestSessionId = sessionId, @@ -352,7 +374,7 @@ file partial class DataSourceGeneratorTests : global::TUnit.Core.Interfaces.Sour ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.GeneratedData_Method(methodArgGeneratedData)), TestFilePath = @"", - TestLineNumber = 9, + TestLineNumber = 12, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -370,7 +392,7 @@ file partial class DataSourceGeneratorTests : global::TUnit.Core.Interfaces.Sour MethodName = $"GeneratedData_Method", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("DataSourceGeneratorTests.GeneratedData_Method failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 9, + TestLineNumber = 12, }); } return nodes; @@ -427,16 +449,19 @@ file partial class DataSourceGeneratorTests : global::TUnit.Core.Interfaces.Sour { Name = "value", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "value2", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "value3", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.DataSourceGeneratorTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -450,23 +475,29 @@ file partial class DataSourceGeneratorTests : global::TUnit.Core.Interfaces.Sour }), Name = "DataSourceGeneratorTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [ new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "value", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "value2", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "value3", Attributes = [], + ReflectionInfo = null!, }, ], Properties = [], @@ -488,16 +519,19 @@ file partial class DataSourceGeneratorTests : global::TUnit.Core.Interfaces.Sour { Name = "value", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "value2", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "value3", Attributes = [], + ReflectionInfo = null!, }, ], TestSessionId = sessionId, @@ -524,16 +558,19 @@ file partial class DataSourceGeneratorTests : global::TUnit.Core.Interfaces.Sour { Name = "value", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "value2", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "value3", Attributes = [], + ReflectionInfo = null!, }, ], TestSessionId = sessionId, @@ -580,7 +617,7 @@ file partial class DataSourceGeneratorTests : global::TUnit.Core.Interfaces.Sour ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.GeneratedData_Method2(methodArg, methodArg1, methodArg2)), TestFilePath = @"", - TestLineNumber = 17, + TestLineNumber = 20, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -598,7 +635,7 @@ file partial class DataSourceGeneratorTests : global::TUnit.Core.Interfaces.Sour MethodName = $"GeneratedData_Method2", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("DataSourceGeneratorTests.GeneratedData_Method2 failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 17, + TestLineNumber = 20, }); } return nodes; @@ -626,16 +663,19 @@ file partial class DataSourceGeneratorTests : global::TUnit.Core.Interfaces.Sour { Name = "value", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "value2", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "value3", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.DataSourceGeneratorTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -649,23 +689,29 @@ file partial class DataSourceGeneratorTests : global::TUnit.Core.Interfaces.Sour }), Name = "DataSourceGeneratorTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [ new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "value", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "value2", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "value3", Attributes = [], + ReflectionInfo = null!, }, ], Properties = [], @@ -687,16 +733,19 @@ file partial class DataSourceGeneratorTests : global::TUnit.Core.Interfaces.Sour { Name = "value", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "value2", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "value3", Attributes = [], + ReflectionInfo = null!, }, ], TestSessionId = sessionId, @@ -723,16 +772,19 @@ file partial class DataSourceGeneratorTests : global::TUnit.Core.Interfaces.Sour { Name = "value", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "value2", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "value3", Attributes = [], + ReflectionInfo = null!, }, ], TestSessionId = sessionId, @@ -779,7 +831,7 @@ file partial class DataSourceGeneratorTests : global::TUnit.Core.Interfaces.Sour ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.GeneratedData_Method2(methodArg, methodArg1, methodArg2)), TestFilePath = @"", - TestLineNumber = 17, + TestLineNumber = 20, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -797,7 +849,7 @@ file partial class DataSourceGeneratorTests : global::TUnit.Core.Interfaces.Sour MethodName = $"GeneratedData_Method2", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("DataSourceGeneratorTests.GeneratedData_Method2 failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 17, + TestLineNumber = 20, }); } return nodes; @@ -854,16 +906,19 @@ file partial class DataSourceGeneratorTests : global::TUnit.Core.Interfaces.Sour { Name = "value", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "value2", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "value3", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.DataSourceGeneratorTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -877,23 +932,29 @@ file partial class DataSourceGeneratorTests : global::TUnit.Core.Interfaces.Sour }), Name = "DataSourceGeneratorTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [ new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "value", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "value2", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "value3", Attributes = [], + ReflectionInfo = null!, }, ], Properties = [], @@ -915,16 +976,19 @@ file partial class DataSourceGeneratorTests : global::TUnit.Core.Interfaces.Sour { Name = "value", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "value2", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "value3", Attributes = [], + ReflectionInfo = null!, }, ], TestSessionId = sessionId, @@ -951,16 +1015,19 @@ file partial class DataSourceGeneratorTests : global::TUnit.Core.Interfaces.Sour { Name = "value", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "value2", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "value3", Attributes = [], + ReflectionInfo = null!, }, ], TestSessionId = sessionId, @@ -1007,7 +1074,7 @@ file partial class DataSourceGeneratorTests : global::TUnit.Core.Interfaces.Sour ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.GeneratedData_Method3(methodArg, methodArg1, methodArg2)), TestFilePath = @"", - TestLineNumber = 25, + TestLineNumber = 27, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -1025,7 +1092,7 @@ file partial class DataSourceGeneratorTests : global::TUnit.Core.Interfaces.Sour MethodName = $"GeneratedData_Method3", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("DataSourceGeneratorTests.GeneratedData_Method3 failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 25, + TestLineNumber = 27, }); } return nodes; @@ -1053,16 +1120,19 @@ file partial class DataSourceGeneratorTests : global::TUnit.Core.Interfaces.Sour { Name = "value", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "value2", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "value3", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.DataSourceGeneratorTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -1076,23 +1146,29 @@ file partial class DataSourceGeneratorTests : global::TUnit.Core.Interfaces.Sour }), Name = "DataSourceGeneratorTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [ new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "value", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "value2", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "value3", Attributes = [], + ReflectionInfo = null!, }, ], Properties = [], @@ -1114,16 +1190,19 @@ file partial class DataSourceGeneratorTests : global::TUnit.Core.Interfaces.Sour { Name = "value", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "value2", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "value3", Attributes = [], + ReflectionInfo = null!, }, ], TestSessionId = sessionId, @@ -1150,16 +1229,19 @@ file partial class DataSourceGeneratorTests : global::TUnit.Core.Interfaces.Sour { Name = "value", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "value2", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "value3", Attributes = [], + ReflectionInfo = null!, }, ], TestSessionId = sessionId, @@ -1206,7 +1288,7 @@ file partial class DataSourceGeneratorTests : global::TUnit.Core.Interfaces.Sour ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.GeneratedData_Method3(methodArg, methodArg1, methodArg2)), TestFilePath = @"", - TestLineNumber = 25, + TestLineNumber = 27, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -1224,7 +1306,7 @@ file partial class DataSourceGeneratorTests : global::TUnit.Core.Interfaces.Sour MethodName = $"GeneratedData_Method3", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("DataSourceGeneratorTests.GeneratedData_Method3 failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 25, + TestLineNumber = 27, }); } return nodes; diff --git a/TUnit.Core.SourceGenerator.Tests/EnumMemberNamesTests.Test.verified.txt b/TUnit.Core.SourceGenerator.Tests/EnumMemberNamesTests.Test.verified.txt index fb7d91599e..005ddbd177 100644 --- a/TUnit.Core.SourceGenerator.Tests/EnumMemberNamesTests.Test.verified.txt +++ b/TUnit.Core.SourceGenerator.Tests/EnumMemberNamesTests.Test.verified.txt @@ -52,6 +52,7 @@ file partial class EnumMemberNamesTests : global::TUnit.Core.Interfaces.SourceGe { Name = "value", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.Bugs._1432.EnumMemberNamesTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -65,7 +66,10 @@ file partial class EnumMemberNamesTests : global::TUnit.Core.Interfaces.SourceGe }), Name = "EnumMemberNamesTests", Namespace = "TUnit.TestProject.Bugs._1432", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -98,7 +102,7 @@ file partial class EnumMemberNamesTests : global::TUnit.Core.Interfaces.SourceGe ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.SomeTest(methodArg)), TestFilePath = @"", - TestLineNumber = 5, + TestLineNumber = 8, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -114,7 +118,7 @@ file partial class EnumMemberNamesTests : global::TUnit.Core.Interfaces.SourceGe MethodName = $"SomeTest", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("EnumMemberNamesTests.SomeTest failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 5, + TestLineNumber = 8, }); } return nodes; @@ -145,6 +149,7 @@ file partial class EnumMemberNamesTests : global::TUnit.Core.Interfaces.SourceGe { Name = "value", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.Bugs._1432.EnumMemberNamesTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -158,7 +163,10 @@ file partial class EnumMemberNamesTests : global::TUnit.Core.Interfaces.SourceGe }), Name = "EnumMemberNamesTests", Namespace = "TUnit.TestProject.Bugs._1432", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -191,7 +199,7 @@ file partial class EnumMemberNamesTests : global::TUnit.Core.Interfaces.SourceGe ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.SomeTest(methodArg)), TestFilePath = @"", - TestLineNumber = 5, + TestLineNumber = 8, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -207,7 +215,7 @@ file partial class EnumMemberNamesTests : global::TUnit.Core.Interfaces.SourceGe MethodName = $"SomeTest", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("EnumMemberNamesTests.SomeTest failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 5, + TestLineNumber = 8, }); } return nodes; @@ -238,6 +246,7 @@ file partial class EnumMemberNamesTests : global::TUnit.Core.Interfaces.SourceGe { Name = "value", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.Bugs._1432.EnumMemberNamesTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -251,7 +260,10 @@ file partial class EnumMemberNamesTests : global::TUnit.Core.Interfaces.SourceGe }), Name = "EnumMemberNamesTests", Namespace = "TUnit.TestProject.Bugs._1432", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -284,7 +296,7 @@ file partial class EnumMemberNamesTests : global::TUnit.Core.Interfaces.SourceGe ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.SomeTest(methodArg)), TestFilePath = @"", - TestLineNumber = 5, + TestLineNumber = 8, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -300,7 +312,7 @@ file partial class EnumMemberNamesTests : global::TUnit.Core.Interfaces.SourceGe MethodName = $"SomeTest", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("EnumMemberNamesTests.SomeTest failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 5, + TestLineNumber = 8, }); } return nodes; diff --git a/TUnit.Core.SourceGenerator.Tests/EnumerableDataSourceDrivenTests.Test.verified.txt b/TUnit.Core.SourceGenerator.Tests/EnumerableDataSourceDrivenTests.Test.verified.txt index e7636f953f..3e87c8b479 100644 --- a/TUnit.Core.SourceGenerator.Tests/EnumerableDataSourceDrivenTests.Test.verified.txt +++ b/TUnit.Core.SourceGenerator.Tests/EnumerableDataSourceDrivenTests.Test.verified.txt @@ -45,6 +45,7 @@ file partial class EnumerableDataSourceDrivenTests : global::TUnit.Core.Interfac { Name = "value", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.EnumerableDataSourceDrivenTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -58,7 +59,10 @@ file partial class EnumerableDataSourceDrivenTests : global::TUnit.Core.Interfac }), Name = "EnumerableDataSourceDrivenTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -93,7 +97,7 @@ file partial class EnumerableDataSourceDrivenTests : global::TUnit.Core.Interfac ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.DataSource_Method(methodData)), TestFilePath = @"", - TestLineNumber = 8, + TestLineNumber = 10, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -110,7 +114,7 @@ file partial class EnumerableDataSourceDrivenTests : global::TUnit.Core.Interfac MethodName = $"DataSource_Method", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("EnumerableDataSourceDrivenTests.DataSource_Method failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 8, + TestLineNumber = 10, }); } return nodes; @@ -164,6 +168,7 @@ file partial class EnumerableDataSourceDrivenTests : global::TUnit.Core.Interfac { Name = "value", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.EnumerableDataSourceDrivenTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -177,7 +182,10 @@ file partial class EnumerableDataSourceDrivenTests : global::TUnit.Core.Interfac }), Name = "EnumerableDataSourceDrivenTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -212,7 +220,7 @@ file partial class EnumerableDataSourceDrivenTests : global::TUnit.Core.Interfac ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.DataSource_Method2(methodData)), TestFilePath = @"", - TestLineNumber = 15, + TestLineNumber = 17, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -229,7 +237,7 @@ file partial class EnumerableDataSourceDrivenTests : global::TUnit.Core.Interfac MethodName = $"DataSource_Method2", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("EnumerableDataSourceDrivenTests.DataSource_Method2 failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 15, + TestLineNumber = 17, }); } return nodes; @@ -283,6 +291,7 @@ file partial class EnumerableDataSourceDrivenTests : global::TUnit.Core.Interfac { Name = "value", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.EnumerableDataSourceDrivenTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -296,7 +305,10 @@ file partial class EnumerableDataSourceDrivenTests : global::TUnit.Core.Interfac }), Name = "EnumerableDataSourceDrivenTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -331,7 +343,7 @@ file partial class EnumerableDataSourceDrivenTests : global::TUnit.Core.Interfac ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.DataSource_WithBaseReturn(methodData)), TestFilePath = @"", - TestLineNumber = 22, + TestLineNumber = 24, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -348,7 +360,7 @@ file partial class EnumerableDataSourceDrivenTests : global::TUnit.Core.Interfac MethodName = $"DataSource_WithBaseReturn", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("EnumerableDataSourceDrivenTests.DataSource_WithBaseReturn failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 22, + TestLineNumber = 24, }); } return nodes; diff --git a/TUnit.Core.SourceGenerator.Tests/EnumerableTupleDataSourceDrivenTests.Test.verified.txt b/TUnit.Core.SourceGenerator.Tests/EnumerableTupleDataSourceDrivenTests.Test.verified.txt index 6128fa84d6..4dad65ad09 100644 --- a/TUnit.Core.SourceGenerator.Tests/EnumerableTupleDataSourceDrivenTests.Test.verified.txt +++ b/TUnit.Core.SourceGenerator.Tests/EnumerableTupleDataSourceDrivenTests.Test.verified.txt @@ -50,16 +50,19 @@ file partial class EnumerableTupleDataSourceDrivenTests : global::TUnit.Core.Int { Name = "value", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "value2", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "value3", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.EnumerableTupleDataSourceDrivenTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -73,7 +76,10 @@ file partial class EnumerableTupleDataSourceDrivenTests : global::TUnit.Core.Int }), Name = "EnumerableTupleDataSourceDrivenTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -112,7 +118,7 @@ file partial class EnumerableTupleDataSourceDrivenTests : global::TUnit.Core.Int ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.DataSource_TupleMethod(methodArg, methodArg1, methodArg2)), TestFilePath = @"", - TestLineNumber = 5, + TestLineNumber = 8, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -129,7 +135,7 @@ file partial class EnumerableTupleDataSourceDrivenTests : global::TUnit.Core.Int MethodName = $"DataSource_TupleMethod", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("EnumerableTupleDataSourceDrivenTests.DataSource_TupleMethod failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 5, + TestLineNumber = 8, }); } return nodes; @@ -159,16 +165,19 @@ file partial class EnumerableTupleDataSourceDrivenTests : global::TUnit.Core.Int { Name = "value", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "value2", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "value3", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.EnumerableTupleDataSourceDrivenTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -182,7 +191,10 @@ file partial class EnumerableTupleDataSourceDrivenTests : global::TUnit.Core.Int }), Name = "EnumerableTupleDataSourceDrivenTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -221,7 +233,7 @@ file partial class EnumerableTupleDataSourceDrivenTests : global::TUnit.Core.Int ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.DataSource_TupleMethod(methodArg, methodArg1, methodArg2)), TestFilePath = @"", - TestLineNumber = 5, + TestLineNumber = 8, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -238,7 +250,7 @@ file partial class EnumerableTupleDataSourceDrivenTests : global::TUnit.Core.Int MethodName = $"DataSource_TupleMethod", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("EnumerableTupleDataSourceDrivenTests.DataSource_TupleMethod failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 5, + TestLineNumber = 8, }); } return nodes; diff --git a/TUnit.Core.SourceGenerator.Tests/GenericMethodTests.Test.verified.txt b/TUnit.Core.SourceGenerator.Tests/GenericMethodTests.Test.verified.txt index e8460810a8..64a65e320c 100644 --- a/TUnit.Core.SourceGenerator.Tests/GenericMethodTests.Test.verified.txt +++ b/TUnit.Core.SourceGenerator.Tests/GenericMethodTests.Test.verified.txt @@ -50,31 +50,37 @@ file partial class GenericMethodTests : global::TUnit.Core.Interfaces.SourceGene { Name = "source", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "keySelector", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "seedSelector", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "func", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "comparer", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "expected", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.GenericMethodTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -88,7 +94,10 @@ file partial class GenericMethodTests : global::TUnit.Core.Interfaces.SourceGene }), Name = "GenericMethodTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -130,7 +139,7 @@ file partial class GenericMethodTests : global::TUnit.Core.Interfaces.SourceGene ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.AggregateBy_HasExpectedOutput(methodArg, methodArg1, methodArg2, methodArg3, methodArg4, methodArg5)), TestFilePath = @"", - TestLineNumber = 5, + TestLineNumber = 8, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -147,7 +156,7 @@ file partial class GenericMethodTests : global::TUnit.Core.Interfaces.SourceGene MethodName = $"AggregateBy_HasExpectedOutput", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("GenericMethodTests.AggregateBy_HasExpectedOutput failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 5, + TestLineNumber = 8, }); } return nodes; @@ -177,31 +186,37 @@ file partial class GenericMethodTests : global::TUnit.Core.Interfaces.SourceGene { Name = "source", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "keySelector", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "seedSelector", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "func", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "comparer", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "expected", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.GenericMethodTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -215,7 +230,10 @@ file partial class GenericMethodTests : global::TUnit.Core.Interfaces.SourceGene }), Name = "GenericMethodTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -257,7 +275,7 @@ file partial class GenericMethodTests : global::TUnit.Core.Interfaces.SourceGene ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.AggregateBy_HasExpectedOutput(methodArg, methodArg1, methodArg2, methodArg3, methodArg4, methodArg5)), TestFilePath = @"", - TestLineNumber = 5, + TestLineNumber = 8, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -274,7 +292,7 @@ file partial class GenericMethodTests : global::TUnit.Core.Interfaces.SourceGene MethodName = $"AggregateBy_HasExpectedOutput", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("GenericMethodTests.AggregateBy_HasExpectedOutput failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 5, + TestLineNumber = 8, }); } return nodes; diff --git a/TUnit.Core.SourceGenerator.Tests/GlobalStaticAfterEachTests.Test.verified.txt b/TUnit.Core.SourceGenerator.Tests/GlobalStaticAfterEachTests.Test.verified.txt index b44ef0877d..b0cc9767fa 100644 --- a/TUnit.Core.SourceGenerator.Tests/GlobalStaticAfterEachTests.Test.verified.txt +++ b/TUnit.Core.SourceGenerator.Tests/GlobalStaticAfterEachTests.Test.verified.txt @@ -390,6 +390,7 @@ file partial class Hooks_GlobalCleanUpTests : global::TUnit.Core.Interfaces.Sour { Name = "cancellationToken", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.AfterTests.GlobalCleanUpTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -479,6 +480,7 @@ file partial class Hooks_GlobalCleanUpTests : global::TUnit.Core.Interfaces.Sour { Name = "testContext", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.AfterTests.GlobalCleanUpTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -569,11 +571,13 @@ file partial class Hooks_GlobalCleanUpTests : global::TUnit.Core.Interfaces.Sour { Name = "testContext", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "cancellationToken", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.AfterTests.GlobalCleanUpTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -650,6 +654,7 @@ file partial class Hooks_GlobalBase1 : global::TUnit.Core.Interfaces.SourceGener { Name = "context", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.AfterTests.GlobalBase1", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -740,6 +745,7 @@ file partial class Hooks_GlobalBase2 : global::TUnit.Core.Interfaces.SourceGener { Name = "context", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.AfterTests.GlobalBase2", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -830,6 +836,7 @@ file partial class Hooks_GlobalBase3 : global::TUnit.Core.Interfaces.SourceGener { Name = "context", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.AfterTests.GlobalBase3", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -920,6 +927,7 @@ file partial class Hooks_GlobalCleanUpTests : global::TUnit.Core.Interfaces.Sour { Name = "context", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.AfterTests.GlobalCleanUpTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -1010,11 +1018,13 @@ file partial class Hooks_GlobalCleanUpTests : global::TUnit.Core.Interfaces.Sour { Name = "context", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "cancellationToken", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.AfterTests.GlobalCleanUpTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -1105,6 +1115,7 @@ file partial class Hooks_GlobalCleanUpTests : global::TUnit.Core.Interfaces.Sour { Name = "context", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.AfterTests.GlobalCleanUpTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -1195,11 +1206,13 @@ file partial class Hooks_GlobalCleanUpTests : global::TUnit.Core.Interfaces.Sour { Name = "context", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "cancellationToken", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.AfterTests.GlobalCleanUpTests", () => new global::TUnit.Core.SourceGeneratedClassInformation diff --git a/TUnit.Core.SourceGenerator.Tests/GlobalStaticBeforeEachTests.Test.verified.txt b/TUnit.Core.SourceGenerator.Tests/GlobalStaticBeforeEachTests.Test.verified.txt index d27d6e1bd2..3559fcba7f 100644 --- a/TUnit.Core.SourceGenerator.Tests/GlobalStaticBeforeEachTests.Test.verified.txt +++ b/TUnit.Core.SourceGenerator.Tests/GlobalStaticBeforeEachTests.Test.verified.txt @@ -384,6 +384,7 @@ file partial class Hooks_GlobalSetUpTests : global::TUnit.Core.Interfaces.Source { Name = "cancellationToken", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.BeforeTests.GlobalSetUpTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -473,6 +474,7 @@ file partial class Hooks_GlobalSetUpTests : global::TUnit.Core.Interfaces.Source { Name = "testContext", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.BeforeTests.GlobalSetUpTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -563,11 +565,13 @@ file partial class Hooks_GlobalSetUpTests : global::TUnit.Core.Interfaces.Source { Name = "testContext", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "cancellationToken", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.BeforeTests.GlobalSetUpTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -644,6 +648,7 @@ file partial class Hooks_GlobalBase1 : global::TUnit.Core.Interfaces.SourceGener { Name = "context", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.BeforeTests.GlobalBase1", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -734,6 +739,7 @@ file partial class Hooks_GlobalBase2 : global::TUnit.Core.Interfaces.SourceGener { Name = "context", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.BeforeTests.GlobalBase2", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -824,6 +830,7 @@ file partial class Hooks_GlobalBase3 : global::TUnit.Core.Interfaces.SourceGener { Name = "context", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.BeforeTests.GlobalBase3", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -914,6 +921,7 @@ file partial class Hooks_GlobalSetUpTests : global::TUnit.Core.Interfaces.Source { Name = "context", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.BeforeTests.GlobalSetUpTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -1004,11 +1012,13 @@ file partial class Hooks_GlobalSetUpTests : global::TUnit.Core.Interfaces.Source { Name = "context", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "cancellationToken", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.BeforeTests.GlobalSetUpTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -1099,6 +1109,7 @@ file partial class Hooks_GlobalSetUpTests : global::TUnit.Core.Interfaces.Source { Name = "context", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.BeforeTests.GlobalSetUpTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -1189,11 +1200,13 @@ file partial class Hooks_GlobalSetUpTests : global::TUnit.Core.Interfaces.Source { Name = "context", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "cancellationToken", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.BeforeTests.GlobalSetUpTests", () => new global::TUnit.Core.SourceGeneratedClassInformation diff --git a/TUnit.Core.SourceGenerator.Tests/Hooks1589.Test.verified.txt b/TUnit.Core.SourceGenerator.Tests/Hooks1589.Test.verified.txt index a6636c2bd2..6cc56c74e7 100644 --- a/TUnit.Core.SourceGenerator.Tests/Hooks1589.Test.verified.txt +++ b/TUnit.Core.SourceGenerator.Tests/Hooks1589.Test.verified.txt @@ -102,6 +102,7 @@ file partial class Hooks_BaseTests : global::TUnit.Core.Interfaces.SourceGenerat { Name = "fixture", Attributes = [], + ReflectionInfo = null!, }, ], Properties = diff --git a/TUnit.Core.SourceGenerator.Tests/Hooks1594.Test.verified.txt b/TUnit.Core.SourceGenerator.Tests/Hooks1594.Test.verified.txt index 74e46d8bac..a0d0daed79 100644 --- a/TUnit.Core.SourceGenerator.Tests/Hooks1594.Test.verified.txt +++ b/TUnit.Core.SourceGenerator.Tests/Hooks1594.Test.verified.txt @@ -61,13 +61,17 @@ file partial class Hooks_MyTests : global::TUnit.Core.Interfaces.SourceGenerator }), Name = "MyTests", Namespace = "TUnit.TestProject.Bugs._1594", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [ new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "myFixture", Attributes = [], + ReflectionInfo = null!, }, ], Properties = [], @@ -191,6 +195,7 @@ file partial class Hooks_ParentTests : global::TUnit.Core.Interfaces.SourceGener { Name = "fixture", Attributes = [], + ReflectionInfo = null!, }, ], Properties = [], @@ -314,6 +319,7 @@ file partial class Hooks_GrandParentTests : global::TUnit.Core.Interfaces.Source { Name = "fixture", Attributes = [], + ReflectionInfo = null!, }, ], Properties = diff --git a/TUnit.Core.SourceGenerator.Tests/InheritedPropertySetterTests.Test.verified.txt b/TUnit.Core.SourceGenerator.Tests/InheritedPropertySetterTests.Test.verified.txt index 80bf84a6bc..bb1e1eb44f 100644 --- a/TUnit.Core.SourceGenerator.Tests/InheritedPropertySetterTests.Test.verified.txt +++ b/TUnit.Core.SourceGenerator.Tests/InheritedPropertySetterTests.Test.verified.txt @@ -52,6 +52,7 @@ file partial class PropertySetterTests : global::TUnit.Core.Interfaces.SourceGen Namespace = "TUnit.TestProject", Attributes = [ + new EngineTest(Pass), new global::TUnit.Core.NotInParallelAttribute("PropertySetterTests") ], Parameters = [], @@ -292,7 +293,7 @@ new global::TUnit.Core.SourceGeneratedPropertyInformation ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.Test()), TestFilePath = @"", - TestLineNumber = 67, + TestLineNumber = 69, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -308,7 +309,7 @@ new global::TUnit.Core.SourceGeneratedPropertyInformation MethodName = $"Test", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("PropertySetterTests.Test failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 67, + TestLineNumber = 69, }); } return nodes; @@ -370,6 +371,7 @@ file partial class Inherited_InheritedPropertySetterTests : global::TUnit.Core.I Attributes = [ new global::TUnit.Core.InheritsTestsAttribute(), + new EngineTest(Pass), new global::TUnit.Core.NotInParallelAttribute("PropertySetterTests") ], Parameters = [], @@ -543,7 +545,7 @@ file partial class Inherited_InheritedPropertySetterTests : global::TUnit.Core.I ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.Test()), TestFilePath = @"", - TestLineNumber = 67, + TestLineNumber = 69, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -559,7 +561,7 @@ file partial class Inherited_InheritedPropertySetterTests : global::TUnit.Core.I MethodName = $"Test", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("InheritedPropertySetterTests.Test failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 67, + TestLineNumber = 69, }); } return nodes; diff --git a/TUnit.Core.SourceGenerator.Tests/InheritedTestsFromDifferentProjectTests.Test.verified.txt b/TUnit.Core.SourceGenerator.Tests/InheritedTestsFromDifferentProjectTests.Test.verified.txt index bb8967a8a3..362bb2420e 100644 --- a/TUnit.Core.SourceGenerator.Tests/InheritedTestsFromDifferentProjectTests.Test.verified.txt +++ b/TUnit.Core.SourceGenerator.Tests/InheritedTestsFromDifferentProjectTests.Test.verified.txt @@ -52,6 +52,7 @@ file partial class InheritedTestsFromDifferentProjectTests : global::TUnit.Core. Namespace = "TUnit.TestProject", Attributes = [ + new EngineTest(Pass), new global::TUnit.Core.InheritsTestsAttribute() ], Parameters = [], @@ -84,7 +85,7 @@ file partial class InheritedTestsFromDifferentProjectTests : global::TUnit.Core. ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.Test()), TestFilePath = @"", - TestLineNumber = 6, + TestLineNumber = 9, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -100,7 +101,7 @@ file partial class InheritedTestsFromDifferentProjectTests : global::TUnit.Core. MethodName = $"Test", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("InheritedTestsFromDifferentProjectTests.Test failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 6, + TestLineNumber = 9, }); } return nodes; @@ -154,6 +155,7 @@ file partial class InheritedTestsFromDifferentProjectTests : global::TUnit.Core. { Name = "value", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.InheritedTestsFromDifferentProjectTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -169,6 +171,7 @@ file partial class InheritedTestsFromDifferentProjectTests : global::TUnit.Core. Namespace = "TUnit.TestProject", Attributes = [ + new EngineTest(Pass), new global::TUnit.Core.InheritsTestsAttribute() ], Parameters = [], @@ -202,7 +205,7 @@ file partial class InheritedTestsFromDifferentProjectTests : global::TUnit.Core. ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.GenericMethodDataSource(methodArg)), TestFilePath = @"", - TestLineNumber = 11, + TestLineNumber = 14, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -218,7 +221,7 @@ file partial class InheritedTestsFromDifferentProjectTests : global::TUnit.Core. MethodName = $"GenericMethodDataSource", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("InheritedTestsFromDifferentProjectTests.GenericMethodDataSource failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 11, + TestLineNumber = 14, }); } return nodes; @@ -272,6 +275,7 @@ file partial class InheritedTestsFromDifferentProjectTests : global::TUnit.Core. { Name = "value", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.InheritedTestsFromDifferentProjectTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -287,6 +291,7 @@ file partial class InheritedTestsFromDifferentProjectTests : global::TUnit.Core. Namespace = "TUnit.TestProject", Attributes = [ + new EngineTest(Pass), new global::TUnit.Core.InheritsTestsAttribute() ], Parameters = [], @@ -320,7 +325,7 @@ file partial class InheritedTestsFromDifferentProjectTests : global::TUnit.Core. ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.NonGenericMethodDataSource(methodArg)), TestFilePath = @"", - TestLineNumber = 17, + TestLineNumber = 20, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -336,7 +341,7 @@ file partial class InheritedTestsFromDifferentProjectTests : global::TUnit.Core. MethodName = $"NonGenericMethodDataSource", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("InheritedTestsFromDifferentProjectTests.NonGenericMethodDataSource failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 17, + TestLineNumber = 20, }); } return nodes; @@ -397,6 +402,7 @@ file partial class Inherited_InheritedTestsFromDifferentProjectTests : global::T Namespace = "TUnit.TestProject", Attributes = [ + new EngineTest(Pass), new global::TUnit.Core.InheritsTestsAttribute() ], Parameters = [], diff --git a/TUnit.Core.SourceGenerator.Tests/MatrixTests.Test.verified.txt b/TUnit.Core.SourceGenerator.Tests/MatrixTests.Test.verified.txt index 8e12f50a40..5e65e48299 100644 --- a/TUnit.Core.SourceGenerator.Tests/MatrixTests.Test.verified.txt +++ b/TUnit.Core.SourceGenerator.Tests/MatrixTests.Test.verified.txt @@ -47,6 +47,7 @@ file partial class MatrixTests : global::TUnit.Core.Interfaces.SourceGenerator.I [ new global::TUnit.Core.MatrixAttribute("A", "B", "C", "D") ], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { @@ -55,6 +56,7 @@ file partial class MatrixTests : global::TUnit.Core.Interfaces.SourceGenerator.I [ new global::TUnit.Core.MatrixAttribute(1, 2, 3) ], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { @@ -63,6 +65,7 @@ file partial class MatrixTests : global::TUnit.Core.Interfaces.SourceGenerator.I [ new global::TUnit.Core.MatrixAttribute(true, false) ], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.MatrixTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -76,7 +79,10 @@ file partial class MatrixTests : global::TUnit.Core.Interfaces.SourceGenerator.I }), Name = "MatrixTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -100,6 +106,7 @@ file partial class MatrixTests : global::TUnit.Core.Interfaces.SourceGenerator.I [ new global::TUnit.Core.MatrixAttribute("A", "B", "C", "D") ], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { @@ -108,6 +115,7 @@ file partial class MatrixTests : global::TUnit.Core.Interfaces.SourceGenerator.I [ new global::TUnit.Core.MatrixAttribute(1, 2, 3) ], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { @@ -116,6 +124,7 @@ file partial class MatrixTests : global::TUnit.Core.Interfaces.SourceGenerator.I [ new global::TUnit.Core.MatrixAttribute(true, false) ], + ReflectionInfo = null!, }, ], TestSessionId = sessionId, @@ -156,7 +165,7 @@ file partial class MatrixTests : global::TUnit.Core.Interfaces.SourceGenerator.I ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.MatrixTest_One(methodArg, methodArg1, methodArg2)), TestFilePath = @"", - TestLineNumber = 10, + TestLineNumber = 12, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -173,7 +182,7 @@ file partial class MatrixTests : global::TUnit.Core.Interfaces.SourceGenerator.I MethodName = $"MatrixTest_One", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("MatrixTests.MatrixTest_One failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 10, + TestLineNumber = 12, }); } return nodes; @@ -229,6 +238,7 @@ file partial class MatrixTests : global::TUnit.Core.Interfaces.SourceGenerator.I [ new global::TUnit.Core.MatrixAttribute(1, 2) ], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { @@ -237,6 +247,7 @@ file partial class MatrixTests : global::TUnit.Core.Interfaces.SourceGenerator.I [ new global::TUnit.Core.MatrixAttribute(1, 2, 3) ], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { @@ -245,6 +256,7 @@ file partial class MatrixTests : global::TUnit.Core.Interfaces.SourceGenerator.I [ new global::TUnit.Core.MatrixAttribute(1, 2, 3, 4) ], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { @@ -253,6 +265,7 @@ file partial class MatrixTests : global::TUnit.Core.Interfaces.SourceGenerator.I [ new global::TUnit.Core.MatrixAttribute(true, false) ], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.MatrixTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -266,7 +279,10 @@ file partial class MatrixTests : global::TUnit.Core.Interfaces.SourceGenerator.I }), Name = "MatrixTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -290,6 +306,7 @@ file partial class MatrixTests : global::TUnit.Core.Interfaces.SourceGenerator.I [ new global::TUnit.Core.MatrixAttribute(1, 2) ], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { @@ -298,6 +315,7 @@ file partial class MatrixTests : global::TUnit.Core.Interfaces.SourceGenerator.I [ new global::TUnit.Core.MatrixAttribute(1, 2, 3) ], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { @@ -306,6 +324,7 @@ file partial class MatrixTests : global::TUnit.Core.Interfaces.SourceGenerator.I [ new global::TUnit.Core.MatrixAttribute(1, 2, 3, 4) ], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { @@ -314,6 +333,7 @@ file partial class MatrixTests : global::TUnit.Core.Interfaces.SourceGenerator.I [ new global::TUnit.Core.MatrixAttribute(true, false) ], + ReflectionInfo = null!, }, ], TestSessionId = sessionId, @@ -355,7 +375,7 @@ file partial class MatrixTests : global::TUnit.Core.Interfaces.SourceGenerator.I ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.MatrixTest_Two(methodArg, methodArg1, methodArg2, methodArg3)), TestFilePath = @"", - TestLineNumber = 20, + TestLineNumber = 22, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -372,7 +392,7 @@ file partial class MatrixTests : global::TUnit.Core.Interfaces.SourceGenerator.I MethodName = $"MatrixTest_Two", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("MatrixTests.MatrixTest_Two failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 20, + TestLineNumber = 22, }); } return nodes; @@ -428,6 +448,7 @@ file partial class MatrixTests : global::TUnit.Core.Interfaces.SourceGenerator.I [ new global::TUnit.Core.MatrixAttribute(1, 2) ], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { @@ -436,11 +457,13 @@ file partial class MatrixTests : global::TUnit.Core.Interfaces.SourceGenerator.I [ new global::TUnit.Core.MatrixAttribute(-1, global::TUnit.TestProject.TestEnum.One) ], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "testEnum2", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.MatrixTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -454,7 +477,10 @@ file partial class MatrixTests : global::TUnit.Core.Interfaces.SourceGenerator.I }), Name = "MatrixTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -478,6 +504,7 @@ file partial class MatrixTests : global::TUnit.Core.Interfaces.SourceGenerator.I [ new global::TUnit.Core.MatrixAttribute(1, 2) ], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { @@ -486,11 +513,13 @@ file partial class MatrixTests : global::TUnit.Core.Interfaces.SourceGenerator.I [ new global::TUnit.Core.MatrixAttribute(-1, global::TUnit.TestProject.TestEnum.One) ], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "testEnum2", Attributes = [], + ReflectionInfo = null!, }, ], TestSessionId = sessionId, @@ -531,7 +560,7 @@ file partial class MatrixTests : global::TUnit.Core.Interfaces.SourceGenerator.I ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.MatrixTest_Enum(methodArg, methodArg1, methodArg2)), TestFilePath = @"", - TestLineNumber = 31, + TestLineNumber = 33, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -548,7 +577,7 @@ file partial class MatrixTests : global::TUnit.Core.Interfaces.SourceGenerator.I MethodName = $"MatrixTest_Enum", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("MatrixTests.MatrixTest_Enum failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 31, + TestLineNumber = 33, }); } return nodes; @@ -604,11 +633,13 @@ file partial class MatrixTests : global::TUnit.Core.Interfaces.SourceGenerator.I [ new global::TUnit.Core.MatrixAttribute("A", "B", "C") ], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "boolean", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.MatrixTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -622,7 +653,10 @@ file partial class MatrixTests : global::TUnit.Core.Interfaces.SourceGenerator.I }), Name = "MatrixTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -646,11 +680,13 @@ file partial class MatrixTests : global::TUnit.Core.Interfaces.SourceGenerator.I [ new global::TUnit.Core.MatrixAttribute("A", "B", "C") ], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "boolean", Attributes = [], + ReflectionInfo = null!, }, ], TestSessionId = sessionId, @@ -690,7 +726,7 @@ file partial class MatrixTests : global::TUnit.Core.Interfaces.SourceGenerator.I ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.AutoGenerateBools(methodArg, methodArg1)), TestFilePath = @"", - TestLineNumber = 41, + TestLineNumber = 43, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -707,7 +743,7 @@ file partial class MatrixTests : global::TUnit.Core.Interfaces.SourceGenerator.I MethodName = $"AutoGenerateBools", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("MatrixTests.AutoGenerateBools failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 41, + TestLineNumber = 43, }); } return nodes; @@ -763,6 +799,7 @@ file partial class MatrixTests : global::TUnit.Core.Interfaces.SourceGenerator.I [ new global::TUnit.Core.MatrixAttribute("A", "B", "C") ], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { @@ -771,6 +808,7 @@ file partial class MatrixTests : global::TUnit.Core.Interfaces.SourceGenerator.I [ new global::TUnit.Core.MatrixAttribute() ], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.MatrixTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -784,7 +822,10 @@ file partial class MatrixTests : global::TUnit.Core.Interfaces.SourceGenerator.I }), Name = "MatrixTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -808,6 +849,7 @@ file partial class MatrixTests : global::TUnit.Core.Interfaces.SourceGenerator.I [ new global::TUnit.Core.MatrixAttribute("A", "B", "C") ], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { @@ -816,6 +858,7 @@ file partial class MatrixTests : global::TUnit.Core.Interfaces.SourceGenerator.I [ new global::TUnit.Core.MatrixAttribute() ], + ReflectionInfo = null!, }, ], TestSessionId = sessionId, @@ -855,7 +898,7 @@ file partial class MatrixTests : global::TUnit.Core.Interfaces.SourceGenerator.I ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.AutoGenerateBools2(methodArg, methodArg1)), TestFilePath = @"", - TestLineNumber = 50, + TestLineNumber = 52, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -872,7 +915,7 @@ file partial class MatrixTests : global::TUnit.Core.Interfaces.SourceGenerator.I MethodName = $"AutoGenerateBools2", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("MatrixTests.AutoGenerateBools2 failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 50, + TestLineNumber = 52, }); } return nodes; @@ -928,6 +971,7 @@ file partial class MatrixTests : global::TUnit.Core.Interfaces.SourceGenerator.I [ new global::TUnit.Core.MatrixAttribute(global::TUnit.TestProject.TestEnum.One, Two) ], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { @@ -936,6 +980,7 @@ file partial class MatrixTests : global::TUnit.Core.Interfaces.SourceGenerator.I [ new global::TUnit.Core.MatrixAttribute() ], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.MatrixTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -949,7 +994,10 @@ file partial class MatrixTests : global::TUnit.Core.Interfaces.SourceGenerator.I }), Name = "MatrixTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -973,6 +1021,7 @@ file partial class MatrixTests : global::TUnit.Core.Interfaces.SourceGenerator.I [ new global::TUnit.Core.MatrixAttribute(global::TUnit.TestProject.TestEnum.One, Two) ], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { @@ -981,6 +1030,7 @@ file partial class MatrixTests : global::TUnit.Core.Interfaces.SourceGenerator.I [ new global::TUnit.Core.MatrixAttribute() ], + ReflectionInfo = null!, }, ], TestSessionId = sessionId, @@ -1020,7 +1070,7 @@ file partial class MatrixTests : global::TUnit.Core.Interfaces.SourceGenerator.I ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.ImplicitConversion(methodArg, methodArg1)), TestFilePath = @"", - TestLineNumber = 59, + TestLineNumber = 61, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -1037,7 +1087,7 @@ file partial class MatrixTests : global::TUnit.Core.Interfaces.SourceGenerator.I MethodName = $"ImplicitConversion", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("MatrixTests.ImplicitConversion failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 59, + TestLineNumber = 61, }); } return nodes; @@ -1096,6 +1146,7 @@ file partial class MatrixTests : global::TUnit.Core.Interfaces.SourceGenerator.I Excluding = [global::TUnit.TestProject.MatrixTests.CountToTenEnum.Three, global::TUnit.TestProject.MatrixTests.CountToTenEnum.Seven], } ], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { @@ -1104,6 +1155,7 @@ file partial class MatrixTests : global::TUnit.Core.Interfaces.SourceGenerator.I [ new global::TUnit.Core.MatrixAttribute() ], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.MatrixTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -1117,7 +1169,10 @@ file partial class MatrixTests : global::TUnit.Core.Interfaces.SourceGenerator.I }), Name = "MatrixTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -1144,6 +1199,7 @@ file partial class MatrixTests : global::TUnit.Core.Interfaces.SourceGenerator.I Excluding = [global::TUnit.TestProject.MatrixTests.CountToTenEnum.Three, global::TUnit.TestProject.MatrixTests.CountToTenEnum.Seven], } ], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { @@ -1152,6 +1208,7 @@ file partial class MatrixTests : global::TUnit.Core.Interfaces.SourceGenerator.I [ new global::TUnit.Core.MatrixAttribute() ], + ReflectionInfo = null!, }, ], TestSessionId = sessionId, @@ -1191,7 +1248,7 @@ file partial class MatrixTests : global::TUnit.Core.Interfaces.SourceGenerator.I ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.ExcludingAutoGeneratedMatrixValues(methodArg, methodArg1)), TestFilePath = @"", - TestLineNumber = 68, + TestLineNumber = 70, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -1208,7 +1265,7 @@ file partial class MatrixTests : global::TUnit.Core.Interfaces.SourceGenerator.I MethodName = $"ExcludingAutoGeneratedMatrixValues", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("MatrixTests.ExcludingAutoGeneratedMatrixValues failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 68, + TestLineNumber = 70, }); } return nodes; @@ -1264,6 +1321,7 @@ file partial class MatrixTests : global::TUnit.Core.Interfaces.SourceGenerator.I [ new global::TUnit.Core.MatrixMethodAttribute("EnumerableMethod") ], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.MatrixTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -1277,7 +1335,10 @@ file partial class MatrixTests : global::TUnit.Core.Interfaces.SourceGenerator.I }), Name = "MatrixTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -1301,6 +1362,7 @@ file partial class MatrixTests : global::TUnit.Core.Interfaces.SourceGenerator.I [ new global::TUnit.Core.MatrixMethodAttribute("EnumerableMethod") ], + ReflectionInfo = null!, }, ], TestSessionId = sessionId, @@ -1339,7 +1401,7 @@ file partial class MatrixTests : global::TUnit.Core.Interfaces.SourceGenerator.I ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.Method1(methodArg)), TestFilePath = @"", - TestLineNumber = 117, + TestLineNumber = 119, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -1356,7 +1418,7 @@ file partial class MatrixTests : global::TUnit.Core.Interfaces.SourceGenerator.I MethodName = $"Method1", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("MatrixTests.Method1 failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 117, + TestLineNumber = 119, }); } return nodes; @@ -1412,6 +1474,7 @@ file partial class MatrixTests : global::TUnit.Core.Interfaces.SourceGenerator.I [ new global::TUnit.Core.MatrixMethodAttribute("ArrayMethod") ], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.MatrixTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -1425,7 +1488,10 @@ file partial class MatrixTests : global::TUnit.Core.Interfaces.SourceGenerator.I }), Name = "MatrixTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -1449,6 +1515,7 @@ file partial class MatrixTests : global::TUnit.Core.Interfaces.SourceGenerator.I [ new global::TUnit.Core.MatrixMethodAttribute("ArrayMethod") ], + ReflectionInfo = null!, }, ], TestSessionId = sessionId, @@ -1487,7 +1554,7 @@ file partial class MatrixTests : global::TUnit.Core.Interfaces.SourceGenerator.I ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.Method2(methodArg)), TestFilePath = @"", - TestLineNumber = 125, + TestLineNumber = 127, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -1504,7 +1571,7 @@ file partial class MatrixTests : global::TUnit.Core.Interfaces.SourceGenerator.I MethodName = $"Method2", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("MatrixTests.Method2 failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 125, + TestLineNumber = 127, }); } return nodes; @@ -1560,6 +1627,7 @@ file partial class MatrixTests : global::TUnit.Core.Interfaces.SourceGenerator.I [ new global::TUnit.Core.MatrixMethodAttribute("IntMethod") ], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.MatrixTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -1573,7 +1641,10 @@ file partial class MatrixTests : global::TUnit.Core.Interfaces.SourceGenerator.I }), Name = "MatrixTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -1597,6 +1668,7 @@ file partial class MatrixTests : global::TUnit.Core.Interfaces.SourceGenerator.I [ new global::TUnit.Core.MatrixMethodAttribute("IntMethod") ], + ReflectionInfo = null!, }, ], TestSessionId = sessionId, @@ -1635,7 +1707,7 @@ file partial class MatrixTests : global::TUnit.Core.Interfaces.SourceGenerator.I ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.Method3(methodArg)), TestFilePath = @"", - TestLineNumber = 133, + TestLineNumber = 135, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -1652,7 +1724,7 @@ file partial class MatrixTests : global::TUnit.Core.Interfaces.SourceGenerator.I MethodName = $"Method3", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("MatrixTests.Method3 failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 133, + TestLineNumber = 135, }); } return nodes; @@ -1708,6 +1780,7 @@ file partial class MatrixTests : global::TUnit.Core.Interfaces.SourceGenerator.I [ new global::TUnit.Core.MatrixMethodAttribute("ObjectMethod") ], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.MatrixTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -1721,7 +1794,10 @@ file partial class MatrixTests : global::TUnit.Core.Interfaces.SourceGenerator.I }), Name = "MatrixTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -1745,6 +1821,7 @@ file partial class MatrixTests : global::TUnit.Core.Interfaces.SourceGenerator.I [ new global::TUnit.Core.MatrixMethodAttribute("ObjectMethod") ], + ReflectionInfo = null!, }, ], TestSessionId = sessionId, @@ -1783,7 +1860,7 @@ file partial class MatrixTests : global::TUnit.Core.Interfaces.SourceGenerator.I ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.Method4(methodArg)), TestFilePath = @"", - TestLineNumber = 141, + TestLineNumber = 143, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -1800,7 +1877,7 @@ file partial class MatrixTests : global::TUnit.Core.Interfaces.SourceGenerator.I MethodName = $"Method4", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("MatrixTests.Method4 failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 141, + TestLineNumber = 143, }); } return nodes; @@ -1859,6 +1936,7 @@ file partial class MatrixTests : global::TUnit.Core.Interfaces.SourceGenerator.I [ new global::TUnit.Core.MatrixMethodAttribute("EnumerableMethod") ], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { @@ -1867,6 +1945,7 @@ file partial class MatrixTests : global::TUnit.Core.Interfaces.SourceGenerator.I [ new global::TUnit.Core.MatrixMethodAttribute("EnumerableMethod") ], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.MatrixTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -1880,7 +1959,10 @@ file partial class MatrixTests : global::TUnit.Core.Interfaces.SourceGenerator.I }), Name = "MatrixTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -1904,6 +1986,7 @@ file partial class MatrixTests : global::TUnit.Core.Interfaces.SourceGenerator.I [ new global::TUnit.Core.MatrixMethodAttribute("EnumerableMethod") ], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { @@ -1912,6 +1995,7 @@ file partial class MatrixTests : global::TUnit.Core.Interfaces.SourceGenerator.I [ new global::TUnit.Core.MatrixMethodAttribute("EnumerableMethod") ], + ReflectionInfo = null!, }, ], TestSessionId = sessionId, @@ -1951,7 +2035,7 @@ file partial class MatrixTests : global::TUnit.Core.Interfaces.SourceGenerator.I ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.Exclusion(methodArg, methodArg1)), TestFilePath = @"", - TestLineNumber = 149, + TestLineNumber = 151, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -1968,7 +2052,7 @@ file partial class MatrixTests : global::TUnit.Core.Interfaces.SourceGenerator.I MethodName = $"Exclusion", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("MatrixTests.Exclusion failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 149, + TestLineNumber = 151, }); } return nodes; diff --git a/TUnit.Core.SourceGenerator.Tests/MethodDataSourceDrivenTests.Test.verified.txt b/TUnit.Core.SourceGenerator.Tests/MethodDataSourceDrivenTests.Test.verified.txt index 1478a9b241..2774308013 100644 --- a/TUnit.Core.SourceGenerator.Tests/MethodDataSourceDrivenTests.Test.verified.txt +++ b/TUnit.Core.SourceGenerator.Tests/MethodDataSourceDrivenTests.Test.verified.txt @@ -45,6 +45,7 @@ file partial class MethodDataSourceDrivenTests : global::TUnit.Core.Interfaces.S { Name = "value", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.MethodDataSourceDrivenTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -58,7 +59,10 @@ file partial class MethodDataSourceDrivenTests : global::TUnit.Core.Interfaces.S }), Name = "MethodDataSourceDrivenTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -90,7 +94,7 @@ file partial class MethodDataSourceDrivenTests : global::TUnit.Core.Interfaces.S ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.DataSource_Method(methodArg)), TestFilePath = @"", - TestLineNumber = 12, + TestLineNumber = 14, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -106,7 +110,7 @@ file partial class MethodDataSourceDrivenTests : global::TUnit.Core.Interfaces.S MethodName = $"DataSource_Method", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("MethodDataSourceDrivenTests.DataSource_Method failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 12, + TestLineNumber = 14, }); } return nodes; @@ -160,6 +164,7 @@ file partial class MethodDataSourceDrivenTests : global::TUnit.Core.Interfaces.S { Name = "value", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.MethodDataSourceDrivenTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -173,7 +178,10 @@ file partial class MethodDataSourceDrivenTests : global::TUnit.Core.Interfaces.S }), Name = "MethodDataSourceDrivenTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -205,7 +213,7 @@ file partial class MethodDataSourceDrivenTests : global::TUnit.Core.Interfaces.S ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.DataSource_Method2(methodArg)), TestFilePath = @"", - TestLineNumber = 19, + TestLineNumber = 21, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -221,7 +229,7 @@ file partial class MethodDataSourceDrivenTests : global::TUnit.Core.Interfaces.S MethodName = $"DataSource_Method2", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("MethodDataSourceDrivenTests.DataSource_Method2 failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 19, + TestLineNumber = 21, }); } return nodes; @@ -275,6 +283,7 @@ file partial class MethodDataSourceDrivenTests : global::TUnit.Core.Interfaces.S { Name = "action", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.MethodDataSourceDrivenTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -288,7 +297,10 @@ file partial class MethodDataSourceDrivenTests : global::TUnit.Core.Interfaces.S }), Name = "MethodDataSourceDrivenTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -320,7 +332,7 @@ file partial class MethodDataSourceDrivenTests : global::TUnit.Core.Interfaces.S ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.DataSource_Method_WithAction(methodArg)), TestFilePath = @"", - TestLineNumber = 26, + TestLineNumber = 28, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -336,7 +348,7 @@ file partial class MethodDataSourceDrivenTests : global::TUnit.Core.Interfaces.S MethodName = $"DataSource_Method_WithAction", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("MethodDataSourceDrivenTests.DataSource_Method_WithAction failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 26, + TestLineNumber = 28, }); } return nodes; @@ -401,6 +413,7 @@ file partial class MethodDataSourceDrivenTests : global::TUnit.Core.Interfaces.S { Name = "value", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.MethodDataSourceDrivenTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -414,7 +427,10 @@ file partial class MethodDataSourceDrivenTests : global::TUnit.Core.Interfaces.S }), Name = "MethodDataSourceDrivenTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -446,7 +462,7 @@ file partial class MethodDataSourceDrivenTests : global::TUnit.Core.Interfaces.S ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.DataSource_Method3(methodArg)), TestFilePath = @"", - TestLineNumber = 33, + TestLineNumber = 35, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -462,7 +478,7 @@ file partial class MethodDataSourceDrivenTests : global::TUnit.Core.Interfaces.S MethodName = $"DataSource_Method3", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("MethodDataSourceDrivenTests.DataSource_Method3 failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 33, + TestLineNumber = 35, }); } return nodes; @@ -498,6 +514,7 @@ file partial class MethodDataSourceDrivenTests : global::TUnit.Core.Interfaces.S { Name = "value", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.MethodDataSourceDrivenTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -511,7 +528,10 @@ file partial class MethodDataSourceDrivenTests : global::TUnit.Core.Interfaces.S }), Name = "MethodDataSourceDrivenTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -543,7 +563,7 @@ file partial class MethodDataSourceDrivenTests : global::TUnit.Core.Interfaces.S ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.DataSource_Method3(methodArg)), TestFilePath = @"", - TestLineNumber = 33, + TestLineNumber = 35, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -559,7 +579,7 @@ file partial class MethodDataSourceDrivenTests : global::TUnit.Core.Interfaces.S MethodName = $"DataSource_Method3", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("MethodDataSourceDrivenTests.DataSource_Method3 failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 33, + TestLineNumber = 35, }); } return nodes; @@ -634,6 +654,7 @@ file partial class MethodDataSourceDrivenTests : global::TUnit.Core.Interfaces.S { Name = "value", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.MethodDataSourceDrivenTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -647,7 +668,10 @@ file partial class MethodDataSourceDrivenTests : global::TUnit.Core.Interfaces.S }), Name = "MethodDataSourceDrivenTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -679,7 +703,7 @@ file partial class MethodDataSourceDrivenTests : global::TUnit.Core.Interfaces.S ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.DataSource_Method4(methodArg)), TestFilePath = @"", - TestLineNumber = 42, + TestLineNumber = 44, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -695,7 +719,7 @@ file partial class MethodDataSourceDrivenTests : global::TUnit.Core.Interfaces.S MethodName = $"DataSource_Method4", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("MethodDataSourceDrivenTests.DataSource_Method4 failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 42, + TestLineNumber = 44, }); } return nodes; @@ -739,6 +763,7 @@ file partial class MethodDataSourceDrivenTests : global::TUnit.Core.Interfaces.S { Name = "value", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.MethodDataSourceDrivenTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -752,7 +777,10 @@ file partial class MethodDataSourceDrivenTests : global::TUnit.Core.Interfaces.S }), Name = "MethodDataSourceDrivenTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -784,7 +812,7 @@ file partial class MethodDataSourceDrivenTests : global::TUnit.Core.Interfaces.S ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.DataSource_Method4(methodArg)), TestFilePath = @"", - TestLineNumber = 42, + TestLineNumber = 44, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -800,7 +828,7 @@ file partial class MethodDataSourceDrivenTests : global::TUnit.Core.Interfaces.S MethodName = $"DataSource_Method4", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("MethodDataSourceDrivenTests.DataSource_Method4 failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 42, + TestLineNumber = 44, }); } return nodes; @@ -844,6 +872,7 @@ file partial class MethodDataSourceDrivenTests : global::TUnit.Core.Interfaces.S { Name = "value", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.MethodDataSourceDrivenTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -857,7 +886,10 @@ file partial class MethodDataSourceDrivenTests : global::TUnit.Core.Interfaces.S }), Name = "MethodDataSourceDrivenTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -889,7 +921,7 @@ file partial class MethodDataSourceDrivenTests : global::TUnit.Core.Interfaces.S ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.DataSource_Method4(methodArg)), TestFilePath = @"", - TestLineNumber = 42, + TestLineNumber = 44, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -905,7 +937,7 @@ file partial class MethodDataSourceDrivenTests : global::TUnit.Core.Interfaces.S MethodName = $"DataSource_Method4", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("MethodDataSourceDrivenTests.DataSource_Method4 failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 42, + TestLineNumber = 44, }); } return nodes; @@ -949,6 +981,7 @@ file partial class MethodDataSourceDrivenTests : global::TUnit.Core.Interfaces.S { Name = "value", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.MethodDataSourceDrivenTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -962,7 +995,10 @@ file partial class MethodDataSourceDrivenTests : global::TUnit.Core.Interfaces.S }), Name = "MethodDataSourceDrivenTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -994,7 +1030,7 @@ file partial class MethodDataSourceDrivenTests : global::TUnit.Core.Interfaces.S ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.DataSource_Method4(methodArg)), TestFilePath = @"", - TestLineNumber = 42, + TestLineNumber = 44, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -1010,7 +1046,7 @@ file partial class MethodDataSourceDrivenTests : global::TUnit.Core.Interfaces.S MethodName = $"DataSource_Method4", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("MethodDataSourceDrivenTests.DataSource_Method4 failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 42, + TestLineNumber = 44, }); } return nodes; @@ -1064,6 +1100,7 @@ file partial class MethodDataSourceDrivenTests : global::TUnit.Core.Interfaces.S { Name = "value", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.MethodDataSourceDrivenTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -1077,7 +1114,10 @@ file partial class MethodDataSourceDrivenTests : global::TUnit.Core.Interfaces.S }), Name = "MethodDataSourceDrivenTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -1109,7 +1149,7 @@ file partial class MethodDataSourceDrivenTests : global::TUnit.Core.Interfaces.S ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.DataSource_WithBaseReturn(methodArg)), TestFilePath = @"", - TestLineNumber = 53, + TestLineNumber = 55, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -1125,7 +1165,7 @@ file partial class MethodDataSourceDrivenTests : global::TUnit.Core.Interfaces.S MethodName = $"DataSource_WithBaseReturn", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("MethodDataSourceDrivenTests.DataSource_WithBaseReturn failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 53, + TestLineNumber = 55, }); } return nodes; @@ -1179,6 +1219,7 @@ file partial class MethodDataSourceDrivenTests : global::TUnit.Core.Interfaces.S { Name = "strings", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.MethodDataSourceDrivenTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -1192,7 +1233,10 @@ file partial class MethodDataSourceDrivenTests : global::TUnit.Core.Interfaces.S }), Name = "MethodDataSourceDrivenTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -1227,7 +1271,7 @@ file partial class MethodDataSourceDrivenTests : global::TUnit.Core.Interfaces.S ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.EnumerableFuncArrayTest(methodData)), TestFilePath = @"", - TestLineNumber = 59, + TestLineNumber = 61, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -1244,7 +1288,7 @@ file partial class MethodDataSourceDrivenTests : global::TUnit.Core.Interfaces.S MethodName = $"EnumerableFuncArrayTest", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("MethodDataSourceDrivenTests.EnumerableFuncArrayTest failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 59, + TestLineNumber = 61, }); } return nodes; diff --git a/TUnit.Core.SourceGenerator.Tests/MethodDataSourceDrivenWithCancellationTokenTests.Test.verified.txt b/TUnit.Core.SourceGenerator.Tests/MethodDataSourceDrivenWithCancellationTokenTests.Test.verified.txt index 8fd2c8fdd9..694fe9edc1 100644 --- a/TUnit.Core.SourceGenerator.Tests/MethodDataSourceDrivenWithCancellationTokenTests.Test.verified.txt +++ b/TUnit.Core.SourceGenerator.Tests/MethodDataSourceDrivenWithCancellationTokenTests.Test.verified.txt @@ -58,11 +58,13 @@ file partial class MethodDataSourceDrivenWithCancellationTokenTests : global::TU { Name = "value", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "cancellationToken", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.MethodDataSourceDrivenWithCancellationTokenTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -78,6 +80,7 @@ file partial class MethodDataSourceDrivenWithCancellationTokenTests : global::TU Namespace = "TUnit.TestProject", Attributes = [ + new EngineTest(Pass), new global::System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute("Usage", "TUnit0046:Return a `Func` rather than a ``") ], Parameters = [], @@ -111,7 +114,7 @@ file partial class MethodDataSourceDrivenWithCancellationTokenTests : global::TU ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.MyTest(methodArg, cancellationToken)), TestFilePath = @"", - TestLineNumber = 10, + TestLineNumber = 12, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -127,7 +130,7 @@ file partial class MethodDataSourceDrivenWithCancellationTokenTests : global::TU MethodName = $"MyTest", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("MethodDataSourceDrivenWithCancellationTokenTests.MyTest failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 10, + TestLineNumber = 12, }); } return nodes; @@ -161,11 +164,13 @@ file partial class MethodDataSourceDrivenWithCancellationTokenTests : global::TU { Name = "value", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "cancellationToken", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.MethodDataSourceDrivenWithCancellationTokenTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -181,6 +186,7 @@ file partial class MethodDataSourceDrivenWithCancellationTokenTests : global::TU Namespace = "TUnit.TestProject", Attributes = [ + new EngineTest(Pass), new global::System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute("Usage", "TUnit0046:Return a `Func` rather than a ``") ], Parameters = [], @@ -214,7 +220,7 @@ file partial class MethodDataSourceDrivenWithCancellationTokenTests : global::TU ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.MyTest(methodArg, cancellationToken)), TestFilePath = @"", - TestLineNumber = 10, + TestLineNumber = 12, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -230,7 +236,7 @@ file partial class MethodDataSourceDrivenWithCancellationTokenTests : global::TU MethodName = $"MyTest", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("MethodDataSourceDrivenWithCancellationTokenTests.MyTest failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 10, + TestLineNumber = 12, }); } return nodes; @@ -264,11 +270,13 @@ file partial class MethodDataSourceDrivenWithCancellationTokenTests : global::TU { Name = "value", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "cancellationToken", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.MethodDataSourceDrivenWithCancellationTokenTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -284,6 +292,7 @@ file partial class MethodDataSourceDrivenWithCancellationTokenTests : global::TU Namespace = "TUnit.TestProject", Attributes = [ + new EngineTest(Pass), new global::System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute("Usage", "TUnit0046:Return a `Func` rather than a ``") ], Parameters = [], @@ -320,7 +329,7 @@ file partial class MethodDataSourceDrivenWithCancellationTokenTests : global::TU ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.MyTest(methodData, cancellationToken)), TestFilePath = @"", - TestLineNumber = 10, + TestLineNumber = 12, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -337,7 +346,7 @@ file partial class MethodDataSourceDrivenWithCancellationTokenTests : global::TU MethodName = $"MyTest", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("MethodDataSourceDrivenWithCancellationTokenTests.MyTest failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 10, + TestLineNumber = 12, }); } return nodes; @@ -371,11 +380,13 @@ file partial class MethodDataSourceDrivenWithCancellationTokenTests : global::TU { Name = "value", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "cancellationToken", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.MethodDataSourceDrivenWithCancellationTokenTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -391,6 +402,7 @@ file partial class MethodDataSourceDrivenWithCancellationTokenTests : global::TU Namespace = "TUnit.TestProject", Attributes = [ + new EngineTest(Pass), new global::System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute("Usage", "TUnit0046:Return a `Func` rather than a ``") ], Parameters = [], @@ -427,7 +439,7 @@ file partial class MethodDataSourceDrivenWithCancellationTokenTests : global::TU ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.MyTest(methodData, cancellationToken)), TestFilePath = @"", - TestLineNumber = 10, + TestLineNumber = 12, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -444,7 +456,7 @@ file partial class MethodDataSourceDrivenWithCancellationTokenTests : global::TU MethodName = $"MyTest", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("MethodDataSourceDrivenWithCancellationTokenTests.MyTest failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 10, + TestLineNumber = 12, }); } return nodes; @@ -478,11 +490,13 @@ file partial class MethodDataSourceDrivenWithCancellationTokenTests : global::TU { Name = "value", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "cancellationToken", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.MethodDataSourceDrivenWithCancellationTokenTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -498,6 +512,7 @@ file partial class MethodDataSourceDrivenWithCancellationTokenTests : global::TU Namespace = "TUnit.TestProject", Attributes = [ + new EngineTest(Pass), new global::System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute("Usage", "TUnit0046:Return a `Func` rather than a ``") ], Parameters = [], @@ -534,7 +549,7 @@ file partial class MethodDataSourceDrivenWithCancellationTokenTests : global::TU ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.MyTest(methodData, cancellationToken)), TestFilePath = @"", - TestLineNumber = 10, + TestLineNumber = 12, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -551,7 +566,7 @@ file partial class MethodDataSourceDrivenWithCancellationTokenTests : global::TU MethodName = $"MyTest", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("MethodDataSourceDrivenWithCancellationTokenTests.MyTest failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 10, + TestLineNumber = 12, }); } return nodes; @@ -585,11 +600,13 @@ file partial class MethodDataSourceDrivenWithCancellationTokenTests : global::TU { Name = "value", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "cancellationToken", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.MethodDataSourceDrivenWithCancellationTokenTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -605,6 +622,7 @@ file partial class MethodDataSourceDrivenWithCancellationTokenTests : global::TU Namespace = "TUnit.TestProject", Attributes = [ + new EngineTest(Pass), new global::System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute("Usage", "TUnit0046:Return a `Func` rather than a ``") ], Parameters = [], @@ -641,7 +659,7 @@ file partial class MethodDataSourceDrivenWithCancellationTokenTests : global::TU ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.MyTest(methodData, cancellationToken)), TestFilePath = @"", - TestLineNumber = 10, + TestLineNumber = 12, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -658,7 +676,7 @@ file partial class MethodDataSourceDrivenWithCancellationTokenTests : global::TU MethodName = $"MyTest", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("MethodDataSourceDrivenWithCancellationTokenTests.MyTest failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 10, + TestLineNumber = 12, }); } return nodes; diff --git a/TUnit.Core.SourceGenerator.Tests/MultipleClassDataSourceDrivenTests.Test.verified.txt b/TUnit.Core.SourceGenerator.Tests/MultipleClassDataSourceDrivenTests.Test.verified.txt index a774d3a0a5..4ae766ff6c 100644 --- a/TUnit.Core.SourceGenerator.Tests/MultipleClassDataSourceDrivenTests.Test.verified.txt +++ b/TUnit.Core.SourceGenerator.Tests/MultipleClassDataSourceDrivenTests.Test.verified.txt @@ -50,33 +50,41 @@ file partial class MultipleClassDataSourceDrivenTests : global::TUnit.Core.Inter }), Name = "MultipleClassDataSourceDrivenTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [ new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "inject1", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "inject2", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "inject3", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "inject4", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "inject5", Attributes = [], + ReflectionInfo = null!, }, ], Properties = [], @@ -98,26 +106,31 @@ file partial class MultipleClassDataSourceDrivenTests : global::TUnit.Core.Inter { Name = "inject1", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "inject2", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "inject3", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "inject4", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "inject5", Attributes = [], + ReflectionInfo = null!, }, ], TestSessionId = sessionId, @@ -164,7 +177,7 @@ file partial class MultipleClassDataSourceDrivenTests : global::TUnit.Core.Inter ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.Test1()), TestFilePath = @"", - TestLineNumber = 14, + TestLineNumber = 17, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -181,7 +194,7 @@ file partial class MultipleClassDataSourceDrivenTests : global::TUnit.Core.Inter MethodName = $"Test1", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("MultipleClassDataSourceDrivenTests.Test1 failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 14, + TestLineNumber = 17, }); } return nodes; @@ -240,33 +253,41 @@ file partial class MultipleClassDataSourceDrivenTests : global::TUnit.Core.Inter }), Name = "MultipleClassDataSourceDrivenTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [ new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "inject1", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "inject2", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "inject3", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "inject4", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "inject5", Attributes = [], + ReflectionInfo = null!, }, ], Properties = [], @@ -288,26 +309,31 @@ file partial class MultipleClassDataSourceDrivenTests : global::TUnit.Core.Inter { Name = "inject1", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "inject2", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "inject3", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "inject4", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "inject5", Attributes = [], + ReflectionInfo = null!, }, ], TestSessionId = sessionId, @@ -354,7 +380,7 @@ file partial class MultipleClassDataSourceDrivenTests : global::TUnit.Core.Inter ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.Test2()), TestFilePath = @"", - TestLineNumber = 20, + TestLineNumber = 23, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -371,7 +397,7 @@ file partial class MultipleClassDataSourceDrivenTests : global::TUnit.Core.Inter MethodName = $"Test2", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("MultipleClassDataSourceDrivenTests.Test2 failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 20, + TestLineNumber = 23, }); } return nodes; diff --git a/TUnit.Core.SourceGenerator.Tests/NameOfArgumentTests.Test.verified.txt b/TUnit.Core.SourceGenerator.Tests/NameOfArgumentTests.Test.verified.txt index 6ea1133fff..0878c0c323 100644 --- a/TUnit.Core.SourceGenerator.Tests/NameOfArgumentTests.Test.verified.txt +++ b/TUnit.Core.SourceGenerator.Tests/NameOfArgumentTests.Test.verified.txt @@ -33,7 +33,7 @@ file partial class NameOfArgumentTests : global::TUnit.Core.Interfaces.SourceGen Type = typeof(global::TUnit.TestProject.NameOfArgumentTests), Name = "TestName", GenericTypeCount = 0, - ReturnType = typeof(void), + ReturnType = typeof(global::System.Threading.Tasks.Task), Attributes = [ new global::TUnit.Core.TestAttribute(), @@ -45,6 +45,7 @@ file partial class NameOfArgumentTests : global::TUnit.Core.Interfaces.SourceGen { Name = "name", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.NameOfArgumentTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -58,7 +59,10 @@ file partial class NameOfArgumentTests : global::TUnit.Core.Interfaces.SourceGen }), Name = "NameOfArgumentTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -91,7 +95,7 @@ file partial class NameOfArgumentTests : global::TUnit.Core.Interfaces.SourceGen ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.TestName(methodArg)), TestFilePath = @"", - TestLineNumber = 5, + TestLineNumber = 8, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -107,7 +111,7 @@ file partial class NameOfArgumentTests : global::TUnit.Core.Interfaces.SourceGen MethodName = $"TestName", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("NameOfArgumentTests.TestName failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 5, + TestLineNumber = 8, }); } return nodes; diff --git a/TUnit.Core.SourceGenerator.Tests/NestedClassDataSourceDrivenTests.Test.DotNet8_0.verified.txt b/TUnit.Core.SourceGenerator.Tests/NestedClassDataSourceDrivenTests.Test.DotNet8_0.verified.txt new file mode 100644 index 0000000000..ac59ac2f7d --- /dev/null +++ b/TUnit.Core.SourceGenerator.Tests/NestedClassDataSourceDrivenTests.Test.DotNet8_0.verified.txt @@ -0,0 +1,84 @@ +[ +// +#pragma warning disable +using global::System; +using global::System.Collections.Generic; +using global::TUnit.Core; + +namespace TUnit.SourceGenerated; + +[global::System.Diagnostics.StackTraceHidden] +[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] +{ + [global::System.Runtime.CompilerServices.ModuleInitializer] + public static void InitializeProperties() + { + global::TUnit.Core.SourceRegistrar.RegisterProperty(); + global::TUnit.Core.SourceRegistrar.RegisterProperty(); + global::TUnit.Core.SourceRegistrar.RegisterProperty(); + } +} + + +// +#pragma warning disable +using global::System; +using global::System.Collections.Generic; +using global::TUnit.Core; + +namespace TUnit.SourceGenerated; + +[global::System.Diagnostics.StackTraceHidden] +[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] +{ + [global::System.Runtime.CompilerServices.ModuleInitializer] + public static void InitializeProperties() + { + global::TUnit.Core.SourceRegistrar.RegisterProperty(); + global::TUnit.Core.SourceRegistrar.RegisterProperty(); + global::TUnit.Core.SourceRegistrar.RegisterProperty(); + } +} + + +// +#pragma warning disable +using global::System; +using global::System.Collections.Generic; +using global::TUnit.Core; + +namespace TUnit.SourceGenerated; + +[global::System.Diagnostics.StackTraceHidden] +[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] +{ + [global::System.Runtime.CompilerServices.ModuleInitializer] + public static void InitializeProperties() + { + global::TUnit.Core.SourceRegistrar.RegisterProperty(); + global::TUnit.Core.SourceRegistrar.RegisterProperty(); + global::TUnit.Core.SourceRegistrar.RegisterProperty(); + } +} + + +// +#pragma warning disable +using global::System; +using global::System.Collections.Generic; +using global::TUnit.Core; + +namespace TUnit.SourceGenerated; + +[global::System.Diagnostics.StackTraceHidden] +[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] +{ + [global::System.Runtime.CompilerServices.ModuleInitializer] + public static void InitializeProperties() + { + global::TUnit.Core.SourceRegistrar.RegisterProperty(); + global::TUnit.Core.SourceRegistrar.RegisterProperty(); + } +} + +] \ No newline at end of file diff --git a/TUnit.Core.SourceGenerator.Tests/NestedClassDataSourceDrivenTests.Test.DotNet9_0.verified.txt b/TUnit.Core.SourceGenerator.Tests/NestedClassDataSourceDrivenTests.Test.DotNet9_0.verified.txt new file mode 100644 index 0000000000..ac59ac2f7d --- /dev/null +++ b/TUnit.Core.SourceGenerator.Tests/NestedClassDataSourceDrivenTests.Test.DotNet9_0.verified.txt @@ -0,0 +1,84 @@ +[ +// +#pragma warning disable +using global::System; +using global::System.Collections.Generic; +using global::TUnit.Core; + +namespace TUnit.SourceGenerated; + +[global::System.Diagnostics.StackTraceHidden] +[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] +{ + [global::System.Runtime.CompilerServices.ModuleInitializer] + public static void InitializeProperties() + { + global::TUnit.Core.SourceRegistrar.RegisterProperty(); + global::TUnit.Core.SourceRegistrar.RegisterProperty(); + global::TUnit.Core.SourceRegistrar.RegisterProperty(); + } +} + + +// +#pragma warning disable +using global::System; +using global::System.Collections.Generic; +using global::TUnit.Core; + +namespace TUnit.SourceGenerated; + +[global::System.Diagnostics.StackTraceHidden] +[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] +{ + [global::System.Runtime.CompilerServices.ModuleInitializer] + public static void InitializeProperties() + { + global::TUnit.Core.SourceRegistrar.RegisterProperty(); + global::TUnit.Core.SourceRegistrar.RegisterProperty(); + global::TUnit.Core.SourceRegistrar.RegisterProperty(); + } +} + + +// +#pragma warning disable +using global::System; +using global::System.Collections.Generic; +using global::TUnit.Core; + +namespace TUnit.SourceGenerated; + +[global::System.Diagnostics.StackTraceHidden] +[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] +{ + [global::System.Runtime.CompilerServices.ModuleInitializer] + public static void InitializeProperties() + { + global::TUnit.Core.SourceRegistrar.RegisterProperty(); + global::TUnit.Core.SourceRegistrar.RegisterProperty(); + global::TUnit.Core.SourceRegistrar.RegisterProperty(); + } +} + + +// +#pragma warning disable +using global::System; +using global::System.Collections.Generic; +using global::TUnit.Core; + +namespace TUnit.SourceGenerated; + +[global::System.Diagnostics.StackTraceHidden] +[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] +{ + [global::System.Runtime.CompilerServices.ModuleInitializer] + public static void InitializeProperties() + { + global::TUnit.Core.SourceRegistrar.RegisterProperty(); + global::TUnit.Core.SourceRegistrar.RegisterProperty(); + } +} + +] \ No newline at end of file diff --git a/TUnit.Core.SourceGenerator.Tests/NestedClassDataSourceDrivenTests.Test.Net4_7.verified.txt b/TUnit.Core.SourceGenerator.Tests/NestedClassDataSourceDrivenTests.Test.Net4_7.verified.txt new file mode 100644 index 0000000000..ac59ac2f7d --- /dev/null +++ b/TUnit.Core.SourceGenerator.Tests/NestedClassDataSourceDrivenTests.Test.Net4_7.verified.txt @@ -0,0 +1,84 @@ +[ +// +#pragma warning disable +using global::System; +using global::System.Collections.Generic; +using global::TUnit.Core; + +namespace TUnit.SourceGenerated; + +[global::System.Diagnostics.StackTraceHidden] +[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] +{ + [global::System.Runtime.CompilerServices.ModuleInitializer] + public static void InitializeProperties() + { + global::TUnit.Core.SourceRegistrar.RegisterProperty(); + global::TUnit.Core.SourceRegistrar.RegisterProperty(); + global::TUnit.Core.SourceRegistrar.RegisterProperty(); + } +} + + +// +#pragma warning disable +using global::System; +using global::System.Collections.Generic; +using global::TUnit.Core; + +namespace TUnit.SourceGenerated; + +[global::System.Diagnostics.StackTraceHidden] +[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] +{ + [global::System.Runtime.CompilerServices.ModuleInitializer] + public static void InitializeProperties() + { + global::TUnit.Core.SourceRegistrar.RegisterProperty(); + global::TUnit.Core.SourceRegistrar.RegisterProperty(); + global::TUnit.Core.SourceRegistrar.RegisterProperty(); + } +} + + +// +#pragma warning disable +using global::System; +using global::System.Collections.Generic; +using global::TUnit.Core; + +namespace TUnit.SourceGenerated; + +[global::System.Diagnostics.StackTraceHidden] +[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] +{ + [global::System.Runtime.CompilerServices.ModuleInitializer] + public static void InitializeProperties() + { + global::TUnit.Core.SourceRegistrar.RegisterProperty(); + global::TUnit.Core.SourceRegistrar.RegisterProperty(); + global::TUnit.Core.SourceRegistrar.RegisterProperty(); + } +} + + +// +#pragma warning disable +using global::System; +using global::System.Collections.Generic; +using global::TUnit.Core; + +namespace TUnit.SourceGenerated; + +[global::System.Diagnostics.StackTraceHidden] +[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] +{ + [global::System.Runtime.CompilerServices.ModuleInitializer] + public static void InitializeProperties() + { + global::TUnit.Core.SourceRegistrar.RegisterProperty(); + global::TUnit.Core.SourceRegistrar.RegisterProperty(); + } +} + +] \ No newline at end of file diff --git a/TUnit.Core.SourceGenerator.Tests/NestedClassDataSourceDrivenTests.cs b/TUnit.Core.SourceGenerator.Tests/NestedClassDataSourceDrivenTests.cs new file mode 100644 index 0000000000..40c25b2308 --- /dev/null +++ b/TUnit.Core.SourceGenerator.Tests/NestedClassDataSourceDrivenTests.cs @@ -0,0 +1,21 @@ +using TUnit.Core.SourceGenerator.CodeGenerators; +using TUnit.Core.SourceGenerator.Tests.Options; + +namespace TUnit.Core.SourceGenerator.Tests; + +internal class NestedClassDataSourceDrivenTests : TestsBase +{ + [Test] + public Task Test() => RunTest(Path.Combine(Git.RootDirectory.FullName, + "TUnit.TestProject", + "NestedClassDataSourceDrivenTests.cs"), + new RunTestOptions() + { + VerifyConfigurator = settingsTask => settingsTask.ScrubLinesContaining("PropertyInitializer_") + .UniqueForTargetFrameworkAndVersion() + }, + async generatedFiles => + { + await Assert.That(generatedFiles.Length).IsEqualTo(4); + }); +} diff --git a/TUnit.Core.SourceGenerator.Tests/NullableByteArgumentTests.Test.verified.txt b/TUnit.Core.SourceGenerator.Tests/NullableByteArgumentTests.Test.verified.txt index cce9ddc911..947fc72fa9 100644 --- a/TUnit.Core.SourceGenerator.Tests/NullableByteArgumentTests.Test.verified.txt +++ b/TUnit.Core.SourceGenerator.Tests/NullableByteArgumentTests.Test.verified.txt @@ -50,6 +50,7 @@ file partial class NullableByteArgumentTests : global::TUnit.Core.Interfaces.Sou { Name = "someByte", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.NullableByteArgumentTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -63,7 +64,10 @@ file partial class NullableByteArgumentTests : global::TUnit.Core.Interfaces.Sou }), Name = "NullableByteArgumentTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -96,7 +100,7 @@ file partial class NullableByteArgumentTests : global::TUnit.Core.Interfaces.Sou ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.Test(methodArg)), TestFilePath = @"", - TestLineNumber = 5, + TestLineNumber = 8, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -112,7 +116,7 @@ file partial class NullableByteArgumentTests : global::TUnit.Core.Interfaces.Sou MethodName = $"Test", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("NullableByteArgumentTests.Test failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 5, + TestLineNumber = 8, }); } return nodes; @@ -142,6 +146,7 @@ file partial class NullableByteArgumentTests : global::TUnit.Core.Interfaces.Sou { Name = "someByte", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.NullableByteArgumentTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -155,7 +160,10 @@ file partial class NullableByteArgumentTests : global::TUnit.Core.Interfaces.Sou }), Name = "NullableByteArgumentTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -188,7 +196,7 @@ file partial class NullableByteArgumentTests : global::TUnit.Core.Interfaces.Sou ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.Test(methodArg)), TestFilePath = @"", - TestLineNumber = 5, + TestLineNumber = 8, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -204,7 +212,7 @@ file partial class NullableByteArgumentTests : global::TUnit.Core.Interfaces.Sou MethodName = $"Test", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("NullableByteArgumentTests.Test failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 5, + TestLineNumber = 8, }); } return nodes; @@ -263,11 +271,13 @@ file partial class NullableByteArgumentTests : global::TUnit.Core.Interfaces.Sou { Name = "byte1", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "byte2", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.NullableByteArgumentTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -281,7 +291,10 @@ file partial class NullableByteArgumentTests : global::TUnit.Core.Interfaces.Sou }), Name = "NullableByteArgumentTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -315,7 +328,7 @@ file partial class NullableByteArgumentTests : global::TUnit.Core.Interfaces.Sou ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.Test2(methodArg, methodArg1)), TestFilePath = @"", - TestLineNumber = 12, + TestLineNumber = 15, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -331,7 +344,7 @@ file partial class NullableByteArgumentTests : global::TUnit.Core.Interfaces.Sou MethodName = $"Test2", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("NullableByteArgumentTests.Test2 failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 12, + TestLineNumber = 15, }); } return nodes; @@ -361,11 +374,13 @@ file partial class NullableByteArgumentTests : global::TUnit.Core.Interfaces.Sou { Name = "byte1", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "byte2", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.NullableByteArgumentTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -379,7 +394,10 @@ file partial class NullableByteArgumentTests : global::TUnit.Core.Interfaces.Sou }), Name = "NullableByteArgumentTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -413,7 +431,7 @@ file partial class NullableByteArgumentTests : global::TUnit.Core.Interfaces.Sou ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.Test2(methodArg, methodArg1)), TestFilePath = @"", - TestLineNumber = 12, + TestLineNumber = 15, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -429,7 +447,7 @@ file partial class NullableByteArgumentTests : global::TUnit.Core.Interfaces.Sou MethodName = $"Test2", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("NullableByteArgumentTests.Test2 failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 12, + TestLineNumber = 15, }); } return nodes; diff --git a/TUnit.Core.SourceGenerator.Tests/NumberArgumentTests.Test.verified.txt b/TUnit.Core.SourceGenerator.Tests/NumberArgumentTests.Test.verified.txt index f75e5f2901..c6b5598c3f 100644 --- a/TUnit.Core.SourceGenerator.Tests/NumberArgumentTests.Test.verified.txt +++ b/TUnit.Core.SourceGenerator.Tests/NumberArgumentTests.Test.verified.txt @@ -45,6 +45,7 @@ file partial class NumberArgumentTests : global::TUnit.Core.Interfaces.SourceGen { Name = "i", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.NumberArgumentTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -58,7 +59,10 @@ file partial class NumberArgumentTests : global::TUnit.Core.Interfaces.SourceGen }), Name = "NumberArgumentTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -91,7 +95,7 @@ file partial class NumberArgumentTests : global::TUnit.Core.Interfaces.SourceGen ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.Int(methodArg)), TestFilePath = @"", - TestLineNumber = 5, + TestLineNumber = 8, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -107,7 +111,7 @@ file partial class NumberArgumentTests : global::TUnit.Core.Interfaces.SourceGen MethodName = $"Int", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("NumberArgumentTests.Int failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 5, + TestLineNumber = 8, }); } return nodes; @@ -161,6 +165,7 @@ file partial class NumberArgumentTests : global::TUnit.Core.Interfaces.SourceGen { Name = "d", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.NumberArgumentTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -174,7 +179,10 @@ file partial class NumberArgumentTests : global::TUnit.Core.Interfaces.SourceGen }), Name = "NumberArgumentTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -207,7 +215,7 @@ file partial class NumberArgumentTests : global::TUnit.Core.Interfaces.SourceGen ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.Double(methodArg)), TestFilePath = @"", - TestLineNumber = 12, + TestLineNumber = 15, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -223,7 +231,7 @@ file partial class NumberArgumentTests : global::TUnit.Core.Interfaces.SourceGen MethodName = $"Double", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("NumberArgumentTests.Double failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 12, + TestLineNumber = 15, }); } return nodes; @@ -277,6 +285,7 @@ file partial class NumberArgumentTests : global::TUnit.Core.Interfaces.SourceGen { Name = "f", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.NumberArgumentTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -290,7 +299,10 @@ file partial class NumberArgumentTests : global::TUnit.Core.Interfaces.SourceGen }), Name = "NumberArgumentTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -323,7 +335,7 @@ file partial class NumberArgumentTests : global::TUnit.Core.Interfaces.SourceGen ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.Float(methodArg)), TestFilePath = @"", - TestLineNumber = 19, + TestLineNumber = 22, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -339,7 +351,7 @@ file partial class NumberArgumentTests : global::TUnit.Core.Interfaces.SourceGen MethodName = $"Float", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("NumberArgumentTests.Float failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 19, + TestLineNumber = 22, }); } return nodes; @@ -393,6 +405,7 @@ file partial class NumberArgumentTests : global::TUnit.Core.Interfaces.SourceGen { Name = "l", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.NumberArgumentTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -406,7 +419,10 @@ file partial class NumberArgumentTests : global::TUnit.Core.Interfaces.SourceGen }), Name = "NumberArgumentTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -439,7 +455,7 @@ file partial class NumberArgumentTests : global::TUnit.Core.Interfaces.SourceGen ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.Long(methodArg)), TestFilePath = @"", - TestLineNumber = 26, + TestLineNumber = 29, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -455,7 +471,7 @@ file partial class NumberArgumentTests : global::TUnit.Core.Interfaces.SourceGen MethodName = $"Long", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("NumberArgumentTests.Long failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 26, + TestLineNumber = 29, }); } return nodes; @@ -509,6 +525,7 @@ file partial class NumberArgumentTests : global::TUnit.Core.Interfaces.SourceGen { Name = "l", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.NumberArgumentTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -522,7 +539,10 @@ file partial class NumberArgumentTests : global::TUnit.Core.Interfaces.SourceGen }), Name = "NumberArgumentTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -555,7 +575,7 @@ file partial class NumberArgumentTests : global::TUnit.Core.Interfaces.SourceGen ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.ULong(methodArg)), TestFilePath = @"", - TestLineNumber = 33, + TestLineNumber = 36, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -571,7 +591,7 @@ file partial class NumberArgumentTests : global::TUnit.Core.Interfaces.SourceGen MethodName = $"ULong", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("NumberArgumentTests.ULong failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 33, + TestLineNumber = 36, }); } return nodes; @@ -625,6 +645,7 @@ file partial class NumberArgumentTests : global::TUnit.Core.Interfaces.SourceGen { Name = "i", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.NumberArgumentTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -638,7 +659,10 @@ file partial class NumberArgumentTests : global::TUnit.Core.Interfaces.SourceGen }), Name = "NumberArgumentTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -671,7 +695,7 @@ file partial class NumberArgumentTests : global::TUnit.Core.Interfaces.SourceGen ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.UInt(methodArg)), TestFilePath = @"", - TestLineNumber = 40, + TestLineNumber = 43, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -687,7 +711,7 @@ file partial class NumberArgumentTests : global::TUnit.Core.Interfaces.SourceGen MethodName = $"UInt", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("NumberArgumentTests.UInt failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 40, + TestLineNumber = 43, }); } return nodes; diff --git a/TUnit.Core.SourceGenerator.Tests/NumberArgumentTests.TestDE.verified.txt b/TUnit.Core.SourceGenerator.Tests/NumberArgumentTests.TestDE.verified.txt index f75e5f2901..c6b5598c3f 100644 --- a/TUnit.Core.SourceGenerator.Tests/NumberArgumentTests.TestDE.verified.txt +++ b/TUnit.Core.SourceGenerator.Tests/NumberArgumentTests.TestDE.verified.txt @@ -45,6 +45,7 @@ file partial class NumberArgumentTests : global::TUnit.Core.Interfaces.SourceGen { Name = "i", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.NumberArgumentTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -58,7 +59,10 @@ file partial class NumberArgumentTests : global::TUnit.Core.Interfaces.SourceGen }), Name = "NumberArgumentTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -91,7 +95,7 @@ file partial class NumberArgumentTests : global::TUnit.Core.Interfaces.SourceGen ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.Int(methodArg)), TestFilePath = @"", - TestLineNumber = 5, + TestLineNumber = 8, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -107,7 +111,7 @@ file partial class NumberArgumentTests : global::TUnit.Core.Interfaces.SourceGen MethodName = $"Int", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("NumberArgumentTests.Int failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 5, + TestLineNumber = 8, }); } return nodes; @@ -161,6 +165,7 @@ file partial class NumberArgumentTests : global::TUnit.Core.Interfaces.SourceGen { Name = "d", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.NumberArgumentTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -174,7 +179,10 @@ file partial class NumberArgumentTests : global::TUnit.Core.Interfaces.SourceGen }), Name = "NumberArgumentTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -207,7 +215,7 @@ file partial class NumberArgumentTests : global::TUnit.Core.Interfaces.SourceGen ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.Double(methodArg)), TestFilePath = @"", - TestLineNumber = 12, + TestLineNumber = 15, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -223,7 +231,7 @@ file partial class NumberArgumentTests : global::TUnit.Core.Interfaces.SourceGen MethodName = $"Double", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("NumberArgumentTests.Double failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 12, + TestLineNumber = 15, }); } return nodes; @@ -277,6 +285,7 @@ file partial class NumberArgumentTests : global::TUnit.Core.Interfaces.SourceGen { Name = "f", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.NumberArgumentTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -290,7 +299,10 @@ file partial class NumberArgumentTests : global::TUnit.Core.Interfaces.SourceGen }), Name = "NumberArgumentTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -323,7 +335,7 @@ file partial class NumberArgumentTests : global::TUnit.Core.Interfaces.SourceGen ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.Float(methodArg)), TestFilePath = @"", - TestLineNumber = 19, + TestLineNumber = 22, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -339,7 +351,7 @@ file partial class NumberArgumentTests : global::TUnit.Core.Interfaces.SourceGen MethodName = $"Float", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("NumberArgumentTests.Float failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 19, + TestLineNumber = 22, }); } return nodes; @@ -393,6 +405,7 @@ file partial class NumberArgumentTests : global::TUnit.Core.Interfaces.SourceGen { Name = "l", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.NumberArgumentTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -406,7 +419,10 @@ file partial class NumberArgumentTests : global::TUnit.Core.Interfaces.SourceGen }), Name = "NumberArgumentTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -439,7 +455,7 @@ file partial class NumberArgumentTests : global::TUnit.Core.Interfaces.SourceGen ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.Long(methodArg)), TestFilePath = @"", - TestLineNumber = 26, + TestLineNumber = 29, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -455,7 +471,7 @@ file partial class NumberArgumentTests : global::TUnit.Core.Interfaces.SourceGen MethodName = $"Long", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("NumberArgumentTests.Long failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 26, + TestLineNumber = 29, }); } return nodes; @@ -509,6 +525,7 @@ file partial class NumberArgumentTests : global::TUnit.Core.Interfaces.SourceGen { Name = "l", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.NumberArgumentTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -522,7 +539,10 @@ file partial class NumberArgumentTests : global::TUnit.Core.Interfaces.SourceGen }), Name = "NumberArgumentTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -555,7 +575,7 @@ file partial class NumberArgumentTests : global::TUnit.Core.Interfaces.SourceGen ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.ULong(methodArg)), TestFilePath = @"", - TestLineNumber = 33, + TestLineNumber = 36, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -571,7 +591,7 @@ file partial class NumberArgumentTests : global::TUnit.Core.Interfaces.SourceGen MethodName = $"ULong", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("NumberArgumentTests.ULong failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 33, + TestLineNumber = 36, }); } return nodes; @@ -625,6 +645,7 @@ file partial class NumberArgumentTests : global::TUnit.Core.Interfaces.SourceGen { Name = "i", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.NumberArgumentTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -638,7 +659,10 @@ file partial class NumberArgumentTests : global::TUnit.Core.Interfaces.SourceGen }), Name = "NumberArgumentTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -671,7 +695,7 @@ file partial class NumberArgumentTests : global::TUnit.Core.Interfaces.SourceGen ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.UInt(methodArg)), TestFilePath = @"", - TestLineNumber = 40, + TestLineNumber = 43, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -687,7 +711,7 @@ file partial class NumberArgumentTests : global::TUnit.Core.Interfaces.SourceGen MethodName = $"UInt", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("NumberArgumentTests.UInt failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 40, + TestLineNumber = 43, }); } return nodes; diff --git a/TUnit.Core.SourceGenerator.Tests/PropertySetterTests.Test.verified.txt b/TUnit.Core.SourceGenerator.Tests/PropertySetterTests.Test.verified.txt index 5f14c95853..7908a3c766 100644 --- a/TUnit.Core.SourceGenerator.Tests/PropertySetterTests.Test.verified.txt +++ b/TUnit.Core.SourceGenerator.Tests/PropertySetterTests.Test.verified.txt @@ -52,6 +52,7 @@ file partial class PropertySetterTests : global::TUnit.Core.Interfaces.SourceGen Namespace = "TUnit.TestProject", Attributes = [ + new EngineTest(Pass), new global::TUnit.Core.NotInParallelAttribute("PropertySetterTests") ], Parameters = [], @@ -292,7 +293,7 @@ new global::TUnit.Core.SourceGeneratedPropertyInformation ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.Test()), TestFilePath = @"", - TestLineNumber = 67, + TestLineNumber = 69, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -308,7 +309,7 @@ new global::TUnit.Core.SourceGeneratedPropertyInformation MethodName = $"Test", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("PropertySetterTests.Test failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 67, + TestLineNumber = 69, }); } return nodes; diff --git a/TUnit.Core.SourceGenerator.Tests/RepeatTests.Test.verified.txt b/TUnit.Core.SourceGenerator.Tests/RepeatTests.Test.verified.txt index ac9698d081..419c54c151 100644 --- a/TUnit.Core.SourceGenerator.Tests/RepeatTests.Test.verified.txt +++ b/TUnit.Core.SourceGenerator.Tests/RepeatTests.Test.verified.txt @@ -57,6 +57,7 @@ file partial class RepeatTests : global::TUnit.Core.Interfaces.SourceGenerator.I Namespace = "TUnit.TestProject", Attributes = [ + new EngineTest(Pass), new global::TUnit.Core.RepeatAttribute(3) ], Parameters = [], @@ -89,7 +90,7 @@ file partial class RepeatTests : global::TUnit.Core.Interfaces.SourceGenerator.I ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.One()), TestFilePath = @"", - TestLineNumber = 6, + TestLineNumber = 9, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -105,7 +106,7 @@ file partial class RepeatTests : global::TUnit.Core.Interfaces.SourceGenerator.I MethodName = $"One", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("RepeatTests.One failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 6, + TestLineNumber = 9, }); } return nodes; @@ -142,6 +143,7 @@ file partial class RepeatTests : global::TUnit.Core.Interfaces.SourceGenerator.I Namespace = "TUnit.TestProject", Attributes = [ + new EngineTest(Pass), new global::TUnit.Core.RepeatAttribute(3) ], Parameters = [], @@ -174,7 +176,7 @@ file partial class RepeatTests : global::TUnit.Core.Interfaces.SourceGenerator.I ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.One()), TestFilePath = @"", - TestLineNumber = 6, + TestLineNumber = 9, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -190,7 +192,7 @@ file partial class RepeatTests : global::TUnit.Core.Interfaces.SourceGenerator.I MethodName = $"One", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("RepeatTests.One failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 6, + TestLineNumber = 9, }); } return nodes; @@ -257,6 +259,7 @@ file partial class RepeatTests : global::TUnit.Core.Interfaces.SourceGenerator.I Namespace = "TUnit.TestProject", Attributes = [ + new EngineTest(Pass), new global::TUnit.Core.RepeatAttribute(3) ], Parameters = [], @@ -289,7 +292,7 @@ file partial class RepeatTests : global::TUnit.Core.Interfaces.SourceGenerator.I ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.Two()), TestFilePath = @"", - TestLineNumber = 13, + TestLineNumber = 16, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -305,7 +308,7 @@ file partial class RepeatTests : global::TUnit.Core.Interfaces.SourceGenerator.I MethodName = $"Two", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("RepeatTests.Two failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 13, + TestLineNumber = 16, }); } return nodes; @@ -342,6 +345,7 @@ file partial class RepeatTests : global::TUnit.Core.Interfaces.SourceGenerator.I Namespace = "TUnit.TestProject", Attributes = [ + new EngineTest(Pass), new global::TUnit.Core.RepeatAttribute(3) ], Parameters = [], @@ -374,7 +378,7 @@ file partial class RepeatTests : global::TUnit.Core.Interfaces.SourceGenerator.I ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.Two()), TestFilePath = @"", - TestLineNumber = 13, + TestLineNumber = 16, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -390,7 +394,7 @@ file partial class RepeatTests : global::TUnit.Core.Interfaces.SourceGenerator.I MethodName = $"Two", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("RepeatTests.Two failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 13, + TestLineNumber = 16, }); } return nodes; @@ -427,6 +431,7 @@ file partial class RepeatTests : global::TUnit.Core.Interfaces.SourceGenerator.I Namespace = "TUnit.TestProject", Attributes = [ + new EngineTest(Pass), new global::TUnit.Core.RepeatAttribute(3) ], Parameters = [], @@ -459,7 +464,7 @@ file partial class RepeatTests : global::TUnit.Core.Interfaces.SourceGenerator.I ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.Two()), TestFilePath = @"", - TestLineNumber = 13, + TestLineNumber = 16, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -475,7 +480,7 @@ file partial class RepeatTests : global::TUnit.Core.Interfaces.SourceGenerator.I MethodName = $"Two", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("RepeatTests.Two failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 13, + TestLineNumber = 16, }); } return nodes; @@ -542,6 +547,7 @@ file partial class RepeatTests : global::TUnit.Core.Interfaces.SourceGenerator.I Namespace = "TUnit.TestProject", Attributes = [ + new EngineTest(Pass), new global::TUnit.Core.RepeatAttribute(3) ], Parameters = [], @@ -574,7 +580,7 @@ file partial class RepeatTests : global::TUnit.Core.Interfaces.SourceGenerator.I ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.Three()), TestFilePath = @"", - TestLineNumber = 20, + TestLineNumber = 23, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -590,7 +596,7 @@ file partial class RepeatTests : global::TUnit.Core.Interfaces.SourceGenerator.I MethodName = $"Three", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("RepeatTests.Three failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 20, + TestLineNumber = 23, }); } return nodes; @@ -626,6 +632,7 @@ file partial class RepeatTests : global::TUnit.Core.Interfaces.SourceGenerator.I Namespace = "TUnit.TestProject", Attributes = [ + new EngineTest(Pass), new global::TUnit.Core.RepeatAttribute(3) ], Parameters = [], @@ -658,7 +665,7 @@ file partial class RepeatTests : global::TUnit.Core.Interfaces.SourceGenerator.I ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.Three()), TestFilePath = @"", - TestLineNumber = 20, + TestLineNumber = 23, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -674,7 +681,7 @@ file partial class RepeatTests : global::TUnit.Core.Interfaces.SourceGenerator.I MethodName = $"Three", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("RepeatTests.Three failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 20, + TestLineNumber = 23, }); } return nodes; @@ -710,6 +717,7 @@ file partial class RepeatTests : global::TUnit.Core.Interfaces.SourceGenerator.I Namespace = "TUnit.TestProject", Attributes = [ + new EngineTest(Pass), new global::TUnit.Core.RepeatAttribute(3) ], Parameters = [], @@ -742,7 +750,7 @@ file partial class RepeatTests : global::TUnit.Core.Interfaces.SourceGenerator.I ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.Three()), TestFilePath = @"", - TestLineNumber = 20, + TestLineNumber = 23, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -758,7 +766,7 @@ file partial class RepeatTests : global::TUnit.Core.Interfaces.SourceGenerator.I MethodName = $"Three", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("RepeatTests.Three failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 20, + TestLineNumber = 23, }); } return nodes; @@ -794,6 +802,7 @@ file partial class RepeatTests : global::TUnit.Core.Interfaces.SourceGenerator.I Namespace = "TUnit.TestProject", Attributes = [ + new EngineTest(Pass), new global::TUnit.Core.RepeatAttribute(3) ], Parameters = [], @@ -826,7 +835,7 @@ file partial class RepeatTests : global::TUnit.Core.Interfaces.SourceGenerator.I ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.Three()), TestFilePath = @"", - TestLineNumber = 20, + TestLineNumber = 23, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -842,7 +851,7 @@ file partial class RepeatTests : global::TUnit.Core.Interfaces.SourceGenerator.I MethodName = $"Three", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("RepeatTests.Three failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 20, + TestLineNumber = 23, }); } return nodes; diff --git a/TUnit.Core.SourceGenerator.Tests/STAThreadHooksTests.Test.verified.txt b/TUnit.Core.SourceGenerator.Tests/STAThreadHooksTests.Test.verified.txt index 9505bc59ab..bddd29fa3d 100644 --- a/TUnit.Core.SourceGenerator.Tests/STAThreadHooksTests.Test.verified.txt +++ b/TUnit.Core.SourceGenerator.Tests/STAThreadHooksTests.Test.verified.txt @@ -64,6 +64,8 @@ file partial class Hooks_STAThreadTests : global::TUnit.Core.Interfaces.SourceGe Namespace = "TUnit.TestProject", Attributes = [ + new EngineTest(Pass), + new WindowsOnly(), new global::System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute("Interoperability", "CA1416:Validate platform compatibility") ], Parameters = [], @@ -156,6 +158,8 @@ file partial class Hooks_STAThreadTests : global::TUnit.Core.Interfaces.SourceGe Namespace = "TUnit.TestProject", Attributes = [ + new EngineTest(Pass), + new WindowsOnly(), new global::System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute("Interoperability", "CA1416:Validate platform compatibility") ], Parameters = [], diff --git a/TUnit.Core.SourceGenerator.Tests/StringArgumentTests.Test.verified.txt b/TUnit.Core.SourceGenerator.Tests/StringArgumentTests.Test.verified.txt index c40a13650b..801a4f70f9 100644 --- a/TUnit.Core.SourceGenerator.Tests/StringArgumentTests.Test.verified.txt +++ b/TUnit.Core.SourceGenerator.Tests/StringArgumentTests.Test.verified.txt @@ -66,6 +66,7 @@ file partial class StringArgumentTests : global::TUnit.Core.Interfaces.SourceGen { Name = "s", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.StringArgumentTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -79,7 +80,10 @@ file partial class StringArgumentTests : global::TUnit.Core.Interfaces.SourceGen }), Name = "StringArgumentTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -112,7 +116,7 @@ file partial class StringArgumentTests : global::TUnit.Core.Interfaces.SourceGen ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.Normal(methodArg)), TestFilePath = @"", - TestLineNumber = 5, + TestLineNumber = 8, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -128,7 +132,7 @@ file partial class StringArgumentTests : global::TUnit.Core.Interfaces.SourceGen MethodName = $"Normal", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("StringArgumentTests.Normal failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 5, + TestLineNumber = 8, }); } return nodes; @@ -168,6 +172,7 @@ file partial class StringArgumentTests : global::TUnit.Core.Interfaces.SourceGen { Name = "s", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.StringArgumentTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -181,7 +186,10 @@ file partial class StringArgumentTests : global::TUnit.Core.Interfaces.SourceGen }), Name = "StringArgumentTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -214,7 +222,7 @@ file partial class StringArgumentTests : global::TUnit.Core.Interfaces.SourceGen ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.Normal(methodArg)), TestFilePath = @"", - TestLineNumber = 5, + TestLineNumber = 8, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -230,7 +238,7 @@ file partial class StringArgumentTests : global::TUnit.Core.Interfaces.SourceGen MethodName = $"Normal", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("StringArgumentTests.Normal failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 5, + TestLineNumber = 8, }); } return nodes; @@ -270,6 +278,7 @@ file partial class StringArgumentTests : global::TUnit.Core.Interfaces.SourceGen { Name = "s", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.StringArgumentTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -283,7 +292,10 @@ file partial class StringArgumentTests : global::TUnit.Core.Interfaces.SourceGen }), Name = "StringArgumentTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -316,7 +328,7 @@ file partial class StringArgumentTests : global::TUnit.Core.Interfaces.SourceGen ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.Normal(methodArg)), TestFilePath = @"", - TestLineNumber = 5, + TestLineNumber = 8, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -332,7 +344,7 @@ file partial class StringArgumentTests : global::TUnit.Core.Interfaces.SourceGen MethodName = $"Normal", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("StringArgumentTests.Normal failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 5, + TestLineNumber = 8, }); } return nodes; @@ -372,6 +384,7 @@ file partial class StringArgumentTests : global::TUnit.Core.Interfaces.SourceGen { Name = "s", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.StringArgumentTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -385,7 +398,10 @@ file partial class StringArgumentTests : global::TUnit.Core.Interfaces.SourceGen }), Name = "StringArgumentTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -418,7 +434,7 @@ file partial class StringArgumentTests : global::TUnit.Core.Interfaces.SourceGen ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.Normal(methodArg)), TestFilePath = @"", - TestLineNumber = 5, + TestLineNumber = 8, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -434,7 +450,7 @@ file partial class StringArgumentTests : global::TUnit.Core.Interfaces.SourceGen MethodName = $"Normal", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("StringArgumentTests.Normal failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 5, + TestLineNumber = 8, }); } return nodes; @@ -474,6 +490,7 @@ file partial class StringArgumentTests : global::TUnit.Core.Interfaces.SourceGen { Name = "s", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.StringArgumentTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -487,7 +504,10 @@ file partial class StringArgumentTests : global::TUnit.Core.Interfaces.SourceGen }), Name = "StringArgumentTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -520,7 +540,7 @@ file partial class StringArgumentTests : global::TUnit.Core.Interfaces.SourceGen ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.Normal(methodArg)), TestFilePath = @"", - TestLineNumber = 5, + TestLineNumber = 8, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -536,7 +556,7 @@ file partial class StringArgumentTests : global::TUnit.Core.Interfaces.SourceGen MethodName = $"Normal", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("StringArgumentTests.Normal failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 5, + TestLineNumber = 8, }); } return nodes; @@ -576,6 +596,7 @@ file partial class StringArgumentTests : global::TUnit.Core.Interfaces.SourceGen { Name = "s", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.StringArgumentTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -589,7 +610,10 @@ file partial class StringArgumentTests : global::TUnit.Core.Interfaces.SourceGen }), Name = "StringArgumentTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -622,7 +646,7 @@ file partial class StringArgumentTests : global::TUnit.Core.Interfaces.SourceGen ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.Normal(methodArg)), TestFilePath = @"", - TestLineNumber = 5, + TestLineNumber = 8, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -638,7 +662,7 @@ file partial class StringArgumentTests : global::TUnit.Core.Interfaces.SourceGen MethodName = $"Normal", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("StringArgumentTests.Normal failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 5, + TestLineNumber = 8, }); } return nodes; @@ -678,6 +702,7 @@ file partial class StringArgumentTests : global::TUnit.Core.Interfaces.SourceGen { Name = "s", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.StringArgumentTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -691,7 +716,10 @@ file partial class StringArgumentTests : global::TUnit.Core.Interfaces.SourceGen }), Name = "StringArgumentTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -724,7 +752,7 @@ file partial class StringArgumentTests : global::TUnit.Core.Interfaces.SourceGen ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.Normal(methodArg)), TestFilePath = @"", - TestLineNumber = 5, + TestLineNumber = 8, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -740,7 +768,7 @@ file partial class StringArgumentTests : global::TUnit.Core.Interfaces.SourceGen MethodName = $"Normal", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("StringArgumentTests.Normal failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 5, + TestLineNumber = 8, }); } return nodes; @@ -780,6 +808,7 @@ file partial class StringArgumentTests : global::TUnit.Core.Interfaces.SourceGen { Name = "s", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.StringArgumentTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -793,7 +822,10 @@ file partial class StringArgumentTests : global::TUnit.Core.Interfaces.SourceGen }), Name = "StringArgumentTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -829,7 +861,7 @@ file partial class StringArgumentTests : global::TUnit.Core.Interfaces.SourceGen ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.Normal(methodArg)), TestFilePath = @"", - TestLineNumber = 5, + TestLineNumber = 8, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -845,7 +877,7 @@ file partial class StringArgumentTests : global::TUnit.Core.Interfaces.SourceGen MethodName = $"Normal", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("StringArgumentTests.Normal failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 5, + TestLineNumber = 8, }); } return nodes; @@ -916,6 +948,7 @@ file partial class StringArgumentTests : global::TUnit.Core.Interfaces.SourceGen { Name = "s", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.StringArgumentTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -929,7 +962,10 @@ file partial class StringArgumentTests : global::TUnit.Core.Interfaces.SourceGen }), Name = "StringArgumentTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -962,7 +998,7 @@ file partial class StringArgumentTests : global::TUnit.Core.Interfaces.SourceGen ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.Nullable(methodArg)), TestFilePath = @"", - TestLineNumber = 24, + TestLineNumber = 27, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -978,7 +1014,7 @@ file partial class StringArgumentTests : global::TUnit.Core.Interfaces.SourceGen MethodName = $"Nullable", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("StringArgumentTests.Nullable failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 24, + TestLineNumber = 27, }); } return nodes; @@ -1014,6 +1050,7 @@ file partial class StringArgumentTests : global::TUnit.Core.Interfaces.SourceGen { Name = "s", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.StringArgumentTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -1027,7 +1064,10 @@ file partial class StringArgumentTests : global::TUnit.Core.Interfaces.SourceGen }), Name = "StringArgumentTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -1060,7 +1100,7 @@ file partial class StringArgumentTests : global::TUnit.Core.Interfaces.SourceGen ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.Nullable(methodArg)), TestFilePath = @"", - TestLineNumber = 24, + TestLineNumber = 27, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -1076,7 +1116,7 @@ file partial class StringArgumentTests : global::TUnit.Core.Interfaces.SourceGen MethodName = $"Nullable", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("StringArgumentTests.Nullable failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 24, + TestLineNumber = 27, }); } return nodes; @@ -1112,6 +1152,7 @@ file partial class StringArgumentTests : global::TUnit.Core.Interfaces.SourceGen { Name = "s", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.StringArgumentTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -1125,7 +1166,10 @@ file partial class StringArgumentTests : global::TUnit.Core.Interfaces.SourceGen }), Name = "StringArgumentTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -1158,7 +1202,7 @@ file partial class StringArgumentTests : global::TUnit.Core.Interfaces.SourceGen ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.Nullable(methodArg)), TestFilePath = @"", - TestLineNumber = 24, + TestLineNumber = 27, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -1174,7 +1218,7 @@ file partial class StringArgumentTests : global::TUnit.Core.Interfaces.SourceGen MethodName = $"Nullable", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("StringArgumentTests.Nullable failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 24, + TestLineNumber = 27, }); } return nodes; @@ -1210,6 +1254,7 @@ file partial class StringArgumentTests : global::TUnit.Core.Interfaces.SourceGen { Name = "s", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.StringArgumentTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -1223,7 +1268,10 @@ file partial class StringArgumentTests : global::TUnit.Core.Interfaces.SourceGen }), Name = "StringArgumentTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -1256,7 +1304,7 @@ file partial class StringArgumentTests : global::TUnit.Core.Interfaces.SourceGen ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.Nullable(methodArg)), TestFilePath = @"", - TestLineNumber = 24, + TestLineNumber = 27, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -1272,7 +1320,7 @@ file partial class StringArgumentTests : global::TUnit.Core.Interfaces.SourceGen MethodName = $"Nullable", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("StringArgumentTests.Nullable failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 24, + TestLineNumber = 27, }); } return nodes; @@ -1308,6 +1356,7 @@ file partial class StringArgumentTests : global::TUnit.Core.Interfaces.SourceGen { Name = "s", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.StringArgumentTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -1321,7 +1370,10 @@ file partial class StringArgumentTests : global::TUnit.Core.Interfaces.SourceGen }), Name = "StringArgumentTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -1354,7 +1406,7 @@ file partial class StringArgumentTests : global::TUnit.Core.Interfaces.SourceGen ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.Nullable(methodArg)), TestFilePath = @"", - TestLineNumber = 24, + TestLineNumber = 27, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -1370,7 +1422,7 @@ file partial class StringArgumentTests : global::TUnit.Core.Interfaces.SourceGen MethodName = $"Nullable", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("StringArgumentTests.Nullable failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 24, + TestLineNumber = 27, }); } return nodes; @@ -1406,6 +1458,7 @@ file partial class StringArgumentTests : global::TUnit.Core.Interfaces.SourceGen { Name = "s", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.StringArgumentTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -1419,7 +1472,10 @@ file partial class StringArgumentTests : global::TUnit.Core.Interfaces.SourceGen }), Name = "StringArgumentTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -1452,7 +1508,7 @@ file partial class StringArgumentTests : global::TUnit.Core.Interfaces.SourceGen ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.Nullable(methodArg)), TestFilePath = @"", - TestLineNumber = 24, + TestLineNumber = 27, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -1468,7 +1524,7 @@ file partial class StringArgumentTests : global::TUnit.Core.Interfaces.SourceGen MethodName = $"Nullable", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("StringArgumentTests.Nullable failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 24, + TestLineNumber = 27, }); } return nodes; @@ -1504,6 +1560,7 @@ file partial class StringArgumentTests : global::TUnit.Core.Interfaces.SourceGen { Name = "s", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.StringArgumentTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -1517,7 +1574,10 @@ file partial class StringArgumentTests : global::TUnit.Core.Interfaces.SourceGen }), Name = "StringArgumentTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -1550,7 +1610,7 @@ file partial class StringArgumentTests : global::TUnit.Core.Interfaces.SourceGen ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.Nullable(methodArg)), TestFilePath = @"", - TestLineNumber = 24, + TestLineNumber = 27, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -1566,7 +1626,7 @@ file partial class StringArgumentTests : global::TUnit.Core.Interfaces.SourceGen MethodName = $"Nullable", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("StringArgumentTests.Nullable failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 24, + TestLineNumber = 27, }); } return nodes; @@ -1602,6 +1662,7 @@ file partial class StringArgumentTests : global::TUnit.Core.Interfaces.SourceGen { Name = "s", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.StringArgumentTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -1615,7 +1676,10 @@ file partial class StringArgumentTests : global::TUnit.Core.Interfaces.SourceGen }), Name = "StringArgumentTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -1648,7 +1712,7 @@ file partial class StringArgumentTests : global::TUnit.Core.Interfaces.SourceGen ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.Nullable(methodArg)), TestFilePath = @"", - TestLineNumber = 24, + TestLineNumber = 27, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -1664,7 +1728,7 @@ file partial class StringArgumentTests : global::TUnit.Core.Interfaces.SourceGen MethodName = $"Nullable", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("StringArgumentTests.Nullable failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 24, + TestLineNumber = 27, }); } return nodes; diff --git a/TUnit.Core.SourceGenerator.Tests/TUnit.Core.SourceGenerator.Tests.csproj b/TUnit.Core.SourceGenerator.Tests/TUnit.Core.SourceGenerator.Tests.csproj index 223bb58407..1a10f3a7fc 100644 --- a/TUnit.Core.SourceGenerator.Tests/TUnit.Core.SourceGenerator.Tests.csproj +++ b/TUnit.Core.SourceGenerator.Tests/TUnit.Core.SourceGenerator.Tests.csproj @@ -1,7 +1,7 @@ - + diff --git a/TUnit.Core.SourceGenerator.Tests/Tests1538.Test.verified.txt b/TUnit.Core.SourceGenerator.Tests/Tests1538.Test.verified.txt index 88c29e9792..860b97586c 100644 --- a/TUnit.Core.SourceGenerator.Tests/Tests1538.Test.verified.txt +++ b/TUnit.Core.SourceGenerator.Tests/Tests1538.Test.verified.txt @@ -45,41 +45,49 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo { Name = "expectedSuccess", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "expectedError", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "expectedT0", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "expectedT1", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "expectedT2", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "expectedT3", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "expectedT4", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "expectedT5", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.Bugs._1538.Tests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -93,7 +101,10 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo }), Name = "Tests", Namespace = "TUnit.TestProject.Bugs._1538", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -137,7 +148,7 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.Eight_Args(methodArg, methodArg1, methodArg2, methodArg3, methodArg4, methodArg5, methodArg6, methodArg7)), TestFilePath = @"", - TestLineNumber = 5, + TestLineNumber = 8, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -154,7 +165,7 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo MethodName = $"Eight_Args", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("Tests.Eight_Args failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 5, + TestLineNumber = 8, }); } return nodes; @@ -208,81 +219,97 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo { Name = "expectedSuccess", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "item1", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "item2", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "item3", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "item4", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "item5", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "item6", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "item7", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "item8", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "item9", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "item10", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "item11", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "item12", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "item13", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "item14", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "item15", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.Bugs._1538.Tests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -296,7 +323,10 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo }), Name = "Tests", Namespace = "TUnit.TestProject.Bugs._1538", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -348,7 +378,7 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.SixteenArgs(methodArg, methodArg1, methodArg2, methodArg3, methodArg4, methodArg5, methodArg6, methodArg7, methodArg8, methodArg9, methodArg10, methodArg11, methodArg12, methodArg13, methodArg14, methodArg15)), TestFilePath = @"", - TestLineNumber = 13, + TestLineNumber = 16, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -365,7 +395,7 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo MethodName = $"SixteenArgs", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("Tests.SixteenArgs failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 13, + TestLineNumber = 16, }); } return nodes; diff --git a/TUnit.Core.SourceGenerator.Tests/Tests1539.Test.verified.txt b/TUnit.Core.SourceGenerator.Tests/Tests1539.Test.verified.txt index 6caa9b9d88..fe1385bd28 100644 --- a/TUnit.Core.SourceGenerator.Tests/Tests1539.Test.verified.txt +++ b/TUnit.Core.SourceGenerator.Tests/Tests1539.Test.verified.txt @@ -54,7 +54,10 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo }), Name = "Tests", Namespace = "TUnit.TestProject.Bugs._1539", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -85,7 +88,7 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.Test()), TestFilePath = @"", - TestLineNumber = 5, + TestLineNumber = 8, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -101,7 +104,7 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo MethodName = $"Test", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("Tests.Test failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 5, + TestLineNumber = 8, }); } return nodes; diff --git a/TUnit.Core.SourceGenerator.Tests/Tests1589.Test.verified.txt b/TUnit.Core.SourceGenerator.Tests/Tests1589.Test.verified.txt index 7c18e3ea85..9a9843dad0 100644 --- a/TUnit.Core.SourceGenerator.Tests/Tests1589.Test.verified.txt +++ b/TUnit.Core.SourceGenerator.Tests/Tests1589.Test.verified.txt @@ -50,13 +50,17 @@ file partial class MyTests : global::TUnit.Core.Interfaces.SourceGenerator.ITest }), Name = "MyTests", Namespace = "TUnit.TestProject.Bugs._1589", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [ new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "myFixture", Attributes = [], + ReflectionInfo = null!, }, ], Properties = [], @@ -78,6 +82,7 @@ file partial class MyTests : global::TUnit.Core.Interfaces.SourceGenerator.ITest { Name = "myFixture", Attributes = [], + ReflectionInfo = null!, }, ], TestSessionId = sessionId, @@ -118,7 +123,7 @@ file partial class MyTests : global::TUnit.Core.Interfaces.SourceGenerator.ITest ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.Test1()), TestFilePath = @"", - TestLineNumber = 15, + TestLineNumber = 17, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -135,7 +140,7 @@ file partial class MyTests : global::TUnit.Core.Interfaces.SourceGenerator.ITest MethodName = $"Test1", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("MyTests.Test1 failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 15, + TestLineNumber = 17, }); } return nodes; diff --git a/TUnit.Core.SourceGenerator.Tests/Tests1594.Test.verified.txt b/TUnit.Core.SourceGenerator.Tests/Tests1594.Test.verified.txt index 7dc074682a..dcfeb58bd1 100644 --- a/TUnit.Core.SourceGenerator.Tests/Tests1594.Test.verified.txt +++ b/TUnit.Core.SourceGenerator.Tests/Tests1594.Test.verified.txt @@ -50,13 +50,17 @@ file partial class MyTests : global::TUnit.Core.Interfaces.SourceGenerator.ITest }), Name = "MyTests", Namespace = "TUnit.TestProject.Bugs._1594", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [ new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "myFixture", Attributes = [], + ReflectionInfo = null!, }, ], Properties = [], @@ -78,6 +82,7 @@ file partial class MyTests : global::TUnit.Core.Interfaces.SourceGenerator.ITest { Name = "myFixture", Attributes = [], + ReflectionInfo = null!, }, ], TestSessionId = sessionId, @@ -118,7 +123,7 @@ file partial class MyTests : global::TUnit.Core.Interfaces.SourceGenerator.ITest ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.Test1()), TestFilePath = @"", - TestLineNumber = 12, + TestLineNumber = 15, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -135,7 +140,7 @@ file partial class MyTests : global::TUnit.Core.Interfaces.SourceGenerator.ITest MethodName = $"Test1", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("MyTests.Test1 failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 12, + TestLineNumber = 15, }); } return nodes; diff --git a/TUnit.Core.SourceGenerator.Tests/Tests1603.Test.verified.txt b/TUnit.Core.SourceGenerator.Tests/Tests1603.Test.verified.txt index cd2deafe24..2d1659f014 100644 --- a/TUnit.Core.SourceGenerator.Tests/Tests1603.Test.verified.txt +++ b/TUnit.Core.SourceGenerator.Tests/Tests1603.Test.verified.txt @@ -45,6 +45,7 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo { Name = "value", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.Bugs._1603.Tests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -58,7 +59,10 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo }), Name = "Tests", Namespace = "TUnit.TestProject.Bugs._1603", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -91,7 +95,7 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.Casted_Integer_To_Short_Converts(methodArg)), TestFilePath = @"", - TestLineNumber = 8, + TestLineNumber = 10, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -107,7 +111,7 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo MethodName = $"Casted_Integer_To_Short_Converts", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("Tests.Casted_Integer_To_Short_Converts failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 8, + TestLineNumber = 10, }); } return nodes; @@ -161,6 +165,7 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo { Name = "value", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.Bugs._1603.Tests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -174,7 +179,10 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo }), Name = "Tests", Namespace = "TUnit.TestProject.Bugs._1603", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -207,7 +215,7 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.Integer_To_Short_Converts(methodArg)), TestFilePath = @"", - TestLineNumber = 15, + TestLineNumber = 17, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -223,7 +231,7 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo MethodName = $"Integer_To_Short_Converts", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("Tests.Integer_To_Short_Converts failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 15, + TestLineNumber = 17, }); } return nodes; diff --git a/TUnit.Core.SourceGenerator.Tests/Tests1692.Test.verified.txt b/TUnit.Core.SourceGenerator.Tests/Tests1692.Test.verified.txt index 8564067b73..4473dbe3fc 100644 --- a/TUnit.Core.SourceGenerator.Tests/Tests1692.Test.verified.txt +++ b/TUnit.Core.SourceGenerator.Tests/Tests1692.Test.verified.txt @@ -50,6 +50,7 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo { Name = "t", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.Bugs._1692.Tests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -63,7 +64,10 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo }), Name = "Tests", Namespace = "TUnit.TestProject.Bugs._1692", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -96,7 +100,7 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.NullTest(methodArg)), TestFilePath = @"", - TestLineNumber = 10, + TestLineNumber = 12, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -112,7 +116,7 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo MethodName = $"NullTest", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("Tests.NullTest failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 10, + TestLineNumber = 12, }); } return nodes; @@ -142,6 +146,7 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo { Name = "t", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.Bugs._1692.Tests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -155,7 +160,10 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo }), Name = "Tests", Namespace = "TUnit.TestProject.Bugs._1692", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -188,7 +196,7 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.NullTest(methodArg)), TestFilePath = @"", - TestLineNumber = 10, + TestLineNumber = 12, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -204,7 +212,7 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo MethodName = $"NullTest", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("Tests.NullTest failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 10, + TestLineNumber = 12, }); } return nodes; diff --git a/TUnit.Core.SourceGenerator.Tests/Tests1821.Test.verified.txt b/TUnit.Core.SourceGenerator.Tests/Tests1821.Test.verified.txt index 11f7808286..e4e1c68464 100644 --- a/TUnit.Core.SourceGenerator.Tests/Tests1821.Test.verified.txt +++ b/TUnit.Core.SourceGenerator.Tests/Tests1821.Test.verified.txt @@ -45,6 +45,7 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo { Name = "value", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.Bugs._1821.Tests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -58,13 +59,17 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo }), Name = "Tests", Namespace = "TUnit.TestProject.Bugs._1821", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [ new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "data", Attributes = [], + ReflectionInfo = null!, }, ], Properties = [], @@ -86,6 +91,7 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo { Name = "data", Attributes = [], + ReflectionInfo = null!, }, ], TestSessionId = sessionId, @@ -128,7 +134,7 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.MethodDataSource(methodData)), TestFilePath = @"", - TestLineNumber = 9, + TestLineNumber = 11, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -146,7 +152,7 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo MethodName = $"MethodDataSource", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("Tests.MethodDataSource failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 9, + TestLineNumber = 11, }); } return nodes; @@ -202,6 +208,7 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo [ new global::TUnit.Core.MatrixInstanceMethodAttribute("DataSource") ], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.Bugs._1821.Tests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -215,13 +222,17 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo }), Name = "Tests", Namespace = "TUnit.TestProject.Bugs._1821", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [ new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "data", Attributes = [], + ReflectionInfo = null!, }, ], Properties = [], @@ -243,6 +254,7 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo { Name = "data", Attributes = [], + ReflectionInfo = null!, }, ], TestSessionId = sessionId, @@ -280,6 +292,7 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo [ new global::TUnit.Core.MatrixInstanceMethodAttribute("DataSource") ], + ReflectionInfo = null!, }, ], TestSessionId = sessionId, @@ -312,7 +325,7 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.MatrixDataSource(methodArg)), TestFilePath = @"", - TestLineNumber = 16, + TestLineNumber = 18, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -330,7 +343,7 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo MethodName = $"MatrixDataSource", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("Tests.MatrixDataSource failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 16, + TestLineNumber = 18, }); } return nodes; diff --git a/TUnit.Core.SourceGenerator.Tests/Tests1889.Test.DotNet8_0.verified.txt b/TUnit.Core.SourceGenerator.Tests/Tests1889.Test.DotNet8_0.verified.txt index 69d5d8027c..8e1e463e6d 100644 --- a/TUnit.Core.SourceGenerator.Tests/Tests1889.Test.DotNet8_0.verified.txt +++ b/TUnit.Core.SourceGenerator.Tests/Tests1889.Test.DotNet8_0.verified.txt @@ -57,6 +57,7 @@ file partial class Inherited_DerivedTest : global::TUnit.Core.Interfaces.SourceG Namespace = "TUnit.TestProject.Bugs._1889", Attributes = [ + new EngineTest(Pass), new global::TUnit.Core.InheritsTestsAttribute() ], Parameters = [], @@ -130,6 +131,7 @@ file partial class Inherited_DerivedTest : global::TUnit.Core.Interfaces.SourceG { Name = "condition", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.Bugs._1889.DerivedTest", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -145,6 +147,7 @@ file partial class Inherited_DerivedTest : global::TUnit.Core.Interfaces.SourceG Namespace = "TUnit.TestProject.Bugs._1889", Attributes = [ + new EngineTest(Pass), new global::TUnit.Core.InheritsTestsAttribute() ], Parameters = [], @@ -167,6 +170,7 @@ file partial class Inherited_DerivedTest : global::TUnit.Core.Interfaces.SourceG { Name = "condition", Attributes = [], + ReflectionInfo = null!, }, ], TestSessionId = sessionId, @@ -247,6 +251,7 @@ file partial class Inherited_DerivedTest : global::TUnit.Core.Interfaces.SourceG { Name = "condition", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.Bugs._1889.DerivedTest", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -262,6 +267,7 @@ file partial class Inherited_DerivedTest : global::TUnit.Core.Interfaces.SourceG Namespace = "TUnit.TestProject.Bugs._1889", Attributes = [ + new EngineTest(Pass), new global::TUnit.Core.InheritsTestsAttribute() ], Parameters = [], @@ -337,6 +343,7 @@ file partial class Inherited_DerivedTest : global::TUnit.Core.Interfaces.SourceG { Name = "condition", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.Bugs._1889.DerivedTest", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -352,6 +359,7 @@ file partial class Inherited_DerivedTest : global::TUnit.Core.Interfaces.SourceG Namespace = "TUnit.TestProject.Bugs._1889", Attributes = [ + new EngineTest(Pass), new global::TUnit.Core.InheritsTestsAttribute() ], Parameters = [], diff --git a/TUnit.Core.SourceGenerator.Tests/Tests1889.Test.DotNet9_0.verified.txt b/TUnit.Core.SourceGenerator.Tests/Tests1889.Test.DotNet9_0.verified.txt index 69d5d8027c..8e1e463e6d 100644 --- a/TUnit.Core.SourceGenerator.Tests/Tests1889.Test.DotNet9_0.verified.txt +++ b/TUnit.Core.SourceGenerator.Tests/Tests1889.Test.DotNet9_0.verified.txt @@ -57,6 +57,7 @@ file partial class Inherited_DerivedTest : global::TUnit.Core.Interfaces.SourceG Namespace = "TUnit.TestProject.Bugs._1889", Attributes = [ + new EngineTest(Pass), new global::TUnit.Core.InheritsTestsAttribute() ], Parameters = [], @@ -130,6 +131,7 @@ file partial class Inherited_DerivedTest : global::TUnit.Core.Interfaces.SourceG { Name = "condition", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.Bugs._1889.DerivedTest", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -145,6 +147,7 @@ file partial class Inherited_DerivedTest : global::TUnit.Core.Interfaces.SourceG Namespace = "TUnit.TestProject.Bugs._1889", Attributes = [ + new EngineTest(Pass), new global::TUnit.Core.InheritsTestsAttribute() ], Parameters = [], @@ -167,6 +170,7 @@ file partial class Inherited_DerivedTest : global::TUnit.Core.Interfaces.SourceG { Name = "condition", Attributes = [], + ReflectionInfo = null!, }, ], TestSessionId = sessionId, @@ -247,6 +251,7 @@ file partial class Inherited_DerivedTest : global::TUnit.Core.Interfaces.SourceG { Name = "condition", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.Bugs._1889.DerivedTest", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -262,6 +267,7 @@ file partial class Inherited_DerivedTest : global::TUnit.Core.Interfaces.SourceG Namespace = "TUnit.TestProject.Bugs._1889", Attributes = [ + new EngineTest(Pass), new global::TUnit.Core.InheritsTestsAttribute() ], Parameters = [], @@ -337,6 +343,7 @@ file partial class Inherited_DerivedTest : global::TUnit.Core.Interfaces.SourceG { Name = "condition", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.Bugs._1889.DerivedTest", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -352,6 +359,7 @@ file partial class Inherited_DerivedTest : global::TUnit.Core.Interfaces.SourceG Namespace = "TUnit.TestProject.Bugs._1889", Attributes = [ + new EngineTest(Pass), new global::TUnit.Core.InheritsTestsAttribute() ], Parameters = [], 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 69d5d8027c..8e1e463e6d 100644 --- a/TUnit.Core.SourceGenerator.Tests/Tests1889.Test.Net4_7.verified.txt +++ b/TUnit.Core.SourceGenerator.Tests/Tests1889.Test.Net4_7.verified.txt @@ -57,6 +57,7 @@ file partial class Inherited_DerivedTest : global::TUnit.Core.Interfaces.SourceG Namespace = "TUnit.TestProject.Bugs._1889", Attributes = [ + new EngineTest(Pass), new global::TUnit.Core.InheritsTestsAttribute() ], Parameters = [], @@ -130,6 +131,7 @@ file partial class Inherited_DerivedTest : global::TUnit.Core.Interfaces.SourceG { Name = "condition", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.Bugs._1889.DerivedTest", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -145,6 +147,7 @@ file partial class Inherited_DerivedTest : global::TUnit.Core.Interfaces.SourceG Namespace = "TUnit.TestProject.Bugs._1889", Attributes = [ + new EngineTest(Pass), new global::TUnit.Core.InheritsTestsAttribute() ], Parameters = [], @@ -167,6 +170,7 @@ file partial class Inherited_DerivedTest : global::TUnit.Core.Interfaces.SourceG { Name = "condition", Attributes = [], + ReflectionInfo = null!, }, ], TestSessionId = sessionId, @@ -247,6 +251,7 @@ file partial class Inherited_DerivedTest : global::TUnit.Core.Interfaces.SourceG { Name = "condition", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.Bugs._1889.DerivedTest", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -262,6 +267,7 @@ file partial class Inherited_DerivedTest : global::TUnit.Core.Interfaces.SourceG Namespace = "TUnit.TestProject.Bugs._1889", Attributes = [ + new EngineTest(Pass), new global::TUnit.Core.InheritsTestsAttribute() ], Parameters = [], @@ -337,6 +343,7 @@ file partial class Inherited_DerivedTest : global::TUnit.Core.Interfaces.SourceG { Name = "condition", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.Bugs._1889.DerivedTest", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -352,6 +359,7 @@ file partial class Inherited_DerivedTest : global::TUnit.Core.Interfaces.SourceG Namespace = "TUnit.TestProject.Bugs._1889", Attributes = [ + new EngineTest(Pass), new global::TUnit.Core.InheritsTestsAttribute() ], Parameters = [], diff --git a/TUnit.Core.SourceGenerator.Tests/Tests2083.Test.verified.txt b/TUnit.Core.SourceGenerator.Tests/Tests2083.Test.verified.txt index fd974c5ef6..2201d390a5 100644 --- a/TUnit.Core.SourceGenerator.Tests/Tests2083.Test.verified.txt +++ b/TUnit.Core.SourceGenerator.Tests/Tests2083.Test.verified.txt @@ -58,6 +58,7 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo { Name = "value", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.Bugs._2083.Tests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -71,7 +72,10 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo }), Name = "Tests", Namespace = "TUnit.TestProject.Bugs._2083", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -104,7 +108,7 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.MyTest(methodArg)), TestFilePath = @"", - TestLineNumber = 5, + TestLineNumber = 8, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -120,7 +124,7 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo MethodName = $"MyTest", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("Tests.MyTest failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 5, + TestLineNumber = 8, }); } return nodes; @@ -154,6 +158,7 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo { Name = "value", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.Bugs._2083.Tests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -167,7 +172,10 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo }), Name = "Tests", Namespace = "TUnit.TestProject.Bugs._2083", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -200,7 +208,7 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.MyTest(methodArg)), TestFilePath = @"", - TestLineNumber = 5, + TestLineNumber = 8, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -216,7 +224,7 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo MethodName = $"MyTest", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("Tests.MyTest failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 5, + TestLineNumber = 8, }); } return nodes; @@ -250,6 +258,7 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo { Name = "value", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.Bugs._2083.Tests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -263,7 +272,10 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo }), Name = "Tests", Namespace = "TUnit.TestProject.Bugs._2083", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -296,7 +308,7 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.MyTest(methodArg)), TestFilePath = @"", - TestLineNumber = 5, + TestLineNumber = 8, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -312,7 +324,7 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo MethodName = $"MyTest", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("Tests.MyTest failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 5, + TestLineNumber = 8, }); } return nodes; @@ -346,6 +358,7 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo { Name = "value", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.Bugs._2083.Tests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -359,7 +372,10 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo }), Name = "Tests", Namespace = "TUnit.TestProject.Bugs._2083", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -392,7 +408,7 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.MyTest(methodArg)), TestFilePath = @"", - TestLineNumber = 5, + TestLineNumber = 8, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -408,7 +424,7 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo MethodName = $"MyTest", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("Tests.MyTest failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 5, + TestLineNumber = 8, }); } return nodes; @@ -442,6 +458,7 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo { Name = "value", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.Bugs._2083.Tests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -455,7 +472,10 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo }), Name = "Tests", Namespace = "TUnit.TestProject.Bugs._2083", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -488,7 +508,7 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.MyTest(methodArg)), TestFilePath = @"", - TestLineNumber = 5, + TestLineNumber = 8, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -504,7 +524,7 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo MethodName = $"MyTest", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("Tests.MyTest failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 5, + TestLineNumber = 8, }); } return nodes; @@ -538,6 +558,7 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo { Name = "value", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.Bugs._2083.Tests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -551,7 +572,10 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo }), Name = "Tests", Namespace = "TUnit.TestProject.Bugs._2083", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -584,7 +608,7 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.MyTest(methodArg)), TestFilePath = @"", - TestLineNumber = 5, + TestLineNumber = 8, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -600,7 +624,7 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo MethodName = $"MyTest", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("Tests.MyTest failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 5, + TestLineNumber = 8, }); } return nodes; diff --git a/TUnit.Core.SourceGenerator.Tests/Tests2085.Test.verified.txt b/TUnit.Core.SourceGenerator.Tests/Tests2085.Test.verified.txt index 35ecbb707a..0cb63515dd 100644 --- a/TUnit.Core.SourceGenerator.Tests/Tests2085.Test.verified.txt +++ b/TUnit.Core.SourceGenerator.Tests/Tests2085.Test.verified.txt @@ -47,6 +47,7 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo [ new global::TUnit.Core.MatrixAttribute(double.NaN, double.PositiveInfinity, double.NegativeInfinity) ], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.Bugs._2085.Tests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -60,7 +61,10 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo }), Name = "Tests", Namespace = "TUnit.TestProject.Bugs._2085", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -84,6 +88,7 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo [ new global::TUnit.Core.MatrixAttribute(double.NaN, double.PositiveInfinity, double.NegativeInfinity) ], + ReflectionInfo = null!, }, ], TestSessionId = sessionId, @@ -122,7 +127,7 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.Double_SpecialConsts(methodArg)), TestFilePath = @"", - TestLineNumber = 8, + TestLineNumber = 10, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -139,7 +144,7 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo MethodName = $"Double_SpecialConsts", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("Tests.Double_SpecialConsts failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 8, + TestLineNumber = 10, }); } return nodes; @@ -195,6 +200,7 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo [ new global::TUnit.Core.MatrixAttribute(float.NaN, float.PositiveInfinity, float.NegativeInfinity) ], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.Bugs._2085.Tests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -208,7 +214,10 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo }), Name = "Tests", Namespace = "TUnit.TestProject.Bugs._2085", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -232,6 +241,7 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo [ new global::TUnit.Core.MatrixAttribute(float.NaN, float.PositiveInfinity, float.NegativeInfinity) ], + ReflectionInfo = null!, }, ], TestSessionId = sessionId, @@ -270,7 +280,7 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.Float_SpecialConsts(methodArg)), TestFilePath = @"", - TestLineNumber = 15, + TestLineNumber = 17, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -287,7 +297,7 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo MethodName = $"Float_SpecialConsts", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("Tests.Float_SpecialConsts failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 15, + TestLineNumber = 17, }); } return nodes; diff --git a/TUnit.Core.SourceGenerator.Tests/Tests2112.Test.verified.txt b/TUnit.Core.SourceGenerator.Tests/Tests2112.Test.verified.txt index b0a5e36bdf..b494f9b34c 100644 --- a/TUnit.Core.SourceGenerator.Tests/Tests2112.Test.verified.txt +++ b/TUnit.Core.SourceGenerator.Tests/Tests2112.Test.verified.txt @@ -50,11 +50,13 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo { Name = "a", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "arr", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.Bugs._2112.Tests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -68,7 +70,10 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo }), Name = "Tests", Namespace = "TUnit.TestProject.Bugs._2112", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -102,7 +107,7 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.Test(methodArg, methodArg1)), TestFilePath = @"", - TestLineNumber = 5, + TestLineNumber = 8, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -118,7 +123,7 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo MethodName = $"Test", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("Tests.Test failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 5, + TestLineNumber = 8, }); } return nodes; @@ -148,11 +153,13 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo { Name = "a", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "arr", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.Bugs._2112.Tests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -166,7 +173,10 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo }), Name = "Tests", Namespace = "TUnit.TestProject.Bugs._2112", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -200,7 +210,7 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.Test(methodArg, methodArg1)), TestFilePath = @"", - TestLineNumber = 5, + TestLineNumber = 8, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -216,7 +226,7 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo MethodName = $"Test", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("Tests.Test failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 5, + TestLineNumber = 8, }); } return nodes; @@ -275,11 +285,13 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo { Name = "a", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "arr", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.Bugs._2112.Tests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -293,7 +305,10 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo }), Name = "Tests", Namespace = "TUnit.TestProject.Bugs._2112", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -327,7 +342,7 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.Test2(methodArg, methodArg1)), TestFilePath = @"", - TestLineNumber = 12, + TestLineNumber = 15, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -343,7 +358,7 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo MethodName = $"Test2", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("Tests.Test2 failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 12, + TestLineNumber = 15, }); } return nodes; @@ -373,11 +388,13 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo { Name = "a", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "arr", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.Bugs._2112.Tests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -391,7 +408,10 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo }), Name = "Tests", Namespace = "TUnit.TestProject.Bugs._2112", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -425,7 +445,7 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.Test2(methodArg, methodArg1)), TestFilePath = @"", - TestLineNumber = 12, + TestLineNumber = 15, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -441,7 +461,7 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo MethodName = $"Test2", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("Tests.Test2 failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 12, + TestLineNumber = 15, }); } return nodes; diff --git a/TUnit.Core.SourceGenerator.Tests/Tests2136.Test.verified.txt b/TUnit.Core.SourceGenerator.Tests/Tests2136.Test.verified.txt index 816995aa64..6b99c11336 100644 --- a/TUnit.Core.SourceGenerator.Tests/Tests2136.Test.verified.txt +++ b/TUnit.Core.SourceGenerator.Tests/Tests2136.Test.verified.txt @@ -56,11 +56,13 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo { Name = "value", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "expected", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.Bugs._2136.Tests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -74,7 +76,10 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo }), Name = "Tests", Namespace = "TUnit.TestProject.Bugs._2136", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -108,7 +113,7 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.GenericArgumentsTest(methodArg, methodArg1)), TestFilePath = @"", - TestLineNumber = 8, + TestLineNumber = 10, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -124,7 +129,7 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo MethodName = $"GenericArgumentsTest", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("Tests.GenericArgumentsTest failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 8, + TestLineNumber = 10, }); } return nodes; @@ -157,11 +162,13 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo { Name = "value", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "expected", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.Bugs._2136.Tests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -175,7 +182,10 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo }), Name = "Tests", Namespace = "TUnit.TestProject.Bugs._2136", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -209,7 +219,7 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.GenericArgumentsTest(methodArg, methodArg1)), TestFilePath = @"", - TestLineNumber = 8, + TestLineNumber = 10, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -225,7 +235,7 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo MethodName = $"GenericArgumentsTest", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("Tests.GenericArgumentsTest failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 8, + TestLineNumber = 10, }); } return nodes; @@ -258,11 +268,13 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo { Name = "value", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "expected", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.Bugs._2136.Tests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -276,7 +288,10 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo }), Name = "Tests", Namespace = "TUnit.TestProject.Bugs._2136", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -310,7 +325,7 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.GenericArgumentsTest(methodArg, methodArg1)), TestFilePath = @"", - TestLineNumber = 8, + TestLineNumber = 10, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -326,7 +341,7 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo MethodName = $"GenericArgumentsTest", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("Tests.GenericArgumentsTest failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 8, + TestLineNumber = 10, }); } return nodes; @@ -359,11 +374,13 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo { Name = "value", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "expected", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.Bugs._2136.Tests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -377,7 +394,10 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo }), Name = "Tests", Namespace = "TUnit.TestProject.Bugs._2136", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -411,7 +431,7 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.GenericArgumentsTest(methodArg, methodArg1)), TestFilePath = @"", - TestLineNumber = 8, + TestLineNumber = 10, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -427,7 +447,7 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo MethodName = $"GenericArgumentsTest", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("Tests.GenericArgumentsTest failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 8, + TestLineNumber = 10, }); } return nodes; @@ -460,11 +480,13 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo { Name = "value", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "expected", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.Bugs._2136.Tests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -478,7 +500,10 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo }), Name = "Tests", Namespace = "TUnit.TestProject.Bugs._2136", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -512,7 +537,7 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.GenericArgumentsTest(methodArg, methodArg1)), TestFilePath = @"", - TestLineNumber = 8, + TestLineNumber = 10, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -528,7 +553,7 @@ file partial class Tests : global::TUnit.Core.Interfaces.SourceGenerator.ITestSo MethodName = $"GenericArgumentsTest", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("Tests.GenericArgumentsTest failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 8, + TestLineNumber = 10, }); } return nodes; diff --git a/TUnit.Core.SourceGenerator.Tests/TimeoutCancellationTokenTests.Test.verified.txt b/TUnit.Core.SourceGenerator.Tests/TimeoutCancellationTokenTests.Test.verified.txt index 829627620b..10f05bb30e 100644 --- a/TUnit.Core.SourceGenerator.Tests/TimeoutCancellationTokenTests.Test.verified.txt +++ b/TUnit.Core.SourceGenerator.Tests/TimeoutCancellationTokenTests.Test.verified.txt @@ -36,7 +36,8 @@ file partial class TimeoutCancellationTokenTests : global::TUnit.Core.Interfaces ReturnType = typeof(global::System.Threading.Tasks.Task), Attributes = [ - new global::TUnit.Core.TestAttribute() + new global::TUnit.Core.TestAttribute(), + new EngineTest(Pass) ], Parameters = [ @@ -44,6 +45,7 @@ file partial class TimeoutCancellationTokenTests : global::TUnit.Core.Interfaces { Name = "cancellationToken", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.TimeoutCancellationTokenTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -68,6 +70,7 @@ file partial class TimeoutCancellationTokenTests : global::TUnit.Core.Interfaces { Name = "value", Attributes = [], + ReflectionInfo = null!, }, ], Properties = [], @@ -100,7 +103,7 @@ file partial class TimeoutCancellationTokenTests : global::TUnit.Core.Interfaces ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.DefaultTest(cancellationToken)), TestFilePath = @"", - TestLineNumber = 15, + TestLineNumber = 16, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -116,7 +119,7 @@ file partial class TimeoutCancellationTokenTests : global::TUnit.Core.Interfaces MethodName = $"DefaultTest", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("TimeoutCancellationTokenTests.DefaultTest failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 15, + TestLineNumber = 16, }); } return nodes; @@ -163,7 +166,8 @@ file partial class TimeoutCancellationTokenTests : global::TUnit.Core.Interfaces [ new global::TUnit.Core.TestAttribute(), new global::TUnit.Core.TimeoutAttribute(5_000), - new global::TUnit.Core.CategoryAttribute("Blah") + new global::TUnit.Core.CategoryAttribute("Blah"), + new EngineTest(Failure) ], Parameters = [ @@ -171,6 +175,7 @@ file partial class TimeoutCancellationTokenTests : global::TUnit.Core.Interfaces { Name = "cancellationToken", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.TimeoutCancellationTokenTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -195,6 +200,7 @@ file partial class TimeoutCancellationTokenTests : global::TUnit.Core.Interfaces { Name = "value", Attributes = [], + ReflectionInfo = null!, }, ], Properties = [], @@ -227,7 +233,7 @@ file partial class TimeoutCancellationTokenTests : global::TUnit.Core.Interfaces ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.BasicTest(cancellationToken)), TestFilePath = @"", - TestLineNumber = 21, + TestLineNumber = 23, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -243,7 +249,7 @@ file partial class TimeoutCancellationTokenTests : global::TUnit.Core.Interfaces MethodName = $"BasicTest", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("TimeoutCancellationTokenTests.BasicTest failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 21, + TestLineNumber = 23, }); } return nodes; @@ -289,7 +295,8 @@ file partial class TimeoutCancellationTokenTests : global::TUnit.Core.Interfaces Attributes = [ new global::TUnit.Core.TestAttribute(), - new global::TUnit.TestProject.TimeoutCancellationTokenTests.FiveSecondTimeout() + new global::TUnit.TestProject.TimeoutCancellationTokenTests.FiveSecondTimeout(), + new EngineTest(Failure) ], Parameters = [ @@ -297,6 +304,7 @@ file partial class TimeoutCancellationTokenTests : global::TUnit.Core.Interfaces { Name = "cancellationToken", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.TimeoutCancellationTokenTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -321,6 +329,7 @@ file partial class TimeoutCancellationTokenTests : global::TUnit.Core.Interfaces { Name = "value", Attributes = [], + ReflectionInfo = null!, }, ], Properties = [], @@ -353,7 +362,7 @@ file partial class TimeoutCancellationTokenTests : global::TUnit.Core.Interfaces ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.InheritedTimeoutAttribute(cancellationToken)), TestFilePath = @"", - TestLineNumber = 29, + TestLineNumber = 32, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -369,7 +378,7 @@ file partial class TimeoutCancellationTokenTests : global::TUnit.Core.Interfaces MethodName = $"InheritedTimeoutAttribute", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("TimeoutCancellationTokenTests.InheritedTimeoutAttribute failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 29, + TestLineNumber = 32, }); } return nodes; @@ -416,7 +425,8 @@ file partial class TimeoutCancellationTokenTests : global::TUnit.Core.Interfaces [ new global::TUnit.Core.TestAttribute(), new global::TUnit.Core.ArgumentsAttribute(1), - new global::TUnit.Core.TimeoutAttribute(5_000) + new global::TUnit.Core.TimeoutAttribute(5_000), + new EngineTest(Failure) ], Parameters = [ @@ -424,11 +434,13 @@ file partial class TimeoutCancellationTokenTests : global::TUnit.Core.Interfaces { Name = "value", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "cancellationToken", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.TimeoutCancellationTokenTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -453,6 +465,7 @@ file partial class TimeoutCancellationTokenTests : global::TUnit.Core.Interfaces { Name = "value", Attributes = [], + ReflectionInfo = null!, }, ], Properties = [], @@ -487,7 +500,7 @@ file partial class TimeoutCancellationTokenTests : global::TUnit.Core.Interfaces ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.DataTest(methodArg, cancellationToken)), TestFilePath = @"", - TestLineNumber = 36, + TestLineNumber = 40, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -503,7 +516,7 @@ file partial class TimeoutCancellationTokenTests : global::TUnit.Core.Interfaces MethodName = $"DataTest", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("TimeoutCancellationTokenTests.DataTest failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 36, + TestLineNumber = 40, }); } return nodes; @@ -550,6 +563,7 @@ file partial class TimeoutCancellationTokenTests : global::TUnit.Core.Interfaces [ new global::TUnit.Core.MethodDataSourceAttribute("DataSource"), new global::TUnit.Core.TimeoutAttribute(5_000), + new EngineTest(Failure), new global::TUnit.Core.TestAttribute() ], Parameters = @@ -558,11 +572,13 @@ file partial class TimeoutCancellationTokenTests : global::TUnit.Core.Interfaces { Name = "value", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "cancellationToken", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.TimeoutCancellationTokenTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -587,6 +603,7 @@ file partial class TimeoutCancellationTokenTests : global::TUnit.Core.Interfaces { Name = "value", Attributes = [], + ReflectionInfo = null!, }, ], Properties = [], @@ -620,7 +637,7 @@ file partial class TimeoutCancellationTokenTests : global::TUnit.Core.Interfaces ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.DataSourceTest(methodArg, cancellationToken)), TestFilePath = @"", - TestLineNumber = 47, + TestLineNumber = 53, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -636,7 +653,7 @@ file partial class TimeoutCancellationTokenTests : global::TUnit.Core.Interfaces MethodName = $"DataSourceTest", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("TimeoutCancellationTokenTests.DataSourceTest failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 47, + TestLineNumber = 53, }); } return nodes; @@ -683,6 +700,7 @@ file partial class TimeoutCancellationTokenTests : global::TUnit.Core.Interfaces [ new global::TUnit.Core.TestAttribute(), new global::TUnit.Core.TimeoutAttribute(5_000), + new EngineTest(Failure), new global::TUnit.Core.CategoryAttribute("Blah") ], Parameters = @@ -694,11 +712,13 @@ file partial class TimeoutCancellationTokenTests : global::TUnit.Core.Interfaces [ new global::TUnit.Core.MatrixAttribute(1, 2, 3) ], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "cancellationToken", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.TimeoutCancellationTokenTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -723,6 +743,7 @@ file partial class TimeoutCancellationTokenTests : global::TUnit.Core.Interfaces { Name = "value", Attributes = [], + ReflectionInfo = null!, }, ], Properties = [], @@ -747,6 +768,7 @@ file partial class TimeoutCancellationTokenTests : global::TUnit.Core.Interfaces [ new global::TUnit.Core.MatrixAttribute(1, 2, 3) ], + ReflectionInfo = null!, }, ], TestSessionId = sessionId, @@ -786,7 +808,7 @@ file partial class TimeoutCancellationTokenTests : global::TUnit.Core.Interfaces ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.MatrixTest(methodArg, cancellationToken)), TestFilePath = @"", - TestLineNumber = 54, + TestLineNumber = 60, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -803,7 +825,7 @@ file partial class TimeoutCancellationTokenTests : global::TUnit.Core.Interfaces MethodName = $"MatrixTest", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("TimeoutCancellationTokenTests.MatrixTest failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 54, + TestLineNumber = 60, }); } return nodes; diff --git a/TUnit.Core.SourceGenerator.Tests/TupleDataSourceDrivenTests.Test.verified.txt b/TUnit.Core.SourceGenerator.Tests/TupleDataSourceDrivenTests.Test.verified.txt index 4f9b2be108..34e516cd24 100644 --- a/TUnit.Core.SourceGenerator.Tests/TupleDataSourceDrivenTests.Test.verified.txt +++ b/TUnit.Core.SourceGenerator.Tests/TupleDataSourceDrivenTests.Test.verified.txt @@ -45,16 +45,19 @@ file partial class TupleDataSourceDrivenTests : global::TUnit.Core.Interfaces.So { Name = "value", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "value2", Attributes = [], + ReflectionInfo = null!, }, new global::TUnit.Core.SourceGeneratedParameterInformation { Name = "value3", Attributes = [], + ReflectionInfo = null!, }, ], Class = global::TUnit.Core.SourceGeneratedClassInformation.GetOrAdd("global::TUnit.TestProject.TupleDataSourceDrivenTests", () => new global::TUnit.Core.SourceGeneratedClassInformation @@ -68,7 +71,10 @@ file partial class TupleDataSourceDrivenTests : global::TUnit.Core.Interfaces.So }), Name = "TupleDataSourceDrivenTests", Namespace = "TUnit.TestProject", - Attributes = [], + Attributes = + [ + new EngineTest(Pass) + ], Parameters = [], Properties = [], }), @@ -103,7 +109,7 @@ file partial class TupleDataSourceDrivenTests : global::TUnit.Core.Interfaces.So ResettableClassFactory = resettableClassFactory, TestMethodFactory = (classInstance, cancellationToken) => AsyncConvert.Convert(() => classInstance.DataSource_TupleMethod(methodArg, methodArg1, methodArg2)), TestFilePath = @"", - TestLineNumber = 5, + TestLineNumber = 8, TestMethod = testInformation, TestBuilderContext = testBuilderContext, }); @@ -119,7 +125,7 @@ file partial class TupleDataSourceDrivenTests : global::TUnit.Core.Interfaces.So MethodName = $"DataSource_TupleMethod", Exception = new TUnit.Core.Exceptions.TestFailedInitializationException("TupleDataSourceDrivenTests.DataSource_TupleMethod failed to initialize", exception), TestFilePath = @"", - TestLineNumber = 5, + TestLineNumber = 8, }); } return nodes; diff --git a/TUnit.Core.SourceGenerator/CodeGenerators/AssemblyLoaderGenerator.cs b/TUnit.Core.SourceGenerator/CodeGenerators/AssemblyLoaderGenerator.cs index 2282c5819a..b042a30803 100644 --- a/TUnit.Core.SourceGenerator/CodeGenerators/AssemblyLoaderGenerator.cs +++ b/TUnit.Core.SourceGenerator/CodeGenerators/AssemblyLoaderGenerator.cs @@ -14,84 +14,92 @@ public class AssemblyLoaderGenerator : IIncrementalGenerator "31bf3856ad364e35", "cc7b13ffcd2ddd51", "7cec85d7bea7798e", - + ]; public void Initialize(IncrementalGeneratorInitializationContext context) { var provider = context.CompilationProvider .WithComparer(new PreventCompilationTriggerOnEveryKeystrokeComparer()); - + context.RegisterSourceOutput(provider, (sourceProductionContext, source) => GenerateCode(sourceProductionContext, source)); } private void GenerateCode(SourceProductionContext context, Compilation compilation) { - var assemblyReferences = compilation.References - .Where(x => x.Properties.Kind == MetadataImageKind.Assembly) - .Where(x => !string.IsNullOrEmpty(x.Display)); - - var assemblySymbols = assemblyReferences - .Select(compilation.GetAssemblyOrModuleSymbol) - .OfType() - .Distinct(SymbolEqualityComparer.Default) - .OfType() - .ToArray(); - - var sourceBuilder = new SourceCodeWriter(); + // Collect all assemblies: start with the current assembly, then traverse references + var visitedAssemblies = new HashSet(SymbolEqualityComparer.Default); + + var assembliesToVisit = new Queue(); + + var currentAssembly = compilation.Assembly; + + assembliesToVisit.Enqueue(currentAssembly); + while (assembliesToVisit.Count > 0) + { + var assembly = assembliesToVisit.Dequeue(); + + if (!visitedAssemblies.Add(assembly)) + { + continue; + } + + foreach (var referenced in assembly.Modules.SelectMany(m => m.ReferencedAssemblySymbols)) + { + if (!visitedAssemblies.Contains(referenced)) + { + assembliesToVisit.Enqueue(referenced); + } + } + } + + var sourceBuilder = new SourceCodeWriter(); sourceBuilder.WriteLine("// "); sourceBuilder.WriteLine("#pragma warning disable"); - sourceBuilder.WriteLine("file static class AssemblyLoader" + Guid.NewGuid().ToString("N")); sourceBuilder.WriteLine("{"); sourceBuilder.WriteLine("[global::System.Runtime.CompilerServices.ModuleInitializer]"); sourceBuilder.WriteLine("public static void Initialize()"); sourceBuilder.WriteLine("{"); - var visitedAssemblies = new HashSet(SymbolEqualityComparer.Default); - foreach (var assembly in assemblySymbols) + foreach (var assembly in visitedAssemblies) { - WriteAssemblyLoad(sourceBuilder, assembly, visitedAssemblies); + WriteAssemblyLoad(sourceBuilder, assembly); } sourceBuilder.WriteLine("}"); sourceBuilder.WriteLine("}"); - context.AddSource("AssemblyLoader.g.cs", sourceBuilder.ToString()); } - private static void WriteAssemblyLoad(SourceCodeWriter sourceBuilder, IAssemblySymbol assembly, HashSet visitedAssemblies) + private static void WriteAssemblyLoad(SourceCodeWriter sourceBuilder, IAssemblySymbol assembly) { - if (!visitedAssemblies.Add(assembly) || IsSystemAssembly(assembly)) + if (IsSystemAssembly(assembly)) { return; } - - sourceBuilder.WriteLine($"global::TUnit.Core.SourceRegistrar.RegisterAssembly(() => global::System.Reflection.Assembly.Load(\"{GetAssemblyFullName(assembly)}\"));"); - foreach (var innerAssembly in assembly.Modules.SelectMany(x => x.ReferencedAssemblySymbols)) - { - WriteAssemblyLoad(sourceBuilder, innerAssembly, visitedAssemblies); - } + sourceBuilder.WriteLine($"global::TUnit.Core.SourceRegistrar.RegisterAssembly(() => global::System.Reflection.Assembly.Load(\"{GetAssemblyFullName(assembly)}\"));"); } - + private static bool IsSystemAssembly(IAssemblySymbol assemblySymbol) { if (assemblySymbol.Identity.PublicKeyToken.IsDefaultOrEmpty) { return false; } - + var stringPublicTokenKey = BitConverter.ToString(assemblySymbol.Identity.PublicKeyToken.ToArray()) .Replace("-", "") .ToLowerInvariant(); - + return _excludedAssemblies.Contains(stringPublicTokenKey); } - + private static string GetAssemblyFullName(IAssemblySymbol assemblySymbol) { var identity = assemblySymbol.Identity; return $"{identity.Name}, Version={identity.Version}, Culture={(string.IsNullOrEmpty(identity.CultureName) ? "neutral" : identity.CultureName)}, PublicKeyToken={(identity.PublicKeyToken.Length > 0 ? BitConverter.ToString(identity.PublicKeyToken.ToArray()).Replace("-", "").ToLowerInvariant() : "null")}"; } -} \ No newline at end of file +} + diff --git a/TUnit.Core.SourceGenerator/CodeGenerators/DataGeneratorPropertyGenerator.cs b/TUnit.Core.SourceGenerator/CodeGenerators/DataGeneratorPropertyGenerator.cs new file mode 100644 index 0000000000..ab4665784c --- /dev/null +++ b/TUnit.Core.SourceGenerator/CodeGenerators/DataGeneratorPropertyGenerator.cs @@ -0,0 +1,158 @@ +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp.Syntax; +using TUnit.Core.SourceGenerator.Extensions; + +namespace TUnit.Core.SourceGenerator.CodeGenerators; + +[Generator] +public class DataGeneratorPropertyGenerator : IIncrementalGenerator +{ + public void Initialize(IncrementalGeneratorInitializationContext context) + { + var classDataSourceClasses = context.SyntaxProvider + .CreateSyntaxProvider( + predicate: static (node, _) => node is AttributeSyntax, + transform: GetClassesWithDataSourceProperties) + .SelectMany(static (symbols, _) => symbols) + .WithComparer(SymbolEqualityComparer.Default); + + context.RegisterSourceOutput(classDataSourceClasses, GeneratePropertyInitializer); + } + + private static IEnumerable GetClassesWithDataSourceProperties(GeneratorSyntaxContext context, CancellationToken cancellationToken) + { + if (context.Node is not AttributeSyntax attributeSyntax) + { + return []; + } + + var semanticModel = context.SemanticModel; + + if(semanticModel.GetSymbolInfo(attributeSyntax).Symbol is not IMethodSymbol attributeConstructorSymbol) + { + return []; + } + + var attributeClass = attributeConstructorSymbol.ContainingType; + + if (attributeClass == null) + { + return []; + } + + if (!IsDataSourceGeneratorAttribute(attributeClass, out var attributeBaseType)) + { + return []; + } + + if (attributeBaseType?.IsGenericType is not true) + { + return []; + } + + return attributeBaseType.TypeArguments + .Where(x => x is not ITypeParameterSymbol) + .OfType() + .Where(HasDataGeneratorProperties); + } + + private static bool HasDataGeneratorProperties(ITypeSymbol type) + { + if (type is not INamedTypeSymbol namedTypeSymbol) + { + return false; + } + + return namedTypeSymbol.GetMembers() + .OfType() + .Any(property => property.GetAttributes().Any(attr => IsDataSourceGeneratorAttribute(attr.AttributeClass, out _))); + } + + private static bool IsDataSourceGeneratorAttribute(INamedTypeSymbol? attributeClass, out INamedTypeSymbol? attributeBaseType) + { + if (attributeClass == null) + { + attributeBaseType = null; + return false; + } + + foreach (var type in attributeClass.GetSelfAndBaseTypes()) + { + if(type.Interfaces.Any(i => + i.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) == "global::TUnit.Core.IDataSourceGeneratorAttribute")) + { + attributeBaseType = type; + return true; + } + } + + attributeBaseType = null; + return false; + } + + private void GeneratePropertyInitializer(SourceProductionContext context, INamedTypeSymbol type) + { + try + { + using var sourceBuilder = new SourceCodeWriter(); + + sourceBuilder.WriteLine("// "); + sourceBuilder.WriteLine("#pragma warning disable"); + sourceBuilder.WriteLine("using global::System;"); + sourceBuilder.WriteLine("using global::System.Collections.Generic;"); + sourceBuilder.WriteLine("using global::TUnit.Core;"); + sourceBuilder.WriteLine(); + + var initializerClassName = $"{type.Name}PropertyInitializer_{Guid.NewGuid():N}"; + + sourceBuilder.WriteLine("namespace TUnit.SourceGenerated;"); + sourceBuilder.WriteLine(); + sourceBuilder.WriteLine("[global::System.Diagnostics.StackTraceHidden]"); + sourceBuilder.WriteLine("[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]"); + sourceBuilder.WriteLine($"file static class {initializerClassName}"); + sourceBuilder.WriteLine("{"); + + // Generate the initialization method + sourceBuilder.WriteLine("[global::System.Runtime.CompilerServices.ModuleInitializer]"); + sourceBuilder.WriteLine("public static void InitializeProperties()"); + sourceBuilder.WriteLine("{"); + + RegisterProperty(type, sourceBuilder); + + sourceBuilder.WriteLine("}"); + sourceBuilder.WriteLine("}"); + + context.AddSource($"PropertyInitializer_{initializerClassName}.g.cs", sourceBuilder.ToString()); + } + catch (Exception ex) + { + var descriptor = new DiagnosticDescriptor( + id: "TUNIT_PROP_001", + title: "Error generating property initializer", + messageFormat: "Failed to generate property initializer: {0}", + category: "SourceGenerator", + DiagnosticSeverity.Warning, + isEnabledByDefault: true); + + context.ReportDiagnostic(Diagnostic.Create(descriptor, null, ex.ToString())); + } + } + + private static void RegisterProperty(INamedTypeSymbol type, SourceCodeWriter sourceBuilder) + { + sourceBuilder.WriteLine($"global::TUnit.Core.SourceRegistrar.RegisterProperty<{type.GloballyQualified()}>();"); + + foreach (var propertySymbol in type.GetSelfAndBaseTypes().SelectMany(x => x.GetMembers()).OfType()) + { + if (!propertySymbol.GetAttributes().Any(x => IsDataSourceGeneratorAttribute(x.AttributeClass, out _))) + { + continue; + } + + if (propertySymbol.Type is INamedTypeSymbol namedTypePropertySymbol) + { + RegisterProperty(namedTypePropertySymbol, sourceBuilder); + } + } + } +} diff --git a/TUnit.Core.SourceGenerator/CodeGenerators/DisableReflectionScannerGenerator.cs b/TUnit.Core.SourceGenerator/CodeGenerators/DisableReflectionScannerGenerator.cs index aa1de17f3f..e4303c1384 100644 --- a/TUnit.Core.SourceGenerator/CodeGenerators/DisableReflectionScannerGenerator.cs +++ b/TUnit.Core.SourceGenerator/CodeGenerators/DisableReflectionScannerGenerator.cs @@ -11,7 +11,7 @@ public void Initialize(IncrementalGeneratorInitializationContext context) { var provider = context.CompilationProvider .WithComparer(new PreventCompilationTriggerOnEveryKeystrokeComparer()); - + context.RegisterSourceOutput(provider, (sourceProductionContext, _) => GenerateCode(sourceProductionContext)); } @@ -40,18 +40,18 @@ private static bool IsSystemAssembly(IAssemblySymbol assemblySymbol) { // Check for well-known public key tokens of system assemblies var publicKeyToken = assemblySymbol.Identity.PublicKeyToken; - + if (publicKeyToken == null) { return false; } - + return publicKeyToken.SequenceEqual(new byte[] { 0xb7, 0x7a, 0x5c, 0x56, 0x19, 0x34, 0xe0, 0x89 }) // .NET Framework || publicKeyToken.SequenceEqual(new byte[] { 0x7c, 0xec, 0x85, 0xd7, 0xbe, 0xa7, 0x79, 0x8e }) // .NET Core || publicKeyToken.SequenceEqual(new byte[] { 0xcc, 0x7b, 0x13, 0xff, 0xcd, 0x2d, 0xdd, 0x51 }) // System.Private || publicKeyToken.SequenceEqual(new byte[] { 0xb0, 0x3f, 0x5f, 0x7f, 0x11, 0xd5, 0x0a, 0x3a }); // mscorlib } - + private static string GetAssemblyFullName(IAssemblySymbol assemblySymbol) { var identity = assemblySymbol.Identity; @@ -75,4 +75,4 @@ private static string GetAssemblyNamesString(ImmutableArray m return string.Join("|", metadataReferences.Select(x => x.Display)); } } -} \ No newline at end of file +} diff --git a/TUnit.Core.SourceGenerator/CodeGenerators/DynamicTestsGenerator.cs b/TUnit.Core.SourceGenerator/CodeGenerators/DynamicTestsGenerator.cs index e24bf5fb9d..f975e7459b 100644 --- a/TUnit.Core.SourceGenerator/CodeGenerators/DynamicTestsGenerator.cs +++ b/TUnit.Core.SourceGenerator/CodeGenerators/DynamicTestsGenerator.cs @@ -17,7 +17,7 @@ public void Initialize(IncrementalGeneratorInitializationContext context) predicate: static (_, _) => true, transform: static (ctx, _) => GetSemanticTargetForTestMethodGeneration(ctx)) .Where(static m => m is not null); - + context.RegisterSourceOutput(standardTests, (sourceContext, data) => GenerateTests(sourceContext, data!)); } @@ -89,15 +89,15 @@ private void GenerateTests(SourceProductionContext context, DynamicTestSourceDat : $"new {dynamicTestSource.Class.GloballyQualified()}()"; sourceBuilder.WriteLine($"{receiver}.{dynamicTestSource.Method.Name}(context);"); - + sourceBuilder.WriteLine("return context.Tests;"); - + sourceBuilder.WriteLine("}"); sourceBuilder.WriteLine("catch (global::System.Exception exception)"); sourceBuilder.WriteLine("{"); FailedTestInitializationWriter.GenerateFailedTestCode(sourceBuilder, dynamicTestSource); sourceBuilder.WriteLine("}"); - + sourceBuilder.WriteLine("}"); sourceBuilder.WriteLine("}"); @@ -110,10 +110,10 @@ private void GenerateTests(SourceProductionContext context, DynamicTestSourceDat title: "Error Generating Source", messageFormat: "{0}", category: "SourceGenerator", - DiagnosticSeverity.Error, + DiagnosticSeverity.Warning, isEnabledByDefault: true); context.ReportDiagnostic(Diagnostic.Create(descriptor, null, ex.ToString())); } } -} \ No newline at end of file +} diff --git a/TUnit.Core.SourceGenerator/CodeGenerators/Helpers/DataSourceGeneratorRetriever.cs b/TUnit.Core.SourceGenerator/CodeGenerators/Helpers/DataSourceGeneratorRetriever.cs index eeaed8df13..f624e4015c 100644 --- a/TUnit.Core.SourceGenerator/CodeGenerators/Helpers/DataSourceGeneratorRetriever.cs +++ b/TUnit.Core.SourceGenerator/CodeGenerators/Helpers/DataSourceGeneratorRetriever.cs @@ -17,7 +17,7 @@ public static ArgumentsContainer Parse(GeneratorAttributeSyntaxContext context, AttributeData attributeData, ArgumentsType argumentsType, int index, - string? propertyName, + string? propertyName, bool isStronglyTyped) { return new DataSourceGeneratorContainer @@ -44,7 +44,7 @@ .Value.Value as bool? ?? }; } - private static INamedTypeSymbol? GetDataGeneratorAttributeBaseClass(ITypeSymbol? attributeClass) + private static INamedTypeSymbol? GetDataGeneratorAttributeBaseClass(INamedTypeSymbol? attributeClass) { var selfAndBaseTypes = attributeClass?.GetSelfAndBaseTypes(); @@ -60,4 +60,4 @@ private static bool HasGeneratorInterface(ITypeSymbol t) { return t.Interfaces.Select(i => i.GloballyQualified()).Contains(WellKnownFullyQualifiedClassNames.IDataSourceGeneratorAttribute.WithGlobalPrefix); } -} \ No newline at end of file +} diff --git a/TUnit.Core.SourceGenerator/CodeGenerators/Helpers/TypedConstantParser.cs b/TUnit.Core.SourceGenerator/CodeGenerators/Helpers/TypedConstantParser.cs index af2fa7ae05..8836a7d13a 100644 --- a/TUnit.Core.SourceGenerator/CodeGenerators/Helpers/TypedConstantParser.cs +++ b/TUnit.Core.SourceGenerator/CodeGenerators/Helpers/TypedConstantParser.cs @@ -84,13 +84,18 @@ public static string GetRawTypedConstantValue(TypedConstant typedConstant) private static string FormatPrimitive(TypedConstant typedConstant) { - var value = typedConstant.Value; + return FormatPrimitive(typedConstant.Value); + } + + public static string FormatPrimitive(object? value) + { return value switch { string s => $"\"{s}\"", char c => $"'{c}'", bool b => b ? "true" : "false", - _ => value?.ToString() ?? "null" + null => "null", + _ => value.ToString() ?? "null" }; } -} \ No newline at end of file +} diff --git a/TUnit.Core.SourceGenerator/CodeGenerators/TestHooksGenerator.cs b/TUnit.Core.SourceGenerator/CodeGenerators/TestHooksGenerator.cs index 8b402e281a..f14176e88d 100644 --- a/TUnit.Core.SourceGenerator/CodeGenerators/TestHooksGenerator.cs +++ b/TUnit.Core.SourceGenerator/CodeGenerators/TestHooksGenerator.cs @@ -26,14 +26,14 @@ public void Initialize(IncrementalGeneratorInitializationContext context) predicate: static (_, _) => true, transform: static (ctx, _) => GetSemanticTargetForGeneration(ctx, HookLocationType.After, false)) .Where(static m => m is not null); - + var beforeEveryMethods = context.SyntaxProvider .ForAttributeWithMetadataName( "TUnit.Core.BeforeEveryAttribute", predicate: static (s, _) => true, transform: static (ctx, _) => GetSemanticTargetForGeneration(ctx, HookLocationType.Before, true)) .Where(static m => m is not null); - + var afterEveryMethods = context.SyntaxProvider .ForAttributeWithMetadataName( "TUnit.Core.AfterEveryAttribute", @@ -54,10 +54,10 @@ static IEnumerable GetSemanticTargetForGeneration(GeneratorAttri { yield break; } - + var containingType = methodSymbol.ContainingType; IEnumerable classTypes; - + if (containingType.IsGenericDefinition()) { classTypes = [containingType.ConstructUnboundGenericType(), ..GenericTypeHelper.GetConstructedTypes(context.SemanticModel.Compilation, containingType)]; @@ -72,7 +72,7 @@ static IEnumerable GetSemanticTargetForGeneration(GeneratorAttri foreach (var contextAttribute in context.Attributes) { var hookLevel = contextAttribute.ConstructorArguments[0].ToCSharpString(); - + yield return new HooksDataModel { Context = context, @@ -199,9 +199,9 @@ private void Generate(SourceProductionContext productionContext, IEnumerable "RegisterTestDiscoveryHookSource", - "TUnit.Core.HookType.TestSession" => "RegisterTestSessionHookSource", - "TUnit.Core.HookType.Assembly" => "RegisterAssemblyHookSource", - "TUnit.Core.HookType.Class" => "RegisterClassHookSource", - "TUnit.Core.HookType.Test" => "RegisterTestHookSource", + "TUnit.Core.HookType.TestSession" => "RegisterTestSessionHookSource", + "TUnit.Core.HookType.Assembly" => "RegisterAssemblyHookSource", + "TUnit.Core.HookType.Class" => "RegisterClassHookSource", + "TUnit.Core.HookType.Test" => "RegisterTestHookSource", _ => throw new ArgumentOutOfRangeException() }; } @@ -224,19 +224,19 @@ private static string GetInterfaceType(string hookLevel) return hookLevel switch { "TUnit.Core.HookType.TestDiscovery" => "global::TUnit.Core.Interfaces.SourceGenerator.ITestDiscoveryHookSource", - "TUnit.Core.HookType.TestSession" => "global::TUnit.Core.Interfaces.SourceGenerator.ITestSessionHookSource", - "TUnit.Core.HookType.Assembly" => "global::TUnit.Core.Interfaces.SourceGenerator.IAssemblyHookSource", - "TUnit.Core.HookType.Class" => "global::TUnit.Core.Interfaces.SourceGenerator.IClassHookSource", - "TUnit.Core.HookType.Test" => "global::TUnit.Core.Interfaces.SourceGenerator.ITestHookSource", + "TUnit.Core.HookType.TestSession" => "global::TUnit.Core.Interfaces.SourceGenerator.ITestSessionHookSource", + "TUnit.Core.HookType.Assembly" => "global::TUnit.Core.Interfaces.SourceGenerator.IAssemblyHookSource", + "TUnit.Core.HookType.Class" => "global::TUnit.Core.Interfaces.SourceGenerator.IClassHookSource", + "TUnit.Core.HookType.Test" => "global::TUnit.Core.Interfaces.SourceGenerator.ITestHookSource", _ => throw new ArgumentOutOfRangeException() }; } - + private static string GetReturnType(string hookLevel, HookLocationType hookLocationType, bool isEvery) { return hookLevel switch { - "TUnit.Core.HookType.TestDiscovery" + "TUnit.Core.HookType.TestDiscovery" when hookLocationType == HookLocationType.Before => "global::TUnit.Core.Hooks.StaticHookMethod", "TUnit.Core.HookType.TestDiscovery" => "global::TUnit.Core.Hooks.StaticHookMethod", "TUnit.Core.HookType.TestSession" => "global::TUnit.Core.Hooks.StaticHookMethod", @@ -247,21 +247,21 @@ private static string GetReturnType(string hookLevel, HookLocationType hookLocat _ => throw new ArgumentOutOfRangeException() }; } - + private static string GetMethodName(string hookLevel, HookLocationType hookLocationType, bool isEvery) { return hookLevel switch { - "TUnit.Core.HookType.TestDiscovery" + "TUnit.Core.HookType.TestDiscovery" when hookLocationType == HookLocationType.Before => "CollectBeforeTestDiscoveryHooks", - "TUnit.Core.HookType.TestDiscovery" + "TUnit.Core.HookType.TestDiscovery" when hookLocationType == HookLocationType.After => "CollectAfterTestDiscoveryHooks", - - "TUnit.Core.HookType.TestSession" + + "TUnit.Core.HookType.TestSession" when hookLocationType == HookLocationType.Before => "CollectBeforeTestSessionHooks", - "TUnit.Core.HookType.TestSession" + "TUnit.Core.HookType.TestSession" when hookLocationType == HookLocationType.After => "CollectAfterTestSessionHooks", - + "TUnit.Core.HookType.Assembly" when hookLocationType == HookLocationType.Before && isEvery => "CollectBeforeEveryAssemblyHooks", "TUnit.Core.HookType.Assembly" @@ -270,7 +270,7 @@ private static string GetMethodName(string hookLevel, HookLocationType hookLocat when hookLocationType == HookLocationType.After && isEvery => "CollectAfterEveryAssemblyHooks", "TUnit.Core.HookType.Assembly" when hookLocationType == HookLocationType.After => "CollectAfterAssemblyHooks", - + "TUnit.Core.HookType.Class" when hookLocationType == HookLocationType.Before && isEvery => "CollectBeforeEveryClassHooks", "TUnit.Core.HookType.Class" @@ -279,7 +279,7 @@ private static string GetMethodName(string hookLevel, HookLocationType hookLocat when hookLocationType == HookLocationType.After && isEvery => "CollectAfterEveryClassHooks", "TUnit.Core.HookType.Class" when hookLocationType == HookLocationType.After => "CollectAfterClassHooks", - + "TUnit.Core.HookType.Test" when hookLocationType == HookLocationType.Before && isEvery => "CollectBeforeEveryTestHooks", "TUnit.Core.HookType.Test" @@ -288,8 +288,8 @@ private static string GetMethodName(string hookLevel, HookLocationType hookLocat when hookLocationType == HookLocationType.After && isEvery => "CollectAfterEveryTestHooks", "TUnit.Core.HookType.Test" when hookLocationType == HookLocationType.After => "CollectAfterTestHooks", - + _ => throw new ArgumentOutOfRangeException() }; } -} \ No newline at end of file +} diff --git a/TUnit.Core.SourceGenerator/CodeGenerators/TestsGenerator.cs b/TUnit.Core.SourceGenerator/CodeGenerators/TestsGenerator.cs index b47e6b8840..af33d3d64b 100644 --- a/TUnit.Core.SourceGenerator/CodeGenerators/TestsGenerator.cs +++ b/TUnit.Core.SourceGenerator/CodeGenerators/TestsGenerator.cs @@ -17,14 +17,14 @@ public void Initialize(IncrementalGeneratorInitializationContext context) predicate: static (_, _) => true, transform: static (ctx, _) => GetSemanticTargetForTestMethodGeneration(ctx)) .Where(static m => m is not null); - + var inheritedTests = context.SyntaxProvider .ForAttributeWithMetadataName( "TUnit.Core.InheritsTestsAttribute", predicate: static (_, _) => true, transform: static (ctx, _) => GetSemanticTargetForInheritedTestsGeneration(ctx)) .Where(static m => m is not null); - + context.RegisterSourceOutput(standardTests, (sourceContext, data) => GenerateTests(sourceContext, data!)); context.RegisterSourceOutput(inheritedTests, (sourceContext, data) => GenerateTests(sourceContext, data!, "Inherited_")); } @@ -58,14 +58,14 @@ public void Initialize(IncrementalGeneratorInitializationContext context) return new TestCollectionDataModel(methodSymbol.ParseTestDatas(context, methodSymbol.ContainingType)); } - + static TestCollectionDataModel? GetSemanticTargetForInheritedTestsGeneration(GeneratorAttributeSyntaxContext context) { if (context.TargetSymbol is not INamedTypeSymbol namedTypeSymbol) { return null; } - + if (namedTypeSymbol.IsAbstract) { return null; @@ -187,10 +187,10 @@ private void GenerateTests(SourceProductionContext context, TestCollectionDataMo title: "Error Generating Source", messageFormat: "{0}", category: "SourceGenerator", - DiagnosticSeverity.Error, + DiagnosticSeverity.Warning, isEnabledByDefault: true); - + context.ReportDiagnostic(Diagnostic.Create(descriptor, null, ex.ToString())); } } -} \ No newline at end of file +} diff --git a/TUnit.Core.SourceGenerator/CodeGenerators/Writers/SourceInformationWriter.cs b/TUnit.Core.SourceGenerator/CodeGenerators/Writers/SourceInformationWriter.cs index dc40569522..bdac8da4e6 100644 --- a/TUnit.Core.SourceGenerator/CodeGenerators/Writers/SourceInformationWriter.cs +++ b/TUnit.Core.SourceGenerator/CodeGenerators/Writers/SourceInformationWriter.cs @@ -1,5 +1,7 @@ using System.Collections.Immutable; +using System.Reflection; using Microsoft.CodeAnalysis; +using TUnit.Core.SourceGenerator.CodeGenerators.Helpers; using TUnit.Core.SourceGenerator.Enums; using TUnit.Core.SourceGenerator.Extensions; @@ -25,16 +27,16 @@ public static void GenerateClassInformation(SourceCodeWriter sourceCodeWriter, G { sourceCodeWriter.WriteLine("Parent = null,"); } - + sourceCodeWriter.WriteLine($"Type = typeof({namedTypeSymbol.GloballyQualified()}),"); - + sourceCodeWriter.WriteTabs(); sourceCodeWriter.Write("Assembly = "); GenerateAssemblyInformation(sourceCodeWriter, context, namedTypeSymbol.ContainingAssembly); - + sourceCodeWriter.WriteLine($"Name = \"{namedTypeSymbol.Name}\","); sourceCodeWriter.WriteLine($"Namespace = \"{namedTypeSymbol.ContainingNamespace.ToDisplayString()}\","); - + sourceCodeWriter.WriteTabs(); sourceCodeWriter.Write("Attributes = "); AttributeWriter.WriteAttributes(sourceCodeWriter, context, namedTypeSymbol.GetSelfAndBaseTypes().SelectMany(type => type.GetAttributes()).ToImmutableArray()); @@ -43,7 +45,7 @@ public static void GenerateClassInformation(SourceCodeWriter sourceCodeWriter, G sourceCodeWriter.Write("Parameters = "); var parameters = namedTypeSymbol.InstanceConstructors.FirstOrDefault()?.Parameters ?? ImmutableArray.Empty; - + if (parameters.Length == 0) { sourceCodeWriter.Write("[],"); @@ -53,7 +55,7 @@ public static void GenerateClassInformation(SourceCodeWriter sourceCodeWriter, G { sourceCodeWriter.WriteLine(); sourceCodeWriter.WriteLine("["); - + foreach (var parameter in parameters) { sourceCodeWriter.WriteTabs(); @@ -67,7 +69,7 @@ public static void GenerateClassInformation(SourceCodeWriter sourceCodeWriter, G sourceCodeWriter.WriteTabs(); sourceCodeWriter.Write("Properties = "); var properties = namedTypeSymbol.GetMembers().OfType().ToArray(); - + if(properties.Length == 0) { sourceCodeWriter.Write("[],"); @@ -94,11 +96,11 @@ private static void GenerateAssemblyInformation(SourceCodeWriter sourceCodeWrite sourceCodeWriter.WriteLine(); sourceCodeWriter.WriteLine("{"); sourceCodeWriter.WriteLine($"Name = \"{assembly.Name}\","); - + sourceCodeWriter.WriteTabs(); sourceCodeWriter.Write("Attributes = "); AttributeWriter.WriteAttributes(sourceCodeWriter, context, assembly.GetAttributes()); - + sourceCodeWriter.WriteLine("}),"); } @@ -113,7 +115,7 @@ public static void GenerateMethodInformation(SourceCodeWriter sourceCodeWriter, sourceCodeWriter.WriteLine($"Name = \"{methodSymbol.Name}\","); sourceCodeWriter.WriteLine($"GenericTypeCount = {methodSymbol.TypeParameters.Length},"); sourceCodeWriter.WriteLine($"ReturnType = typeof({methodSymbol.ReturnType.GloballyQualified()}),"); - + sourceCodeWriter.WriteTabs(); sourceCodeWriter.Write("Attributes = "); AttributeWriter.WriteAttributes(sourceCodeWriter, context, methodSymbol.GetAttributes()); @@ -121,7 +123,7 @@ public static void GenerateMethodInformation(SourceCodeWriter sourceCodeWriter, sourceCodeWriter.WriteTabs(); sourceCodeWriter.Write("Parameters = "); var parameters = methodSymbol.Parameters; - + if (parameters.Length == 0) { sourceCodeWriter.Write("[],"); @@ -131,7 +133,7 @@ public static void GenerateMethodInformation(SourceCodeWriter sourceCodeWriter, { sourceCodeWriter.WriteLine(); sourceCodeWriter.WriteLine("["); - + foreach (var parameter in parameters) { sourceCodeWriter.WriteTabs(); @@ -141,9 +143,9 @@ public static void GenerateMethodInformation(SourceCodeWriter sourceCodeWriter, sourceCodeWriter.WriteLine("],"); } - + sourceCodeWriter.WriteTabs(); - + sourceCodeWriter.Write("Class = "); GenerateClassInformation(sourceCodeWriter, context, namedTypeSymbol); @@ -160,7 +162,7 @@ public static void GenerateMembers(SourceCodeWriter sourceCodeWriter, GeneratorA sourceCodeWriter.WriteLine(); return; } - + sourceCodeWriter.WriteLine(); sourceCodeWriter.WriteLine("["); @@ -175,7 +177,7 @@ public static void GenerateMembers(SourceCodeWriter sourceCodeWriter, GeneratorA sourceCodeWriter.WriteTabs(); GenerateParameterInformation(sourceCodeWriter, context, parameter, argumentsType, null); } - + sourceCodeWriter.WriteLine("],"); } @@ -198,27 +200,59 @@ public static void GeneratePropertyInformation(SourceCodeWriter sourceCodeWriter public static void GenerateParameterInformation(SourceCodeWriter sourceCodeWriter, GeneratorAttributeSyntaxContext context, - IParameterSymbol parameter, ArgumentsType argumentsType, IDictionary? genericSubstitutions) + IParameterSymbol parameter, ArgumentsType argumentsType, + IDictionary? genericSubstitutions) { var type = parameter.Type.GloballyQualified(); if (parameter.Type.IsGenericDefinition()) { - type = genericSubstitutions?.TryGetValue(type, out var substitution) == true - ? substitution - // We can't find the generic type - Fall back to object - : "object"; + type = GetTypeOrSubstitution(parameter.Type); } sourceCodeWriter.Write($"new global::TUnit.Core.SourceGeneratedParameterInformation<{type}>"); sourceCodeWriter.WriteLine(); sourceCodeWriter.WriteLine("{"); sourceCodeWriter.WriteLine($"Name = \"{parameter.Name}\","); - + sourceCodeWriter.WriteTabs(); sourceCodeWriter.Write("Attributes = "); AttributeWriter.WriteAttributes(sourceCodeWriter, context, parameter.GetAttributes()); - + + // TODO: Struggling to get this to work with generic type parameters + sourceCodeWriter.WriteLine("ReflectionInfo = null!,"); + + // if(argumentsType == ArgumentsType.ClassConstructor) + // { + // var methodSymbol = (IMethodSymbol)parameter.ContainingSymbol; + // var parameterTypesString = string.Join(", ", methodSymbol.Parameters.Select(p => $"typeof({GetTypeOrSubstitution(p.Type)})")); + // var containingType = methodSymbol.ContainingType.GloballyQualified(); + // var parameterIndex = parameter.Ordinal; + // + // sourceCodeWriter.WriteLine($"ReflectionInfo = global::TUnit.Core.Helpers.RobustParameterInfoRetriever.GetConstructorParameterInfo(typeof({containingType}), new Type[] {{{parameterTypesString}}}, {parameterIndex}, typeof({parameter.Type.GloballyQualified()}), \"{parameter.Name}\"),"); + // } + // + // if (argumentsType == ArgumentsType.Method) + // { + // var methodSymbol = (IMethodSymbol)parameter.ContainingSymbol; + // var parameterTypesString = string.Join(", ", methodSymbol.Parameters.Select(p => $"typeof({GetTypeOrSubstitution(p.Type)})")); + // var containingType = parameter.ContainingSymbol.ContainingType.GloballyQualified(); + // var methodName = parameter.ContainingSymbol.Name; + // var parameterIndex = parameter.Ordinal; + // var isStatic = methodSymbol.IsStatic; + // var genericParameterCount = methodSymbol.TypeParameters.Length; + // + // sourceCodeWriter.WriteLine($"ReflectionInfo = global::TUnit.Core.Helpers.RobustParameterInfoRetriever.GetMethodParameterInfo(typeof({containingType}), \"{methodName}\", {parameterIndex}, new Type[] {{{parameterTypesString}}}, {isStatic.ToString().ToLowerInvariant()}, {genericParameterCount}),"); + // } + sourceCodeWriter.WriteLine("},"); + + string GetTypeOrSubstitution(ITypeSymbol type) + { + return genericSubstitutions?.TryGetValue(type.GloballyQualified(), out var substitution) == true + ? substitution + // We can't find the generic type - Fall back to object + : "object"; + } } -} \ No newline at end of file +} diff --git a/TUnit.Core.SourceGenerator/Extensions/TypeExtensions.cs b/TUnit.Core.SourceGenerator/Extensions/TypeExtensions.cs index 320c8f9406..7228e0306a 100644 --- a/TUnit.Core.SourceGenerator/Extensions/TypeExtensions.cs +++ b/TUnit.Core.SourceGenerator/Extensions/TypeExtensions.cs @@ -26,12 +26,12 @@ public static class TypeExtensions { "System.Object", "object" }, { "System.String", "string" } }; - + public static string GetMetadataName(this Type type) { return $"{type.Namespace}.{type.Name}"; } - + public static IEnumerable GetMembersIncludingBase(this ITypeSymbol namedTypeSymbol, bool reverse = true) { var list = new List(); @@ -49,11 +49,11 @@ public static IEnumerable GetMembersIncludingBase(this ITypeSymbol name { break; } - + list.AddRange(reverse ? symbol.GetMembers().Reverse() : symbol.GetMembers()); symbol = symbol.BaseType; } - + if (reverse) { list.Reverse(); @@ -61,53 +61,53 @@ public static IEnumerable GetMembersIncludingBase(this ITypeSymbol name return list; } - - public static IEnumerable GetSelfAndBaseTypes(this ITypeSymbol namedTypeSymbol) + + public static IEnumerable GetSelfAndBaseTypes(this INamedTypeSymbol namedTypeSymbol) { return [namedTypeSymbol, ..GetBaseTypes(namedTypeSymbol)]; } - public static IEnumerable GetBaseTypes(this ITypeSymbol namedTypeSymbol) + public static IEnumerable GetBaseTypes(this ITypeSymbol namedTypeSymbol) { var type = namedTypeSymbol.BaseType; - + while (type != null && type.SpecialType != SpecialType.System_Object) { yield return type; type = type.BaseType; } } - - public static IEnumerable GetAttributesIncludingBaseTypes(this ITypeSymbol namedTypeSymbol) + + public static IEnumerable GetAttributesIncludingBaseTypes(this INamedTypeSymbol namedTypeSymbol) { return GetSelfAndBaseTypes(namedTypeSymbol).SelectMany(x => x.GetAttributes()); } - public static bool IsOrInherits(this ITypeSymbol namedTypeSymbol, string typeName) + public static bool IsOrInherits(this INamedTypeSymbol namedTypeSymbol, string typeName) { return namedTypeSymbol .GetSelfAndBaseTypes() .Any(x => x.GloballyQualifiedNonGeneric() == typeName); } - - public static bool IsOrInherits(this ITypeSymbol namedTypeSymbol, [NotNullWhen(true)] ITypeSymbol? inheritedType) + + public static bool IsOrInherits(this INamedTypeSymbol namedTypeSymbol, [NotNullWhen(true)] ITypeSymbol? inheritedType) { if (inheritedType is null) { return false; } - + return namedTypeSymbol .GetSelfAndBaseTypes() .Any(x => SymbolEqualityComparer.Default.Equals(x, inheritedType)); } - + public static bool IsIEnumerable(this ITypeSymbol namedTypeSymbol, Compilation compilation, [NotNullWhen(true)] out ITypeSymbol? innerType) { var interfaces = namedTypeSymbol.TypeKind == TypeKind.Interface ? [(INamedTypeSymbol)namedTypeSymbol, ..namedTypeSymbol.AllInterfaces] : namedTypeSymbol.AllInterfaces.AsEnumerable(); - + foreach (var enumerable in interfaces .Where(x => x.IsGenericType) .Where(x => SymbolEqualityComparer.Default.Equals(x.OriginalDefinition, compilation.GetSpecialType(SpecialType.System_Collections_Generic_IEnumerable_T)))) @@ -115,18 +115,18 @@ public static bool IsIEnumerable(this ITypeSymbol namedTypeSymbol, Compilation c innerType = enumerable.TypeArguments[0]; return true; } - + innerType = null; return false; } - + public static string GloballyQualifiedOrFallback(this ITypeSymbol? typeSymbol, TypedConstant? typedConstant = null) { if (typeSymbol is not null and not ITypeParameterSymbol) { return typeSymbol.GloballyQualified(); } - + if (typedConstant is not null) { return TypedConstantParser.GetFullyQualifiedTypeNameFromTypedConstantValue(typedConstant.Value); @@ -157,10 +157,10 @@ public static bool EnumerableGenericTypeIs(this ITypeSymbol enumerable, Generato var enumerableInterface = enumerable.AllInterfaces.FirstOrDefault(x => x.IsGenericType && x.ConstructUnboundGenericType() .Equals(genericEnumerableType, SymbolEqualityComparer.Default)); - + enumerableInnerType = enumerableInterface?.TypeArguments.FirstOrDefault(); } - + if (enumerableInnerType is null) { enumerableInnerType = null; @@ -168,12 +168,12 @@ public static bool EnumerableGenericTypeIs(this ITypeSymbol enumerable, Generato } var firstParameterType = parameterTypes.FirstOrDefault(); - + if (context.SemanticModel.Compilation.HasImplicitConversionOrGenericParameter(enumerableInnerType, firstParameterType)) { return true; } - + if (!enumerableInnerType.IsTupleType && firstParameterType is INamedTypeSymbol { IsGenericType:true }) { return true; @@ -192,7 +192,7 @@ public static bool EnumerableGenericTypeIs(this ITypeSymbol enumerable, Generato { continue; } - + if (!context.SemanticModel.Compilation.HasImplicitConversionOrGenericParameter(tupleType, parameterType)) { return false; @@ -201,13 +201,13 @@ public static bool EnumerableGenericTypeIs(this ITypeSymbol enumerable, Generato return true; } - + return false; } - + public static string GloballyQualified(this ISymbol typeSymbol) => typeSymbol.ToDisplayString(DisplayFormats.FullyQualifiedGenericWithGlobalPrefix); - + public static string GloballyQualifiedNonGeneric(this ISymbol typeSymbol) => typeSymbol.ToDisplayString(DisplayFormats.FullyQualifiedNonGenericWithGlobalPrefix); @@ -217,7 +217,7 @@ public static bool IsGenericDefinition(this ITypeSymbol typeSymbol) { return true; } - + if (typeSymbol is not INamedTypeSymbol namedTypeSymbol) { return false; @@ -230,7 +230,7 @@ public static bool IsGenericDefinition(this ITypeSymbol typeSymbol) return namedTypeSymbol.TypeArguments.Any(IsGenericDefinition); } - + public static bool IsCollectionType(this ITypeSymbol typeSymbol, Compilation compilation, [NotNullWhen(true)] out ITypeSymbol? innerType) { if (typeSymbol.SpecialType == SpecialType.System_String) @@ -247,7 +247,7 @@ public static bool IsCollectionType(this ITypeSymbol typeSymbol, Compilation com } var enumerableT = compilation.GetSpecialType(SpecialType.System_Collections_Generic_IEnumerable_T); - + if (typeSymbol is INamedTypeSymbol namedTypeSymbol && SymbolEqualityComparer.Default.Equals(typeSymbol.OriginalDefinition, enumerableT)) { @@ -266,4 +266,4 @@ public static bool IsCollectionType(this ITypeSymbol typeSymbol, Compilation com innerType = null; return false; } -} \ No newline at end of file +} diff --git a/TUnit.Core/AsyncConvert.cs b/TUnit.Core/AsyncConvert.cs index 0a85efae91..b6d4d36d5d 100644 --- a/TUnit.Core/AsyncConvert.cs +++ b/TUnit.Core/AsyncConvert.cs @@ -10,7 +10,7 @@ namespace TUnit.Core; public static class AsyncConvert { private static Type? _fSharpAsyncType; - + [MethodImpl(MethodImplOptions.AggressiveInlining #if NET | MethodImplOptions.AggressiveOptimization @@ -31,7 +31,7 @@ public static ValueTask Convert(Func action) { return action(); } - + [MethodImpl(MethodImplOptions.AggressiveInlining #if NET | MethodImplOptions.AggressiveOptimization @@ -60,31 +60,31 @@ public static ValueTask ConvertObject(object? invoke) { return default; } - + if (invoke is Func syncFunc) { syncFunc(); return default; } - + if (invoke is Func asyncFunc) { return Convert(asyncFunc); } - + if (invoke is Func asyncValueFunc) { return Convert(asyncValueFunc); } - - + + if (invoke is Task task) { if(task is { IsCompleted: true, IsFaulted: false }) { return default; } - + if(task.IsFaulted || !task.IsCompleted) { return new ValueTask(task); @@ -96,16 +96,28 @@ public static ValueTask ConvertObject(object? invoke) return valueTask; } + // If it has a GetAwaiter method, we can assume it's an awaitable type + if (TryGetAwaitableTask(invoke, out var awaitable)) + { + if (awaitable is { IsCompleted: true, IsFaulted: false }) + { + return default; + } + + return new ValueTask(awaitable); + } + var type = invoke.GetType(); - if (type.IsGenericType + if (type.IsGenericType && type.GetGenericTypeDefinition().FullName == "Microsoft.FSharp.Control.FSharpAsync`1") { return StartAsFSharpTask(invoke, type); } - throw new ArgumentException("Invalid object type: " + type.Name, nameof(invoke)); + // We can assume it's not awaitable, and so the invocation should have completed synchronously. + return default; } - + [UnconditionalSuppressMessage("Trimming", "IL2077:Target parameter argument does not satisfy \'DynamicallyAccessedMembersAttribute\' in call to target method. The source field does not have matching annotations.")] [UnconditionalSuppressMessage("Trimming", "IL2072:Target parameter argument does not satisfy \'DynamicallyAccessedMembersAttribute\' in call to target method. The return value of the source method does not have matching annotations.")] [UnconditionalSuppressMessage("AOT", "IL3050:Calling members annotated with \'RequiresDynamicCodeAttribute\' may break functionality when AOT compiling.")] @@ -119,7 +131,59 @@ private static ValueTask StartAsFSharpTask(object invoke, Type type) var fSharpTask = (Task)startAsTaskOpenGenericMethod.MakeGenericMethod(type.GetGenericArguments()[0]) .Invoke(null, [invoke, null, null])!; - + return new ValueTask(fSharpTask); } -} \ No newline at end of file + + [UnconditionalSuppressMessage("Trimming", "IL2075:\'this\' argument does not satisfy \'DynamicallyAccessedMembersAttribute\' in call to target method. The return value of the source method does not have matching annotations.")] + public static bool TryGetAwaitableTask(object awaitable, [NotNullWhen(true)] out Task? task) + { + var getAwaiter = awaitable.GetType().GetMethod("GetAwaiter", Type.EmptyTypes); + + if (getAwaiter == null) + { + task = null; + return false; + } + + var awaiter = getAwaiter.Invoke(awaitable, null); + + if (awaiter == null) + { + task = null; + return false; + } + + var isCompletedProp = awaiter.GetType().GetProperty("IsCompleted"); + + if (isCompletedProp == null) + { + task = null; + return false; + } + + var isCompleted = isCompletedProp.GetValue(awaiter) as bool?; + + if (isCompleted == true) + { + task = Task.CompletedTask; + return true; + } + + if(!isCompleted.HasValue) + { + task = null; + return false; + } + + var tcs = new TaskCompletionSource(); + + var onCompleted = awaiter.GetType().GetMethod("OnCompleted", [typeof(Action)]); + + onCompleted!.Invoke(awaiter, [new Action(() => tcs.SetResult(null))]); + + task = tcs.Task; + + return true; + } +} diff --git a/TUnit.Core/Attributes/TestData/ClassDataSourceAttribute.cs b/TUnit.Core/Attributes/TestData/ClassDataSourceAttribute.cs index fb0724b486..744971d5df 100644 --- a/TUnit.Core/Attributes/TestData/ClassDataSourceAttribute.cs +++ b/TUnit.Core/Attributes/TestData/ClassDataSourceAttribute.cs @@ -3,10 +3,13 @@ namespace TUnit.Core; [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method | AttributeTargets.Property, AllowMultiple = true)] -public sealed class ClassDataSourceAttribute<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicProperties)] T> : DataSourceGeneratorAttribute +public sealed class ClassDataSourceAttribute<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicProperties)] T> + : DataSourceGeneratorAttribute, + ISharedDataSourceAttribute { public SharedType Shared { get; set; } = SharedType.None; public string Key { get; set; } = string.Empty; + public Type ClassType => typeof(T); public override IEnumerable> GenerateDataSources(DataGeneratorMetadata dataGeneratorMetadata) { yield return () => @@ -33,12 +36,12 @@ await ClassDataSources.Get(dataGeneratorMetadata.TestSessionId).OnInitialize( Key, item); }; - + dataGeneratorMetadata.TestBuilderContext.Current.Events.OnTestStart += async (obj, context) => { await ClassDataSources.Get(dataGeneratorMetadata.TestSessionId).OnTestStart(context, item); }; - + dataGeneratorMetadata.TestBuilderContext.Current.Events.OnTestEnd += async (obj, context) => { await ClassDataSources.Get(dataGeneratorMetadata.TestSessionId).OnTestEnd(context, item); @@ -48,48 +51,52 @@ await ClassDataSources.Get(dataGeneratorMetadata.TestSessionId).OnInitialize( { await ClassDataSources.Get(dataGeneratorMetadata.TestSessionId).OnDispose(context, Shared, Key, item); }; - + dataGeneratorMetadata.TestBuilderContext.Current.Events.OnDispose += async (obj, context) => { await ClassDataSources.Get(dataGeneratorMetadata.TestSessionId).OnDispose(context, Shared, Key, item); }; - + return item; }; } + + public IEnumerable GetSharedTypes() => [Shared]; + + public IEnumerable GetKeys() => string.IsNullOrEmpty(Key) ? [] : [Key]; } [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method | AttributeTargets.Property, AllowMultiple = true)] -public sealed class ClassDataSourceAttribute : NonTypedDataSourceGeneratorAttribute +public sealed class ClassDataSourceAttribute : NonTypedDataSourceGeneratorAttribute, ISharedDataSourceAttribute { private readonly Type[] _types; - + [UnconditionalSuppressMessage("Trimming", "IL2026:Members annotated with 'RequiresUnreferencedCodeAttribute' require dynamic access otherwise can break functionality when trimming application code", Justification = "")] [UnconditionalSuppressMessage("AOT", "IL3050:Calling members annotated with \'RequiresDynamicCodeAttribute\' may break functionality when AOT compiling.")] public ClassDataSourceAttribute( - [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicProperties)] + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicProperties)] Type type) : this([type]) { } - + [UnconditionalSuppressMessage("Trimming", "IL2026:Members annotated with 'RequiresUnreferencedCodeAttribute' require dynamic access otherwise can break functionality when trimming application code", Justification = "")] [UnconditionalSuppressMessage("AOT", "IL3050:Calling members annotated with \'RequiresDynamicCodeAttribute\' may break functionality when AOT compiling.")] public ClassDataSourceAttribute( - [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicProperties)] + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicProperties)] Type type, - [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicProperties)] + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicProperties)] Type type2) : this([type, type2]) { } - + [UnconditionalSuppressMessage("Trimming", "IL2026:Members annotated with 'RequiresUnreferencedCodeAttribute' require dynamic access otherwise can break functionality when trimming application code", Justification = "")] [UnconditionalSuppressMessage("AOT", "IL3050:Calling members annotated with \'RequiresDynamicCodeAttribute\' may break functionality when AOT compiling.")] public ClassDataSourceAttribute( - [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicProperties)] + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicProperties)] Type type, - [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicProperties)] + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicProperties)] Type type2, - [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicProperties)] + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicProperties)] Type type3) : this([type, type2, type3]) { } @@ -97,13 +104,13 @@ public ClassDataSourceAttribute( [UnconditionalSuppressMessage("Trimming", "IL2026:Members annotated with 'RequiresUnreferencedCodeAttribute' require dynamic access otherwise can break functionality when trimming application code", Justification = "")] [UnconditionalSuppressMessage("AOT", "IL3050:Calling members annotated with \'RequiresDynamicCodeAttribute\' may break functionality when AOT compiling.")] public ClassDataSourceAttribute( - [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicProperties)] + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicProperties)] Type type, - [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicProperties)] + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicProperties)] Type type2, - [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicProperties)] + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicProperties)] Type type3, - [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicProperties)] + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicProperties)] Type type4) : this([type, type2, type3, type4]) { } @@ -111,19 +118,19 @@ public ClassDataSourceAttribute( [UnconditionalSuppressMessage("Trimming", "IL2026:Members annotated with 'RequiresUnreferencedCodeAttribute' require dynamic access otherwise can break functionality when trimming application code", Justification = "")] [UnconditionalSuppressMessage("AOT", "IL3050:Calling members annotated with \'RequiresDynamicCodeAttribute\' may break functionality when AOT compiling.")] public ClassDataSourceAttribute( - [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicProperties)] + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicProperties)] Type type, - [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicProperties)] + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicProperties)] Type type2, - [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicProperties)] + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicProperties)] Type type3, - [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicProperties)] + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicProperties)] Type type4, - [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicProperties)] + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicProperties)] Type type5) : this([type, type2, type3, type4, type5]) { } - + [RequiresUnreferencedCode("Reflection")] [RequiresDynamicCode("Reflection")] public ClassDataSourceAttribute(params Type[] types) @@ -131,22 +138,22 @@ public ClassDataSourceAttribute(params Type[] types) _types = types; } - public SharedType Shared { get; set; } = SharedType.None; - public string Key { get; set; } = string.Empty; - + public SharedType[] Shared { get; set; } = [SharedType.None]; + public string[] Keys { get; set; } = []; + [UnconditionalSuppressMessage("Trimming", "IL2062:The parameter of method has a DynamicallyAccessedMembersAttribute, but the value passed to it can not be statically analyzed.")] public override IEnumerable> GenerateDataSources(DataGeneratorMetadata dataGeneratorMetadata) { yield return () => { var items = new object?[_types.Length]; - + for (var i = 0; i < _types.Length; i++) { items[i] = ClassDataSources.Get(dataGeneratorMetadata.TestSessionId) - .Get(Shared, _types[i], dataGeneratorMetadata.TestClassType, Key, dataGeneratorMetadata); + .Get(Shared.ElementAtOrDefault(0), _types[i], dataGeneratorMetadata.TestClassType, Keys.ElementAtOrDefault(0), dataGeneratorMetadata); } - + dataGeneratorMetadata.TestBuilderContext.Current.Events.OnTestRegistered += async (obj, context) => { foreach (var item in items) @@ -154,8 +161,8 @@ public ClassDataSourceAttribute(params Type[] types) await ClassDataSources.Get(dataGeneratorMetadata.TestSessionId).OnTestRegistered( context.TestContext, ClassDataSources.IsStaticProperty(dataGeneratorMetadata), - Shared, - Key, + Shared.ElementAtOrDefault(0), + Keys.ElementAtOrDefault(0), item); } }; @@ -167,12 +174,12 @@ await ClassDataSources.Get(dataGeneratorMetadata.TestSessionId).OnTestRegistered await ClassDataSources.Get(dataGeneratorMetadata.TestSessionId).OnInitialize( context, ClassDataSources.IsStaticProperty(dataGeneratorMetadata), - Shared, - Key, + Shared.ElementAtOrDefault(0), + Keys.ElementAtOrDefault(0), item); } }; - + dataGeneratorMetadata.TestBuilderContext.Current.Events.OnTestStart += async (obj, context) => { foreach (var item in items) @@ -180,7 +187,7 @@ await ClassDataSources.Get(dataGeneratorMetadata.TestSessionId).OnInitialize( await ClassDataSources.Get(dataGeneratorMetadata.TestSessionId).OnTestStart(context, item); } }; - + dataGeneratorMetadata.TestBuilderContext.Current.Events.OnTestEnd += async (obj, context) => { foreach (var item in items) @@ -193,19 +200,23 @@ await ClassDataSources.Get(dataGeneratorMetadata.TestSessionId).OnInitialize( { foreach (var item in items) { - await ClassDataSources.Get(dataGeneratorMetadata.TestSessionId).OnDispose(context, Shared, Key, item); + await ClassDataSources.Get(dataGeneratorMetadata.TestSessionId).OnDispose(context, Shared.ElementAtOrDefault(0), Keys.ElementAtOrDefault(0), item); } }; - + dataGeneratorMetadata.TestBuilderContext.Current.Events.OnDispose += async (obj, context) => { foreach (var item in items) { - await ClassDataSources.Get(dataGeneratorMetadata.TestSessionId).OnDispose(context, Shared, Key, item); + await ClassDataSources.Get(dataGeneratorMetadata.TestSessionId).OnDispose(context, Shared.ElementAtOrDefault(0), Keys.ElementAtOrDefault(0), item); } }; - + return items; }; } -} \ No newline at end of file + + public IEnumerable GetSharedTypes() => Shared; + + public IEnumerable GetKeys() => Keys; +} diff --git a/TUnit.Core/Attributes/TestData/ClassDataSourceAttribute_2.cs b/TUnit.Core/Attributes/TestData/ClassDataSourceAttribute_2.cs index 764da0fabd..e8a72aab88 100644 --- a/TUnit.Core/Attributes/TestData/ClassDataSourceAttribute_2.cs +++ b/TUnit.Core/Attributes/TestData/ClassDataSourceAttribute_2.cs @@ -4,15 +4,15 @@ namespace TUnit.Core; [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true)] public sealed class ClassDataSourceAttribute< - [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicProperties)] T1, + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicProperties)] T1, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicProperties)] T2> - : DataSourceGeneratorAttribute + : DataSourceGeneratorAttribute, ISharedDataSourceAttribute where T1 : new() where T2 : new() { public SharedType[] Shared { get; set; } = [SharedType.None, SharedType.None, SharedType.None, SharedType.None, SharedType.None]; public string[] Keys { get; set; } = [string.Empty, string.Empty, string.Empty, string.Empty, string.Empty]; - + public override IEnumerable> GenerateDataSources(DataGeneratorMetadata dataGeneratorMetadata) { yield return () => @@ -62,29 +62,29 @@ await ClassDataSources.Get(dataGeneratorMetadata.TestSessionId).OnInitialize( itemsWithMetadata.Item2.Key, itemsWithMetadata.Item2.T); }; - + dataGeneratorMetadata.TestBuilderContext.Current.Events.OnTestStart += async (obj, context) => { await ClassDataSources.Get(dataGeneratorMetadata.TestSessionId).OnTestStart(context, itemsWithMetadata.Item1.T); await ClassDataSources.Get(dataGeneratorMetadata.TestSessionId).OnTestStart(context, itemsWithMetadata.Item2.T); }; - + dataGeneratorMetadata.TestBuilderContext.Current.Events.OnTestEnd += async (obj, context) => { await ClassDataSources.Get(dataGeneratorMetadata.TestSessionId).OnTestEnd(context, itemsWithMetadata.Item1.T); await ClassDataSources.Get(dataGeneratorMetadata.TestSessionId).OnTestEnd(context, itemsWithMetadata.Item2.T); }; - + dataGeneratorMetadata.TestBuilderContext.Current.Events.OnTestSkipped += async (obj, context) => { await ClassDataSources.Get(dataGeneratorMetadata.TestSessionId).OnDispose( - context, + context, itemsWithMetadata.Item1.SharedType, itemsWithMetadata.Item1.Key, itemsWithMetadata.Item1.T); await ClassDataSources.Get(dataGeneratorMetadata.TestSessionId).OnDispose( - context, + context, itemsWithMetadata.Item2.SharedType, itemsWithMetadata.Item2.Key, itemsWithMetadata.Item2.T); @@ -93,13 +93,13 @@ await ClassDataSources.Get(dataGeneratorMetadata.TestSessionId).OnDispose( dataGeneratorMetadata.TestBuilderContext.Current.Events.OnDispose += async (obj, context) => { await ClassDataSources.Get(dataGeneratorMetadata.TestSessionId).OnDispose( - context, + context, itemsWithMetadata.Item1.SharedType, itemsWithMetadata.Item1.Key, itemsWithMetadata.Item1.T); await ClassDataSources.Get(dataGeneratorMetadata.TestSessionId).OnDispose( - context, + context, itemsWithMetadata.Item2.SharedType, itemsWithMetadata.Item2.Key, itemsWithMetadata.Item2.T); @@ -111,4 +111,8 @@ await ClassDataSources.Get(dataGeneratorMetadata.TestSessionId).OnDispose( ); }; } -} \ No newline at end of file + + public IEnumerable GetSharedTypes() => Shared; + + public IEnumerable GetKeys() => Keys; +} diff --git a/TUnit.Core/Attributes/TestData/ClassDataSourceAttribute_3.cs b/TUnit.Core/Attributes/TestData/ClassDataSourceAttribute_3.cs index 08b2fcf32a..11cf3f0583 100644 --- a/TUnit.Core/Attributes/TestData/ClassDataSourceAttribute_3.cs +++ b/TUnit.Core/Attributes/TestData/ClassDataSourceAttribute_3.cs @@ -4,17 +4,17 @@ namespace TUnit.Core; [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true)] public sealed class ClassDataSourceAttribute< - [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicProperties)] T1, - [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicProperties)] T2, + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicProperties)] T1, + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicProperties)] T2, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicProperties)] T3> - : DataSourceGeneratorAttribute + : DataSourceGeneratorAttribute, ISharedDataSourceAttribute where T1 : new() where T2 : new() where T3 : new() { public SharedType[] Shared { get; set; } = [SharedType.None, SharedType.None, SharedType.None, SharedType.None, SharedType.None]; public string[] Keys { get; set; } = [string.Empty, string.Empty, string.Empty, string.Empty, string.Empty]; - + public override IEnumerable> GenerateDataSources(DataGeneratorMetadata dataGeneratorMetadata) { yield return () => @@ -81,14 +81,14 @@ await ClassDataSources.Get(dataGeneratorMetadata.TestSessionId).OnInitialize( itemsWithMetadata.Item3.Key, itemsWithMetadata.Item3.T); }; - + dataGeneratorMetadata.TestBuilderContext.Current.Events.OnTestStart += async (obj, context) => { await ClassDataSources.Get(dataGeneratorMetadata.TestSessionId).OnTestStart(context, itemsWithMetadata.Item1.T); await ClassDataSources.Get(dataGeneratorMetadata.TestSessionId).OnTestStart(context, itemsWithMetadata.Item2.T); await ClassDataSources.Get(dataGeneratorMetadata.TestSessionId).OnTestStart(context, itemsWithMetadata.Item2.T); }; - + dataGeneratorMetadata.TestBuilderContext.Current.Events.OnTestEnd += async (obj, context) => { await ClassDataSources.Get(dataGeneratorMetadata.TestSessionId).OnTestEnd(context, itemsWithMetadata.Item1.T); @@ -99,45 +99,45 @@ await ClassDataSources.Get(dataGeneratorMetadata.TestSessionId).OnInitialize( dataGeneratorMetadata.TestBuilderContext.Current.Events.OnTestSkipped += async (obj, context) => { await ClassDataSources.Get(dataGeneratorMetadata.TestSessionId).OnDispose( - context, + context, itemsWithMetadata.Item1.SharedType, itemsWithMetadata.Item1.Key, itemsWithMetadata.Item1.T); await ClassDataSources.Get(dataGeneratorMetadata.TestSessionId).OnDispose( - context, + context, itemsWithMetadata.Item2.SharedType, itemsWithMetadata.Item2.Key, itemsWithMetadata.Item2.T); await ClassDataSources.Get(dataGeneratorMetadata.TestSessionId).OnDispose( - context, + context, itemsWithMetadata.Item3.SharedType, itemsWithMetadata.Item3.Key, itemsWithMetadata.Item3.T); }; - + dataGeneratorMetadata.TestBuilderContext.Current.Events.OnDispose += async (obj, context) => { await ClassDataSources.Get(dataGeneratorMetadata.TestSessionId).OnDispose( - context, + context, itemsWithMetadata.Item1.SharedType, itemsWithMetadata.Item1.Key, itemsWithMetadata.Item1.T); await ClassDataSources.Get(dataGeneratorMetadata.TestSessionId).OnDispose( - context, + context, itemsWithMetadata.Item2.SharedType, itemsWithMetadata.Item2.Key, itemsWithMetadata.Item2.T); await ClassDataSources.Get(dataGeneratorMetadata.TestSessionId).OnDispose( - context, + context, itemsWithMetadata.Item3.SharedType, itemsWithMetadata.Item3.Key, itemsWithMetadata.Item3.T); }; - + return ( itemsWithMetadata.Item1.T, itemsWithMetadata.Item2.T, @@ -145,4 +145,8 @@ await ClassDataSources.Get(dataGeneratorMetadata.TestSessionId).OnDispose( ); }; } -} \ No newline at end of file + + public IEnumerable GetSharedTypes() => Shared; + + public IEnumerable GetKeys() => Keys; +} diff --git a/TUnit.Core/Attributes/TestData/ClassDataSourceAttribute_4.cs b/TUnit.Core/Attributes/TestData/ClassDataSourceAttribute_4.cs index dd674e909f..1cf58b3678 100644 --- a/TUnit.Core/Attributes/TestData/ClassDataSourceAttribute_4.cs +++ b/TUnit.Core/Attributes/TestData/ClassDataSourceAttribute_4.cs @@ -4,11 +4,11 @@ namespace TUnit.Core; [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true)] public sealed class ClassDataSourceAttribute< - [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicProperties)] T1, - [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicProperties)] T2, - [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicProperties)] T3, + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicProperties)] T1, + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicProperties)] T2, + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicProperties)] T3, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicProperties)] T4> - : DataSourceGeneratorAttribute + : DataSourceGeneratorAttribute, ISharedDataSourceAttribute where T1 : new() where T2 : new() where T3 : new() @@ -16,7 +16,7 @@ public sealed class ClassDataSourceAttribute< { public SharedType[] Shared { get; set; } = [SharedType.None, SharedType.None, SharedType.None, SharedType.None, SharedType.None]; public string[] Keys { get; set; } = [string.Empty, string.Empty, string.Empty, string.Empty, string.Empty]; - + public override IEnumerable> GenerateDataSources(DataGeneratorMetadata dataGeneratorMetadata) { yield return () => @@ -100,7 +100,7 @@ await ClassDataSources.Get(dataGeneratorMetadata.TestSessionId).OnInitialize( itemsWithMetadata.Item4.Key, itemsWithMetadata.Item4.T); }; - + dataGeneratorMetadata.TestBuilderContext.Current.Events.OnTestStart += async (obj, context) => { await ClassDataSources.Get(dataGeneratorMetadata.TestSessionId).OnTestStart(context, itemsWithMetadata.Item1.T); @@ -108,7 +108,7 @@ await ClassDataSources.Get(dataGeneratorMetadata.TestSessionId).OnInitialize( await ClassDataSources.Get(dataGeneratorMetadata.TestSessionId).OnTestStart(context, itemsWithMetadata.Item2.T); await ClassDataSources.Get(dataGeneratorMetadata.TestSessionId).OnTestStart(context, itemsWithMetadata.Item4.T); }; - + dataGeneratorMetadata.TestBuilderContext.Current.Events.OnTestEnd += async (obj, context) => { await ClassDataSources.Get(dataGeneratorMetadata.TestSessionId).OnTestEnd(context, itemsWithMetadata.Item1.T); @@ -143,7 +143,7 @@ await ClassDataSources.Get(dataGeneratorMetadata.TestSessionId).OnDispose( itemsWithMetadata.Item4.Key, itemsWithMetadata.Item4.T); }; - + dataGeneratorMetadata.TestBuilderContext.Current.Events.OnDispose += async (obj, context) => { await ClassDataSources.Get(dataGeneratorMetadata.TestSessionId).OnDispose( @@ -179,4 +179,8 @@ await ClassDataSources.Get(dataGeneratorMetadata.TestSessionId).OnDispose( ); }; } -} \ No newline at end of file + + public IEnumerable GetSharedTypes() => Shared; + + public IEnumerable GetKeys() => Keys; +} diff --git a/TUnit.Core/Attributes/TestData/ClassDataSourceAttribute_5.cs b/TUnit.Core/Attributes/TestData/ClassDataSourceAttribute_5.cs index fd22895eef..19b4895602 100644 --- a/TUnit.Core/Attributes/TestData/ClassDataSourceAttribute_5.cs +++ b/TUnit.Core/Attributes/TestData/ClassDataSourceAttribute_5.cs @@ -4,12 +4,12 @@ namespace TUnit.Core; [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true)] public sealed class ClassDataSourceAttribute< - [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicProperties)] T1, - [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicProperties)] T2, - [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicProperties)] T3, - [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicProperties)] T4, - [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicProperties)] T5> - : DataSourceGeneratorAttribute + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicProperties)] T1, + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicProperties)] T2, + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicProperties)] T3, + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicProperties)] T4, + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicProperties)] T5> + : DataSourceGeneratorAttribute, ISharedDataSourceAttribute where T1 : new() where T2 : new() where T3 : new() @@ -18,7 +18,7 @@ public sealed class ClassDataSourceAttribute< { public SharedType[] Shared { get; set; } = [SharedType.None, SharedType.None, SharedType.None, SharedType.None, SharedType.None]; public string[] Keys { get; set; } = [string.Empty, string.Empty, string.Empty, string.Empty, string.Empty]; - + public override IEnumerable> GenerateDataSources(DataGeneratorMetadata dataGeneratorMetadata) { yield return () => @@ -119,7 +119,7 @@ await ClassDataSources.Get(dataGeneratorMetadata.TestSessionId).OnInitialize( itemsWithMetadata.Item5.Key, itemsWithMetadata.Item5.T); }; - + dataGeneratorMetadata.TestBuilderContext.Current.Events.OnTestStart += async (obj, context) => { await ClassDataSources.Get(dataGeneratorMetadata.TestSessionId).OnTestStart(context, itemsWithMetadata.Item1.T); @@ -128,7 +128,7 @@ await ClassDataSources.Get(dataGeneratorMetadata.TestSessionId).OnInitialize( await ClassDataSources.Get(dataGeneratorMetadata.TestSessionId).OnTestStart(context, itemsWithMetadata.Item4.T); await ClassDataSources.Get(dataGeneratorMetadata.TestSessionId).OnTestStart(context, itemsWithMetadata.Item5.T); }; - + dataGeneratorMetadata.TestBuilderContext.Current.Events.OnTestEnd += async (obj, context) => { await ClassDataSources.Get(dataGeneratorMetadata.TestSessionId).OnTestEnd(context, itemsWithMetadata.Item1.T); @@ -170,7 +170,7 @@ await ClassDataSources.Get(dataGeneratorMetadata.TestSessionId).OnDispose( itemsWithMetadata.Item5.Key, itemsWithMetadata.Item5.T); }; - + dataGeneratorMetadata.TestBuilderContext.Current.Events.OnDispose += async (obj, context) => { await ClassDataSources.Get(dataGeneratorMetadata.TestSessionId).OnDispose( @@ -203,7 +203,7 @@ await ClassDataSources.Get(dataGeneratorMetadata.TestSessionId).OnDispose( itemsWithMetadata.Item5.Key, itemsWithMetadata.Item5.T); }; - + return ( itemsWithMetadata.Item1.T, itemsWithMetadata.Item2.T, @@ -213,4 +213,8 @@ await ClassDataSources.Get(dataGeneratorMetadata.TestSessionId).OnDispose( ); }; } -} \ No newline at end of file + + public IEnumerable GetSharedTypes() => Shared; + + public IEnumerable GetKeys() => Keys; +} diff --git a/TUnit.Core/Attributes/TestData/ClassDataSources.cs b/TUnit.Core/Attributes/TestData/ClassDataSources.cs index 3d1e4550ce..e49b25e856 100644 --- a/TUnit.Core/Attributes/TestData/ClassDataSources.cs +++ b/TUnit.Core/Attributes/TestData/ClassDataSources.cs @@ -6,6 +6,8 @@ using TUnit.Core.Enums; using TUnit.Core.Helpers; using TUnit.Core.Interfaces; +using TUnit.Core.Logging; + #pragma warning disable CS0618 // Type or member is obsolete namespace TUnit.Core; @@ -15,7 +17,7 @@ internal class ClassDataSources private ClassDataSources() { } - + public GetOnlyDictionary GlobalInitializers = new(); public readonly GetOnlyDictionary> TestClassTypeInitializers = new(); public readonly GetOnlyDictionary> AssemblyInitializers = new(); @@ -24,7 +26,7 @@ private ClassDataSources() public static readonly GetOnlyDictionary SourcesPerSession = new(); public static ClassDataSources Get(string sessionId) => SourcesPerSession.GetOrAdd(sessionId, _ => new()); - + public (T, SharedType, string) GetItemForIndex<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicProperties)] T>(int index, Type testClassType, SharedType[] sharedTypes, string[] keys, DataGeneratorMetadata dataGeneratorMetadata) where T : new() { var shared = sharedTypes.ElementAtOrDefault(index); @@ -44,7 +46,7 @@ private string GetKey(int index, SharedType[] sharedTypes, string[] keys) return keys.ElementAtOrDefault(keyedIndex) ?? throw new ArgumentException($"Key at index {keyedIndex} not found"); } - + public T Get<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicProperties)] T>(SharedType sharedType, Type testClassType, string key, DataGeneratorMetadata dataGeneratorMetadata) { if (sharedType == SharedType.None) @@ -74,7 +76,8 @@ private string GetKey(int index, SharedType[] sharedTypes, string[] keys) throw new ArgumentOutOfRangeException(); } - public object Get(SharedType sharedType, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicProperties)] Type type, Type testClassType, string key, DataGeneratorMetadata dataGeneratorMetadata) + + public object Get(SharedType sharedType, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicProperties)] Type type, Type testClassType, string? key, DataGeneratorMetadata dataGeneratorMetadata) { if (sharedType == SharedType.None) { @@ -93,7 +96,7 @@ public object Get(SharedType sharedType, [DynamicallyAccessedMembers(Dynamically if (sharedType == SharedType.Keyed) { - return TestDataContainer.GetInstanceForKey(key, type, () => Create(type, dataGeneratorMetadata)); + return TestDataContainer.GetInstanceForKey(key!, type, () => Create(type, dataGeneratorMetadata)); } if (sharedType == SharedType.PerAssembly) @@ -103,18 +106,18 @@ public object Get(SharedType sharedType, [DynamicallyAccessedMembers(Dynamically throw new ArgumentOutOfRangeException(); } - + public Task InitializeObject(object? item) { if (item is IAsyncInitializer asyncInitializer) { return asyncInitializer.InitializeAsync(); } - + return Task.CompletedTask; } - - public async ValueTask OnTestRegistered(TestContext testContext, bool isStatic, SharedType shared, string key, T? item) + + public async ValueTask OnTestRegistered(TestContext testContext, bool isStatic, SharedType shared, string? key, T? item) { switch (shared) { @@ -130,7 +133,7 @@ public async ValueTask OnTestRegistered(TestContext testContext, bool isStati TestDataContainer.IncrementGlobalUsage(typeof(T)); break; case SharedType.Keyed: - TestDataContainer.IncrementKeyUsage(key, typeof(T)); + TestDataContainer.IncrementKeyUsage(key!, typeof(T)); break; default: throw new ArgumentOutOfRangeException(); @@ -138,7 +141,7 @@ public async ValueTask OnTestRegistered(TestContext testContext, bool isStati if (isStatic) { - await Initialize(testContext, shared, key, item); + await Initialize(testContext, shared, key!, item); } if (item is ITestRegisteredEventReceiver testRegisteredEventReceiver) @@ -147,18 +150,18 @@ public async ValueTask OnTestRegistered(TestContext testContext, bool isStati } } - public async ValueTask OnInitialize(TestContext testContext, bool isStatic, SharedType shared, string key, T? item) + public async ValueTask OnInitialize(TestContext testContext, bool isStatic, SharedType shared, string? key, T? item) { if (isStatic) { // Done already before test start return; } - + await Initialize(testContext, shared, key, item); } - public Task Initialize(TestContext testContext, SharedType shared, string key, T? item) + public Task Initialize(TestContext testContext, SharedType shared, string? key, T? item) { if (shared == SharedType.PerTestSession) { @@ -174,7 +177,7 @@ public Task Initialize(TestContext testContext, SharedType shared, string key { var innerDictionary = TestClassTypeInitializers.GetOrAdd(typeof(T), _ => new GetOnlyDictionary()); - + return innerDictionary.GetOrAdd(testContext.TestDetails.TestClass.Type, _ => InitializeObject(item)); } @@ -183,7 +186,7 @@ public Task Initialize(TestContext testContext, SharedType shared, string key { var innerDictionary = AssemblyInitializers.GetOrAdd(typeof(T), _ => new GetOnlyDictionary()); - + return innerDictionary.GetOrAdd(testContext.TestDetails.TestClass.Type.Assembly, _ => InitializeObject(item)); } @@ -192,25 +195,25 @@ public Task Initialize(TestContext testContext, SharedType shared, string key { var innerDictionary = KeyedInitializers.GetOrAdd(typeof(T), _ => new GetOnlyDictionary()); - - return innerDictionary.GetOrAdd(key, _ => InitializeObject(item)); + + return innerDictionary.GetOrAdd(key!, _ => InitializeObject(item)); } throw new ArgumentOutOfRangeException(nameof(shared)); } - public async ValueTask OnDispose(TestContext testContext, SharedType shared, string key, T? item) + public async ValueTask OnDispose(TestContext testContext, SharedType shared, string? key, T? item) { if (shared is SharedType.None) { await new Disposer(GlobalContext.Current.GlobalLogger).DisposeAsync(item); } - + if (shared == SharedType.Keyed) { - await TestDataContainer.ConsumeKey(key, typeof(T)); + await TestDataContainer.ConsumeKey(key!, typeof(T)); } - + if (shared == SharedType.PerClass) { await TestDataContainer.ConsumeTestClassCount(testContext.TestDetails.TestClass.Type, item); @@ -220,13 +223,13 @@ public async ValueTask OnDispose(TestContext testContext, SharedType shared, { await TestDataContainer.ConsumeAssemblyCount(testContext.TestDetails.TestClass.Type.Assembly, item); } - + if (shared == SharedType.PerTestSession) { await TestDataContainer.ConsumeGlobalCount(item); } } - + public static bool IsStaticProperty(DataGeneratorMetadata dataGeneratorMetadata) { return dataGeneratorMetadata.MembersToGenerate is [SourceGeneratedPropertyInformation { IsStatic: true }]; @@ -243,9 +246,14 @@ private static object Create([DynamicallyAccessedMembers(DynamicallyAccessedMemb try { var instance = Activator.CreateInstance(type)!; - - InitializeDataSourceProperties(type, dataGeneratorMetadata, instance); - + + if (!Sources.DataGeneratorProperties.TryGetValue(instance.GetType(), out var properties)) + { + properties = type.GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.FlattenHierarchy); + } + + InitializeDataSourceProperties(dataGeneratorMetadata, instance, properties); + return instance; } catch (TargetInvocationException targetInvocationException) @@ -263,44 +271,55 @@ private static object Create([DynamicallyAccessedMembers(DynamicallyAccessedMemb [UnconditionalSuppressMessage("Trimming", "IL2026:Members annotated with \'RequiresUnreferencedCodeAttribute\' require dynamic access otherwise can break functionality when trimming application code")] [UnconditionalSuppressMessage("Trimming", "IL2072:Target parameter argument does not satisfy \'DynamicallyAccessedMembersAttribute\' in call to target method. The return value of the source method does not have matching annotations.")] [UnconditionalSuppressMessage("Trimming", "IL2075:\'this\' argument does not satisfy \'DynamicallyAccessedMembersAttribute\' in call to target method. The return value of the source method does not have matching annotations.")] - private static void InitializeDataSourceProperties([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicProperties)] Type type, DataGeneratorMetadata dataGeneratorMetadata, object instance) + private static void InitializeDataSourceProperties(DataGeneratorMetadata dataGeneratorMetadata, object instance, PropertyInfo[] properties) { - foreach (var propertyInfo in type.GetProperties(BindingFlags.Public | BindingFlags.Instance)) + foreach (var propertyInfo in properties) { if (propertyInfo.GetCustomAttributes().OfType().FirstOrDefault() is not { } dataSourceGeneratorAttribute) { continue; } - - var result = dataSourceGeneratorAttribute.GetType() - .GetMethod(nameof(DataSourceGeneratorAttribute<>.GenerateDataSources), BindingFlags.Public | BindingFlags.Instance) - ?.Invoke(dataSourceGeneratorAttribute, [dataGeneratorMetadata with - { - Type = DataGeneratorType.Property, - MembersToGenerate = [ReflectionToSourceModelHelpers.GenerateProperty(propertyInfo)] - }]); - if (result is IEnumerable enumerable) + var resultDelegateArray = dataSourceGeneratorAttribute.GenerateDataSourcesInternal(dataGeneratorMetadata with { - var enumerator = enumerable.GetEnumerator(); - - using var enumerator1 = enumerator as IDisposable; + Type = DataGeneratorType.Property, + MembersToGenerate = [ReflectionToSourceModelHelpers.GenerateProperty(propertyInfo)] + }); - enumerator.MoveNext(); - - result = enumerator.Current; - } + var result = resultDelegateArray.FirstOrDefault()?.Invoke()?.FirstOrDefault(); + + propertyInfo.SetValue(instance, result); - if (result is Delegate @delegate) + if (result is not null && dataSourceGeneratorAttribute.GetType().IsAssignableTo(typeof(IDataSourceGeneratorAttribute))) { - result = @delegate.DynamicInvoke(); + SharedType sharedType; + string? key; + if (dataSourceGeneratorAttribute is ISharedDataSourceAttribute sharedDataSourceAttribute) + { + sharedType = sharedDataSourceAttribute.GetSharedTypes().FirstOrDefault(); + key = sharedDataSourceAttribute.GetKeys().FirstOrDefault(); + } + else + { + sharedType = SharedType.None; + key = null; + } + + TestDataContainer.RegisterNestedDependency(instance, result, sharedType, key); + + // Register the nested dependency with the test lifecycle - this is the key fix! + // We need to register it as if it were a main ClassDataSource so it gets proper usage tracking + RegisterNestedDependencyWithLifecycle(result, sharedType, key, dataGeneratorMetadata); } - - propertyInfo.SetValue(instance, result); if (result is not null) { - InitializeDataSourceProperties(propertyInfo.PropertyType, dataGeneratorMetadata, result); + if (!Sources.DataGeneratorProperties.TryGetValue(result.GetType(), out var nestedProperties)) + { + nestedProperties = result.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.FlattenHierarchy); + } + + InitializeDataSourceProperties(dataGeneratorMetadata, result, nestedProperties); } } } @@ -312,7 +331,7 @@ public async Task OnTestStart(BeforeTestContext context, T item) await testStartEventReceiver.OnTestStart(context); } } - + public async Task OnTestEnd(AfterTestContext context, T item) { if (item is ITestEndEventReceiver testEndEventReceiver) @@ -320,4 +339,37 @@ public async Task OnTestEnd(AfterTestContext context, T item) await testEndEventReceiver.OnTestEnd(context); } } -} \ No newline at end of file + + /// + /// Registers a nested dependency with proper usage tracking for its shared type. + /// + /// The nested dependency object. + /// The shared type of the nested dependency. + /// The key for keyed sharing. + /// The data generator metadata. + private static void RegisterNestedDependencyWithLifecycle(object nestedObject, SharedType sharedType, string? key, DataGeneratorMetadata dataGeneratorMetadata) + { + // Increment usage count for the nested dependency based on its shared type + // This ensures it gets the same usage tracking as if it were a main ClassDataSource + switch (sharedType) + { + case SharedType.None: + // No usage tracking needed for non-shared objects + break; + case SharedType.PerClass: + TestDataContainer.IncrementTestClassUsage(dataGeneratorMetadata.TestClassType, nestedObject.GetType()); + break; + case SharedType.PerAssembly: + TestDataContainer.IncrementAssemblyUsage(dataGeneratorMetadata.TestClassType.Assembly, nestedObject.GetType()); + break; + case SharedType.PerTestSession: + TestDataContainer.IncrementGlobalUsage(nestedObject.GetType()); + break; + case SharedType.Keyed: + TestDataContainer.IncrementKeyUsage(key!, nestedObject.GetType()); + break; + default: + throw new ArgumentOutOfRangeException(nameof(sharedType)); + } + } +} diff --git a/TUnit.Core/Attributes/TestData/DataSourceGeneratorAttribute.cs b/TUnit.Core/Attributes/TestData/DataSourceGeneratorAttribute.cs index e5504ba984..6f91478509 100644 --- a/TUnit.Core/Attributes/TestData/DataSourceGeneratorAttribute.cs +++ b/TUnit.Core/Attributes/TestData/DataSourceGeneratorAttribute.cs @@ -1,31 +1,73 @@ -namespace TUnit.Core; +using TUnit.Core.Extensions; + +namespace TUnit.Core; [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class | AttributeTargets.Property, AllowMultiple = true)] public abstract class DataSourceGeneratorAttribute : TestDataAttribute, IDataSourceGeneratorAttribute { public abstract IEnumerable> GenerateDataSources(DataGeneratorMetadata dataGeneratorMetadata); + + IEnumerable> IDataSourceGeneratorAttribute.GenerateDataSourcesInternal(DataGeneratorMetadata dataGeneratorMetadata) + { + foreach (var dataSourceDelegate in GenerateDataSources(dataGeneratorMetadata)) + { + yield return () => [dataSourceDelegate()]; + } + } } [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, AllowMultiple = true)] public abstract class DataSourceGeneratorAttribute : TestDataAttribute, IDataSourceGeneratorAttribute { public abstract IEnumerable> GenerateDataSources(DataGeneratorMetadata dataGeneratorMetadata); + + IEnumerable> IDataSourceGeneratorAttribute.GenerateDataSourcesInternal(DataGeneratorMetadata dataGeneratorMetadata) + { + foreach (var dataSourceDelegate in GenerateDataSources(dataGeneratorMetadata)) + { + yield return () => dataSourceDelegate().ToObjectArray(); + } + } } [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, AllowMultiple = true)] public abstract class DataSourceGeneratorAttribute : TestDataAttribute, IDataSourceGeneratorAttribute { public abstract IEnumerable> GenerateDataSources(DataGeneratorMetadata dataGeneratorMetadata); + + IEnumerable> IDataSourceGeneratorAttribute.GenerateDataSourcesInternal(DataGeneratorMetadata dataGeneratorMetadata) + { + foreach (var dataSourceDelegate in GenerateDataSources(dataGeneratorMetadata)) + { + yield return () => dataSourceDelegate().ToObjectArray(); + } + } } [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, AllowMultiple = true)] public abstract class DataSourceGeneratorAttribute : TestDataAttribute, IDataSourceGeneratorAttribute { public abstract IEnumerable> GenerateDataSources(DataGeneratorMetadata dataGeneratorMetadata); + + IEnumerable> IDataSourceGeneratorAttribute.GenerateDataSourcesInternal(DataGeneratorMetadata dataGeneratorMetadata) + { + foreach (var dataSourceDelegate in GenerateDataSources(dataGeneratorMetadata)) + { + yield return () => dataSourceDelegate().ToObjectArray(); + } + } } [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, AllowMultiple = true)] public abstract class DataSourceGeneratorAttribute : TestDataAttribute, IDataSourceGeneratorAttribute { public abstract IEnumerable> GenerateDataSources(DataGeneratorMetadata dataGeneratorMetadata); -} \ No newline at end of file + + IEnumerable> IDataSourceGeneratorAttribute.GenerateDataSourcesInternal(DataGeneratorMetadata dataGeneratorMetadata) + { + foreach (var dataSourceDelegate in GenerateDataSources(dataGeneratorMetadata)) + { + yield return () => dataSourceDelegate().ToObjectArray(); + } + } +} diff --git a/TUnit.Core/Attributes/TestData/IDataSourceGeneratorAttribute.cs b/TUnit.Core/Attributes/TestData/IDataSourceGeneratorAttribute.cs index ea8e02aa1d..2a856f0d90 100644 --- a/TUnit.Core/Attributes/TestData/IDataSourceGeneratorAttribute.cs +++ b/TUnit.Core/Attributes/TestData/IDataSourceGeneratorAttribute.cs @@ -1,3 +1,12 @@ namespace TUnit.Core; -internal interface IDataSourceGeneratorAttribute : IDataAttribute; \ No newline at end of file +internal interface IDataSourceGeneratorAttribute : IDataAttribute +{ + internal IEnumerable> GenerateDataSourcesInternal(DataGeneratorMetadata dataGeneratorMetadata); +} + +internal interface ISharedDataSourceAttribute +{ + internal IEnumerable GetSharedTypes(); + internal IEnumerable GetKeys(); +} diff --git a/TUnit.Core/Attributes/TestData/NonTypedDataSourceGeneratorAttribute.cs b/TUnit.Core/Attributes/TestData/NonTypedDataSourceGeneratorAttribute.cs index ec3201c154..98727a37b9 100644 --- a/TUnit.Core/Attributes/TestData/NonTypedDataSourceGeneratorAttribute.cs +++ b/TUnit.Core/Attributes/TestData/NonTypedDataSourceGeneratorAttribute.cs @@ -4,4 +4,5 @@ public abstract class NonTypedDataSourceGeneratorAttribute : TestDataAttribute, INonTypedDataSourceGeneratorAttribute, IDataSourceGeneratorAttribute { public abstract IEnumerable> GenerateDataSources(DataGeneratorMetadata dataGeneratorMetadata); -} \ No newline at end of file + IEnumerable> IDataSourceGeneratorAttribute.GenerateDataSourcesInternal(DataGeneratorMetadata dataGeneratorMetadata) => GenerateDataSources(dataGeneratorMetadata); +} diff --git a/TUnit.Core/Context.cs b/TUnit.Core/Context.cs index dd8accc532..90b625365f 100644 --- a/TUnit.Core/Context.cs +++ b/TUnit.Core/Context.cs @@ -10,6 +10,11 @@ namespace TUnit.Core; /// public abstract class Context : IContext, IDisposable { + protected Context? Parent + { + get; + } + /// /// Gets the current context. /// @@ -18,7 +23,7 @@ TestContext.Current as Context ?? ClassHookContext.Current as Context ?? AssemblyHookContext.Current as Context ?? TestSessionContext.Current as Context - ?? TestDiscoveryContext.Current as Context + ?? TestSessionContext.Current as Context ?? BeforeTestDiscoveryContext.Current as Context ?? GlobalContext.Current; @@ -35,12 +40,33 @@ TestContext.Current as Context /// /// Initializes a new instance of the class. /// - internal Context() + internal Context(Context? parent) { + Parent = parent; } - internal ExecutionContext? ExecutionContext { get; set; } - +#if NET + internal ExecutionContext? ExecutionContext { get; private set; } +#endif + + public void RestoreExecutionContext() + { +#if NET + RestoreContextAsyncLocal(); + + Parent?.RestoreExecutionContext(); + + if (ExecutionContext is not null) + { + ExecutionContext.Restore(ExecutionContext); + } + + RestoreContextAsyncLocal(); +#endif + } + + internal abstract void RestoreContextAsyncLocal(); + /// /// Adds async local values to the context. /// @@ -49,7 +75,10 @@ public void AddAsyncLocalValues() #if NETSTANDARD throw new PlatformNotSupportedException("This method is not supported in .NET Standard - Please upgrade to .NET 8+."); #else - ExecutionContext = ExecutionContext.Capture(); + if (ExecutionContext.Capture() is {} executionContext) + { + ExecutionContext = executionContext; + } #endif } @@ -85,6 +114,8 @@ public DefaultLogger GetDefaultLogger() /// public void Dispose() { +#if NET ExecutionContext?.Dispose(); +#endif } } \ No newline at end of file diff --git a/TUnit.Core/Data/DependencyTracker.cs b/TUnit.Core/Data/DependencyTracker.cs new file mode 100644 index 0000000000..e4a71fb80f --- /dev/null +++ b/TUnit.Core/Data/DependencyTracker.cs @@ -0,0 +1,89 @@ +using System.Collections.Concurrent; +using System.Runtime.CompilerServices; +using System.Threading.Tasks; + +namespace TUnit.Core.Data; + +/// +/// Tracks nested dependencies between objects for proper disposal ordering. +/// +internal class DependencyTracker +{ + // Use ConditionalWeakTable to avoid preventing garbage collection + private readonly ConditionalWeakTable> _dependencies = new(); + private readonly object _lock = new(); + private int _dependencyCount = 0; + + /// + /// Registers a nested dependency relationship. + /// + /// The type of the child object. + /// The parent object. + /// The child object that the parent depends on. + /// The scope manager responsible for the child object. + public void RegisterDependency(object parent, T child, IScopeManager scopeManager) + { + if (parent == null || child == null || scopeManager == null) + { + return; + } + + lock (_lock) + { + var dependencies = _dependencies.GetOrCreateValue(parent); + var wasEmpty = dependencies.Count == 0; + dependencies.Add(new ScopedReference(child, scopeManager)); + + // Only increment count if this is the first dependency for this parent + if (wasEmpty) + { + _dependencyCount++; + } + } + } + + /// + /// Disposes all nested dependencies for the specified parent object. + /// + /// The parent object whose dependencies should be disposed. + /// A task representing the disposal operation. + public async Task DisposeNestedDependenciesAsync(object parent) + { + if (parent == null) + { + return; + } + + List? dependencies = null; + bool hadDependencies = false; + + lock (_lock) + { + if (_dependencies.TryGetValue(parent, out dependencies)) + { + _dependencies.Remove(parent); + hadDependencies = true; + _dependencyCount--; + } + } + + if (dependencies != null && hadDependencies) + { + // Dispose dependencies in parallel for better performance + var disposalTasks = dependencies.Select(dep => dep.DisposeAsync()); + await Task.WhenAll(disposalTasks); + } + } + + /// + /// Gets the number of objects that have nested dependencies. + /// + /// The count of parent objects with dependencies. + public int GetDependencyCount() + { + lock (_lock) + { + return _dependencyCount; + } + } +} diff --git a/TUnit.Core/Data/IDisposableReference.cs b/TUnit.Core/Data/IDisposableReference.cs new file mode 100644 index 0000000000..102def604c --- /dev/null +++ b/TUnit.Core/Data/IDisposableReference.cs @@ -0,0 +1,46 @@ +using System; +using System.Threading.Tasks; + +namespace TUnit.Core.Data; + +/// +/// Represents a disposable reference to an object managed by a scope manager. +/// +internal interface IDisposableReference +{ + /// + /// Attempts to dispose the referenced object. + /// + /// A task representing the disposal operation. + Task DisposeAsync(); +} + +/// +/// A concrete implementation of a disposable reference. +/// +/// The type of the referenced object. +internal class ScopedReference : IDisposableReference +{ + private readonly T _instance; + private readonly IScopeManager _scopeManager; + + /// + /// Initializes a new instance of the class. + /// + /// The referenced instance. + /// The scope manager responsible for disposal. + public ScopedReference(T instance, IScopeManager scopeManager) + { + _instance = instance; + _scopeManager = scopeManager ?? throw new ArgumentNullException(nameof(scopeManager)); + } + + /// + /// Attempts to dispose the referenced object through its scope manager. + /// + /// A task representing the disposal operation. + public async Task DisposeAsync() + { + await _scopeManager.TryDisposeAsync(_instance); + } +} diff --git a/TUnit.Core/Data/IScopeManager.cs b/TUnit.Core/Data/IScopeManager.cs new file mode 100644 index 0000000000..112a46d1ee --- /dev/null +++ b/TUnit.Core/Data/IScopeManager.cs @@ -0,0 +1,31 @@ +using System.Threading.Tasks; + +namespace TUnit.Core.Data; + +/// +/// Interface for managing object disposal in a specific scope. +/// +internal interface IScopeManager +{ + /// + /// Gets or creates an instance of the specified type. + /// + /// The type of object to get or create. + /// The factory function to create the instance if it doesn't exist. + /// The instance. + T GetOrCreate(Func factory); + + /// + /// Increments the usage count for the specified type. + /// + /// The type to increment usage for. + void IncrementUsage(); + + /// + /// Attempts to dispose an instance of the specified type. + /// + /// The type of object to dispose. + /// The item to dispose. + /// True if the item was disposed; false if it's still in use. + Task TryDisposeAsync(T item); +} diff --git a/TUnit.Core/Data/ScopedContainer.cs b/TUnit.Core/Data/ScopedContainer.cs new file mode 100644 index 0000000000..6fd97b3d42 --- /dev/null +++ b/TUnit.Core/Data/ScopedContainer.cs @@ -0,0 +1,81 @@ +using System.Collections.Concurrent; +using TUnit.Core.Helpers; + +namespace TUnit.Core.Data; + +/// +/// A unified container for managing scoped test data instances with usage counting. +/// +/// The type of the scoping key (e.g., Type for class scope, Assembly for assembly scope). +internal class ScopedContainer where TKey : notnull +{ + private readonly ConcurrentDictionary> _containers = new(); + + /// + /// Gets or creates an instance for the specified key and type. + /// + /// The scoping key. + /// The type of object to retrieve or create. + /// The factory function to create the instance if it doesn't exist. + /// The scoped instance containing the object and its usage counter. + public ScopedInstance GetOrCreate(TKey key, Type type, Func factory) + { + var container = _containers.GetOrAdd(key, _ => new ConcurrentDictionary()); + return container.GetOrAdd(type, _ => new ScopedInstance(factory(), new Counter())); + } + + /// + /// Attempts to get an existing instance for the specified key and type. + /// + /// The scoping key. + /// The type of object to retrieve. + /// The scoped instance if found. + /// True if the instance was found; otherwise, false. + public bool TryGet(TKey key, Type type, out ScopedInstance? instance) + { + instance = null; + return _containers.TryGetValue(key, out var container) && + container.TryGetValue(type, out instance); + } + + /// + /// Removes an instance from the container. + /// + /// The scoping key. + /// The type of object to remove. + /// The removed instance, or null if not found. + public ScopedInstance? Remove(TKey key, Type type) + { + if (!_containers.TryGetValue(key, out var container)) + { + return null; + } + + container.TryRemove(type, out var instance); + + // Clean up empty containers + if (container.IsEmpty) + { + _containers.TryRemove(key, out _); + } + + return instance; + } + + /// + /// Gets diagnostic information about the container state. + /// + /// A dictionary containing diagnostic information. + public Dictionary GetDiagnostics() + { + var scopeCount = _containers.Count; + var totalInstances = _containers.Values.Sum(c => c.Count); + + return new Dictionary + { + ["ScopeCount"] = scopeCount, + ["TotalInstances"] = totalInstances, + ["Scopes"] = _containers.Keys.Select(k => k.ToString()).ToList() + }; + } +} diff --git a/TUnit.Core/Data/ScopedInstance.cs b/TUnit.Core/Data/ScopedInstance.cs new file mode 100644 index 0000000000..7456b016d0 --- /dev/null +++ b/TUnit.Core/Data/ScopedInstance.cs @@ -0,0 +1,30 @@ +using TUnit.Core.Helpers; + +namespace TUnit.Core.Data; + +/// +/// Represents an instance with its usage counter for scoped test data management. +/// +internal class ScopedInstance +{ + /// + /// Gets the object instance. + /// + public object Instance { get; } + + /// + /// Gets the usage counter for this instance. + /// + public Counter UsageCount { get; } + + /// + /// Initializes a new instance of the class. + /// + /// The object instance. + /// The usage counter. + public ScopedInstance(object instance, Counter counter) + { + Instance = instance ?? throw new ArgumentNullException(nameof(instance)); + UsageCount = counter ?? throw new ArgumentNullException(nameof(counter)); + } +} diff --git a/TUnit.Core/Data/TestDataMetrics.cs b/TUnit.Core/Data/TestDataMetrics.cs new file mode 100644 index 0000000000..28b01c8fe9 --- /dev/null +++ b/TUnit.Core/Data/TestDataMetrics.cs @@ -0,0 +1,53 @@ +namespace TUnit.Core.Data; + +/// +/// Provides metrics and diagnostic information about the test data container state. +/// +internal class TestDataMetrics +{ + /// + /// Gets or sets the number of globally scoped instances. + /// + public int GlobalInstances { get; set; } + + /// + /// Gets or sets the number of class-scoped instances. + /// + public int ClassScopedInstances { get; set; } + + /// + /// Gets or sets the number of assembly-scoped instances. + /// + public int AssemblyScopedInstances { get; set; } + + /// + /// Gets or sets the number of key-scoped instances. + /// + public int KeyScopedInstances { get; set; } + + /// + /// Gets or sets the number of tracked nested dependencies. + /// + public int NestedDependencies { get; set; } + + /// + /// Gets or sets detailed diagnostic information. + /// + public Dictionary Details { get; set; } = new(); + + /// + /// Gets the total number of managed instances across all scopes. + /// + public int TotalInstances => GlobalInstances + ClassScopedInstances + AssemblyScopedInstances + KeyScopedInstances; + + /// + /// Returns a string representation of the metrics. + /// + /// A formatted string containing the metrics. + public override string ToString() + { + return $"TestDataMetrics: Total={TotalInstances}, Global={GlobalInstances}, " + + $"Class={ClassScopedInstances}, Assembly={AssemblyScopedInstances}, " + + $"Key={KeyScopedInstances}, Nested={NestedDependencies}"; + } +} diff --git a/TUnit.Core/DependencyTracker.cs b/TUnit.Core/DependencyTracker.cs new file mode 100644 index 0000000000..72cb6f8ec2 --- /dev/null +++ b/TUnit.Core/DependencyTracker.cs @@ -0,0 +1,28 @@ +using System; +using System.Runtime.CompilerServices; + +namespace TUnit.Core; + +internal class DependencyTracker : IDisposable +{ + private readonly ConditionalWeakTable _dependencies = new(); + private int _dependencyCount; + + public void TrackDependency(object dependency) + { + if (dependency == null) + return; + + _dependencies.GetOrCreateValue(dependency); + _dependencyCount++; + } + + public int Count => _dependencyCount; + + public void Dispose() + { + // ConditionalWeakTable doesn't need explicit cleanup - it handles GC automatically + // Just reset the count + _dependencyCount = 0; + } +} diff --git a/TUnit.Core/EngineCancellationToken.cs b/TUnit.Core/EngineCancellationToken.cs index 8017b17b77..7618139774 100644 --- a/TUnit.Core/EngineCancellationToken.cs +++ b/TUnit.Core/EngineCancellationToken.cs @@ -9,12 +9,12 @@ public class EngineCancellationToken : IDisposable /// Gets the internal cancellation token source. /// internal CancellationTokenSource CancellationTokenSource { get; private set; } = new(); - + /// /// Gets the cancellation token. /// public CancellationToken Token { get; private set; } - + /// /// Initializes the cancellation token with a linked token source. /// @@ -23,6 +23,21 @@ internal void Initialise(CancellationToken cancellationToken) { CancellationTokenSource = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken); Token = CancellationTokenSource.Token; + + Console.CancelKeyPress += (sender, e) => + { + if (!CancellationTokenSource.IsCancellationRequested) + { + CancellationTokenSource.Cancel(); + e.Cancel = true; + } + + _ = Task.Delay(TimeSpan.FromSeconds(10)).ContinueWith(_ => + { + Console.WriteLine("Forcefully terminating the process due to cancellation request."); + Environment.Exit(1); + }); + }; } /// @@ -32,4 +47,4 @@ public void Dispose() { CancellationTokenSource.Dispose(); } -} \ No newline at end of file +} diff --git a/TUnit.Core/Extensions/TupleExtensions.cs b/TUnit.Core/Extensions/TupleExtensions.cs new file mode 100644 index 0000000000..3d8cdc3102 --- /dev/null +++ b/TUnit.Core/Extensions/TupleExtensions.cs @@ -0,0 +1,24 @@ +namespace TUnit.Core.Extensions; + +internal static class TupleExtensions +{ + public static object?[] ToObjectArray(this (T1, T2) tuple) + { + return [tuple.Item1, tuple.Item2]; + } + + public static object?[] ToObjectArray(this (T1, T2, T3) tuple) + { + return [tuple.Item1, tuple.Item2, tuple.Item3]; + } + + public static object?[] ToObjectArray(this (T1, T2, T3, T4) tuple) + { + return [tuple.Item1, tuple.Item2, tuple.Item3, tuple.Item4]; + } + + public static object?[] ToObjectArray(this (T1, T2, T3, T4, T5) tuple) + { + return [tuple.Item1, tuple.Item2, tuple.Item3, tuple.Item4, tuple.Item5]; + } +} diff --git a/TUnit.Core/Helpers/CastHelper.cs b/TUnit.Core/Helpers/CastHelper.cs index 74b713afcb..c0bc334e09 100644 --- a/TUnit.Core/Helpers/CastHelper.cs +++ b/TUnit.Core/Helpers/CastHelper.cs @@ -13,7 +13,7 @@ public static class CastHelper { return default; } - + if (value is T successfulCast) { return successfulCast; @@ -25,14 +25,14 @@ public static class CastHelper { return (T)value; } - - if (value is not string - && value is IEnumerable enumerable + + if (value is not string + && value is IEnumerable enumerable && !typeof(IEnumerable).IsAssignableFrom(typeof(T))) { value = enumerable.Cast().ElementAtOrDefault(0); } - + if (underlyingType.IsEnum) { return (T?) Enum.ToObject(underlyingType, value!); @@ -44,15 +44,15 @@ public static class CastHelper { return (T?) Convert.ChangeType(value, underlyingType); } - + if (conversionMethod is null) { return (T?) value; } - + return (T?) conversionMethod!.Invoke(null, [value]); } - + [UnconditionalSuppressMessage("", "IL2072")] public static object? Cast([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods)] Type type, object? value) { @@ -60,7 +60,7 @@ public static class CastHelper { return null; } - + var underlyingType = Nullable.GetUnderlyingType(type) ?? type; if (value.GetType().IsAssignableTo(underlyingType)) @@ -72,14 +72,14 @@ public static class CastHelper { return value; } - - if (value is not string - && value is IEnumerable enumerable + + if (value is not string + && value is IEnumerable enumerable && !typeof(IEnumerable).IsAssignableFrom(type)) { value = enumerable.Cast().ElementAtOrDefault(0); } - + if (underlyingType.IsEnum) { return Enum.ToObject(underlyingType, value!); @@ -96,11 +96,11 @@ public static class CastHelper { return value; } - + return conversionMethod!.Invoke(null, [value]); } - private static MethodInfo? GetConversionMethod([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods)] Type baseType, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods)] Type targetType) + public static MethodInfo? GetConversionMethod([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods)] Type baseType, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods)] Type targetType) { var methods = baseType.GetMethods(BindingFlags.Public | BindingFlags.Static) .Concat(targetType.GetMethods(BindingFlags.Public | BindingFlags.Static)) @@ -119,4 +119,4 @@ private static bool HasCorrectInputType(Type baseType, MethodInfo mi) var pi = mi.GetParameters().FirstOrDefault(); return pi != null && pi.ParameterType == baseType; } -} \ No newline at end of file +} diff --git a/TUnit.Core/Helpers/ReflectionToSourceModelHelpers.cs b/TUnit.Core/Helpers/ReflectionToSourceModelHelpers.cs index 0871c6cf24..6691bef745 100644 --- a/TUnit.Core/Helpers/ReflectionToSourceModelHelpers.cs +++ b/TUnit.Core/Helpers/ReflectionToSourceModelHelpers.cs @@ -35,7 +35,7 @@ public static SourceGeneratedMethodInformation BuildTestMethod([DynamicallyAcces { return null; } - + return GenerateClass(type.DeclaringType); } @@ -74,7 +74,7 @@ public static SourceGeneratedPropertyInformation GenerateProperty(PropertyInfo p Attributes = property.GetCustomAttributes().ToArray(), Name = property.Name, Type = property.PropertyType, - IsStatic = property.GetMethod?.IsStatic is true + IsStatic = property.GetMethod?.IsStatic is true || property.SetMethod?.IsStatic is true, }; } @@ -90,6 +90,7 @@ public static SourceGeneratedParameterInformation GenerateParameter(ParameterInf { Attributes = parameter.GetCustomAttributes().ToArray(), Name = parameter.Name ?? string.Empty, + ReflectionInfo = parameter, }; } -} \ No newline at end of file +} diff --git a/TUnit.Core/Helpers/RobustParameterInfoRetriever.cs b/TUnit.Core/Helpers/RobustParameterInfoRetriever.cs new file mode 100644 index 0000000000..5797fffa0d --- /dev/null +++ b/TUnit.Core/Helpers/RobustParameterInfoRetriever.cs @@ -0,0 +1,206 @@ +using System.Diagnostics.CodeAnalysis; +using System.Reflection; + +namespace TUnit.Core.Helpers; + +/// +/// Provides robust parameter info retrieval for source-generated code with comprehensive fallback strategies. +/// +[RequiresUnreferencedCode("Uses reflection to retrieve parameter information")] +[RequiresDynamicCode("Uses reflection to retrieve parameter information")] +public static class RobustParameterInfoRetriever +{ + private static readonly BindingFlags RobustBindingFlags = + BindingFlags.Instance + | BindingFlags.Public + | BindingFlags.NonPublic + | BindingFlags.Static + | BindingFlags.FlattenHierarchy; + + /// + /// Retrieves constructor parameter info with comprehensive fallback strategies. + /// + /// The type containing the constructor + /// The zero-based index of the parameter + /// The expected parameter types for exact matching + /// + /// + /// The ParameterInfo for the specified parameter + /// Thrown when no suitable constructor is found + public static ParameterInfo GetConstructorParameterInfo( + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] Type type, + Type[] parameterTypes, + int parameterIndex, + Type expectedType, + string parameterName) + { + var parameterInfo = type.GetConstructor(RobustBindingFlags, null, parameterTypes, null)?.GetParameters()[parameterIndex]; + + if (parameterInfo?.Name == parameterName && (parameterInfo.ParameterType == expectedType || parameterInfo.ParameterType.IsGenericParameter)) + { + return parameterInfo; + } + + foreach (var constructorInfo in type.GetConstructors(RobustBindingFlags).Where(x => x.GetParameters().Length == parameterTypes.Length)) + { + foreach (var parameter in constructorInfo.GetParameters()) + { + if (parameter.Name == parameterName && (parameter.ParameterType == expectedType || parameter.ParameterType.IsGenericParameter)) + { + return parameter; + } + } + } + + foreach (var constructorInfo in type.GetConstructors(RobustBindingFlags)) + { + foreach (var parameter in constructorInfo.GetParameters()) + { + if (parameter.Name == parameterName && (parameter.ParameterType == expectedType || parameter.ParameterType.IsGenericParameter)) + { + return parameter; + } + } + } + + return null!; + } + + /// + /// Retrieves method parameter info with comprehensive fallback strategies. + /// + /// The type containing the method + /// The name of the method + /// The zero-based index of the parameter + /// The expected parameter types for exact matching + /// Whether the method is static + /// The number of generic parameters the method has + /// The ParameterInfo for the specified parameter + /// Thrown when no suitable method is found + public static ParameterInfo GetMethodParameterInfo( + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods | DynamicallyAccessedMemberTypes.NonPublicMethods)] Type type, + string methodName, + int parameterIndex, + Type[] parameterTypes, + bool isStatic, + int genericParameterCount) + { + try + { + var bindingFlags = RobustBindingFlags; + + if (isStatic) + { + bindingFlags &= ~BindingFlags.Instance; + } + else + { + bindingFlags &= ~BindingFlags.Static; + } + + if (genericParameterCount == 0) + { + var method = type.GetMethod(methodName, bindingFlags, null, parameterTypes, null); + + if (method != null) + { + return method.GetParameters()[parameterIndex]; + } + } + + var methods = type.GetMethods(bindingFlags) + .Where(m => m.Name == methodName) + .Where(m => m.GetGenericArguments().Length == genericParameterCount) + .Where(m => m.GetParameters().Length == parameterTypes.Length) + .ToArray(); + + if (methods.Length > 0) + { + // Prefer exact type match if available + var exactMatch = methods.FirstOrDefault(m => ParameterTypesMatch(m.GetParameters(), parameterTypes)); + + if (exactMatch != null) + { + return exactMatch.GetParameters()[parameterIndex]; + } + + return methods[0].GetParameters()[parameterIndex]; + } + + var methodByCount = type + .GetMethods(bindingFlags) + .Where(m => m.Name == methodName) + .FirstOrDefault(m => m.GetParameters().Length == parameterTypes.Length); + + if (methodByCount != null) + { + return methodByCount.GetParameters()[parameterIndex]; + } + + var methodByName = type.GetMethods(bindingFlags) + .Where(m => m.Name == methodName) + .Where(m => m.GetParameters().Length > parameterIndex) + .OrderBy(m => m.GetParameters().Length) + .FirstOrDefault(); + + if (methodByName != null) + { + return methodByName.GetParameters()[parameterIndex]; + } + + var methodAny = type + .GetMethods(RobustBindingFlags) + .Where(m => m.Name == methodName) + .FirstOrDefault(m => m.GetParameters().Length > parameterIndex); + + if (methodAny != null) + { + return methodAny.GetParameters()[parameterIndex]; + } + + throw new InvalidOperationException($"No suitable method found for type {type.FullName}, method {methodName} with parameter index {parameterIndex}"); + } + catch (Exception ex) when (ex is not InvalidOperationException) + { + throw new InvalidOperationException($"Failed to get method parameter info for type {type.FullName}, method {methodName}, parameter index {parameterIndex}: {ex.Message}", ex); + } + } + + /// + /// Checks if parameter types match, accounting for generic parameters, nullable types, and assignability. + /// + private static bool ParameterTypesMatch(ParameterInfo[] parameters, Type[] expectedTypes) + { + if (parameters.Length != expectedTypes.Length) + return false; + + for (int i = 0; i < parameters.Length; i++) + { + var paramType = parameters[i].ParameterType; + var expectedType = expectedTypes[i]; + + // Exact match + if (paramType == expectedType) + continue; + + // Handle generic parameters and open generic types + if (paramType.IsGenericParameter || expectedType.IsGenericParameter) + continue; + + // Handle nullable types + var underlyingParamType = Nullable.GetUnderlyingType(paramType) ?? paramType; + var underlyingExpectedType = Nullable.GetUnderlyingType(expectedType) ?? expectedType; + + if (underlyingParamType == underlyingExpectedType) + continue; + + // Check assignability + if (expectedType.IsAssignableFrom(paramType) || paramType.IsAssignableFrom(expectedType)) + continue; + + return false; + } + + return true; + } +} diff --git a/TUnit.Core/Hooks/LastTestInAssemblyClassAdapter.cs b/TUnit.Core/Hooks/LastTestInAssemblyClassAdapter.cs index db0f243fda..8ea51d8f49 100644 --- a/TUnit.Core/Hooks/LastTestInAssemblyClassAdapter.cs +++ b/TUnit.Core/Hooks/LastTestInAssemblyClassAdapter.cs @@ -16,11 +16,13 @@ public class LastTestInAssemblyAdapter(ILastTestInAssemblyEventReceiver lastTest Parameters = [new SourceGeneratedParameterInformation { Attributes = [], - Name = "context" + Name = "context", + ReflectionInfo = typeof(ILastTestInAssemblyEventReceiver).GetMethod(nameof(ILastTestInAssemblyEventReceiver.OnLastTestInAssembly))!.GetParameters()[0], }, new SourceGeneratedParameterInformation { Attributes = [], - Name = "testContext" + Name = "testContext", + ReflectionInfo = typeof(ILastTestInAssemblyEventReceiver).GetMethod(nameof(ILastTestInAssemblyEventReceiver.OnLastTestInAssembly))!.GetParameters()[1], }], GenericTypeCount = 0, ReturnType = typeof(ValueTask), @@ -40,7 +42,7 @@ public class LastTestInAssemblyAdapter(ILastTestInAssemblyEventReceiver lastTest Properties = [], } }; - + public int Order => 0; public bool Execute(AssemblyHookContext context, CancellationToken cancellationToken) @@ -52,4 +54,4 @@ public async ValueTask ExecuteAsync(AssemblyHookContext context, CancellationTok { await lastTestInAssemblyEventReceiver.OnLastTestInAssembly(context, testContext); } -} \ No newline at end of file +} diff --git a/TUnit.Core/Hooks/LastTestInClassAdapter.cs b/TUnit.Core/Hooks/LastTestInClassAdapter.cs index 6ee1a93365..2a7b0b59a0 100644 --- a/TUnit.Core/Hooks/LastTestInClassAdapter.cs +++ b/TUnit.Core/Hooks/LastTestInClassAdapter.cs @@ -16,11 +16,13 @@ public class LastTestInClassAdapter(ILastTestInClassEventReceiver lastTestInClas Parameters = [new SourceGeneratedParameterInformation { Attributes = [], - Name = "context" + Name = "context", + ReflectionInfo = typeof(ILastTestInClassEventReceiver).GetMethod(nameof(ILastTestInClassEventReceiver.OnLastTestInClass))!.GetParameters()[0], }, new SourceGeneratedParameterInformation { Attributes = [], - Name = "testContext" + Name = "testContext", + ReflectionInfo = typeof(ILastTestInClassEventReceiver).GetMethod(nameof(ILastTestInClassEventReceiver.OnLastTestInClass))!.GetParameters()[0], }], GenericTypeCount = 0, ReturnType = typeof(ValueTask), @@ -40,7 +42,7 @@ public class LastTestInClassAdapter(ILastTestInClassEventReceiver lastTestInClas Properties = [], } }; - + public int Order => 0; public bool Execute(ClassHookContext context, CancellationToken cancellationToken) @@ -52,4 +54,4 @@ public async ValueTask ExecuteAsync(ClassHookContext context, CancellationToken { await lastTestInClassEventReceiver.OnLastTestInClass(context, testContext); } -} \ No newline at end of file +} diff --git a/TUnit.Core/Models/AssemblyHookContext.cs b/TUnit.Core/Models/AssemblyHookContext.cs index ae2a85f899..5c507e0b32 100644 --- a/TUnit.Core/Models/AssemblyHookContext.cs +++ b/TUnit.Core/Models/AssemblyHookContext.cs @@ -1,3 +1,4 @@ +using System.Diagnostics.CodeAnalysis; using System.Reflection; namespace TUnit.Core; @@ -11,17 +12,42 @@ public class AssemblyHookContext : Context internal set => Contexts.Value = value; } - internal AssemblyHookContext() + internal AssemblyHookContext(TestSessionContext testSessionContext) : base(testSessionContext) { + testSessionContext.AddAssembly(this); } + + public TestSessionContext TestSessionContext => (TestSessionContext) Parent!; public required Assembly Assembly { get; init; } + + private readonly List _testClasses = []; + + public void AddClass(ClassHookContext classHookContext) + { + _testClasses.Add(classHookContext); + } + + public IReadOnlyList TestClasses => _testClasses; - public HashSet TestClasses { get; init; } = []; - - public IEnumerable AllTests => TestClasses.SelectMany(x => x.Tests); + public IReadOnlyList AllTests => TestClasses.SelectMany(x => x.Tests).ToArray(); - public int TestCount => AllTests.Count(); + public int TestCount => AllTests.Count; internal bool FirstTestStarted { get; set; } + + internal void RemoveClass(ClassHookContext classContext) + { + _testClasses.Remove(classContext); + + if (_testClasses.Count == 0) + { + TestSessionContext.RemoveAssembly(this); + } + } + + internal override void RestoreContextAsyncLocal() + { + Current = this; + } } \ No newline at end of file diff --git a/TUnit.Core/Models/BeforeTestDiscoveryContext.cs b/TUnit.Core/Models/BeforeTestDiscoveryContext.cs index d85dc3be23..82baa4df34 100644 --- a/TUnit.Core/Models/BeforeTestDiscoveryContext.cs +++ b/TUnit.Core/Models/BeforeTestDiscoveryContext.cs @@ -19,13 +19,21 @@ public class BeforeTestDiscoveryContext : Context /// /// Initializes a new instance of the class. /// - internal BeforeTestDiscoveryContext() + internal BeforeTestDiscoveryContext() : base(GlobalContext.Current) { Current = this; } + + public GlobalContext GlobalContext => (GlobalContext) Parent!; + /// /// Gets or sets the test filter. /// public required string? TestFilter { get; init; } + + internal override void RestoreContextAsyncLocal() + { + Current = this; + } } \ No newline at end of file diff --git a/TUnit.Core/Models/ClassHookContext.cs b/TUnit.Core/Models/ClassHookContext.cs index b1ce64076f..c9dd617179 100644 --- a/TUnit.Core/Models/ClassHookContext.cs +++ b/TUnit.Core/Models/ClassHookContext.cs @@ -9,14 +9,24 @@ public class ClassHookContext : Context internal set => Contexts.Value = value; } - internal ClassHookContext() + internal ClassHookContext(AssemblyHookContext assemblyHookContext) : base(assemblyHookContext) { + assemblyHookContext.AddClass(this); } + public AssemblyHookContext AssemblyContext => (AssemblyHookContext) Parent!; + public required Type ClassType { get; init; } - public List Tests { get; init; } = []; - + private readonly List _tests = []; + + public void AddTest(TestContext testContext) + { + _tests.Add(testContext); + } + + public IReadOnlyList Tests => _tests; + public int TestCount => Tests.Count; internal bool FirstTestStarted { get; set; } @@ -49,4 +59,19 @@ public override int GetHashCode() { return ClassType.GetHashCode(); } + + internal void RemoveTest(TestContext test) + { + _tests.Remove(test); + + if(_tests.Count is 0) + { + AssemblyContext.RemoveClass(this); + } + } + + internal override void RestoreContextAsyncLocal() + { + Current = this; + } } \ No newline at end of file diff --git a/TUnit.Core/Models/DynamicTest.cs b/TUnit.Core/Models/DynamicTest.cs index d6e29e836d..73ad8a6916 100644 --- a/TUnit.Core/Models/DynamicTest.cs +++ b/TUnit.Core/Models/DynamicTest.cs @@ -14,27 +14,27 @@ public abstract record DynamicTest public string? TestName { get; init; } internal abstract MethodInfo TestBody { get; } - - [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors - | DynamicallyAccessedMemberTypes.PublicMethods + + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors + | DynamicallyAccessedMemberTypes.PublicMethods | DynamicallyAccessedMemberTypes.NonPublicMethods | DynamicallyAccessedMemberTypes.PublicProperties)] public abstract Type TestClassType { get; } - + public object?[]? TestClassArguments { get; init; } public required object?[] TestMethodArguments { get; init; } - + public Dictionary? Properties { get; init; } - + public abstract IEnumerable BuildTestMetadatas(); - + internal string TestFilePath { get; init; } = string.Empty; internal int TestLineNumber { get; init; } = 0; - + internal Exception? Exception { get; set; } public Attribute[] Attributes { get; init; } = []; - + public Attribute[] GetAttributes() { return @@ -45,9 +45,9 @@ public Attribute[] GetAttributes() ..TestClassType.Assembly.GetCustomAttributes() ]; } - + public static T Argument() => default!; - + protected SourceGeneratedMethodInformation BuildTestMethod(MethodInfo methodInfo) { return new SourceGeneratedMethodInformation @@ -108,18 +108,14 @@ protected SourceGeneratedParameterInformation[] GetParameters(ParameterInfo[] pa protected SourceGeneratedParameterInformation GenerateParameter(ParameterInfo parameter) { - return new SourceGeneratedParameterInformation(parameter.ParameterType) - { - Attributes = parameter.GetCustomAttributes().ToArray(), - Name = parameter.Name ?? string.Empty, - }; + return ReflectionToSourceModelHelpers.GenerateParameter(parameter); } } [RequiresDynamicCode("Reflection")] [RequiresUnreferencedCode("Reflection")] public record DynamicTest< - [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicMethods | DynamicallyAccessedMemberTypes.PublicProperties)] TClass> : DynamicTest where TClass : class @@ -132,22 +128,22 @@ public DynamicTest() { _dynamicTestCounter = Interlocked.Increment(ref _dynamicTestCounter); } - + public override string TestId => $"DynamicTest-{typeof(TClass).FullName}-{TestBody.Name}-{_dynamicTestCounter}"; public required Expression> TestMethod { get; init; } internal override MethodInfo TestBody => GetMethodInfo(TestMethod); - - [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors - | DynamicallyAccessedMemberTypes.PublicMethods + + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors + | DynamicallyAccessedMemberTypes.PublicMethods | DynamicallyAccessedMemberTypes.NonPublicMethods | DynamicallyAccessedMemberTypes.PublicProperties)] public override Type TestClassType { get; } = typeof(TClass); - + public override IEnumerable BuildTestMetadatas() { var attributes = GetAttributes(); - + var repeatLimit = attributes.OfType() .FirstOrDefault() ?.Times ?? 0; @@ -157,7 +153,7 @@ public override IEnumerable BuildTestMetadatas() var testBuilderContext = new TestBuilderContext(); var sourceGeneratedMethodInformation = BuildTestMethod(TestBody); - + yield return new TestMetadata { TestId = $"{TestId}-{i}", @@ -197,7 +193,7 @@ private MethodInfo GetMethodInfo(Expression> expression) { return methodCallExpression.Method; } - + throw new InvalidOperationException($"A method call expression was not passed to the TestMethod property. Received: {expression.Body.GetType()}."); } @@ -205,7 +201,7 @@ public record MethodBody { public Action? SynchronousBody { get; init; } public Func? TaskBody { get; init; } - + public static implicit operator MethodBody(Action action) { return new MethodBody @@ -213,7 +209,7 @@ public static implicit operator MethodBody(Action action) SynchronousBody = action }; } - + public static implicit operator MethodBody(Func taskBody) { return new MethodBody @@ -222,4 +218,4 @@ public static implicit operator MethodBody(Func taskBody) }; } } -} \ No newline at end of file +} diff --git a/TUnit.Core/Models/GlobalContext.cs b/TUnit.Core/Models/GlobalContext.cs index 7a6ca78965..17c86b1305 100644 --- a/TUnit.Core/Models/GlobalContext.cs +++ b/TUnit.Core/Models/GlobalContext.cs @@ -14,7 +14,7 @@ public class GlobalContext : Context internal set => Contexts.Value = value; } - internal GlobalContext() + internal GlobalContext() : base(null) { } @@ -23,4 +23,9 @@ internal GlobalContext() public string? TestFilter { get; internal set; } public TextWriter OriginalConsoleOut { get; set; } = Console.Out; public TextWriter OriginalConsoleError { get; set; } = Console.Error; + + internal override void RestoreContextAsyncLocal() + { + Current = this; + } } \ No newline at end of file diff --git a/TUnit.Core/Models/SourceGenerations/SourceGeneratedParameterInformation.cs b/TUnit.Core/Models/SourceGenerations/SourceGeneratedParameterInformation.cs index 5b0760a1c8..648f7d7f7a 100644 --- a/TUnit.Core/Models/SourceGenerations/SourceGeneratedParameterInformation.cs +++ b/TUnit.Core/Models/SourceGenerations/SourceGeneratedParameterInformation.cs @@ -1,15 +1,22 @@ using System.Diagnostics; using System.Diagnostics.CodeAnalysis; +using System.Reflection; namespace TUnit.Core; [DebuggerDisplay("{Type} {Name})")] -public record SourceGeneratedParameterInformation<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors +public record SourceGeneratedParameterInformation<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicMethods | DynamicallyAccessedMemberTypes.NonPublicMethods)]T>() : SourceGeneratedParameterInformation(typeof(T)); [DebuggerDisplay("{Type} {Name})")] -public record SourceGeneratedParameterInformation([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors +public record SourceGeneratedParameterInformation([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicMethods - | DynamicallyAccessedMemberTypes.NonPublicMethods)] Type Type) : SourceGeneratedMemberInformation; - \ No newline at end of file + | DynamicallyAccessedMemberTypes.NonPublicMethods)] Type Type) : SourceGeneratedMemberInformation +{ + public required ParameterInfo ReflectionInfo { get; set; } + public bool IsParams => ReflectionInfo.IsDefined(typeof(ParamArrayAttribute), false); + public bool IsOptional => ReflectionInfo.IsOptional; + + public object? DefaultValue => ReflectionInfo.DefaultValue; +} diff --git a/TUnit.Core/Models/SourceGenerations/SourceGeneratedPropertyInformation.cs b/TUnit.Core/Models/SourceGenerations/SourceGeneratedPropertyInformation.cs index b6818c2774..c04cd0bfb6 100644 --- a/TUnit.Core/Models/SourceGenerations/SourceGeneratedPropertyInformation.cs +++ b/TUnit.Core/Models/SourceGenerations/SourceGeneratedPropertyInformation.cs @@ -12,4 +12,6 @@ public record SourceGeneratedPropertyInformation : SourceGeneratedMemberInformat | DynamicallyAccessedMemberTypes.NonPublicMethods)] public override required Type Type { get; init; } public required bool IsStatic { get; init; } + public SharedType Shared { get; init; } = SharedType.None; + public string? Key { get; init; } = null; } \ No newline at end of file diff --git a/TUnit.Core/Models/TestDiscoveryContext.cs b/TUnit.Core/Models/TestDiscoveryContext.cs index 112f787862..3c1ea9fc3c 100644 --- a/TUnit.Core/Models/TestDiscoveryContext.cs +++ b/TUnit.Core/Models/TestDiscoveryContext.cs @@ -1,4 +1,6 @@ -namespace TUnit.Core; +using System.Diagnostics.CodeAnalysis; + +namespace TUnit.Core; /// /// Represents the context for test discovery. @@ -12,28 +14,29 @@ public class TestDiscoveryContext : Context internal set => Contexts.Value = value; } - internal TestDiscoveryContext(IEnumerable discoveredTests) + internal TestDiscoveryContext(BeforeTestDiscoveryContext parent) : base(parent) { - var classContexts = discoveredTests.GroupBy(x => x.TestDetails.TestClass.Type).Select(x => new ClassHookContext - { - ClassType = x.Key, - Tests = [..x.Select(dt => dt.TestContext)] - }); - - var assemblyContexts = classContexts.GroupBy(x => x.ClassType.Assembly).Select(x => new AssemblyHookContext - { - Assembly = x.Key, - TestClasses = [..x] - }); + } - Assemblies = assemblyContexts; - Current = this; + public void AddTests(IEnumerable tests) + { + AllTests = tests as IReadOnlyList ?? tests.ToArray(); } + + public BeforeTestDiscoveryContext BeforeTestDiscoveryContext => (BeforeTestDiscoveryContext) Parent!; public required string? TestFilter { get; init; } - public IEnumerable Assemblies { get; } - public IEnumerable TestClasses => Assemblies.SelectMany(x => x.TestClasses); + [field: AllowNull, MaybeNull] + public IEnumerable Assemblies => field ??= TestClasses.Select(x => x.AssemblyContext).Distinct().ToArray(); + + [field: AllowNull, MaybeNull] + public IEnumerable TestClasses => field ??= AllTests.Select(x => x.ClassContext).Distinct().ToArray(); - public IEnumerable AllTests => TestClasses.SelectMany(x => x.Tests); + public IReadOnlyList AllTests { get; private set; } = []; + + internal override void RestoreContextAsyncLocal() + { + Current = this; + } } \ No newline at end of file diff --git a/TUnit.Core/Models/TestSessionContext.cs b/TUnit.Core/Models/TestSessionContext.cs index 7a928dec41..f6a05429f3 100644 --- a/TUnit.Core/Models/TestSessionContext.cs +++ b/TUnit.Core/Models/TestSessionContext.cs @@ -1,3 +1,5 @@ +using System.Diagnostics.CodeAnalysis; + namespace TUnit.Core; public class TestSessionContext : Context @@ -9,20 +11,30 @@ public class TestSessionContext : Context internal set => Contexts.Value = value; } - internal TestSessionContext(IEnumerable assemblies) + internal TestSessionContext(TestDiscoveryContext beforeTestDiscoveryContext) : base(beforeTestDiscoveryContext) { - Assemblies = assemblies; Current = this; } + + public BeforeTestDiscoveryContext TestDiscoveryContext => (BeforeTestDiscoveryContext) Parent!; public required string Id { get; init; } public required string? TestFilter { get; init; } - public IEnumerable Assemblies { get; } - public IEnumerable TestClasses => Assemblies.SelectMany(x => x.TestClasses); + private readonly List _assemblies = []; + + public void AddAssembly(AssemblyHookContext assemblyHookContext) + { + _assemblies.Add(assemblyHookContext); + } + + public IReadOnlyList Assemblies => _assemblies; + + public IReadOnlyList TestClasses => Assemblies.SelectMany(x => x.TestClasses).ToArray(); - public IEnumerable AllTests => TestClasses.SelectMany(x => x.Tests); + public IReadOnlyList AllTests => TestClasses.SelectMany(x => x.Tests).ToArray(); + internal bool FirstTestStarted { get; set; } internal readonly List Artifacts = []; @@ -31,4 +43,14 @@ public void AddArtifact(Artifact artifact) { Artifacts.Add(artifact); } + + internal void RemoveAssembly(AssemblyHookContext assemblyContext) + { + _assemblies.Remove(assemblyContext); + } + + internal override void RestoreContextAsyncLocal() + { + Current = this; + } } \ No newline at end of file diff --git a/TUnit.Core/SourceRegistrar.cs b/TUnit.Core/SourceRegistrar.cs index be66698403..c050a550aa 100644 --- a/TUnit.Core/SourceRegistrar.cs +++ b/TUnit.Core/SourceRegistrar.cs @@ -1,4 +1,5 @@ using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; using System.Reflection; using System.Runtime.CompilerServices; using TUnit.Core.Interfaces.SourceGenerator; @@ -15,7 +16,7 @@ namespace TUnit.Core; public class SourceRegistrar { public static bool IsEnabled { get; set; } - + /// /// Registers an assembly loader. /// @@ -27,11 +28,11 @@ public static void RegisterAssembly(Func assemblyLoader) { return; } -#endif - +#endif + Sources.AssemblyLoaders.Enqueue(assemblyLoader); } - + /// /// Registers a test source. /// @@ -40,7 +41,7 @@ public static void Register(ITestSource testSource) { Sources.TestSources.Enqueue(testSource); } - + /// /// Registers a test source. /// @@ -94,4 +95,22 @@ public static void RegisterTestDiscoveryHookSource(ITestDiscoveryHookSource test { Sources.TestDiscoveryHookSources.Enqueue(testSource); } -} \ No newline at end of file + + /// + /// Registers a property initializer for a specific type that takes a DataGeneratorMetadata parameter. + /// + /// The type to register the initializer for. + public static void RegisterProperty<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties | DynamicallyAccessedMemberTypes.PublicConstructors)] T>() + { + var properties = typeof(T).GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static) + .Where(p => p.CanWrite && p.IsDefined(typeof(IDataSourceGeneratorAttribute), true)) + .ToArray(); + + if (properties.Length == 0) + { + return; + } + + Sources.DataGeneratorProperties.TryAdd(typeof(T), properties); + } +} diff --git a/TUnit.Core/Sources.cs b/TUnit.Core/Sources.cs index ecd3d95470..a48d1d7057 100644 --- a/TUnit.Core/Sources.cs +++ b/TUnit.Core/Sources.cs @@ -12,10 +12,12 @@ internal static class Sources public static readonly ConcurrentQueue> AssemblyLoaders = []; public static readonly ConcurrentQueue TestSources = []; public static readonly ConcurrentQueue DynamicTestSources = []; - + public static readonly ConcurrentQueue TestHookSources = []; public static readonly ConcurrentQueue ClassHookSources = []; public static readonly ConcurrentQueue AssemblyHookSources = []; public static readonly ConcurrentQueue TestSessionHookSources = []; public static readonly ConcurrentQueue TestDiscoveryHookSources = []; -} \ No newline at end of file + + public static readonly ConcurrentDictionary DataGeneratorProperties = new(); +} diff --git a/TUnit.Core/TUnit.Core.csproj b/TUnit.Core/TUnit.Core.csproj index b00867f09a..db045f010c 100644 --- a/TUnit.Core/TUnit.Core.csproj +++ b/TUnit.Core/TUnit.Core.csproj @@ -65,4 +65,8 @@ + + + + \ No newline at end of file diff --git a/TUnit.Core/TestContext.cs b/TUnit.Core/TestContext.cs index 35ce779241..6fa75ca6ce 100644 --- a/TUnit.Core/TestContext.cs +++ b/TUnit.Core/TestContext.cs @@ -35,21 +35,26 @@ public partial class TestContext : Context #endif internal bool ReportResult = true; - + /// /// Initializes a new instance of the class. /// /// The service provider. /// The test details. /// The original metadata. - internal TestContext(IServiceProvider serviceProvider, TestDetails testDetails, TestMetadata originalMetadata) + /// + internal TestContext(IServiceProvider serviceProvider, TestDetails testDetails, TestMetadata originalMetadata, ClassHookContext classHookContext) : base(classHookContext) { _serviceProvider = serviceProvider; OriginalMetadata = originalMetadata; TestDetails = testDetails; ObjectBag = originalMetadata.TestBuilderContext.ObjectBag; Events = originalMetadata.TestBuilderContext.Events; + classHookContext.AddTest(this); } + + public ClassHookContext ClassContext => (ClassHookContext) Parent!; + public AssemblyHookContext AssemblyContext => ClassContext.AssemblyContext; /// /// Gets the events associated with the test context. @@ -139,4 +144,9 @@ public void AddArtifact(Artifact artifact) internal object?[]? EventObjects { get; set; } internal bool RunOnTestDiscovery { get; set; } + + internal override void RestoreContextAsyncLocal() + { + Current = this; + } } \ No newline at end of file diff --git a/TUnit.Core/TestDataContainer.cs b/TUnit.Core/TestDataContainer.cs index ec952bde25..aa69218c5b 100644 --- a/TUnit.Core/TestDataContainer.cs +++ b/TUnit.Core/TestDataContainer.cs @@ -2,27 +2,25 @@ using System.Reflection; using TUnit.Core.Data; using TUnit.Core.Helpers; +using TUnit.Core.Logging; namespace TUnit.Core; /// -/// Represents a container for test data. +/// Represents a container for test data with improved error handling and unified data structures. /// internal static class TestDataContainer { - private static readonly GetOnlyDictionary InjectedSharedGlobally = new(); - private static readonly GetOnlyDictionary> InjectedSharedPerClassType = new(); - private static readonly GetOnlyDictionary> InjectedSharedPerAssembly = new(); - private static readonly GetOnlyDictionary> InjectedSharedPerKey = new(); - - private static readonly ConcurrentDictionary> CountsPerKey = new(); - private static readonly ConcurrentDictionary CountsPerTestSession = new(); - private static readonly ConcurrentDictionary> CountsPerAssembly = new(); - private static readonly ConcurrentDictionary> CountsPerTestClass = new(); - - private static Disposer Disposer => new(GlobalContext.Current.GlobalLogger); - - /// + // Unified containers using the new improved architecture + private static readonly ScopedContainer GlobalContainer = new(); + private static readonly ScopedContainer ClassContainer = new(); + private static readonly ScopedContainer AssemblyContainer = new(); + private static readonly ScopedContainer KeyContainer = new(); + + // Improved dependency tracking + private static readonly Data.DependencyTracker DependencyTracker = new(); + + private static Disposer Disposer => new(GlobalContext.Current.GlobalLogger); /// /// Gets an instance for the specified class. /// /// The test class type. @@ -31,9 +29,8 @@ internal static class TestDataContainer /// The instance. public static object GetInstanceForClass(Type testClass, Type type, Func func) { - var objectsForClass = InjectedSharedPerClassType.GetOrAdd(testClass, _ => new GetOnlyDictionary()); - - return objectsForClass.GetOrAdd(type, _ => func()); + var scopedInstance = ClassContainer.GetOrCreate(testClass, type, func); + return scopedInstance.Instance; } /// @@ -45,20 +42,22 @@ public static object GetInstanceForClass(Type testClass, Type type, Func /// The instance. public static object GetInstanceForAssembly(Assembly assembly, Type type, Func func) { - var objectsForClass = InjectedSharedPerAssembly.GetOrAdd(assembly, _ => new GetOnlyDictionary()); - - return objectsForClass.GetOrAdd(type, _ => func()); + var scopedInstance = AssemblyContainer.GetOrCreate(assembly, type, func); + return scopedInstance.Instance; } - + /// /// Increments the global usage count for the specified type. /// /// The type. public static void IncrementGlobalUsage(Type type) { - CountsPerTestSession.GetOrAdd(type, _ => new Counter()).Increment(); + if (GlobalContainer.TryGet(typeof(object).FullName!, type, out var instance)) + { + instance?.UsageCount.Increment(); + } } - + /// /// Gets a global instance of the specified type. /// @@ -67,9 +66,10 @@ public static void IncrementGlobalUsage(Type type) /// The instance. public static object GetGlobalInstance(Type type, Func func) { - return InjectedSharedGlobally.GetOrAdd(type, _ => func()); + var scopedInstance = GlobalContainer.GetOrCreate(typeof(object).FullName!, type, func); + return scopedInstance.Instance; } - + /// /// Increments the usage count for the specified test class and type. /// @@ -77,11 +77,12 @@ public static object GetGlobalInstance(Type type, Func func) /// The type. public static void IncrementTestClassUsage(Type testClassType, Type type) { - var itemsForTestClass = CountsPerTestClass.GetOrAdd(testClassType, _ => []); - - itemsForTestClass.GetOrAdd(type, _ => new Counter()).Increment(); + if (ClassContainer.TryGet(testClassType, type, out var instance)) + { + instance?.UsageCount.Increment(); + } } - + /// /// Increments the usage count for the specified assembly and type. /// @@ -89,9 +90,10 @@ public static void IncrementTestClassUsage(Type testClassType, Type type) /// The type. public static void IncrementAssemblyUsage(Assembly assembly, Type type) { - var itemsForAssembly = CountsPerAssembly.GetOrAdd(assembly, _ => []); - - itemsForAssembly.GetOrAdd(type, _ => new Counter()).Increment(); + if (AssemblyContainer.TryGet(assembly, type, out var instance)) + { + instance?.UsageCount.Increment(); + } } /// @@ -101,9 +103,10 @@ public static void IncrementAssemblyUsage(Assembly assembly, Type type) /// The type. public static void IncrementKeyUsage(string key, Type type) { - var keysForType = CountsPerKey.GetOrAdd(type, _ => []); - - keysForType.GetOrAdd(key, _ => new Counter()).Increment(); + if (KeyContainer.TryGet(key, type, out var instance)) + { + instance?.UsageCount.Increment(); + } } /// @@ -115,74 +118,266 @@ public static void IncrementKeyUsage(string key, Type type) /// The instance. public static object GetInstanceForKey(string key, Type type, Func func) { - var instancesForType = InjectedSharedPerKey.GetOrAdd(type, _ => new GetOnlyDictionary()); - - return instancesForType.GetOrAdd(key, _ => func()); - } - - /// + var scopedInstance = KeyContainer.GetOrCreate(key, type, func); + return scopedInstance.Instance; + } /// /// Consumes the count for the specified key and type. /// /// The key. /// The type. internal static async ValueTask ConsumeKey(string key, Type type) { - var keysForType = CountsPerKey[type]; - - if (keysForType[key].Decrement() > 0) + if (!KeyContainer.TryGet(key, type, out var instance) || instance == null) { + // Log warning about untracked object disposal + GlobalContext.Current.GlobalLogger?.LogWarning($"Attempting to dispose untracked key-scoped object of type {type.Name} with key {key}"); return; } - - var instancesForType = InjectedSharedPerKey.GetOrAdd(type, _ => new GetOnlyDictionary()); - - await Disposer.DisposeAsync(instancesForType.Remove(key)); + + if (instance.UsageCount.Decrement() > 0) + { + return; + } + + var removedInstance = KeyContainer.Remove(key, type); + if (removedInstance != null) + { + await DisposeWithNestedDependencies(removedInstance.Instance); + } } /// - /// Consumes the global count for the specified item. + /// Consumes the global count for the specified item with improved error handling. /// /// The type of the item. /// The item. internal static async ValueTask ConsumeGlobalCount(T? item) { - if (CountsPerTestSession[typeof(T)].Decrement() > 0) + if (!GlobalContainer.TryGet(typeof(object).FullName!, typeof(T), out var instance) || instance == null) { + // Log warning about untracked object disposal + GlobalContext.Current.GlobalLogger?.LogWarning($"Attempting to dispose untracked global object of type {typeof(T).Name}"); + await Disposer.DisposeAsync(item); return; } - - await Disposer.DisposeAsync(item); + + if (instance.UsageCount.Decrement() > 0) + { + return; + } + + var removedInstance = GlobalContainer.Remove(typeof(object).FullName!, typeof(T)); + if (removedInstance != null) + { + await DisposeWithNestedDependencies(removedInstance.Instance); + } } - + /// - /// Consumes the assembly count for the specified item. + /// Consumes the assembly count for the specified item with improved error handling. /// /// The type of the item. /// The assembly. /// The item. internal static async ValueTask ConsumeAssemblyCount(Assembly assembly, T? item) { - if (CountsPerAssembly[assembly][typeof(T)].Decrement() > 0) + if (!AssemblyContainer.TryGet(assembly, typeof(T), out var instance) || instance == null) { + // Log warning about untracked object disposal + GlobalContext.Current.GlobalLogger?.LogWarning($"Attempting to dispose untracked assembly-scoped object of type {typeof(T).Name} in assembly {assembly.GetName().Name}"); + await Disposer.DisposeAsync(item); return; } - - await Disposer.DisposeAsync(item); + + if (instance.UsageCount.Decrement() > 0) + { + return; + } + + var removedInstance = AssemblyContainer.Remove(assembly, typeof(T)); + if (removedInstance != null) + { + await DisposeWithNestedDependencies(removedInstance.Instance); + } } - + /// - /// Consumes the test class count for the specified item. + /// Consumes the test class count for the specified item with improved error handling. /// /// The type of the item. /// The test class type. /// The item. internal static async ValueTask ConsumeTestClassCount(Type testClassType, T? item) { - if (CountsPerTestClass[testClassType][typeof(T)].Decrement() > 0) + if (!ClassContainer.TryGet(testClassType, typeof(T), out var instance) || instance == null) + { + // Log warning about untracked object disposal + GlobalContext.Current.GlobalLogger?.LogWarning($"Attempting to dispose untracked class-scoped object of type {typeof(T).Name} in class {testClassType.Name}"); + await Disposer.DisposeAsync(item); + return; + } + + if (instance.UsageCount.Decrement() > 0) + { + return; + } + + var removedInstance = ClassContainer.Remove(testClassType, typeof(T)); + if (removedInstance != null) + { + await DisposeWithNestedDependencies(removedInstance.Instance); + } + } + /// + /// Gets an improved global instance using the unified container approach. + /// + /// The type of object to retrieve + /// The function to create the instance. + /// The instance. + public static T GetImprovedGlobalInstance(Func func) where T : class + { + var scopedInstance = GlobalContainer.GetOrCreate(typeof(T).FullName!, typeof(T), () => func()!); + return (T)scopedInstance.Instance; + } /// + /// Gets diagnostic metrics for the test data container. + /// + /// The metrics information. + public static TestDataMetrics GetMetrics() + { + var globalDiagnostics = GlobalContainer.GetDiagnostics(); + var classDiagnostics = ClassContainer.GetDiagnostics(); + var assemblyDiagnostics = AssemblyContainer.GetDiagnostics(); + var keyDiagnostics = KeyContainer.GetDiagnostics(); + + return new TestDataMetrics + { + GlobalInstances = (int)globalDiagnostics["TotalInstances"], + ClassScopedInstances = (int)classDiagnostics["TotalInstances"], + AssemblyScopedInstances = (int)assemblyDiagnostics["TotalInstances"], + KeyScopedInstances = (int)keyDiagnostics["TotalInstances"], + NestedDependencies = DependencyTracker.GetDependencyCount(), + Details = new Dictionary + { + ["Global"] = globalDiagnostics, + ["Class"] = classDiagnostics, + ["Assembly"] = assemblyDiagnostics, + ["Key"] = keyDiagnostics, + } + }; + } + + /// + /// Dumps diagnostic information about the current state of the container. + /// + /// A string containing diagnostic information. + public static string DumpDiagnostics() + { + var metrics = GetMetrics(); + var sb = new System.Text.StringBuilder(); + + sb.AppendLine("=== TestDataContainer Diagnostics ==="); + sb.AppendLine($"Timestamp: {DateTimeOffset.UtcNow}"); + sb.AppendLine(); + + sb.AppendLine("New Unified Containers:"); + sb.AppendLine($" Global Instances: {metrics.GlobalInstances}"); + sb.AppendLine($" Class Instances: {metrics.ClassScopedInstances}"); + sb.AppendLine($" Assembly Instances: {metrics.AssemblyScopedInstances}"); + sb.AppendLine($" Keyed Instances: {metrics.KeyScopedInstances}"); + sb.AppendLine(); + + sb.AppendLine($"Total Dependencies Tracked: {metrics.NestedDependencies}"); + sb.AppendLine($"Total Instances: {metrics.TotalInstances}"); + + return sb.ToString(); + } /// + /// Disposes an object and all its nested dependencies using the new dependency tracker. + /// + /// The item to dispose. + private static async ValueTask DisposeWithNestedDependencies(T? item) + { + if (item is null) { return; } - + + // First, dispose nested dependencies using the new dependency tracker + await DependencyTracker.DisposeNestedDependenciesAsync(item); + + // Then dispose the item itself await Disposer.DisposeAsync(item); + } /// + /// Registers a nested dependency relationship between a parent and child object using the new dependency tracker. + /// + /// The parent object that depends on the child. + /// The child object that the parent depends on. + /// The shared type of the child object. + /// The key of the child object (for keyed sharing). + internal static void RegisterNestedDependency(object parentObject, object childObject, SharedType childSharedType, string? childKey) + { + // For now, we'll track the dependency relationship directly without scope managers + // since the current scope managers don't have a unified interface that supports all scenarios + // The new dependency tracker will handle disposal ordering properly + + // Create a simple disposable reference that just disposes the child directly + var disposableRef = new DirectDisposableReference(childObject); + DependencyTracker.RegisterDependency(parentObject, childObject, new DirectScopeManager()); + + // Don't increment usage counts here - they're already managed by the main ClassDataSource attribute logic + // We only track the relationship for proper disposal ordering + } + + /// + /// A simple scope manager that directly disposes objects without additional scope logic. + /// This is used for nested dependency tracking where we just want disposal ordering. + /// + private class DirectScopeManager : IScopeManager + { + public T GetOrCreate(Func factory) => factory(); + public void IncrementUsage() { /* No-op for direct disposal */ } + public Task TryDisposeAsync(T item) + { + // Always dispose directly since this is for nested dependencies + return DisposeHelper.DisposeAsync(item).AsTask().ContinueWith(_ => true); + } + } + + /// + /// A direct disposable reference implementation. + /// + private class DirectDisposableReference + { + private readonly object _instance; + + public DirectDisposableReference(object instance) + { + _instance = instance; + } + + public async Task DisposeAsync() + { + await DisposeHelper.DisposeAsync(_instance); + } + } + + /// + /// Helper class for disposing objects (duplicate of the one in GlobalScopeManager for internal use). + /// + private static class DisposeHelper + { + public static async ValueTask DisposeAsync(object? obj) + { + switch (obj) + { + case null: + return; + case IAsyncDisposable asyncDisposable: + await asyncDisposable.DisposeAsync(); + break; + case IDisposable disposable: + disposable.Dispose(); + break; + } + } } -} \ No newline at end of file +} diff --git a/TUnit.Core/UntypedDiscoveredTest.cs b/TUnit.Core/UntypedDiscoveredTest.cs index 134d51666a..119a6beb06 100644 --- a/TUnit.Core/UntypedDiscoveredTest.cs +++ b/TUnit.Core/UntypedDiscoveredTest.cs @@ -7,14 +7,16 @@ namespace TUnit.Core; [UnconditionalSuppressMessage("Trimming", "IL2072:Target parameter argument does not satisfy \'DynamicallyAccessedMembersAttribute\' in call to target method. The return value of the source method does not have matching annotations.")] +[UnconditionalSuppressMessage("Trimming", "IL2060:Call to \'System.Reflection.MethodInfo.MakeGenericMethod\' can not be statically analyzed. It\'s not possible to guarantee the availability of requirements of the generic method.")] +[UnconditionalSuppressMessage("AOT", "IL3050:Calling members annotated with \'RequiresDynamicCodeAttribute\' may break functionality when AOT compiling.")] internal record UntypedDiscoveredTest(ResettableLazy ResettableLazy) : DiscoveredTest { public override async ValueTask ExecuteTest(CancellationToken cancellationToken) { TestContext.CancellationToken = cancellationToken; - + var arguments = TestDetails.TestMethodArguments.ToList(); - + if (TestDetails.TestMethod.Parameters.Any(x => x.Type == typeof(CancellationToken))) { arguments.Add(cancellationToken); @@ -24,14 +26,15 @@ public override async ValueTask ExecuteTest(CancellationToken cancellationToken) { await TestExecutor.ExecuteTest(TestContext, () => { - return AsyncConvert.ConvertObject(TestDetails.TestMethod.ReflectionInformation.Invoke(ResettableLazy.Value, arguments.Select((x, i) => CastHelper.Cast(TestDetails.TestMethod.Parameters[i].Type, x)).ToArray())); + return AsyncConvert.ConvertObject(TestDetails.TestMethod.ReflectionInformation.Invoke(ResettableLazy.Value, + arguments.Select((x, i) => CastHelper.Cast(TestDetails.TestMethod.Parameters[i].Type, x)).ToArray())); }); } catch (TargetInvocationException targetInvocationException) { if (targetInvocationException.InnerException != null) { - ExceptionDispatchInfo.Capture(targetInvocationException.InnerException).Throw(); + ExceptionDispatchInfo.Capture(targetInvocationException.InnerException ?? targetInvocationException).Throw(); } throw; @@ -47,4 +50,4 @@ public override IClassConstructor? ClassConstructor { get; } = ResettableLazy.ClassConstructor; -} \ No newline at end of file +} diff --git a/TUnit.Core/UntypedTestMetadata.cs b/TUnit.Core/UntypedTestMetadata.cs index 00af413077..b01b217e9d 100644 --- a/TUnit.Core/UntypedTestMetadata.cs +++ b/TUnit.Core/UntypedTestMetadata.cs @@ -12,7 +12,7 @@ public record UntypedTestMetadata( { [field: AllowNull, MaybeNull] private ResettableLazy ResettableLazy => field ??= new ResettableLazy(() => InstanceHelper.CreateInstance(TestMethod.Class, TestClassArguments, TestClassProperties, TestBuilderContext), string.Empty, new TestBuilderContext()); - + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] public override Type TestClassType { @@ -63,4 +63,4 @@ public override TestMetadata CloneWithNewMethodFactory(Func result.ResultSummary.Outcome.ShouldBe("Completed"), - result => result.ResultSummary.Counters.Total.ShouldBe(6), - result => result.ResultSummary.Counters.Passed.ShouldBe(6), - result => result.ResultSummary.Counters.Failed.ShouldBe(0), - result => result.ResultSummary.Counters.NotExecuted.ShouldBe(0) - ]); - } -} \ No newline at end of file diff --git a/TUnit.Engine.Tests/AsyncLocalTest.cs b/TUnit.Engine.Tests/AsyncLocalTest.cs deleted file mode 100644 index 5e9345db80..0000000000 --- a/TUnit.Engine.Tests/AsyncLocalTest.cs +++ /dev/null @@ -1,23 +0,0 @@ -using Shouldly; -using TUnit.Engine.Tests.Attributes; -using TUnit.Engine.Tests.Enums; - -namespace TUnit.Engine.Tests; - -[SkipNetFramework("ExecutionContext.Restore is not supported on .NET Framework")] -public class AsyncLocalTest(TestMode testMode) : InvokableTestBase(testMode) -{ - [Test] - public async Task Test() - { - await RunTestsWithFilter( - "/*/*/AsyncLocalTest/*", - [ - result => result.ResultSummary.Outcome.ShouldBe("Completed"), - result => result.ResultSummary.Counters.Total.ShouldBe(1), - result => result.ResultSummary.Counters.Passed.ShouldBe(1), - result => result.ResultSummary.Counters.Failed.ShouldBe(0), - result => result.ResultSummary.Counters.NotExecuted.ShouldBe(0) - ]); - } -} \ No newline at end of file diff --git a/TUnit.Engine.Tests/BasicTestsHooksFromLibrary.cs b/TUnit.Engine.Tests/BasicTestsHooksFromLibrary.cs deleted file mode 100644 index d6cf9145fb..0000000000 --- a/TUnit.Engine.Tests/BasicTestsHooksFromLibrary.cs +++ /dev/null @@ -1,21 +0,0 @@ -using Shouldly; -using TUnit.Engine.Tests.Enums; - -namespace TUnit.Engine.Tests; - -public class BasicTestsHooksFromLibrary(TestMode testMode) : InvokableTestBase(testMode) -{ - [Test] - public async Task Test() - { - await RunTestsWithFilter( - "/*/*/BasicTestsHooksFromLibrary/*", - [ - result => result.ResultSummary.Outcome.ShouldBe("Completed"), - result => result.ResultSummary.Counters.Total.ShouldBe(1), - result => result.ResultSummary.Counters.Passed.ShouldBe(1), - result => result.ResultSummary.Counters.Failed.ShouldBe(0), - result => result.ResultSummary.Counters.NotExecuted.ShouldBe(0) - ]); - } -} \ No newline at end of file diff --git a/TUnit.Engine.Tests/Bugs/Bug1187.cs b/TUnit.Engine.Tests/Bugs/Bug1187.cs deleted file mode 100644 index ef4abe1afd..0000000000 --- a/TUnit.Engine.Tests/Bugs/Bug1187.cs +++ /dev/null @@ -1,21 +0,0 @@ -using Shouldly; -using TUnit.Engine.Tests.Enums; - -namespace TUnit.Engine.Tests.Bugs; - -public class Bug1187(TestMode testMode) : InvokableTestBase(testMode) -{ - [Test] - public async Task Test() - { - await RunTestsWithFilter( - "/*/TUnit.TestProject.Bugs._1187/*/*", - [ - result => result.ResultSummary.Outcome.ShouldBe("Completed"), - result => result.ResultSummary.Counters.Total.ShouldBe(24), - result => result.ResultSummary.Counters.Passed.ShouldBe(24), - result => result.ResultSummary.Counters.Failed.ShouldBe(0), - result => result.ResultSummary.Counters.NotExecuted.ShouldBe(0) - ]); - } -} \ No newline at end of file diff --git a/TUnit.Engine.Tests/Bugs/Bug1410.cs b/TUnit.Engine.Tests/Bugs/Bug1410.cs deleted file mode 100644 index 91e34ce56b..0000000000 --- a/TUnit.Engine.Tests/Bugs/Bug1410.cs +++ /dev/null @@ -1,21 +0,0 @@ -using Shouldly; -using TUnit.Engine.Tests.Enums; - -namespace TUnit.Engine.Tests.Bugs; - -public class Bug1410(TestMode testMode) : InvokableTestBase(testMode) -{ - [Test] - public async Task Test() - { - await RunTestsWithFilter( - "/*/TUnit.TestProject.Bugs._1410/*/ReproTest2", - [ - result => result.ResultSummary.Outcome.ShouldBe("Completed"), - result => result.ResultSummary.Counters.Total.ShouldBe(2), - result => result.ResultSummary.Counters.Passed.ShouldBe(2), - result => result.ResultSummary.Counters.Failed.ShouldBe(0), - result => result.ResultSummary.Counters.NotExecuted.ShouldBe(0) - ]); - } -} \ No newline at end of file diff --git a/TUnit.Engine.Tests/Bugs/Bug1570.cs b/TUnit.Engine.Tests/Bugs/Bug1570.cs deleted file mode 100644 index faad305c3c..0000000000 --- a/TUnit.Engine.Tests/Bugs/Bug1570.cs +++ /dev/null @@ -1,21 +0,0 @@ -using Shouldly; -using TUnit.Engine.Tests.Enums; - -namespace TUnit.Engine.Tests.Bugs; - -public class Bug1570(TestMode testMode) : InvokableTestBase(testMode) -{ - [Test] - public async Task Test() - { - await RunTestsWithFilter( - "/*/TUnit.TestProject.Bugs._1570/*/*", - [ - result => result.ResultSummary.Outcome.ShouldBe("Completed"), - result => result.ResultSummary.Counters.Total.ShouldBe(6), - result => result.ResultSummary.Counters.Passed.ShouldBe(6), - result => result.ResultSummary.Counters.Failed.ShouldBe(0), - result => result.ResultSummary.Counters.NotExecuted.ShouldBe(0) - ]); - } -} \ No newline at end of file diff --git a/TUnit.Engine.Tests/Bugs/Bug1577.cs b/TUnit.Engine.Tests/Bugs/Bug1577.cs deleted file mode 100644 index 59d7268acc..0000000000 --- a/TUnit.Engine.Tests/Bugs/Bug1577.cs +++ /dev/null @@ -1,21 +0,0 @@ -using Shouldly; -using TUnit.Engine.Tests.Enums; - -namespace TUnit.Engine.Tests.Bugs; - -public class Bug1577(TestMode testMode) : InvokableTestBase(testMode) -{ - [Test] - public async Task Test() - { - await RunTestsWithFilter( - "/*/TUnit.TestProject.Bugs._1577/*/*", - [ - result => result.ResultSummary.Outcome.ShouldBe("Completed"), - result => result.ResultSummary.Counters.Total.ShouldBe(4), - result => result.ResultSummary.Counters.Passed.ShouldBe(4), - result => result.ResultSummary.Counters.Failed.ShouldBe(0), - result => result.ResultSummary.Counters.NotExecuted.ShouldBe(0) - ]); - } -} \ No newline at end of file diff --git a/TUnit.Engine.Tests/Bugs/Bug1603.cs b/TUnit.Engine.Tests/Bugs/Bug1603.cs deleted file mode 100644 index b7e6e819e6..0000000000 --- a/TUnit.Engine.Tests/Bugs/Bug1603.cs +++ /dev/null @@ -1,21 +0,0 @@ -using Shouldly; -using TUnit.Engine.Tests.Enums; - -namespace TUnit.Engine.Tests.Bugs; - -public class Bug1603(TestMode testMode) : InvokableTestBase(testMode) -{ - [Test] - public async Task Test() - { - await RunTestsWithFilter( - "/*/TUnit.TestProject.Bugs._1603/*/*", - [ - result => result.ResultSummary.Outcome.ShouldBe("Completed"), - result => result.ResultSummary.Counters.Total.ShouldBe(2), - result => result.ResultSummary.Counters.Passed.ShouldBe(2), - result => result.ResultSummary.Counters.Failed.ShouldBe(0), - result => result.ResultSummary.Counters.NotExecuted.ShouldBe(0) - ]); - } -} \ No newline at end of file diff --git a/TUnit.Engine.Tests/Bugs/Bug1821.cs b/TUnit.Engine.Tests/Bugs/Bug1821.cs deleted file mode 100644 index 627eb04df2..0000000000 --- a/TUnit.Engine.Tests/Bugs/Bug1821.cs +++ /dev/null @@ -1,21 +0,0 @@ -using Shouldly; -using TUnit.Engine.Tests.Enums; - -namespace TUnit.Engine.Tests.Bugs; - -public class Bug1821(TestMode testMode) : InvokableTestBase(testMode) -{ - [Test] - public async Task Test() - { - await RunTestsWithFilter( - "/*/TUnit.TestProject.Bugs._1821/*/*", - [ - result => result.ResultSummary.Outcome.ShouldBe("Completed"), - result => result.ResultSummary.Counters.Total.ShouldBe(2), - result => result.ResultSummary.Counters.Passed.ShouldBe(2), - result => result.ResultSummary.Counters.Failed.ShouldBe(0), - result => result.ResultSummary.Counters.NotExecuted.ShouldBe(0) - ]); - } -} \ No newline at end of file diff --git a/TUnit.Engine.Tests/Bugs/Bug1836.cs b/TUnit.Engine.Tests/Bugs/Bug1836.cs deleted file mode 100644 index 5829360171..0000000000 --- a/TUnit.Engine.Tests/Bugs/Bug1836.cs +++ /dev/null @@ -1,21 +0,0 @@ -using Shouldly; -using TUnit.Engine.Tests.Enums; - -namespace TUnit.Engine.Tests.Bugs; - -public class Bug1836(TestMode testMode) : InvokableTestBase(testMode) -{ - [Test] - public async Task Test() - { - await RunTestsWithFilter( - "/*/TUnit.TestProject.Bugs._1836/*/*", - [ - result => result.ResultSummary.Outcome.ShouldBe("Completed"), - result => result.ResultSummary.Counters.Total.ShouldBe(1), - result => result.ResultSummary.Counters.Passed.ShouldBe(1), - result => result.ResultSummary.Counters.Failed.ShouldBe(0), - result => result.ResultSummary.Counters.NotExecuted.ShouldBe(0) - ]); - } -} \ No newline at end of file diff --git a/TUnit.Engine.Tests/Bugs/Bug1899.cs b/TUnit.Engine.Tests/Bugs/Bug1899.cs deleted file mode 100644 index 43eac83249..0000000000 --- a/TUnit.Engine.Tests/Bugs/Bug1899.cs +++ /dev/null @@ -1,21 +0,0 @@ -using Shouldly; -using TUnit.Engine.Tests.Enums; - -namespace TUnit.Engine.Tests.Bugs; - -public class Bug1899(TestMode testMode) : InvokableTestBase(testMode) -{ - [Test] - public async Task Test() - { - await RunTestsWithFilter( - "/*/TUnit.TestProject.Bugs._1899/*/*", - [ - result => result.ResultSummary.Outcome.ShouldBe("Completed"), - result => result.ResultSummary.Counters.Total.ShouldBe(1), - result => result.ResultSummary.Counters.Passed.ShouldBe(1), - result => result.ResultSummary.Counters.Failed.ShouldBe(0), - result => result.ResultSummary.Counters.NotExecuted.ShouldBe(0) - ]); - } -} \ No newline at end of file diff --git a/TUnit.Engine.Tests/Bugs/Bug1924.cs b/TUnit.Engine.Tests/Bugs/Bug1924.cs deleted file mode 100644 index b1fe191980..0000000000 --- a/TUnit.Engine.Tests/Bugs/Bug1924.cs +++ /dev/null @@ -1,21 +0,0 @@ -using Shouldly; -using TUnit.Engine.Tests.Enums; - -namespace TUnit.Engine.Tests.Bugs; - -public class Bug1924(TestMode testMode) : InvokableTestBase(testMode) -{ - [Test] - public async Task Test() - { - await RunTestsWithFilter( - "/*/TUnit.TestProject.Bugs._1924.*/*/*", - [ - result => result.ResultSummary.Outcome.ShouldBe("Completed"), - result => result.ResultSummary.Counters.Total.ShouldBe(660), - result => result.ResultSummary.Counters.Passed.ShouldBe(660), - result => result.ResultSummary.Counters.Failed.ShouldBe(0), - result => result.ResultSummary.Counters.NotExecuted.ShouldBe(0) - ]); - } -} \ No newline at end of file diff --git a/TUnit.Engine.Tests/Bugs/Bug1939.cs b/TUnit.Engine.Tests/Bugs/Bug1939.cs deleted file mode 100644 index e9824ff83f..0000000000 --- a/TUnit.Engine.Tests/Bugs/Bug1939.cs +++ /dev/null @@ -1,21 +0,0 @@ -using Shouldly; -using TUnit.Engine.Tests.Enums; - -namespace TUnit.Engine.Tests.Bugs; - -public class Bug1939(TestMode testMode) : InvokableTestBase(testMode) -{ - [Test] - public async Task Test() - { - await RunTestsWithFilter( - "/*/TUnit.TestProject.Bugs._1939/*/*", - [ - result => result.ResultSummary.Outcome.ShouldBe("Completed"), - result => result.ResultSummary.Counters.Total.ShouldBe(6), - result => result.ResultSummary.Counters.Passed.ShouldBe(6), - result => result.ResultSummary.Counters.Failed.ShouldBe(0), - result => result.ResultSummary.Counters.NotExecuted.ShouldBe(0) - ]); - } -} \ No newline at end of file diff --git a/TUnit.Engine.Tests/Bugs/Bug2067.cs b/TUnit.Engine.Tests/Bugs/Bug2067.cs deleted file mode 100644 index e918c9a102..0000000000 --- a/TUnit.Engine.Tests/Bugs/Bug2067.cs +++ /dev/null @@ -1,21 +0,0 @@ -using Shouldly; -using TUnit.Engine.Tests.Enums; - -namespace TUnit.Engine.Tests.Bugs; - -public class Bug2067(TestMode testMode) : InvokableTestBase(testMode) -{ - [Test] - public async Task Test() - { - await RunTestsWithFilter( - "/*/TUnit.TestProject.Bugs._2067/*/*", - [ - result => result.ResultSummary.Outcome.ShouldBe("Completed"), - result => result.ResultSummary.Counters.Total.ShouldBe(1), - result => result.ResultSummary.Counters.Passed.ShouldBe(1), - result => result.ResultSummary.Counters.Failed.ShouldBe(0), - result => result.ResultSummary.Counters.NotExecuted.ShouldBe(0) - ]); - } -} \ No newline at end of file diff --git a/TUnit.Engine.Tests/Bugs/Bug2136.cs b/TUnit.Engine.Tests/Bugs/Bug2136.cs deleted file mode 100644 index e86f87da9d..0000000000 --- a/TUnit.Engine.Tests/Bugs/Bug2136.cs +++ /dev/null @@ -1,21 +0,0 @@ -using Shouldly; -using TUnit.Engine.Tests.Enums; - -namespace TUnit.Engine.Tests.Bugs; - -public class Bug2136(TestMode testMode) : InvokableTestBase(testMode) -{ - [Test] - public async Task Test() - { - await RunTestsWithFilter( - "/*/TUnit.TestProject.Bugs._2136/*/*", - [ - result => result.ResultSummary.Outcome.ShouldBe("Completed"), - result => result.ResultSummary.Counters.Total.ShouldBe(5), - result => result.ResultSummary.Counters.Passed.ShouldBe(5), - result => result.ResultSummary.Counters.Failed.ShouldBe(0), - result => result.ResultSummary.Counters.NotExecuted.ShouldBe(0) - ]); - } -} \ No newline at end of file diff --git a/TUnit.Engine.Tests/Bugs/Bug2449.cs b/TUnit.Engine.Tests/Bugs/Bug2449.cs deleted file mode 100644 index 2333cd6db0..0000000000 --- a/TUnit.Engine.Tests/Bugs/Bug2449.cs +++ /dev/null @@ -1,21 +0,0 @@ -using Shouldly; -using TUnit.Engine.Tests.Enums; - -namespace TUnit.Engine.Tests.Bugs; - -public class Bug2449(TestMode testMode) : InvokableTestBase(testMode) -{ - [Test] - public async Task Test() - { - await RunTestsWithFilter( - "/*/TUnit.TestProject.Bugs._2449/*/*", - [ - result => result.ResultSummary.Outcome.ShouldBe("Completed"), - result => result.ResultSummary.Counters.Total.ShouldBe(2), - result => result.ResultSummary.Counters.Passed.ShouldBe(2), - result => result.ResultSummary.Counters.Failed.ShouldBe(0), - result => result.ResultSummary.Counters.NotExecuted.ShouldBe(0) - ]); - } -} \ No newline at end of file diff --git a/TUnit.Engine.Tests/ClassConstructorWithEnumerableTests.cs b/TUnit.Engine.Tests/ClassConstructorWithEnumerableTests.cs deleted file mode 100644 index fd2451236a..0000000000 --- a/TUnit.Engine.Tests/ClassConstructorWithEnumerableTests.cs +++ /dev/null @@ -1,21 +0,0 @@ -using Shouldly; -using TUnit.Engine.Tests.Enums; - -namespace TUnit.Engine.Tests; - -public class ClassConstructorWithEnumerableTests(TestMode testMode) : InvokableTestBase(testMode) -{ - [Test] - public async Task Test() - { - await RunTestsWithFilter( - "/*/*/ClassConstructorWithEnumerableTest/*", - [ - result => result.ResultSummary.Outcome.ShouldBe("Completed"), - result => result.ResultSummary.Counters.Total.ShouldBe(4), - result => result.ResultSummary.Counters.Passed.ShouldBe(4), - result => result.ResultSummary.Counters.Failed.ShouldBe(0), - result => result.ResultSummary.Counters.NotExecuted.ShouldBe(0) - ]); - } -} \ No newline at end of file diff --git a/TUnit.Engine.Tests/ClassDataSourceDrivenTests.cs b/TUnit.Engine.Tests/ClassDataSourceDrivenTests.cs deleted file mode 100644 index 97c4e0ee92..0000000000 --- a/TUnit.Engine.Tests/ClassDataSourceDrivenTests.cs +++ /dev/null @@ -1,21 +0,0 @@ -using Shouldly; -using TUnit.Engine.Tests.Enums; - -namespace TUnit.Engine.Tests; - -public class ClassDataSourceDrivenTests(TestMode testMode) : InvokableTestBase(testMode) -{ - [Test] - public async Task Test() - { - await RunTestsWithFilter( - "/*/*/ClassDataSourceDrivenTests/*", - [ - result => result.ResultSummary.Outcome.ShouldBe("Completed"), - result => result.ResultSummary.Counters.Total.ShouldBe(7), - result => result.ResultSummary.Counters.Passed.ShouldBe(7), - result => result.ResultSummary.Counters.Failed.ShouldBe(0), - result => result.ResultSummary.Counters.NotExecuted.ShouldBe(0) - ]); - } -} \ No newline at end of file diff --git a/TUnit.Engine.Tests/ClassHooksExecutionCountTests.cs b/TUnit.Engine.Tests/ClassHooksExecutionCountTests.cs deleted file mode 100644 index 6cc81badd7..0000000000 --- a/TUnit.Engine.Tests/ClassHooksExecutionCountTests.cs +++ /dev/null @@ -1,21 +0,0 @@ -using Shouldly; -using TUnit.Engine.Tests.Enums; - -namespace TUnit.Engine.Tests; - -public class ClassHooksExecutionCountTests(TestMode testMode) : InvokableTestBase(testMode) -{ - [Test] - public async Task Test() - { - await RunTestsWithFilter( - "/*/*/ClassHooksExecutionCountTests/*", - [ - result => result.ResultSummary.Outcome.ShouldBe("Completed"), - result => result.ResultSummary.Counters.Total.ShouldBe(5), - result => result.ResultSummary.Counters.Passed.ShouldBe(5), - result => result.ResultSummary.Counters.Failed.ShouldBe(0), - result => result.ResultSummary.Counters.NotExecuted.ShouldBe(0), - ]); - } -} \ No newline at end of file diff --git a/TUnit.Engine.Tests/ComplexDependsOnTests.cs b/TUnit.Engine.Tests/ComplexDependsOnTests.cs deleted file mode 100644 index 4c1b3f88c0..0000000000 --- a/TUnit.Engine.Tests/ComplexDependsOnTests.cs +++ /dev/null @@ -1,21 +0,0 @@ -using Shouldly; -using TUnit.Engine.Tests.Enums; - -namespace TUnit.Engine.Tests; - -public class ComplexDependsOnTests(TestMode testMode) : InvokableTestBase(testMode) -{ - [Test] - public async Task Test() - { - await RunTestsWithFilter( - "/*/*ComplexDependsOn/*/*", - [ - result => result.ResultSummary.Outcome.ShouldBe("Completed"), - result => result.ResultSummary.Counters.Total.ShouldBe(45), - result => result.ResultSummary.Counters.Passed.ShouldBe(45), - result => result.ResultSummary.Counters.Failed.ShouldBe(0), - result => result.ResultSummary.Counters.NotExecuted.ShouldBe(0) - ]); - } -} \ No newline at end of file diff --git a/TUnit.Engine.Tests/ComplexDependsOnTests2.cs b/TUnit.Engine.Tests/ComplexDependsOnTests2.cs deleted file mode 100644 index cd9e5d956e..0000000000 --- a/TUnit.Engine.Tests/ComplexDependsOnTests2.cs +++ /dev/null @@ -1,21 +0,0 @@ -using Shouldly; -using TUnit.Engine.Tests.Enums; - -namespace TUnit.Engine.Tests; - -public class ComplexDependsOnTests2(TestMode testMode) : InvokableTestBase(testMode) -{ - [Test] - public async Task Test() - { - await RunTestsWithFilter( - "/*/*ComplexDependsOn2/*/*", - [ - result => result.ResultSummary.Outcome.ShouldBe("Completed"), - result => result.ResultSummary.Counters.Total.ShouldBe(144), - result => result.ResultSummary.Counters.Passed.ShouldBe(144), - result => result.ResultSummary.Counters.Failed.ShouldBe(0), - result => result.ResultSummary.Counters.NotExecuted.ShouldBe(0) - ]); - } -} \ No newline at end of file diff --git a/TUnit.Engine.Tests/ConcreteBasedOnAbstractClassTests.cs b/TUnit.Engine.Tests/ConcreteBasedOnAbstractClassTests.cs deleted file mode 100644 index 6d9e0974c0..0000000000 --- a/TUnit.Engine.Tests/ConcreteBasedOnAbstractClassTests.cs +++ /dev/null @@ -1,21 +0,0 @@ -using Shouldly; -using TUnit.Engine.Tests.Enums; - -namespace TUnit.Engine.Tests; - -public class ConcreteBasedOnAbstractClassTests(TestMode testMode) : InvokableTestBase(testMode) -{ - [Test] - public async Task Test() - { - await RunTestsWithFilter( - "/*/*/(ConcreteClass1|ConcreteClass2)/*", - [ - result => result.ResultSummary.Outcome.ShouldBe("Failed"), - result => result.ResultSummary.Counters.Total.ShouldBe(3), - result => result.ResultSummary.Counters.Passed.ShouldBe(2), - result => result.ResultSummary.Counters.Failed.ShouldBe(1), - result => result.ResultSummary.Counters.NotExecuted.ShouldBe(0) - ]); - } -} \ No newline at end of file diff --git a/TUnit.Engine.Tests/ConfigurationTests.cs b/TUnit.Engine.Tests/ConfigurationTests.cs deleted file mode 100644 index 5a97896f1c..0000000000 --- a/TUnit.Engine.Tests/ConfigurationTests.cs +++ /dev/null @@ -1,22 +0,0 @@ -using Shouldly; -using TUnit.Engine.Tests.Enums; - -namespace TUnit.Engine.Tests; - -[Skip("Issue with AOT - https://github.com/microsoft/testfx/issues/4972")] -public class ConfigurationTests(TestMode testMode) : InvokableTestBase(testMode) -{ - [Test] - public async Task Test() - { - await RunTestsWithFilter( - "/*/*/ConfigurationTests/*", - [ - result => result.ResultSummary.Outcome.ShouldBe("Completed"), - result => result.ResultSummary.Counters.Total.ShouldBe(3), - result => result.ResultSummary.Counters.Passed.ShouldBe(3), - result => result.ResultSummary.Counters.Failed.ShouldBe(0), - result => result.ResultSummary.Counters.NotExecuted.ShouldBe(0) - ]); - } -} \ No newline at end of file diff --git a/TUnit.Engine.Tests/ConflictingDependsOnTests.cs b/TUnit.Engine.Tests/ConflictingDependsOnTests.cs index 0d8b4667e1..b4a91a6080 100644 --- a/TUnit.Engine.Tests/ConflictingDependsOnTests.cs +++ b/TUnit.Engine.Tests/ConflictingDependsOnTests.cs @@ -16,9 +16,8 @@ await RunTestsWithFilter( result => result.ResultSummary.Counters.Passed.ShouldBe(0), result => result.ResultSummary.Counters.Failed.ShouldBe(2), result => result.ResultSummary.Counters.NotExecuted.ShouldBe(0), - result => result.Results.First(x => x.TestName == "Test1").Output?.ErrorInfo?.Message.ShouldContain("DependsOn Conflict: ConflictingDependsOnTests.Test1 > ConflictingDependsOnTests.Test2 > ConflictingDependsOnTests.Test1"), - result => result.Results.First(x => x.TestName == "Test2").Output?.ErrorInfo?.Message.ShouldContain("DependsOn Conflict: ConflictingDependsOnTests.Test2 > ConflictingDependsOnTests.Test1 > ConflictingDependsOnTests.Test2"), - + result => result.Results.First(x => x.TestName.Contains("Test1")).Output?.ErrorInfo?.Message.ShouldContain("DependsOn Conflict: ConflictingDependsOnTests.Test1 > ConflictingDependsOnTests.Test2 > ConflictingDependsOnTests.Test1"), + result => result.Results.First(x => x.TestName.Contains("Test2")).Output?.ErrorInfo?.Message.ShouldContain("DependsOn Conflict: ConflictingDependsOnTests.Test2 > ConflictingDependsOnTests.Test1 > ConflictingDependsOnTests.Test2"), ]); } } \ No newline at end of file diff --git a/TUnit.Engine.Tests/ConflictingDependsOnTests2.cs b/TUnit.Engine.Tests/ConflictingDependsOnTests2.cs deleted file mode 100644 index f52f8b7001..0000000000 --- a/TUnit.Engine.Tests/ConflictingDependsOnTests2.cs +++ /dev/null @@ -1,24 +0,0 @@ -using Shouldly; -using TUnit.Engine.Tests.Enums; - -namespace TUnit.Engine.Tests; - -public class ConflictingDependsOnTests2(TestMode testMode) : InvokableTestBase(testMode) -{ - [Test] - public async Task Test() - { - await RunTestsWithFilter( - "/*/*/ConflictingDependsOnTests2/*", - [ - result => result.ResultSummary.Outcome.ShouldBe("Failed"), - result => result.ResultSummary.Counters.Total.ShouldBe(3), - result => result.ResultSummary.Counters.Passed.ShouldBe(0), - result => result.ResultSummary.Counters.Failed.ShouldBe(3), - result => result.ResultSummary.Counters.NotExecuted.ShouldBe(0), - result => result.Results.First(x => x.TestName == "Test1").Output?.ErrorInfo?.Message.ShouldContain("DependsOn Conflict: ConflictingDependsOnTests2.Test1 > ConflictingDependsOnTests2.Test3 > ConflictingDependsOnTests2.Test2 > ConflictingDependsOnTests2.Test1"), - result => result.Results.First(x => x.TestName == "Test2").Output?.ErrorInfo?.Message.ShouldContain("DependsOn Conflict: ConflictingDependsOnTests2.Test2 > ConflictingDependsOnTests2.Test1 > ConflictingDependsOnTests2.Test3 > ConflictingDependsOnTests2.Test2"), - result => result.Results.First(x => x.TestName == "Test3").Output?.ErrorInfo?.Message.ShouldContain("DependsOn Conflict: ConflictingDependsOnTests2.Test3 > ConflictingDependsOnTests2.Test2 > ConflictingDependsOnTests2.Test1 > ConflictingDependsOnTests2.Test3"), - ]); - } -} \ No newline at end of file diff --git a/TUnit.Engine.Tests/ConflictingDependsOnTests3.cs b/TUnit.Engine.Tests/ConflictingDependsOnTests3.cs deleted file mode 100644 index dde4f1bd56..0000000000 --- a/TUnit.Engine.Tests/ConflictingDependsOnTests3.cs +++ /dev/null @@ -1,26 +0,0 @@ -using Shouldly; -using TUnit.Engine.Tests.Enums; - -namespace TUnit.Engine.Tests; - -public class ConflictingDependsOnTests3(TestMode testMode) : InvokableTestBase(testMode) -{ - [Test] - public async Task Test() - { - await RunTestsWithFilter( - "/*/*/ConflictingDependsOnTests3/*", - [ - result => result.ResultSummary.Outcome.ShouldBe("Failed"), - result => result.ResultSummary.Counters.Total.ShouldBe(5), - result => result.ResultSummary.Counters.Passed.ShouldBe(0), - result => result.ResultSummary.Counters.Failed.ShouldBe(5), - result => result.ResultSummary.Counters.NotExecuted.ShouldBe(0), - result => result.Results.First(x => x.TestName == "Test1").Output?.ErrorInfo?.Message.ShouldContain("DependsOn Conflict: ConflictingDependsOnTests3.Test1 > ConflictingDependsOnTests3.Test5 > ConflictingDependsOnTests3.Test4 > ConflictingDependsOnTests3.Test3 > ConflictingDependsOnTests3.Test2 > ConflictingDependsOnTests3.Test1"), - result => result.Results.First(x => x.TestName == "Test2").Output?.ErrorInfo?.Message.ShouldContain("DependsOn Conflict: ConflictingDependsOnTests3.Test2 > ConflictingDependsOnTests3.Test1 > ConflictingDependsOnTests3.Test5 > ConflictingDependsOnTests3.Test4 > ConflictingDependsOnTests3.Test3 > ConflictingDependsOnTests3.Test2"), - result => result.Results.First(x => x.TestName == "Test3").Output?.ErrorInfo?.Message.ShouldContain("DependsOn Conflict: ConflictingDependsOnTests3.Test3 > ConflictingDependsOnTests3.Test2 > ConflictingDependsOnTests3.Test1 > ConflictingDependsOnTests3.Test5 > ConflictingDependsOnTests3.Test4 > ConflictingDependsOnTests3.Test3"), - result => result.Results.First(x => x.TestName == "Test4").Output?.ErrorInfo?.Message.ShouldContain("DependsOn Conflict: ConflictingDependsOnTests3.Test4 > ConflictingDependsOnTests3.Test3 > ConflictingDependsOnTests3.Test2 > ConflictingDependsOnTests3.Test1 > ConflictingDependsOnTests3.Test5 > ConflictingDependsOnTests3.Test4"), - result => result.Results.First(x => x.TestName == "Test5").Output?.ErrorInfo?.Message.ShouldContain("DependsOn Conflict: ConflictingDependsOnTests3.Test5 > ConflictingDependsOnTests3.Test4 > ConflictingDependsOnTests3.Test3 > ConflictingDependsOnTests3.Test2 > ConflictingDependsOnTests3.Test1 > ConflictingDependsOnTests3.Test5"), - ]); - } -} \ No newline at end of file diff --git a/TUnit.Engine.Tests/ConsoleTests.cs b/TUnit.Engine.Tests/ConsoleTests.cs deleted file mode 100644 index d95b2a4728..0000000000 --- a/TUnit.Engine.Tests/ConsoleTests.cs +++ /dev/null @@ -1,21 +0,0 @@ -using Shouldly; -using TUnit.Engine.Tests.Enums; - -namespace TUnit.Engine.Tests; - -public class ConsoleTests(TestMode testMode) : InvokableTestBase(testMode) -{ - [Test] - public async Task Test() - { - await RunTestsWithFilter( - "/*/*/ConsoleTests/*", - [ - result => result.ResultSummary.Outcome.ShouldBe("Completed"), - result => result.ResultSummary.Counters.Total.ShouldBe(1), - result => result.ResultSummary.Counters.Passed.ShouldBe(1), - result => result.ResultSummary.Counters.Failed.ShouldBe(0), - result => result.ResultSummary.Counters.NotExecuted.ShouldBe(0) - ]); - } -} \ No newline at end of file diff --git a/TUnit.Engine.Tests/CultureTests.cs b/TUnit.Engine.Tests/CultureTests.cs deleted file mode 100644 index b6afe4dcbc..0000000000 --- a/TUnit.Engine.Tests/CultureTests.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System.Runtime.InteropServices; -using Shouldly; -using TUnit.Engine.Tests.Enums; - -namespace TUnit.Engine.Tests; - -public class CultureTests(TestMode testMode) : InvokableTestBase(testMode) -{ - [Test] - public async Task Test() - { - await RunTestsWithFilter( - "/*/*/CultureTests/*", - [ - result => result.ResultSummary.Outcome.ShouldBe("Completed"), - result => result.ResultSummary.Counters.Total.ShouldBe(3), - result => result.ResultSummary.Counters.Passed.ShouldBe(3), - result => result.ResultSummary.Counters.Failed.ShouldBe(0), - result => result.ResultSummary.Counters.NotExecuted.ShouldBe(0) - ]); - } -} \ No newline at end of file diff --git a/TUnit.Engine.Tests/CustomAssertionTests.cs b/TUnit.Engine.Tests/CustomAssertionTests.cs deleted file mode 100644 index 174516b708..0000000000 --- a/TUnit.Engine.Tests/CustomAssertionTests.cs +++ /dev/null @@ -1,23 +0,0 @@ -using Shouldly; -using TUnit.Engine.Tests.Attributes; -using TUnit.Engine.Tests.Enums; - -namespace TUnit.Engine.Tests; - -[SkipNetFramework("Json library not available")] -public class CustomAssertionTests(TestMode testMode) : InvokableTestBase(testMode) -{ - [Test] - public async Task Test() - { - await RunTestsWithFilter( - "/*/TUnit.TestProject.CustomAssertions/*/*", - [ - result => result.ResultSummary.Outcome.ShouldBe("Completed"), - result => result.ResultSummary.Counters.Total.ShouldBe(1), - result => result.ResultSummary.Counters.Passed.ShouldBe(1), - result => result.ResultSummary.Counters.Failed.ShouldBe(0), - result => result.ResultSummary.Counters.NotExecuted.ShouldBe(0) - ]); - } -} \ No newline at end of file diff --git a/TUnit.Engine.Tests/CustomDisplayNameTests.cs b/TUnit.Engine.Tests/CustomDisplayNameTests.cs deleted file mode 100644 index dda4f4de60..0000000000 --- a/TUnit.Engine.Tests/CustomDisplayNameTests.cs +++ /dev/null @@ -1,21 +0,0 @@ -using Shouldly; -using TUnit.Engine.Tests.Enums; - -namespace TUnit.Engine.Tests; - -public class CustomDisplayNameTests(TestMode testMode) : InvokableTestBase(testMode) -{ - [Test] - public async Task Test() - { - await RunTestsWithFilter( - "/*/*/CustomDisplayNameTests/*", - [ - result => result.ResultSummary.Outcome.ShouldBe("Completed"), - result => result.ResultSummary.Counters.Total.ShouldBe(9), - result => result.ResultSummary.Counters.Passed.ShouldBe(9), - result => result.ResultSummary.Counters.Failed.ShouldBe(0), - result => result.ResultSummary.Counters.NotExecuted.ShouldBe(0) - ]); - } -} \ No newline at end of file diff --git a/TUnit.Engine.Tests/CustomFilteringTests12.cs b/TUnit.Engine.Tests/CustomFilteringTests12.cs deleted file mode 100644 index 948b2d3c07..0000000000 --- a/TUnit.Engine.Tests/CustomFilteringTests12.cs +++ /dev/null @@ -1,21 +0,0 @@ -using Shouldly; -using TUnit.Engine.Tests.Enums; - -namespace TUnit.Engine.Tests; - -public class CaptureOutputTests(TestMode testMode) : InvokableTestBase(testMode) -{ - [Test] - public async Task Test() - { - await RunTestsWithFilter( - "/*/*/CaptureOutputTests/*", - [ - result => result.ResultSummary.Outcome.ShouldBe("Completed"), - result => result.ResultSummary.Counters.Total.ShouldBe(80), - result => result.ResultSummary.Counters.Passed.ShouldBe(80), - result => result.ResultSummary.Counters.Failed.ShouldBe(0), - result => result.ResultSummary.Counters.NotExecuted.ShouldBe(0) - ]); - } -} \ No newline at end of file diff --git a/TUnit.Engine.Tests/CustomPropertyTests.cs b/TUnit.Engine.Tests/CustomPropertyTests.cs deleted file mode 100644 index 9ee8ec2d71..0000000000 --- a/TUnit.Engine.Tests/CustomPropertyTests.cs +++ /dev/null @@ -1,21 +0,0 @@ -using Shouldly; -using TUnit.Engine.Tests.Enums; - -namespace TUnit.Engine.Tests; - -public class CustomPropertyTests(TestMode testMode) : InvokableTestBase(testMode) -{ - [Test] - public async Task Test() - { - await RunTestsWithFilter( - "/*/*/CustomPropertyTests/*", - [ - result => result.ResultSummary.Outcome.ShouldBe("Completed"), - result => result.ResultSummary.Counters.Total.ShouldBe(1), - result => result.ResultSummary.Counters.Passed.ShouldBe(1), - result => result.ResultSummary.Counters.Failed.ShouldBe(0), - result => result.ResultSummary.Counters.NotExecuted.ShouldBe(0) - ]); - } -} \ No newline at end of file diff --git a/TUnit.Engine.Tests/DataSourceClassCombinedWithDataSourceMethodTests.cs b/TUnit.Engine.Tests/DataSourceClassCombinedWithDataSourceMethodTests.cs deleted file mode 100644 index 3160b65802..0000000000 --- a/TUnit.Engine.Tests/DataSourceClassCombinedWithDataSourceMethodTests.cs +++ /dev/null @@ -1,21 +0,0 @@ -using Shouldly; -using TUnit.Engine.Tests.Enums; - -namespace TUnit.Engine.Tests; - -public class DataSourceClassCombinedWithDataSourceMethodTests(TestMode testMode) : InvokableTestBase(testMode) -{ - [Test] - public async Task Test() - { - await RunTestsWithFilter( - "/*/*/DataSourceClassCombinedWithDataSourceMethod/*", - [ - result => result.ResultSummary.Outcome.ShouldBe("Completed"), - result => result.ResultSummary.Counters.Total.ShouldBe(9), - result => result.ResultSummary.Counters.Passed.ShouldBe(9), - result => result.ResultSummary.Counters.Failed.ShouldBe(0), - result => result.ResultSummary.Counters.NotExecuted.ShouldBe(0) - ]); - } -} \ No newline at end of file diff --git a/TUnit.Engine.Tests/DebugAssertFailureTests.cs b/TUnit.Engine.Tests/DebugAssertFailureTests.cs deleted file mode 100644 index df80ee19cf..0000000000 --- a/TUnit.Engine.Tests/DebugAssertFailureTests.cs +++ /dev/null @@ -1,21 +0,0 @@ -using Shouldly; -using TUnit.Engine.Tests.Enums; - -namespace TUnit.Engine.Tests; - -public class DebugAssertFailureTests(TestMode testMode) : InvokableTestBase(testMode) -{ - [Test] - public async Task Test() - { - await RunTestsWithFilter( - "/*/*/DebugAssertFailureTests/*", - [ - result => result.ResultSummary.Outcome.ShouldBe("Failed"), - result => result.ResultSummary.Counters.Total.ShouldBe(1), - result => result.ResultSummary.Counters.Passed.ShouldBe(0), - result => result.ResultSummary.Counters.Failed.ShouldBe(1), - result => result.ResultSummary.Counters.NotExecuted.ShouldBe(0) - ]); - } -} \ No newline at end of file diff --git a/TUnit.Engine.Tests/DeepNestedDependencyConflictTests.cs b/TUnit.Engine.Tests/DeepNestedDependencyConflictTests.cs deleted file mode 100644 index 3499fb50cb..0000000000 --- a/TUnit.Engine.Tests/DeepNestedDependencyConflictTests.cs +++ /dev/null @@ -1,21 +0,0 @@ -using Shouldly; -using TUnit.Engine.Tests.Enums; - -namespace TUnit.Engine.Tests; - -public class DeepNestedDependencyConflictTests(TestMode testMode) : InvokableTestBase(testMode) -{ - [Test] - public async Task Test() - { - await RunTestsWithFilter( - "/*/*/DeepNestedDependencyConflict/*", - [ - result => result.ResultSummary.Outcome.ShouldBe("Failed"), - result => result.ResultSummary.Counters.Total.ShouldBe(10), - result => result.ResultSummary.Counters.Passed.ShouldBe(0), - result => result.ResultSummary.Counters.Failed.ShouldBe(10), - result => result.ResultSummary.Counters.NotExecuted.ShouldBe(0) - ]); - } -} \ No newline at end of file diff --git a/TUnit.Engine.Tests/DependsOnAndNotInParallelTests.cs b/TUnit.Engine.Tests/DependsOnAndNotInParallelTests.cs deleted file mode 100644 index b504603837..0000000000 --- a/TUnit.Engine.Tests/DependsOnAndNotInParallelTests.cs +++ /dev/null @@ -1,22 +0,0 @@ -using Shouldly; -using TUnit.Engine.Tests.Enums; - -namespace TUnit.Engine.Tests; - -public class DependsOnAndNotInParallelTests(TestMode testMode) : InvokableTestBase(testMode) -{ - [Test] - public async Task Test() - { - await RunTestsWithFilter( - "/*/*/DependsOnAndNotInParallelTests/*", - [ - result => result.ResultSummary.Outcome.ShouldBe("Completed"), - result => result.ResultSummary.Counters.Total.ShouldBe(2), - result => result.ResultSummary.Counters.Passed.ShouldBe(2), - result => result.ResultSummary.Counters.Failed.ShouldBe(0), - result => result.ResultSummary.Counters.NotExecuted.ShouldBe(0), - - ]); - } -} \ No newline at end of file diff --git a/TUnit.Engine.Tests/DependsOnAndNotInParallelTests2.cs b/TUnit.Engine.Tests/DependsOnAndNotInParallelTests2.cs deleted file mode 100644 index 4a9db4680c..0000000000 --- a/TUnit.Engine.Tests/DependsOnAndNotInParallelTests2.cs +++ /dev/null @@ -1,22 +0,0 @@ -using Shouldly; -using TUnit.Engine.Tests.Enums; - -namespace TUnit.Engine.Tests; - -public class NotInParallelWithDependsOnTests(TestMode testMode) : InvokableTestBase(testMode) -{ - [Test] - public async Task Test() - { - await RunTestsWithFilter( - "/*/*/NotInParallelWithDependsOnTests/*", - [ - result => result.ResultSummary.Outcome.ShouldBe("Failed"), - result => result.ResultSummary.Counters.Total.ShouldBe(3), - result => result.ResultSummary.Counters.Passed.ShouldBe(0), - result => result.ResultSummary.Counters.Failed.ShouldBe(3), - result => result.ResultSummary.Counters.NotExecuted.ShouldBe(0), - - ]); - } -} \ No newline at end of file diff --git a/TUnit.Engine.Tests/DependsOnTests2.cs b/TUnit.Engine.Tests/DependsOnTests2.cs deleted file mode 100644 index d7916a0636..0000000000 --- a/TUnit.Engine.Tests/DependsOnTests2.cs +++ /dev/null @@ -1,27 +0,0 @@ -using Shouldly; -using TUnit.Engine.Tests.Enums; - -namespace TUnit.Engine.Tests; - -public class DependsOnTests2(TestMode testMode) : InvokableTestBase(testMode) -{ - public async Task Test() - { - await RunTestsWithFilter( - "/*/*/DependsOnTests2/*", - [ - result => result.ResultSummary.Outcome.ShouldBe("Completed"), - result => result.ResultSummary.Counters.Total.ShouldBe(3), - result => result.ResultSummary.Counters.Passed.ShouldBe(3), - result => result.ResultSummary.Counters.Failed.ShouldBe(0), - result => result.ResultSummary.Counters.NotExecuted.ShouldBe(0), - result => - { - var test1Start = DateTime.Parse(result.Results.First(x => x.TestName!.StartsWith("Test1")).StartTime!); - var test2Start = DateTime.Parse(result.Results.First(x => x.TestName!.StartsWith("Test2")).StartTime!); - - test2Start.ShouldBeGreaterThanOrEqualTo(test1Start.AddSeconds(4.9)); - } - ]); - } -} \ No newline at end of file diff --git a/TUnit.Engine.Tests/DependsOnTests3.cs b/TUnit.Engine.Tests/DependsOnTests3.cs deleted file mode 100644 index de3f2dde5f..0000000000 --- a/TUnit.Engine.Tests/DependsOnTests3.cs +++ /dev/null @@ -1,30 +0,0 @@ -using Shouldly; -using TUnit.Engine.Tests.Enums; - -namespace TUnit.Engine.Tests; - -public class DependsOnTests3(TestMode testMode) : InvokableTestBase(testMode) -{ - public async Task Test() - { - await RunTestsWithFilter( - "/*/*/DependsOnTests3/*", - [ - result => result.ResultSummary.Outcome.ShouldBe("Completed"), - result => result.ResultSummary.Counters.Total.ShouldBe(3), - result => result.ResultSummary.Counters.Passed.ShouldBe(3), - result => result.ResultSummary.Counters.Failed.ShouldBe(0), - result => result.ResultSummary.Counters.NotExecuted.ShouldBe(0), - result => - { - var test1Start = DateTime.Parse(result.Results.First(x => x.TestName!.StartsWith("Test1")).StartTime!); - var test2Start = DateTime.Parse(result.Results.First(x => x.TestName!.StartsWith("Test2")).StartTime!); - var test3Start = DateTime.Parse(result.Results.First(x => x.TestName!.StartsWith("Test3")).StartTime!); - - test3Start.ShouldBeGreaterThanOrEqualTo(test1Start.AddSeconds(0.9)); - test3Start.ShouldBeGreaterThanOrEqualTo(test2Start.AddSeconds(0.9)); - - } - ]); - } -} \ No newline at end of file diff --git a/TUnit.Engine.Tests/DependsOnWithBaseTests.cs b/TUnit.Engine.Tests/DependsOnWithBaseTests.cs deleted file mode 100644 index 62b540168f..0000000000 --- a/TUnit.Engine.Tests/DependsOnWithBaseTests.cs +++ /dev/null @@ -1,27 +0,0 @@ -using Shouldly; -using TUnit.Engine.Tests.Enums; - -namespace TUnit.Engine.Tests; - -public class DependsOnWithBaseTests(TestMode testMode) : InvokableTestBase(testMode) -{ - public async Task Test() - { - await RunTestsWithFilter( - "/*/*/DependsOnWithBaseTests/*", - [ - result => result.ResultSummary.Outcome.ShouldBe("Completed"), - result => result.ResultSummary.Counters.Total.ShouldBe(2), - result => result.ResultSummary.Counters.Passed.ShouldBe(2), - result => result.ResultSummary.Counters.Failed.ShouldBe(0), - result => result.ResultSummary.Counters.NotExecuted.ShouldBe(0), - result => - { - // var baseTest = result.TrxReport.UnitTestResults.First(x => x.TestName!.StartsWith("SubTypeTest")).StartTime!; - // var subTypeTestStart = result.TrxReport.UnitTestResults.First(x => x.TestName!.StartsWith("BaseTest")).StartTime!; - // - // subTypeTestStart.ShouldBeGreaterThanOrEqualTo(baseTest.AddSeconds(4.9)); - } - ]); - } -} \ No newline at end of file diff --git a/TUnit.Engine.Tests/DisposedReproTests.cs b/TUnit.Engine.Tests/DisposedReproTests.cs deleted file mode 100644 index 1871204ee6..0000000000 --- a/TUnit.Engine.Tests/DisposedReproTests.cs +++ /dev/null @@ -1,21 +0,0 @@ -using Shouldly; -using TUnit.Engine.Tests.Enums; - -namespace TUnit.Engine.Tests; - -public class DisposedReproTests(TestMode testMode) : InvokableTestBase(testMode) -{ - [Test] - public async Task Test() - { - await RunTestsWithFilter( - "/*/*/DisposedRepro/*", - [ - result => result.ResultSummary.Outcome.ShouldBe("Completed"), - result => result.ResultSummary.Counters.Total.ShouldBe(3), - result => result.ResultSummary.Counters.Passed.ShouldBe(3), - result => result.ResultSummary.Counters.Failed.ShouldBe(0), - result => result.ResultSummary.Counters.NotExecuted.ShouldBe(0) - ]); - } -} \ No newline at end of file diff --git a/TUnit.Engine.Tests/ExpectedStateTests.cs b/TUnit.Engine.Tests/ExpectedStateTests.cs new file mode 100644 index 0000000000..ead349a507 --- /dev/null +++ b/TUnit.Engine.Tests/ExpectedStateTests.cs @@ -0,0 +1,27 @@ +using Shouldly; +using TUnit.Engine.Tests.Enums; + +namespace TUnit.Engine.Tests; + +public class ExpectedStateTests(TestMode testMode) : InvokableTestBase(testMode) +{ + [Test] + public async Task Pass() + { + await RunTestsWithFilter( + "/**[EngineTest=Pass]", + [ + result => result.ResultSummary.Outcome.ShouldBe("Completed") + ]); + } + + [Test] + public async Task Fail() + { + await RunTestsWithFilter( + "/**[EngineTest=Failure]", + [ + result => result.ResultSummary.Outcome.ShouldBe("Failed") + ]); + } +} \ No newline at end of file diff --git a/TUnit.Engine.Tests/FSharp.cs b/TUnit.Engine.Tests/FSharp.cs index 3064186fcf..f7b8c4a246 100644 --- a/TUnit.Engine.Tests/FSharp.cs +++ b/TUnit.Engine.Tests/FSharp.cs @@ -14,7 +14,7 @@ public async Task Test() var testProject = Sourcy.DotNet.Projects.TUnit_TestProject_FSharp; var guid = Guid.NewGuid().ToString("N"); var trxFilename = guid + ".trx"; - var result = await Cli.Wrap("dotnet") + var command = Cli.Wrap("dotnet") .WithArguments( [ "run", @@ -31,10 +31,11 @@ public async Task Test() ] ) .WithWorkingDirectory(testProject.DirectoryName!) - .WithValidation(CommandResultValidation.None) - .ExecuteBufferedAsync(); + .WithValidation(CommandResultValidation.None); + + var result = await command.ExecuteBufferedAsync(); - await TrxAsserter.AssertTrx(result, + await TrxAsserter.AssertTrx(command, result, [ result => result.ResultSummary.Outcome.ShouldBe("Completed"), diff --git a/TUnit.Engine.Tests/FailedInitializationTests2.cs b/TUnit.Engine.Tests/FailedInitializationTests2.cs deleted file mode 100644 index 8422a2d357..0000000000 --- a/TUnit.Engine.Tests/FailedInitializationTests2.cs +++ /dev/null @@ -1,21 +0,0 @@ -using Shouldly; -using TUnit.Engine.Tests.Enums; - -namespace TUnit.Engine.Tests; - -public class FailedInitializationTests2(TestMode testMode) : InvokableTestBase(testMode) -{ - [Test] - public async Task Test() - { - await RunTestsWithFilter( - "/*/*/FailedInitializationTests2/*", - [ - result => result.ResultSummary.Outcome.ShouldBe("Failed"), - result => result.ResultSummary.Counters.Total.ShouldBe(2), - result => result.ResultSummary.Counters.Passed.ShouldBe(0), - result => result.ResultSummary.Counters.Failed.ShouldBe(2), - result => result.ResultSummary.Counters.NotExecuted.ShouldBe(0) - ]); - } -} \ No newline at end of file diff --git a/TUnit.Engine.Tests/InheritedPropertySetterTests.cs b/TUnit.Engine.Tests/InheritedPropertySetterTests.cs deleted file mode 100644 index 5eeb655cbe..0000000000 --- a/TUnit.Engine.Tests/InheritedPropertySetterTests.cs +++ /dev/null @@ -1,22 +0,0 @@ -using Shouldly; -using TUnit.Engine.Tests.Enums; -using TUnit.Engine.Tests.Extensions; - -namespace TUnit.Engine.Tests; - -public class InheritedPropertySetterTests(TestMode testMode) : InvokableTestBase(testMode) -{ - [Test] - public async Task Test() - { - await RunTestsWithFilter( - "/*/*/InheritedPropertySetterTests/*", - [ - result => result.ResultSummary.Outcome.ShouldBe("Completed"), - result => result.ResultSummary.Counters.Total.ShouldBe(1), - result => result.ResultSummary.Counters.Passed.ShouldBe(1), - result => result.ResultSummary.Counters.Failed.ShouldBe(0), - result => result.ResultSummary.Counters.NotExecuted.ShouldBe(0) - ]); - } -} \ No newline at end of file diff --git a/TUnit.Engine.Tests/InheritedTestsFromDifferentProjectTests.cs b/TUnit.Engine.Tests/InheritedTestsFromDifferentProjectTests.cs deleted file mode 100644 index 136879b2b2..0000000000 --- a/TUnit.Engine.Tests/InheritedTestsFromDifferentProjectTests.cs +++ /dev/null @@ -1,21 +0,0 @@ -using Shouldly; -using TUnit.Engine.Tests.Enums; - -namespace TUnit.Engine.Tests; - -public class InheritedTestsFromDifferentProjectTests(TestMode testMode) : InvokableTestBase(testMode) -{ - [Test] - public async Task Test() - { - await RunTestsWithFilter( - "/*/*/InheritedTestsFromDifferentProjectTests/*", - [ - result => result.ResultSummary.Outcome.ShouldBe("Completed"), - result => result.ResultSummary.Counters.Total.ShouldBe(4), - result => result.ResultSummary.Counters.Passed.ShouldBe(4), - result => result.ResultSummary.Counters.Failed.ShouldBe(0), - result => result.ResultSummary.Counters.NotExecuted.ShouldBe(0) - ]); - } -} \ No newline at end of file diff --git a/TUnit.Engine.Tests/InvokableTestBase.cs b/TUnit.Engine.Tests/InvokableTestBase.cs index d00927bec8..ab2db61208 100644 --- a/TUnit.Engine.Tests/InvokableTestBase.cs +++ b/TUnit.Engine.Tests/InvokableTestBase.cs @@ -52,7 +52,7 @@ private async Task RunWithoutAot(string filter, var testProject = Sourcy.DotNet.Projects.TUnit_TestProject; var guid = Guid.NewGuid().ToString("N"); var trxFilename = guid + ".trx"; - var result = await Cli.Wrap("dotnet") + var command = Cli.Wrap("dotnet") .WithArguments( [ "run", @@ -70,10 +70,11 @@ private async Task RunWithoutAot(string filter, ] ) .WithWorkingDirectory(testProject.DirectoryName!) - .WithValidation(CommandResultValidation.None) - .ExecuteBufferedAsync(); + .WithValidation(CommandResultValidation.None); + + var result = await command.ExecuteBufferedAsync(); - await TrxAsserter.AssertTrx(result, assertions, trxFilename, assertionExpression); + await TrxAsserter.AssertTrx(command, result, assertions, trxFilename, assertionExpression); } private async Task RunWithAot(string filter, List> assertions, @@ -93,8 +94,8 @@ private async Task RunWithAot(string filter, List> assertions, var guid = Guid.NewGuid().ToString("N"); var trxFilename = guid + ".trx"; - - var result = await Cli.Wrap(aotApp.FullName) + + var command = Cli.Wrap(aotApp.FullName) .WithArguments( [ "--treenode-filter", filter, @@ -105,10 +106,11 @@ private async Task RunWithAot(string filter, List> assertions, ..runOptions.AdditionalArguments ] ) - .WithValidation(CommandResultValidation.None) - .ExecuteBufferedAsync(); + .WithValidation(CommandResultValidation.None); + + var result = await command.ExecuteBufferedAsync(); - await TrxAsserter.AssertTrx(result, assertions, trxFilename, assertionExpression); + await TrxAsserter.AssertTrx(command, result, assertions, trxFilename, assertionExpression: assertionExpression); } private async Task RunWithSingleFile(string filter, @@ -128,8 +130,8 @@ private async Task RunWithSingleFile(string filter, var guid = Guid.NewGuid().ToString("N"); var trxFilename = guid + ".trx"; - - var result = await Cli.Wrap(aotApp.FullName) + + var command = Cli.Wrap(aotApp.FullName) .WithArguments( [ "--treenode-filter", filter, @@ -140,10 +142,11 @@ private async Task RunWithSingleFile(string filter, ..runOptions.AdditionalArguments ] ) - .WithValidation(CommandResultValidation.None) - .ExecuteBufferedAsync(); + .WithValidation(CommandResultValidation.None); + + var result = await command.ExecuteBufferedAsync(); - await TrxAsserter.AssertTrx(result, assertions, trxFilename, assertionExpression); + await TrxAsserter.AssertTrx(command, result, assertions, trxFilename, assertionExpression: assertionExpression); } protected static FileInfo? FindFile(Func predicate) diff --git a/TUnit.Engine.Tests/MEDITest.cs b/TUnit.Engine.Tests/MEDITest.cs deleted file mode 100644 index 2c34f8eff5..0000000000 --- a/TUnit.Engine.Tests/MEDITest.cs +++ /dev/null @@ -1,21 +0,0 @@ -using Shouldly; -using TUnit.Engine.Tests.Enums; - -namespace TUnit.Engine.Tests; - -public class MEDITest(TestMode testMode) : InvokableTestBase(testMode) -{ - [Test] - public async Task Test() - { - await RunTestsWithFilter( - "/*/*/MEDITest/*", - [ - result => result.ResultSummary.Outcome.ShouldBe("Completed"), - result => result.ResultSummary.Counters.Total.ShouldBe(1), - result => result.ResultSummary.Counters.Passed.ShouldBe(1), - result => result.ResultSummary.Counters.Failed.ShouldBe(0), - result => result.ResultSummary.Counters.NotExecuted.ShouldBe(0) - ]); - } -} \ No newline at end of file diff --git a/TUnit.Engine.Tests/MethodDataSourceDrivenWithCancellationTokenTests.cs b/TUnit.Engine.Tests/MethodDataSourceDrivenWithCancellationTokenTests.cs deleted file mode 100644 index eb8da38f0d..0000000000 --- a/TUnit.Engine.Tests/MethodDataSourceDrivenWithCancellationTokenTests.cs +++ /dev/null @@ -1,21 +0,0 @@ -using Shouldly; -using TUnit.Engine.Tests.Enums; - -namespace TUnit.Engine.Tests; - -public class MethodDataSourceDrivenWithCancellationTokenTests(TestMode testMode) : InvokableTestBase(testMode) -{ - [Test] - public async Task Test() - { - await RunTestsWithFilter( - "/*/*/MethodDataSourceDrivenWithCancellationTokenTests/*", - [ - result => result.ResultSummary.Outcome.ShouldBe("Completed"), - result => result.ResultSummary.Counters.Total.ShouldBe(6), - result => result.ResultSummary.Counters.Passed.ShouldBe(6), - result => result.ResultSummary.Counters.Failed.ShouldBe(0), - result => result.ResultSummary.Counters.NotExecuted.ShouldBe(0) - ]); - } -} \ No newline at end of file diff --git a/TUnit.Engine.Tests/MixedMatrixTests.cs b/TUnit.Engine.Tests/MixedMatrixTests.cs deleted file mode 100644 index f770628a76..0000000000 --- a/TUnit.Engine.Tests/MixedMatrixTests.cs +++ /dev/null @@ -1,21 +0,0 @@ -using Shouldly; -using TUnit.Engine.Tests.Enums; - -namespace TUnit.Engine.Tests; - -public class MixedMatrixTests(TestMode testMode) : InvokableTestBase(testMode) -{ - [Test] - public async Task Test() - { - await RunTestsWithFilter( - "/*/*/MixedMatrixTests/*", - [ - result => result.ResultSummary.Outcome.ShouldBe("Completed"), - result => result.ResultSummary.Counters.Total.ShouldBe(864, "Total"), - result => result.ResultSummary.Counters.Passed.ShouldBe(864, "Passed"), - result => result.ResultSummary.Counters.Failed.ShouldBe(0, "Failed"), - result => result.ResultSummary.Counters.NotExecuted.ShouldBe(0, "Skipped") - ]); - } -} \ No newline at end of file diff --git a/TUnit.Engine.Tests/NestedBaseTests.cs b/TUnit.Engine.Tests/NestedBaseTests.cs deleted file mode 100644 index bf036137d8..0000000000 --- a/TUnit.Engine.Tests/NestedBaseTests.cs +++ /dev/null @@ -1,21 +0,0 @@ -using Shouldly; -using TUnit.Engine.Tests.Enums; - -namespace TUnit.Engine.Tests; - -public class NestedBaseTests(TestMode testMode) : InvokableTestBase(testMode) -{ - [Test] - public async Task Test() - { - await RunTestsWithFilter( - "/*/*/NestedBaseTests/*", - [ - result => result.ResultSummary.Outcome.ShouldBe("Completed"), - result => result.ResultSummary.Counters.Total.ShouldBe(1), - result => result.ResultSummary.Counters.Passed.ShouldBe(1), - result => result.ResultSummary.Counters.Failed.ShouldBe(0), - result => result.ResultSummary.Counters.NotExecuted.ShouldBe(0) - ]); - } -} \ No newline at end of file diff --git a/TUnit.Engine.Tests/OrderedByAttributeOrderParameterSetupTests.cs b/TUnit.Engine.Tests/OrderedByAttributeOrderParameterSetupTests.cs deleted file mode 100644 index 03cb89cd6b..0000000000 --- a/TUnit.Engine.Tests/OrderedByAttributeOrderParameterSetupTests.cs +++ /dev/null @@ -1,21 +0,0 @@ -using Shouldly; -using TUnit.Engine.Tests.Enums; - -namespace TUnit.Engine.Tests; - -public class OrderedByAttributeOrderParameterSetupTests(TestMode testMode) : InvokableTestBase(testMode) -{ - [Test] - public async Task Test() - { - await RunTestsWithFilter( - "/*/TUnit.TestProject.OrderedByAttributeOrderParameterSetupTests/*/*", - [ - result => result.ResultSummary.Outcome.ShouldBe("Completed"), - result => result.ResultSummary.Counters.Total.ShouldBe(1), - result => result.ResultSummary.Counters.Passed.ShouldBe(1), - result => result.ResultSummary.Counters.Failed.ShouldBe(0), - result => result.ResultSummary.Counters.NotExecuted.ShouldBe(0) - ]); - } -} \ No newline at end of file diff --git a/TUnit.Engine.Tests/OrderedSetupTests.cs b/TUnit.Engine.Tests/OrderedSetupTests.cs deleted file mode 100644 index f1878f211e..0000000000 --- a/TUnit.Engine.Tests/OrderedSetupTests.cs +++ /dev/null @@ -1,21 +0,0 @@ -using Shouldly; -using TUnit.Engine.Tests.Enums; - -namespace TUnit.Engine.Tests; - -public class OrderedSetupTests(TestMode testMode) : InvokableTestBase(testMode) -{ - [Test] - public async Task Test() - { - await RunTestsWithFilter( - "/*/TUnit.TestProject.OrderedSetupTests/*/*", - [ - result => result.ResultSummary.Outcome.ShouldBe("Completed"), - result => result.ResultSummary.Counters.Total.ShouldBe(1), - result => result.ResultSummary.Counters.Passed.ShouldBe(1), - result => result.ResultSummary.Counters.Failed.ShouldBe(0), - result => result.ResultSummary.Counters.NotExecuted.ShouldBe(0) - ]); - } -} \ No newline at end of file diff --git a/TUnit.Engine.Tests/OrderedTests.cs b/TUnit.Engine.Tests/OrderedTests.cs deleted file mode 100644 index aae9e8df7f..0000000000 --- a/TUnit.Engine.Tests/OrderedTests.cs +++ /dev/null @@ -1,21 +0,0 @@ -using Shouldly; -using TUnit.Engine.Tests.Enums; - -namespace TUnit.Engine.Tests; - -public class OrderedTests(TestMode testMode) : InvokableTestBase(testMode) -{ - [Test] - public async Task Test() - { - await RunTestsWithFilter( - "/*/*/OrderedTests/*", - [ - result => result.ResultSummary.Outcome.ShouldBe("Completed"), - result => result.ResultSummary.Counters.Total.ShouldBe(6), - result => result.ResultSummary.Counters.Passed.ShouldBe(6), - result => result.ResultSummary.Counters.Failed.ShouldBe(0), - result => result.ResultSummary.Counters.NotExecuted.ShouldBe(0) - ]); - } -} \ No newline at end of file diff --git a/TUnit.Engine.Tests/ParallelLimiterTests.cs b/TUnit.Engine.Tests/ParallelLimiterTests.cs deleted file mode 100644 index 3b2b526821..0000000000 --- a/TUnit.Engine.Tests/ParallelLimiterTests.cs +++ /dev/null @@ -1,20 +0,0 @@ -using Shouldly; -using TUnit.Engine.Tests.Enums; - -namespace TUnit.Engine.Tests; - -public class ParallelLimiterTests(TestMode testMode) : InvokableTestBase(testMode) -{ - public async Task Test() - { - await RunTestsWithFilter( - "/*/*/ParallelLimiterTests/*", - [ - result => result.ResultSummary.Outcome.ShouldBe("Completed"), - result => result.ResultSummary.Counters.Total.ShouldBe(12), - result => result.ResultSummary.Counters.Passed.ShouldBe(12), - result => result.ResultSummary.Counters.Failed.ShouldBe(0), - result => result.ResultSummary.Counters.NotExecuted.ShouldBe(0) - ]); - } -} \ No newline at end of file diff --git a/TUnit.Engine.Tests/TrxAsserter.cs b/TUnit.Engine.Tests/TrxAsserter.cs index f2a3d64b7a..81944bde35 100644 --- a/TUnit.Engine.Tests/TrxAsserter.cs +++ b/TUnit.Engine.Tests/TrxAsserter.cs @@ -1,4 +1,5 @@ using System.Runtime.CompilerServices; +using CliWrap; using CliWrap.Buffered; using TrxTools.TrxParser; @@ -6,7 +7,7 @@ namespace TUnit.Engine.Tests; public class TrxAsserter { - public static async Task AssertTrx(BufferedCommandResult commandResult, + public static async Task AssertTrx(Command command, BufferedCommandResult commandResult, List> assertions, string trxFilename, [CallerArgumentExpression("assertions")] string assertionExpression = "") { @@ -22,7 +23,7 @@ public static async Task AssertTrx(BufferedCommandResult commandResult, } catch (Exception e) { - Console.WriteLine(@$"Command Input: {commandResult}"); + Console.WriteLine(@$"Command Input: {command}"); Console.WriteLine(@$"Error: {commandResult.StandardError}"); Console.WriteLine(@$"Output: {commandResult.StandardOutput}"); diff --git a/TUnit.Engine.Tests/UniqueBuilderContextsOnEnumerableDataGeneratorTests.cs b/TUnit.Engine.Tests/UniqueBuilderContextsOnEnumerableDataGeneratorTests.cs deleted file mode 100644 index aa427040c7..0000000000 --- a/TUnit.Engine.Tests/UniqueBuilderContextsOnEnumerableDataGeneratorTests.cs +++ /dev/null @@ -1,21 +0,0 @@ -using Shouldly; -using TUnit.Engine.Tests.Enums; - -namespace TUnit.Engine.Tests; - -public class UniqueBuilderContextsOnEnumerableDataGeneratorTests(TestMode testMode) : InvokableTestBase(testMode) -{ - [Test] - public async Task Test() - { - await RunTestsWithFilter( - "/*/*/UniqueBuilderContextsOnEnumerableDataGeneratorTests/*", - [ - result => result.ResultSummary.Outcome.ShouldBe("Completed"), - result => result.ResultSummary.Counters.Total.ShouldBe(2), - result => result.ResultSummary.Counters.Passed.ShouldBe(2), - result => result.ResultSummary.Counters.Failed.ShouldBe(0), - result => result.ResultSummary.Counters.NotExecuted.ShouldBe(0) - ]); - } -} \ No newline at end of file diff --git a/TUnit.Engine.Tests/UniqueObjectsOnEnumerableDataGeneratorTests.cs b/TUnit.Engine.Tests/UniqueObjectsOnEnumerableDataGeneratorTests.cs deleted file mode 100644 index d66087ea8f..0000000000 --- a/TUnit.Engine.Tests/UniqueObjectsOnEnumerableDataGeneratorTests.cs +++ /dev/null @@ -1,21 +0,0 @@ -using Shouldly; -using TUnit.Engine.Tests.Enums; - -namespace TUnit.Engine.Tests; - -public class UniqueObjectsOnEnumerableDataGeneratorTests(TestMode testMode) : InvokableTestBase(testMode) -{ - [Test] - public async Task Test() - { - await RunTestsWithFilter( - "/*/*/UniqueObjectsOnEnumerableDataGeneratorTests/*", - [ - result => result.ResultSummary.Outcome.ShouldBe("Completed"), - result => result.ResultSummary.Counters.Total.ShouldBe(9), - result => result.ResultSummary.Counters.Passed.ShouldBe(9), - result => result.ResultSummary.Counters.Failed.ShouldBe(0), - result => result.ResultSummary.Counters.NotExecuted.ShouldBe(0) - ]); - } -} \ No newline at end of file diff --git a/TUnit.Engine.Tests/VB.cs b/TUnit.Engine.Tests/VB.cs index 377ba2172a..169685d607 100644 --- a/TUnit.Engine.Tests/VB.cs +++ b/TUnit.Engine.Tests/VB.cs @@ -14,7 +14,7 @@ public async Task Test() var testProject = Sourcy.DotNet.Projects.TUnit_TestProject_VB_NET; var guid = Guid.NewGuid().ToString("N"); var trxFilename = guid + ".trx"; - var result = await Cli.Wrap("dotnet") + var command = Cli.Wrap("dotnet") .WithArguments( [ "run", @@ -31,11 +31,11 @@ public async Task Test() ] ) .WithWorkingDirectory(testProject.DirectoryName!) - .WithValidation(CommandResultValidation.None) - .ExecuteBufferedAsync(); + .WithValidation(CommandResultValidation.None); + + var result = await command.ExecuteBufferedAsync(); - await TrxAsserter.AssertTrx(result, - + await TrxAsserter.AssertTrx(command, result, [ result => result.ResultSummary.Outcome.ShouldBe("Completed"), result => result.ResultSummary.Counters.Total.ShouldBeGreaterThanOrEqualTo(9), diff --git a/TUnit.Engine/Capabilities/BannerCapability.cs b/TUnit.Engine/Capabilities/BannerCapability.cs index eeb838b3ed..12906a85d2 100644 --- a/TUnit.Engine/Capabilities/BannerCapability.cs +++ b/TUnit.Engine/Capabilities/BannerCapability.cs @@ -1,5 +1,7 @@ using System.Reflection; +using System.Runtime.CompilerServices; using System.Runtime.InteropServices; +using System.Text; using Microsoft.Testing.Platform.Capabilities.TestFramework; using Microsoft.Testing.Platform.CommandLine; using Microsoft.Testing.Platform.Services; @@ -20,22 +22,39 @@ internal class BannerCapability(IPlatformInformation platformInformation, IComma { return Task.FromResult(GetRuntimeDetails()); } - - return Task.FromResult( + + var stringBuilder = new StringBuilder( $""" - - ████████╗██╗ ██╗███╗ ██╗██╗████████╗ - ╚══██╔══╝██║ ██║████╗ ██║██║╚══██╔══╝ - ██║ ██║ ██║██╔██╗ ██║██║ ██║ - ██║ ██║ ██║██║╚██╗██║██║ ██║ - ██║ ╚██████╔╝██║ ╚████║██║ ██║ - ╚═╝ ╚═════╝ ╚═╝ ╚═══╝╚═╝ ╚═╝ - - {GetRuntimeDetails()} - - Engine Mode: {GetMode()} - - """ + + ████████╗██╗ ██╗███╗ ██╗██╗████████╗ + ╚══██╔══╝██║ ██║████╗ ██║██║╚══██╔══╝ + ██║ ██║ ██║██╔██╗ ██║██║ ██║ + ██║ ██║ ██║██║╚██╗██║██║ ██║ + ██║ ╚██████╔╝██║ ╚████║██║ ██║ + ╚═╝ ╚═════╝ ╚═╝ ╚═══╝╚═╝ ╚═╝ + + {GetRuntimeDetails()} + + Engine Mode: {GetMode()} + + """ + ); + + #if NET + if (!RuntimeFeature.IsDynamicCodeSupported) + { + stringBuilder.Append( + """ + + AOT compilation detected. Dynamic code generation is not supported. + + """ + ); + } + #endif + + return Task.FromResult( + stringBuilder.ToString() ); } @@ -76,4 +95,3 @@ private string GetApplicationMemorySize() } } - \ No newline at end of file diff --git a/TUnit.Engine/Extensions/TypeExtensions.cs b/TUnit.Engine/Extensions/TypeExtensions.cs index bcb462ec89..13e4f95b08 100644 --- a/TUnit.Engine/Extensions/TypeExtensions.cs +++ b/TUnit.Engine/Extensions/TypeExtensions.cs @@ -5,11 +5,16 @@ internal static class TypeExtensions public static IEnumerable GetSelfAndBaseTypes(this Type type) { var nullableType = type; - + while (nullableType != null) { yield return nullableType; nullableType = nullableType.BaseType; } } -} \ No newline at end of file + + public static Type GetUnderlyingNonNullableType(this Type type) + { + return Nullable.GetUnderlyingType(type) ?? type; + } +} diff --git a/TUnit.Engine/Framework/TUnitServiceProvider.cs b/TUnit.Engine/Framework/TUnitServiceProvider.cs index 84a6fe59d4..6320a3f124 100644 --- a/TUnit.Engine/Framework/TUnitServiceProvider.cs +++ b/TUnit.Engine/Framework/TUnitServiceProvider.cs @@ -35,6 +35,8 @@ internal class TUnitServiceProvider : IServiceProvider, IAsyncDisposable public TUnitFrameworkLogger Logger { get; } public TUnitMessageBus TUnitMessageBus { get; } + public ContextManager ContextManager { get; } + public HooksCollectorBase HooksCollector { get; set; } public TUnitInitializer Initializer { get; } public StandardOutConsoleInterceptor StandardOutConsoleInterceptor { get; } @@ -54,37 +56,39 @@ internal class TUnitServiceProvider : IServiceProvider, IAsyncDisposable public TUnitServiceProvider(IExtension extension, ExecuteRequestContext context, IMessageBus messageBus, - IServiceProvider frameworkServiceProvider, + IServiceProvider frameworkServiceProvider, ITestFrameworkCapabilities capabilities) { _capabilities = capabilities; - + Register(context); - + EngineCancellationToken = Register(new EngineCancellationToken()); - + LoggerFactory = frameworkServiceProvider.GetLoggerFactory(); - + OutputDevice = frameworkServiceProvider.GetOutputDevice(); - + CommandLineOptions = frameworkServiceProvider.GetCommandLineOptions(); Logger = Register(new TUnitFrameworkLogger(extension, OutputDevice, LoggerFactory.CreateLogger(), CommandLineOptions)); - + Initializer = Register(new TUnitInitializer(CommandLineOptions)); - + StandardOutConsoleInterceptor = Register(new StandardOutConsoleInterceptor(CommandLineOptions)); - + StandardErrorConsoleInterceptor = Register(new StandardErrorConsoleInterceptor(CommandLineOptions)); FilterParser = Register(new FilterParser()); var stringFilter = FilterParser.GetTestFilter(context); + ContextManager = new ContextManager(context.Request.Session.SessionUid.Value, stringFilter); + TUnitMessageBus = Register(new TUnitMessageBus(extension, CommandLineOptions, context)); var instanceTracker = Register(new InstanceTracker()); - + var isReflectionScannerEnabled = IsReflectionScannerEnabled(CommandLineOptions); HooksCollector = Register @@ -95,51 +99,52 @@ public TUnitServiceProvider(IExtension extension, ); var dependencyCollector = new DependencyCollector(); - + var testMetadataCollector = Register(new TestsCollector(context.Request.Session.SessionUid.Value)); var testsConstructor = Register ( isReflectionScannerEnabled - ? new ReflectionTestsConstructor(extension, dependencyCollector, this) - : new SourceGeneratedTestsConstructor(extension, testMetadataCollector, dependencyCollector, this) + ? new ReflectionTestsConstructor(extension, dependencyCollector, ContextManager, this) + : new SourceGeneratedTestsConstructor(extension, testMetadataCollector, dependencyCollector, ContextManager, this) ); - + var testFilterService = Register(new TestFilterService(LoggerFactory)); - + TestGrouper = Register(new TestGrouper()); - - AssemblyHookOrchestrator = Register(new AssemblyHookOrchestrator(instanceTracker, HooksCollector)); - TestDiscoveryHookOrchestrator = Register(new TestDiscoveryHookOrchestrator(HooksCollector, stringFilter)); - TestSessionHookOrchestrator = Register(new TestSessionHookOrchestrator(HooksCollector, AssemblyHookOrchestrator, stringFilter)); - + TestSessionHookOrchestrator = Register(new TestSessionHookOrchestrator(HooksCollector)); + + AssemblyHookOrchestrator = Register(new AssemblyHookOrchestrator(instanceTracker, HooksCollector, ContextManager, TestSessionHookOrchestrator)); + + TestDiscoveryHookOrchestrator = Register(new TestDiscoveryHookOrchestrator(HooksCollector)); + var classHookOrchestrator = Register(new ClassHookOrchestrator(instanceTracker, HooksCollector)); - + var testHookOrchestrator = Register(new TestHookOrchestrator(HooksCollector)); - var testRegistrar = Register(new TestRegistrar(instanceTracker, AssemblyHookOrchestrator, classHookOrchestrator)); - + var testRegistrar = Register(new TestRegistrar(instanceTracker)); + Disposer = Register(new Disposer(Logger)); - + var testInvoker = Register(new TestInvoker(testHookOrchestrator, Disposer)); var parallelLimitProvider = Register(new ParallelLimitLockProvider()); - + var singleTestExecutor = Register(new SingleTestExecutor(extension, instanceTracker, testInvoker, parallelLimitProvider, AssemblyHookOrchestrator, classHookOrchestrator, TUnitMessageBus, Logger, EngineCancellationToken, testRegistrar, GetCapability())); - + TestsExecutor = Register(new TestsExecutor(singleTestExecutor, Logger, CommandLineOptions, EngineCancellationToken, AssemblyHookOrchestrator, classHookOrchestrator)); - + TestDiscoverer = Register(new TUnitTestDiscoverer(testsConstructor, testFilterService, TestGrouper, testRegistrar, TUnitMessageBus, Logger, TestsExecutor)); DynamicTestRegistrar = Register(new DynamicTestRegistrar(testsConstructor, testRegistrar, TestGrouper, TUnitMessageBus, TestsExecutor, EngineCancellationToken)); - + TestFinder = Register(new TestsFinder(TestDiscoverer)); Register(TestFinder); - + // TODO Register(new HookMessagePublisher(extension, messageBus)); - + OnEndExecutor = Register(new OnEndExecutor(CommandLineOptions, Logger)); } @@ -166,7 +171,7 @@ public async ValueTask DisposeAsync() private T Register(T t) { _services.Add(typeof(T), t!); - + return t; } @@ -175,7 +180,7 @@ private T Register(T t) _services.TryGetValue(serviceType, out object? result); return result; } - + public TCapability GetCapability() where TCapability : class, ITestFrameworkCapability { @@ -185,10 +190,10 @@ public TCapability GetCapability() { throw new InvalidOperationException($"No capability registered for {typeof(TCapability).Name}"); } - + return capability; } - + private static bool IsReflectionScannerEnabled(ICommandLineOptions commandLineOptions) { #if NET @@ -205,4 +210,4 @@ private static bool IsReflectionScannerEnabledByCommandLine(ICommandLineOptions { return commandLineOptions.IsOptionSet(ReflectionScannerCommandProvider.ReflectionScanner); } -} \ No newline at end of file +} diff --git a/TUnit.Engine/Framework/TUnitTestFramework.cs b/TUnit.Engine/Framework/TUnitTestFramework.cs index a8aa81c9d1..abe53a217c 100644 --- a/TUnit.Engine/Framework/TUnitTestFramework.cs +++ b/TUnit.Engine/Framework/TUnitTestFramework.cs @@ -96,33 +96,41 @@ public async Task ExecuteRequestAsync(ExecuteRequestContext context) serviceProvider.Initializer.Initialize(); - TestSessionContext? testSessionContext = null; + var beforeTestDiscoveryContext = serviceProvider.ContextManager.BeforeTestDiscoveryContext; + + var testSessionContext = serviceProvider.ContextManager.TestSessionContext; + try { serviceProvider.EngineCancellationToken.Initialise(context.CancellationToken); + + await serviceProvider.TestDiscoveryHookOrchestrator.RunBeforeTestDiscovery(beforeTestDiscoveryContext); - ExecutionContextHelper.RestoreContext(await serviceProvider.TestDiscoveryHookOrchestrator.RunBeforeTestDiscovery()); + beforeTestDiscoveryContext.RestoreExecutionContext(); - var allDiscoveredTests = serviceProvider.TestDiscoverer.GetTests(serviceProvider.EngineCancellationToken.Token); + serviceProvider.ContextManager.AfterTestDiscoveryContext.AddTests( + serviceProvider.TestDiscoverer.GetTests().Select(x => x.TestContext) + ); var afterDiscoveryHooks = serviceProvider.TestDiscoveryHookOrchestrator.CollectAfterHooks(); - var afterContext = serviceProvider.TestDiscoveryHookOrchestrator.GetAfterContext(allDiscoveredTests); - + foreach (var afterDiscoveryHook in afterDiscoveryHooks) { try { - await afterDiscoveryHook.ExecuteAsync(afterContext, CancellationToken.None); + await afterDiscoveryHook.ExecuteAsync(serviceProvider.ContextManager.AfterTestDiscoveryContext, CancellationToken.None); } catch (Exception e) { - throw new HookFailedException($"Error executing [Before(Test)] hook: {afterDiscoveryHook.MethodInfo.Type.FullName}.{afterDiscoveryHook.Name}", e); + throw new HookFailedException($"Error executing [After(TestDiscovery)] hook: {afterDiscoveryHook.MethodInfo.Type.FullName}.{afterDiscoveryHook.Name}", e); } } + testSessionContext.RestoreExecutionContext(); + var filteredTests = await serviceProvider.TestDiscoverer .FilterTests(context, serviceProvider.EngineCancellationToken.Token); - + switch (context.Request) { case DiscoverTestExecutionRequest: @@ -134,17 +142,11 @@ public async Task ExecuteRequestAsync(ExecuteRequestContext context) break; } case RunTestExecutionRequest runTestExecutionRequest: - testSessionContext = - new TestSessionContext(serviceProvider.AssemblyHookOrchestrator.GetAllAssemblyHookContexts()) - { - TestFilter = stringFilter, - Id = runTestExecutionRequest.Session.SessionUid.Value - }; TestSessionContext.Current = testSessionContext; - ExecutionContextHelper.RestoreContext(await serviceProvider.TestSessionHookOrchestrator.RunBeforeTestSession(context)); - + await serviceProvider.TestSessionHookOrchestrator.RunBeforeTestSession(testSessionContext, context.CancellationToken); + await serviceProvider.TestsExecutor.ExecuteAsync(filteredTests, runTestExecutionRequest.Filter, context.CancellationToken); diff --git a/TUnit.Engine/Helpers/ExecutionContextHelper.cs b/TUnit.Engine/Helpers/ExecutionContextHelper.cs index acd20f4173..3d932069f5 100644 --- a/TUnit.Engine/Helpers/ExecutionContextHelper.cs +++ b/TUnit.Engine/Helpers/ExecutionContextHelper.cs @@ -1,4 +1,6 @@ -using System.Runtime.CompilerServices; +using System.Diagnostics.CodeAnalysis; +using System.Reflection; +using System.Runtime.CompilerServices; using TUnit.Core; namespace TUnit.Engine.Helpers; @@ -6,13 +8,10 @@ namespace TUnit.Engine.Helpers; internal static class ExecutionContextHelper { [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void RestoreContext(Context context) => RestoreContext(context.ExecutionContext); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void RestoreContext(ExecutionContext? executionContext) + public static void RestoreContexts(ExecutionContext[] executionContexts) { #if NET - if (executionContext != null) + foreach (var executionContext in executionContexts) { ExecutionContext.Restore(executionContext); } diff --git a/TUnit.Engine/Helpers/TupleHelper.cs b/TUnit.Engine/Helpers/TupleHelper.cs index 91a425af10..6b406c468e 100644 --- a/TUnit.Engine/Helpers/TupleHelper.cs +++ b/TUnit.Engine/Helpers/TupleHelper.cs @@ -8,7 +8,7 @@ internal class TupleHelper public static bool TryParseTupleToObjectArray(object? tuple, [NotNullWhen(true)] out object?[]? objectArray) { objectArray = null; - + if (tuple == null) { return false; @@ -18,27 +18,88 @@ public static bool TryParseTupleToObjectArray(object? tuple, [NotNullWhen(true)] if (type.IsGenericType && type.FullName!.StartsWith("System.Tuple")) { - // Handle Tuple - objectArray = type.GetProperties() - .Where(p => p.Name.StartsWith("Item")) - .OrderBy(p => p.Name) - .Select(p => p.GetValue(tuple)) - .ToArray(); - + // Handle Tuple recursively + var result = new List(); + FlattenTuple(tuple, result); + objectArray = result.ToArray(); + return true; } - + if (type.IsValueType && type.FullName!.StartsWith("System.ValueTuple")) { - // Handle ValueTuple - objectArray = type.GetFields() - .OrderBy(f => f.Name) - .Select(f => f.GetValue(tuple)) - .ToArray(); + // Handle ValueTuple recursively + var result = new List(); + FlattenValueTuple(tuple, result); + objectArray = result.ToArray(); return true; } return false; } -} \ No newline at end of file + + private static void FlattenTuple(object tuple, List result) + { + var type = tuple.GetType(); + + var properties = type.GetProperties() + .Where(p => p.Name.StartsWith("Item")) + .OrderBy(p => p.Name) + .ToList(); + + // Process items 1 to 7 (or fewer if the tuple is smaller) + for (var i = 0; i < properties.Count - 1; i++) + { + result.Add(properties[i].GetValue(tuple)); + } + + // Check if we have a Rest property (8th item in a large tuple) + if (properties.Count == 8) + { + var rest = properties[7].GetValue(tuple); + + if (rest != null && rest.GetType().FullName!.StartsWith("System.Tuple")) + { + FlattenTuple(rest, result); + } + else + { + result.Add(rest); + } + } + } + + private static void FlattenValueTuple(object tuple, List result) + { + var type = tuple.GetType(); + + var fields = type.GetFields() + .OrderBy(f => f.Name) + .ToList(); + + // Process items 1 to 7 (or fewer if the tuple is smaller) + for (var i = 0; i < fields.Count; i++) + { + // Skip the last field if it's called Rest + if (i == 7 || (i == fields.Count - 1 && fields[i].Name == "Rest")) + { + var rest = fields[i].GetValue(tuple); + + if (rest != null && rest.GetType().IsValueType && rest.GetType().FullName!.StartsWith("System.ValueTuple")) + { + FlattenValueTuple(rest, result); + } + else + { + result.Add(rest); + } + + break; + } + + result.Add(fields[i].GetValue(tuple)); + } + } +} + diff --git a/TUnit.Engine/Hooks/AssemblyHookOrchestrator.cs b/TUnit.Engine/Hooks/AssemblyHookOrchestrator.cs index aebe1ee1f6..baab077331 100644 --- a/TUnit.Engine/Hooks/AssemblyHookOrchestrator.cs +++ b/TUnit.Engine/Hooks/AssemblyHookOrchestrator.cs @@ -4,43 +4,46 @@ using TUnit.Core.Data; using TUnit.Core.Extensions; using TUnit.Core.Hooks; -using TUnit.Core.Logging; using TUnit.Engine.Exceptions; -using TUnit.Engine.Helpers; using TUnit.Engine.Services; namespace TUnit.Engine.Hooks; -internal class AssemblyHookOrchestrator(InstanceTracker instanceTracker, HooksCollectorBase hooksCollector) +internal class AssemblyHookOrchestrator(InstanceTracker instanceTracker, HooksCollectorBase hooksCollector, ContextManager contextManager, TestSessionHookOrchestrator testSessionHookOrchestrator) { - private readonly ConcurrentDictionary _assemblyHookContexts = new(); - private readonly ConcurrentDictionary _beforeHooksReached = new(); internal GetOnlyDictionary> PreviouslyRunBeforeHooks { get; } = new(); - public async Task ExecuteBeforeAssemblyHooks(TestContext testContext) + public async Task ExecuteBeforeAssemblyHooks(TestContext testContext) { - var assemblyHookContext = GetContext(testContext.TestDetails.TestClass.Type.Assembly); + var assemblyHookContext = testContext.AssemblyContext; var assemblyHooksTaskCompletionSource = PreviouslyRunBeforeHooks.GetOrAdd( testContext.TestDetails.TestClass.Type.Assembly, _ => new TaskCompletionSource(), out var assemblyHooksTaskPreviouslyExisted); - + if (assemblyHooksTaskPreviouslyExisted) { await assemblyHooksTaskCompletionSource.Task; - return assemblyHookContext.ExecutionContext; + + assemblyHookContext.RestoreExecutionContext(); + + return; } try { var beforeAssemblyHooks = CollectBeforeHooks(testContext.TestDetails.TestClass.Type.Assembly); + await testSessionHookOrchestrator.RunBeforeTestSession(testContext.AssemblyContext.TestSessionContext, testContext.CancellationToken); + AssemblyHookContext.Current = assemblyHookContext; foreach (var beforeHook in beforeAssemblyHooks) { + assemblyHookContext.RestoreExecutionContext(); + try { await beforeHook.ExecuteAsync(assemblyHookContext, CancellationToken.None); @@ -49,8 +52,6 @@ internal class AssemblyHookOrchestrator(InstanceTracker instanceTracker, HooksCo { throw new HookFailedException($"Error executing [Before(Assembly)] hook: {beforeHook.MethodInfo.Type.FullName}.{beforeHook.Name}", e); } - - ExecutionContextHelper.RestoreContext(assemblyHookContext.ExecutionContext); } AssemblyHookContext.Current = null; @@ -61,16 +62,14 @@ internal class AssemblyHookOrchestrator(InstanceTracker instanceTracker, HooksCo assemblyHooksTaskCompletionSource.SetException(e); throw; } - - return assemblyHookContext.ExecutionContext; } public IEnumerable> CollectBeforeHooks(Assembly assembly) { _beforeHooksReached.GetOrAdd(assembly, true); - var context = GetContext(assembly); - + var context = contextManager.GetAssemblyHookContext(assembly); + AssemblyHookContext.Current = context; foreach (var beforeEveryAssembly in hooksCollector.BeforeEveryAssemblyHooks @@ -122,17 +121,4 @@ Assembly assembly yield return afterEveryAssembly; } } - - public AssemblyHookContext GetContext(Assembly assembly) - { - return _assemblyHookContexts.GetOrAdd(assembly, _ => new AssemblyHookContext - { - Assembly = assembly - }); - } - - public IEnumerable GetAllAssemblyHookContexts() - { - return _assemblyHookContexts.Values; - } } \ No newline at end of file diff --git a/TUnit.Engine/Hooks/ClassHookOrchestrator.cs b/TUnit.Engine/Hooks/ClassHookOrchestrator.cs index 54099831a1..69754a22fc 100644 --- a/TUnit.Engine/Hooks/ClassHookOrchestrator.cs +++ b/TUnit.Engine/Hooks/ClassHookOrchestrator.cs @@ -3,17 +3,13 @@ using TUnit.Core.Data; using TUnit.Core.Extensions; using TUnit.Core.Hooks; -using TUnit.Core.Logging; using TUnit.Engine.Exceptions; -using TUnit.Engine.Helpers; using TUnit.Engine.Services; namespace TUnit.Engine.Hooks; internal class ClassHookOrchestrator(InstanceTracker instanceTracker, HooksCollectorBase hooksCollector) { - private readonly ConcurrentDictionary _classHookContexts = new(); - private readonly ConcurrentDictionary _beforeHooksReached = new(); internal GetOnlyDictionary> PreviouslyRunBeforeHooks { get; } = new(); @@ -43,9 +39,9 @@ public IEnumerable> CollectBeforeHooks(Type t } } - public async Task ExecuteBeforeClassHooks(TestContext testContext) + public async Task ExecuteBeforeClassHooks(TestContext testContext) { - var classHookContext = GetContext(testContext.TestDetails.TestClass.Type); + var classHookContext = testContext.ClassContext; var classHooksTaskCompletionSource = PreviouslyRunBeforeHooks.GetOrAdd( testContext.TestDetails.TestClass.Type, _ => new TaskCompletionSource(), @@ -54,7 +50,7 @@ public IEnumerable> CollectBeforeHooks(Type t if (classHooksTaskPreviouslyExisted) { await classHooksTaskCompletionSource.Task; - return classHookContext.ExecutionContext; + return; } try @@ -65,6 +61,8 @@ public IEnumerable> CollectBeforeHooks(Type t foreach (var beforeHook in beforeClassHooks) { + classHookContext.RestoreExecutionContext(); + try { await beforeHook.ExecuteAsync(classHookContext, CancellationToken.None); @@ -73,8 +71,6 @@ public IEnumerable> CollectBeforeHooks(Type t { throw new HookFailedException($"Error executing [Before(Class)] hook: {beforeHook.MethodInfo.Type.FullName}.{beforeHook.Name}", e); } - - ExecutionContextHelper.RestoreContext(classHookContext.ExecutionContext); } ClassHookContext.Current = null; @@ -85,8 +81,6 @@ public IEnumerable> CollectBeforeHooks(Type t classHooksTaskCompletionSource.SetException(e); throw; } - - return classHookContext.ExecutionContext; } public IEnumerable> CollectAfterHooks( @@ -139,12 +133,4 @@ private static IEnumerable GetTypesIncludingBase(Type testClassType) type = type.BaseType; } } - - public ClassHookContext GetContext(Type type) - { - return _classHookContexts.GetOrAdd(type, _ => new ClassHookContext - { - ClassType = type - }); - } } \ No newline at end of file diff --git a/TUnit.Engine/Hooks/TestDiscoveryHookOrchestrator.cs b/TUnit.Engine/Hooks/TestDiscoveryHookOrchestrator.cs index 62e9a08411..0eda3e2e60 100644 --- a/TUnit.Engine/Hooks/TestDiscoveryHookOrchestrator.cs +++ b/TUnit.Engine/Hooks/TestDiscoveryHookOrchestrator.cs @@ -1,41 +1,29 @@ using TUnit.Core; using TUnit.Core.Hooks; -using TUnit.Core.Logging; using TUnit.Engine.Exceptions; -using TUnit.Engine.Helpers; using TUnit.Engine.Services; namespace TUnit.Engine.Hooks; -internal class TestDiscoveryHookOrchestrator(HooksCollectorBase hooksCollector, string? stringFilter) +internal class TestDiscoveryHookOrchestrator(HooksCollectorBase hooksCollector) { - private BeforeTestDiscoveryContext? _beforeContext; - private TestDiscoveryContext? _afterContext; - - - - public async Task RunBeforeTestDiscovery() + public async Task RunBeforeTestDiscovery(BeforeTestDiscoveryContext beforeTestDiscoveryContext) { - hooksCollector.CollectDiscoveryHooks(); - var beforeDiscoveryHooks = CollectBeforeHooks(); - var beforeContext = GetBeforeContext(); foreach (var beforeDiscoveryHook in beforeDiscoveryHooks) { + beforeTestDiscoveryContext.RestoreExecutionContext(); + try { - await beforeDiscoveryHook.ExecuteAsync(beforeContext, CancellationToken.None); + await beforeDiscoveryHook.ExecuteAsync(beforeTestDiscoveryContext, CancellationToken.None); } catch (Exception e) { throw new HookFailedException($"Error executing [Before(TestDiscovery)] hook: {beforeDiscoveryHook.MethodInfo.Type.FullName}.{beforeDiscoveryHook.Name}", e); } - - ExecutionContextHelper.RestoreContext(beforeContext.ExecutionContext); } - - return beforeContext.ExecutionContext; } public IEnumerable> CollectBeforeHooks() @@ -49,20 +37,4 @@ public IEnumerable> CollectAfterHooks() return hooksCollector.AfterTestDiscoveryHooks .OrderBy(x => x.Order); } - - public BeforeTestDiscoveryContext GetBeforeContext() - { - return _beforeContext ??= new BeforeTestDiscoveryContext - { - TestFilter = stringFilter - }; - } - - public TestDiscoveryContext GetAfterContext(IEnumerable discoveredTests) - { - return _afterContext ??= new TestDiscoveryContext(discoveredTests) - { - TestFilter = stringFilter - }; - } } \ No newline at end of file diff --git a/TUnit.Engine/Hooks/TestHookOrchestrator.cs b/TUnit.Engine/Hooks/TestHookOrchestrator.cs index be438b6d3f..176e6c7f02 100644 --- a/TUnit.Engine/Hooks/TestHookOrchestrator.cs +++ b/TUnit.Engine/Hooks/TestHookOrchestrator.cs @@ -12,7 +12,7 @@ namespace TUnit.Engine.Hooks; #endif internal class TestHookOrchestrator(HooksCollectorBase hooksCollector) { - public async Task ExecuteBeforeHooks(DiscoveredTest discoveredTest, CancellationToken cancellationToken) + public async Task ExecuteBeforeHooks(DiscoveredTest discoveredTest, CancellationToken cancellationToken) { var beforeHooks = CollectBeforeHooks( discoveredTest.TestContext.TestDetails.ClassInstance, @@ -20,6 +20,8 @@ internal class TestHookOrchestrator(HooksCollectorBase hooksCollector) foreach (var executableHook in beforeHooks) { + discoveredTest.TestContext.RestoreExecutionContext(); + await Timings.Record($"Before(Test): {executableHook.Name}", discoveredTest.TestContext, () => { try @@ -31,11 +33,7 @@ await Timings.Record($"Before(Test): {executableHook.Name}", discoveredTest.Test throw new HookFailedException($"Error executing [Before(Test)] hook: {executableHook.MethodInfo.Type.FullName}.{executableHook.Name}", e); } }); - - ExecutionContextHelper.RestoreContext(discoveredTest.TestContext.ExecutionContext); } - - return discoveredTest.TestContext.ExecutionContext; } internal IEnumerable> CollectBeforeHooks(object classInstance, DiscoveredTest discoveredTest) diff --git a/TUnit.Engine/Hooks/TestSessionHookOrchestrator.cs b/TUnit.Engine/Hooks/TestSessionHookOrchestrator.cs index 4a5398bb0b..3140f872d4 100644 --- a/TUnit.Engine/Hooks/TestSessionHookOrchestrator.cs +++ b/TUnit.Engine/Hooks/TestSessionHookOrchestrator.cs @@ -1,43 +1,53 @@ using Microsoft.Testing.Platform.Extensions.TestFramework; using TUnit.Core; using TUnit.Core.Hooks; -using TUnit.Core.Logging; using TUnit.Engine.Exceptions; -using TUnit.Engine.Helpers; using TUnit.Engine.Services; namespace TUnit.Engine.Hooks; -internal class TestSessionHookOrchestrator(HooksCollectorBase hooksCollector, AssemblyHookOrchestrator assemblyHookOrchestrator, string? stringFilter) +internal class TestSessionHookOrchestrator(HooksCollectorBase hooksCollector) { - private TestSessionContext? _context; + private readonly SemaphoreSlim _semaphoreSlim = new(1, 1); + private bool _executed; - public async Task RunBeforeTestSession(ExecuteRequestContext executeRequestContext) + public async Task RunBeforeTestSession(TestSessionContext testSessionContext, CancellationToken cancellationToken) { - hooksCollector.CollectionTestSessionHooks(); - - var testSessionContext = GetContext(executeRequestContext); - var beforeSessionHooks = CollectBeforeHooks(); + if (_executed) + { + return; + } + + await _semaphoreSlim.WaitAsync(cancellationToken); - foreach (var beforeSessionHook in beforeSessionHooks) + try { - try + if (_executed) { - await beforeSessionHook.ExecuteAsync(testSessionContext, executeRequestContext.CancellationToken); + return; } - catch (Exception e) + + var beforeSessionHooks = CollectBeforeHooks(); + + foreach (var beforeSessionHook in beforeSessionHooks) { - throw new HookFailedException($"Error executing [Before(TestSession)] hook: {beforeSessionHook.MethodInfo.Type.FullName}.{beforeSessionHook.Name}", e); + try + { + testSessionContext.RestoreExecutionContext(); + + await beforeSessionHook.ExecuteAsync(testSessionContext, cancellationToken); + } + catch (Exception e) + { + throw new HookFailedException($"Error executing [Before(TestSession)] hook: {beforeSessionHook.MethodInfo.Type.FullName}.{beforeSessionHook.Name}", e); + } } - - ExecutionContextHelper.RestoreContext(testSessionContext.ExecutionContext); } - - // After Discovery and Before test session hooks are run, more chance of referenced assemblies - // being loaded into the AppDomain, so now we collect the test hooks which should pick up loaded libraries too - hooksCollector.CollectHooks(); - - return testSessionContext.ExecutionContext; + finally + { + _executed = true; + _semaphoreSlim.Release(); + } } public IEnumerable> CollectBeforeHooks() @@ -51,13 +61,4 @@ public IEnumerable> CollectAfterHooks() return hooksCollector.AfterTestSessionHooks .OrderBy(x => x.Order); } - - public TestSessionContext GetContext(ExecuteRequestContext executeRequestContext) - { - return _context ??= new TestSessionContext(assemblyHookOrchestrator.GetAllAssemblyHookContexts()) - { - TestFilter = stringFilter, - Id = executeRequestContext.Request.Session.SessionUid.Value - }; - } } \ No newline at end of file diff --git a/TUnit.Engine/Services/BaseTestsConstructor.cs b/TUnit.Engine/Services/BaseTestsConstructor.cs index 31839c9a10..9d3f29100a 100644 --- a/TUnit.Engine/Services/BaseTestsConstructor.cs +++ b/TUnit.Engine/Services/BaseTestsConstructor.cs @@ -1,5 +1,4 @@ using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; using Microsoft.Testing.Platform.Extensions; using Microsoft.Testing.Platform.Extensions.Messages; using TUnit.Core; @@ -14,26 +13,27 @@ namespace TUnit.Engine.Services; [UnconditionalSuppressMessage("Trimming", "IL2072:Target parameter argument does not satisfy \'DynamicallyAccessedMembersAttribute\' in call to target method. The return value of the source method does not have matching annotations.")] [UnconditionalSuppressMessage("Trimming", "IL2075:\'this\' argument does not satisfy \'DynamicallyAccessedMembersAttribute\' in call to target method. The return value of the source method does not have matching annotations.")] [UnconditionalSuppressMessage("AOT", "IL3050:Calling members annotated with \'RequiresDynamicCodeAttribute\' may break functionality when AOT compiling.")] -internal abstract class BaseTestsConstructor(IExtension extension, - DependencyCollector dependencyCollector, +internal abstract class BaseTestsConstructor(IExtension extension, + DependencyCollector dependencyCollector, + ContextManager contextManager, IServiceProvider serviceProvider) : IDataProducer { public DiscoveredTest[] GetTests(CancellationToken cancellationToken) { var discoveredTests = DiscoverTests(); - + dependencyCollector.ResolveDependencies(discoveredTests, cancellationToken); - + return discoveredTests; } protected abstract DiscoveredTest[] DiscoverTests(); - internal protected DiscoveredTest ConstructTest(TestMetadata testMetadata) + protected internal DiscoveredTest ConstructTest(TestMetadata testMetadata) { var testDetails = testMetadata.BuildTestDetails(); - var testContext = new TestContext(serviceProvider, testDetails, testMetadata); + var testContext = new TestContext(serviceProvider, testDetails, testMetadata, contextManager.GetClassHookContext(testDetails.TestClass.Type)); if (testMetadata.DiscoveryException is not null) { @@ -49,7 +49,7 @@ internal protected DiscoveredTest ConstructTest(TestMetadata testMetadata) return discoveredTest; } - internal protected IEnumerable ConstructTests(DynamicTest dynamicTest) + protected internal IEnumerable ConstructTests(DynamicTest dynamicTest) { return dynamicTest.BuildTestMetadatas().Select(ConstructTest); } @@ -62,7 +62,7 @@ private static void RunOnTestDiscoveryAttributeHooks(IEnumerable attr onTestDiscoveryAttribute.OnTestDiscovery(discoveredTestContext ??= new DiscoveredTestContext(testContext)); } } - + public Task IsEnabledAsync() { return extension.IsEnabledAsync(); @@ -73,4 +73,4 @@ public Task IsEnabledAsync() public string DisplayName => extension.DisplayName; public string Description => extension.Description; public Type[] DataTypesProduced => [typeof(TestNodeUpdateMessage)]; -} \ No newline at end of file +} diff --git a/TUnit.Engine/Services/ContextManager.cs b/TUnit.Engine/Services/ContextManager.cs new file mode 100644 index 0000000000..f8c1ca91c5 --- /dev/null +++ b/TUnit.Engine/Services/ContextManager.cs @@ -0,0 +1,43 @@ +using System.Diagnostics.CodeAnalysis; +using System.Reflection; +using TUnit.Core; +using TUnit.Core.Data; + +namespace TUnit.Engine.Services; + +internal class ContextManager(string sessionId, string? testFilter) +{ + [field: AllowNull, MaybeNull] + public BeforeTestDiscoveryContext BeforeTestDiscoveryContext => field ??= new BeforeTestDiscoveryContext + { + TestFilter = testFilter + }; + + [field: AllowNull, MaybeNull] + public TestDiscoveryContext AfterTestDiscoveryContext => field ??= new TestDiscoveryContext(BeforeTestDiscoveryContext) + { + TestFilter = testFilter + }; + + [field: AllowNull, MaybeNull] + public TestSessionContext TestSessionContext => field ??= new TestSessionContext(AfterTestDiscoveryContext) + { + TestFilter = testFilter, + Id = sessionId + }; + + private readonly GetOnlyDictionary _assemblyHookContexts = new (); + private readonly GetOnlyDictionary _classHookContexts = new (); + + public AssemblyHookContext GetAssemblyHookContext(Assembly assembly) => + _assemblyHookContexts.GetOrAdd(assembly, _ => new AssemblyHookContext(TestSessionContext) + { + Assembly = assembly + }); + + public ClassHookContext GetClassHookContext(Type type) => + _classHookContexts.GetOrAdd(type, _ => new ClassHookContext(GetAssemblyHookContext(type.Assembly)) + { + ClassType = type + }); +} diff --git a/TUnit.Engine/Services/HooksCollectorBase.cs b/TUnit.Engine/Services/HooksCollectorBase.cs index b4a5358b10..19b4430b70 100644 --- a/TUnit.Engine/Services/HooksCollectorBase.cs +++ b/TUnit.Engine/Services/HooksCollectorBase.cs @@ -1,31 +1,94 @@ -using System.Reflection; -using TUnit.Core; -using TUnit.Core.Data; -using TUnit.Core.Hooks; +using System.Diagnostics.CodeAnalysis; +using System.Reflection; + using TUnit.Core; + using TUnit.Core.Data; + using TUnit.Core.Hooks; + + namespace TUnit.Engine.Services; + + internal abstract class HooksCollectorBase(string sessionId) + { + public string SessionId { get; } = sessionId; + + [field: AllowNull, MaybeNull] + internal List> BeforeTestDiscoveryHooks + => field ??= CollectBeforeTestDiscoveryHooks(); + + [field: AllowNull, MaybeNull] + internal List> BeforeTestSessionHooks + => field ??= CollectBeforeTestSessionHooks(); + + [field: AllowNull, MaybeNull] + internal GetOnlyDictionary>> BeforeAssemblyHooks + => field ??= CollectBeforeAssemblyHooks(); -namespace TUnit.Engine.Services; + [field: AllowNull, MaybeNull] + internal GetOnlyDictionary>> BeforeClassHooks + => field ??= CollectBeforeClassHooks(); + + [field: AllowNull, MaybeNull] + internal GetOnlyDictionary> BeforeTestHooks + => field ??= CollectBeforeTestHooks(); + + [field: AllowNull, MaybeNull] + internal List> BeforeEveryAssemblyHooks + => field ??= CollectBeforeEveryAssemblyHooks(); + + [field: AllowNull, MaybeNull] + internal List> BeforeEveryClassHooks + => field ??= CollectBeforeEveryClassHooks(); + + [field: AllowNull, MaybeNull] + internal List> BeforeEveryTestHooks + => field ??= CollectBeforeEveryTestHooks(); + + [field: AllowNull, MaybeNull] + internal List> AfterTestDiscoveryHooks + => field ??= CollectAfterTestDiscoveryHooks(); + + [field: AllowNull, MaybeNull] + internal List> AfterTestSessionHooks + => field ??= CollectAfterTestSessionHooks(); + + [field: AllowNull, MaybeNull] + internal GetOnlyDictionary>> AfterAssemblyHooks + => field ??= CollectAfterAssemblyHooks(); + + [field: AllowNull, MaybeNull] + internal GetOnlyDictionary>> AfterClassHooks + => field ??= CollectAfterClassHooks(); + + [field: AllowNull, MaybeNull] + internal GetOnlyDictionary> AfterTestHooks + => field ??= CollectAfterTestHooks(); + + [field: AllowNull, MaybeNull] + internal List> AfterEveryAssemblyHooks + => field ??= CollectAfterEveryAssemblyHooks(); + + [field: AllowNull, MaybeNull] + internal List> AfterEveryClassHooks + => field ??= CollectAfterEveryClassHooks(); + + [field: AllowNull, MaybeNull] + internal List> AfterEveryTestHooks + => field ??= CollectAfterEveryTestHooks(); + + private protected abstract List> CollectBeforeTestDiscoveryHooks(); + private protected abstract List> CollectBeforeTestSessionHooks(); + private protected abstract GetOnlyDictionary>> CollectBeforeAssemblyHooks(); + private protected abstract GetOnlyDictionary>> CollectBeforeClassHooks(); + private protected abstract GetOnlyDictionary> CollectBeforeTestHooks(); + private protected abstract List> CollectBeforeEveryAssemblyHooks(); + private protected abstract List> CollectBeforeEveryClassHooks(); + private protected abstract List> CollectBeforeEveryTestHooks(); + private protected abstract List> CollectAfterTestDiscoveryHooks(); + private protected abstract List> CollectAfterTestSessionHooks(); + private protected abstract GetOnlyDictionary>> CollectAfterAssemblyHooks(); + private protected abstract GetOnlyDictionary>> CollectAfterClassHooks(); + private protected abstract GetOnlyDictionary> CollectAfterTestHooks(); + private protected abstract List> CollectAfterEveryAssemblyHooks(); + private protected abstract List> CollectAfterEveryClassHooks(); + private protected abstract List> CollectAfterEveryTestHooks(); + } -internal abstract class HooksCollectorBase(string sessionId) -{ - public string SessionId { get; } = sessionId; - - internal readonly List> BeforeTestDiscoveryHooks = []; - internal readonly List> BeforeTestSessionHooks = []; - internal readonly GetOnlyDictionary>> BeforeAssemblyHooks = new (); - internal readonly GetOnlyDictionary>> BeforeClassHooks = new (); - internal readonly GetOnlyDictionary> BeforeTestHooks = new (); - internal readonly List> BeforeEveryAssemblyHooks = []; - internal readonly List> BeforeEveryClassHooks = []; - internal readonly List> BeforeEveryTestHooks = []; - internal readonly List> AfterTestDiscoveryHooks = []; - internal readonly List> AfterTestSessionHooks = []; - internal readonly GetOnlyDictionary>> AfterAssemblyHooks = new (); - internal readonly GetOnlyDictionary>> AfterClassHooks = new (); - internal readonly GetOnlyDictionary> AfterTestHooks = new (); - internal readonly List> AfterEveryAssemblyHooks = []; - internal readonly List> AfterEveryClassHooks = []; - internal readonly List> AfterEveryTestHooks = []; - public abstract void CollectDiscoveryHooks(); - public abstract void CollectionTestSessionHooks(); - public abstract void CollectHooks(); -} \ No newline at end of file diff --git a/TUnit.Engine/Services/ReflectionHooksCollector.cs b/TUnit.Engine/Services/ReflectionHooksCollector.cs index accd61eb46..5afe0eed25 100644 --- a/TUnit.Engine/Services/ReflectionHooksCollector.cs +++ b/TUnit.Engine/Services/ReflectionHooksCollector.cs @@ -2,6 +2,7 @@ using System.Reflection; using System.Runtime.CompilerServices; using TUnit.Core; +using TUnit.Core.Data; using TUnit.Core.Exceptions; using TUnit.Core.Executors; using TUnit.Core.Helpers; @@ -23,338 +24,490 @@ internal class ReflectionHooksCollector(string sessionId) : HooksCollectorBase(s | BindingFlags.Instance | BindingFlags.Static | BindingFlags.DeclaredOnly; - - public override void CollectDiscoveryHooks() + + private bool HasHookType(MethodInfo methodInfo, HookType hookType, [NotNullWhen(true)] out HookAttribute? hookAttribute) + { + hookAttribute = methodInfo.GetCustomAttributes() + .OfType() + .FirstOrDefault(x => IsHookType(x, hookType)); + + return hookAttribute is not null; + } + + private static bool IsHookType(Attribute x, HookType hookType) + { + return x switch + { + BeforeAttribute beforeAttribute when beforeAttribute.HookType == hookType => true, + BeforeEveryAttribute beforeEveryAttribute when beforeEveryAttribute.HookType == hookType => true, + AfterAttribute afterAttribute when afterAttribute.HookType == hookType => true, + _ => x is AfterEveryAttribute afterEveryAttribute && afterEveryAttribute.HookType == hookType + }; + } + + private static IHookExecutor GetHookExecutor(MethodInfo arg) { -#if NET - if (!RuntimeFeature.IsDynamicCodeSupported) + var customHookExecutorType = arg.GetCustomAttribute()?.HookExecutorType; + + if (customHookExecutorType is not null) { - throw new InvalidOperationException("Reflection tests are not supported with AOT or trimming enabled."); + return (IHookExecutor)Activator.CreateInstance(customHookExecutorType)!; } -#endif - + + return DefaultExecutor.Instance; + } + + private bool IsHook(MethodInfo arg) + { + try + { + return arg.GetCustomAttributes() + .OfType() + .Any(); + } + catch + { + return false; + } + } + + private protected override List> CollectBeforeTestDiscoveryHooks() + { + var list = new List>(); foreach (var type in ReflectionScanner.GetTypes()) { foreach (var methodInfo in type.GetMethods(BindingFlags) .Where(x => !x.IsAbstract) .Where(IsHook)) { - if (HasHookType(methodInfo, HookType.TestDiscovery, out var hookAttribute)) + if (HasHookType(methodInfo, HookType.TestDiscovery, out var hookAttribute) && hookAttribute is BeforeAttribute or BeforeEveryAttribute) { var sourceGeneratedMethodInformation = ReflectionToSourceModelHelpers.BuildTestMethod(type, methodInfo, methodInfo.Name); - - if (hookAttribute is BeforeAttribute or BeforeEveryAttribute) + list.Add(new BeforeTestDiscoveryHookMethod { - BeforeTestDiscoveryHooks.Add(new BeforeTestDiscoveryHookMethod - { - MethodInfo = sourceGeneratedMethodInformation, - Order = hookAttribute.Order, - HookExecutor = GetHookExecutor(methodInfo), - FilePath = hookAttribute.File, - LineNumber = hookAttribute.Line, - Body = (context, token) => AsyncConvert.ConvertObject(methodInfo.InvokeStaticHook(context, token)), - }); - } - else - { - AfterTestDiscoveryHooks.Add(new AfterTestDiscoveryHookMethod - { - MethodInfo = sourceGeneratedMethodInformation, - Order = hookAttribute.Order, - HookExecutor = GetHookExecutor(methodInfo), - FilePath = hookAttribute.File, - LineNumber = hookAttribute.Line, - Body = (context, token) => AsyncConvert.ConvertObject(methodInfo.InvokeStaticHook(context, token)), - }); - } + MethodInfo = sourceGeneratedMethodInformation, + Order = hookAttribute.Order, + HookExecutor = GetHookExecutor(methodInfo), + FilePath = hookAttribute.File, + LineNumber = hookAttribute.Line, + Body = (context, token) => AsyncConvert.ConvertObject(methodInfo.InvokeStaticHook(context, token)), + }); } } } + return list; } - public override void CollectionTestSessionHooks() + private protected override List> CollectBeforeTestSessionHooks() { + var list = new List>(); foreach (var type in ReflectionScanner.GetTypes()) { foreach (var methodInfo in type.GetMethods(BindingFlags) .Where(x => !x.IsAbstract) .Where(IsHook)) { - if (HasHookType(methodInfo, HookType.TestSession, out var hookAttribute)) + if (HasHookType(methodInfo, HookType.TestSession, out var hookAttribute) && hookAttribute is BeforeAttribute or BeforeEveryAttribute) { var sourceGeneratedMethodInformation = ReflectionToSourceModelHelpers.BuildTestMethod(type, methodInfo, methodInfo.Name); - - if (hookAttribute is BeforeAttribute or BeforeEveryAttribute) + + list.Add(new BeforeTestSessionHookMethod { - BeforeTestSessionHooks.Add(new BeforeTestSessionHookMethod - { - MethodInfo = sourceGeneratedMethodInformation, - Order = hookAttribute.Order, - HookExecutor = GetHookExecutor(methodInfo), - FilePath = hookAttribute.File, - LineNumber = hookAttribute.Line, - Body = (context, token) => AsyncConvert.ConvertObject(methodInfo.InvokeStaticHook(context, token)), - }); - } - else - { - AfterTestSessionHooks.Add(new AfterTestSessionHookMethod - { - MethodInfo = sourceGeneratedMethodInformation, - Order = hookAttribute.Order, - HookExecutor = GetHookExecutor(methodInfo), - FilePath = hookAttribute.File, - LineNumber = hookAttribute.Line, - Body = (context, token) => AsyncConvert.ConvertObject(methodInfo.InvokeStaticHook(context, token)), - }); - } + MethodInfo = sourceGeneratedMethodInformation, + Order = hookAttribute.Order, + HookExecutor = GetHookExecutor(methodInfo), + FilePath = hookAttribute.File, + LineNumber = hookAttribute.Line, + Body = (context, token) => AsyncConvert.ConvertObject(methodInfo.InvokeStaticHook(context, token)), + }); } } } + return list; } - public override void CollectHooks() + private protected override GetOnlyDictionary>> CollectBeforeAssemblyHooks() { + var dict = new GetOnlyDictionary>>(); foreach (var type in ReflectionScanner.GetTypes()) { foreach (var methodInfo in type.GetMethods(BindingFlags) .Where(x => !x.IsAbstract) .Where(IsHook)) { - try + if (HasHookType(methodInfo, HookType.Assembly, out var hookAttribute) && hookAttribute is BeforeAttribute) { var sourceGeneratedMethodInformation = ReflectionToSourceModelHelpers.BuildTestMethod(type, methodInfo, methodInfo.Name); - - if (HasHookType(methodInfo, HookType.Assembly, out var assemblyHookAttribute)) - { - RegisterAssemblyHook(assemblyHookAttribute, sourceGeneratedMethodInformation, methodInfo); - } - - if (HasHookType(methodInfo, HookType.Class, out var classHookAttribute)) - { - RegisterClassHook(classHookAttribute, sourceGeneratedMethodInformation, methodInfo); - } - - if (HasHookType(methodInfo, HookType.Test, out var testHookAttribute)) + var assembly = sourceGeneratedMethodInformation.Class.Type.Assembly; + + dict.GetOrAdd(assembly, _ => []).Add(new BeforeAssemblyHookMethod { - RegisterTestHook(testHookAttribute, sourceGeneratedMethodInformation, methodInfo); - } - } - catch (Exception e) - { - throw new TUnitException($""" - Error collecting hooks for method {methodInfo.Name} in type {type.FullName} - Line: {methodInfo.GetCustomAttribute()?.Line} - File: {methodInfo.GetCustomAttribute()?.File} - """, e); + MethodInfo = sourceGeneratedMethodInformation, + Order = hookAttribute.Order, + HookExecutor = GetHookExecutor(methodInfo), + FilePath = hookAttribute.File, + LineNumber = hookAttribute.Line, + Body = (context, token) => AsyncConvert.ConvertObject(methodInfo.InvokeStaticHook(context, token)), + }); } } } + return dict; } - private void RegisterAssemblyHook(HookAttribute hookAttribute, SourceGeneratedMethodInformation sourceGeneratedMethodInformation, MethodInfo methodInfo) + private protected override GetOnlyDictionary>> CollectBeforeClassHooks() { - var assembly = sourceGeneratedMethodInformation.Class.Type.Assembly; - - if (hookAttribute is BeforeAttribute) - { - BeforeAssemblyHooks.GetOrAdd(assembly, _ => []).Add(new BeforeAssemblyHookMethod - { - MethodInfo = sourceGeneratedMethodInformation, - Order = hookAttribute.Order, - HookExecutor = GetHookExecutor(methodInfo), - FilePath = hookAttribute.File, - LineNumber = hookAttribute.Line, - Body = (context, token) => AsyncConvert.ConvertObject(methodInfo.InvokeStaticHook(context, token)), - }); - } - else if (hookAttribute is AfterAttribute) - { - AfterAssemblyHooks.GetOrAdd(assembly, _ => []).Add(new AfterAssemblyHookMethod - { - MethodInfo = sourceGeneratedMethodInformation, - Order = hookAttribute.Order, - HookExecutor = GetHookExecutor(methodInfo), - FilePath = hookAttribute.File, - LineNumber = hookAttribute.Line, - Body = (context, token) => AsyncConvert.ConvertObject(methodInfo.InvokeStaticHook(context, token)), - }); - } - else if (hookAttribute is BeforeEveryAttribute) - { - BeforeEveryAssemblyHooks.Add(new BeforeAssemblyHookMethod - { - MethodInfo = sourceGeneratedMethodInformation, - Order = hookAttribute.Order, - HookExecutor = GetHookExecutor(methodInfo), - FilePath = hookAttribute.File, - LineNumber = hookAttribute.Line, - Body = (context, token) => AsyncConvert.ConvertObject(methodInfo.InvokeStaticHook(context, token)), - }); - } - else + var dict = new GetOnlyDictionary>>(); + foreach (var type in ReflectionScanner.GetTypes()) { - AfterEveryAssemblyHooks.Add(new AfterAssemblyHookMethod + foreach (var methodInfo in type.GetMethods(BindingFlags) + .Where(x => !x.IsAbstract) + .Where(IsHook)) { - MethodInfo = sourceGeneratedMethodInformation, - Order = hookAttribute.Order, - HookExecutor = GetHookExecutor(methodInfo), - FilePath = hookAttribute.File, - LineNumber = hookAttribute.Line, - Body = (context, token) => AsyncConvert.ConvertObject(methodInfo.InvokeStaticHook(context, token)), - }); + if (HasHookType(methodInfo, HookType.Class, out var hookAttribute) && hookAttribute is BeforeAttribute) + { + var sourceGeneratedMethodInformation = ReflectionToSourceModelHelpers.BuildTestMethod(type, methodInfo, methodInfo.Name); + + dict.GetOrAdd(type, _ => []).Add(new BeforeClassHookMethod + { + MethodInfo = sourceGeneratedMethodInformation, + Order = hookAttribute.Order, + HookExecutor = GetHookExecutor(methodInfo), + FilePath = hookAttribute.File, + LineNumber = hookAttribute.Line, + Body = (context, token) => AsyncConvert.ConvertObject(methodInfo.InvokeStaticHook(context, token)), + }); + } + } } + return dict; } - private void RegisterClassHook(HookAttribute hookAttribute, SourceGeneratedMethodInformation sourceGeneratedMethodInformation, MethodInfo methodInfo) + private protected override GetOnlyDictionary> CollectBeforeTestHooks() { - var type = sourceGeneratedMethodInformation.Class.Type; - - if (hookAttribute is BeforeAttribute) + var dict = new GetOnlyDictionary>(); + foreach (var type in ReflectionScanner.GetTypes()) { - BeforeClassHooks.GetOrAdd(type, _ => []).Add(new BeforeClassHookMethod + foreach (var methodInfo in type.GetMethods(BindingFlags) + .Where(x => !x.IsAbstract) + .Where(IsHook)) { - MethodInfo = sourceGeneratedMethodInformation, - Order = hookAttribute.Order, - HookExecutor = GetHookExecutor(methodInfo), - FilePath = hookAttribute.File, - LineNumber = hookAttribute.Line, - Body = (context, token) => AsyncConvert.ConvertObject(methodInfo.InvokeStaticHook(context, token)), - }); + if (HasHookType(methodInfo, HookType.Test, out var hookAttribute) && hookAttribute is BeforeAttribute) + { + var sourceGeneratedMethodInformation = ReflectionToSourceModelHelpers.BuildTestMethod(type, methodInfo, methodInfo.Name); + + dict.GetOrAdd(type, _ => []).Add(new InstanceHookMethod + { + MethodInfo = sourceGeneratedMethodInformation, + Order = hookAttribute.Order, + HookExecutor = GetHookExecutor(methodInfo), + ClassType = type, + Body = (instance, context, token) => AsyncConvert.ConvertObject(methodInfo.InvokeInstanceHook(instance, context, token)), + }); + } + } } - else if (hookAttribute is AfterAttribute) + return dict; + } + + private protected override List> CollectBeforeEveryAssemblyHooks() + { + var list = new List>(); + foreach (var type in ReflectionScanner.GetTypes()) { - AfterClassHooks.GetOrAdd(type, _ => []).Add(new AfterClassHookMethod + foreach (var methodInfo in type.GetMethods(BindingFlags) + .Where(x => !x.IsAbstract) + .Where(IsHook)) { - MethodInfo = sourceGeneratedMethodInformation, - Order = hookAttribute.Order, - HookExecutor = GetHookExecutor(methodInfo), - FilePath = hookAttribute.File, - LineNumber = hookAttribute.Line, - Body = (context, token) => AsyncConvert.ConvertObject(methodInfo.InvokeStaticHook(context, token)), - }); + if (HasHookType(methodInfo, HookType.Assembly, out var hookAttribute) && hookAttribute is BeforeEveryAttribute) + { + var sourceGeneratedMethodInformation = ReflectionToSourceModelHelpers.BuildTestMethod(type, methodInfo, methodInfo.Name); + list.Add(new BeforeAssemblyHookMethod + { + MethodInfo = sourceGeneratedMethodInformation, + Order = hookAttribute.Order, + HookExecutor = GetHookExecutor(methodInfo), + FilePath = hookAttribute.File, + LineNumber = hookAttribute.Line, + Body = (context, token) => AsyncConvert.ConvertObject(methodInfo.InvokeStaticHook(context, token)), + }); + } + } } - else if (hookAttribute is BeforeEveryAttribute) + return list; + } + + private protected override List> CollectBeforeEveryClassHooks() + { + var list = new List>(); + foreach (var type in ReflectionScanner.GetTypes()) { - BeforeEveryClassHooks.Add(new BeforeClassHookMethod + foreach (var methodInfo in type.GetMethods(BindingFlags) + .Where(x => !x.IsAbstract) + .Where(IsHook)) { - MethodInfo = sourceGeneratedMethodInformation, - Order = hookAttribute.Order, - HookExecutor = GetHookExecutor(methodInfo), - FilePath = hookAttribute.File, - LineNumber = hookAttribute.Line, - Body = (context, token) => AsyncConvert.ConvertObject(methodInfo.InvokeStaticHook(context, token)), - }); + if (HasHookType(methodInfo, HookType.Class, out var hookAttribute) && hookAttribute is BeforeEveryAttribute) + { + var sourceGeneratedMethodInformation = ReflectionToSourceModelHelpers.BuildTestMethod(type, methodInfo, methodInfo.Name); + list.Add(new BeforeClassHookMethod + { + MethodInfo = sourceGeneratedMethodInformation, + Order = hookAttribute.Order, + HookExecutor = GetHookExecutor(methodInfo), + FilePath = hookAttribute.File, + LineNumber = hookAttribute.Line, + Body = (context, token) => AsyncConvert.ConvertObject(methodInfo.InvokeStaticHook(context, token)), + }); + } + } } - else + return list; + } + + private protected override List> CollectBeforeEveryTestHooks() + { + var list = new List>(); + foreach (var type in ReflectionScanner.GetTypes()) { - AfterEveryClassHooks.Add(new AfterClassHookMethod + foreach (var methodInfo in type.GetMethods(BindingFlags) + .Where(x => !x.IsAbstract) + .Where(IsHook)) { - MethodInfo = sourceGeneratedMethodInformation, - Order = hookAttribute.Order, - HookExecutor = GetHookExecutor(methodInfo), - FilePath = hookAttribute.File, - LineNumber = hookAttribute.Line, - Body = (context, token) => AsyncConvert.ConvertObject(methodInfo.InvokeStaticHook(context, token)), - }); + if (HasHookType(methodInfo, HookType.Test, out var hookAttribute) && hookAttribute is BeforeEveryAttribute) + { + var sourceGeneratedMethodInformation = ReflectionToSourceModelHelpers.BuildTestMethod(type, methodInfo, methodInfo.Name); + list.Add(new BeforeTestHookMethod + { + MethodInfo = sourceGeneratedMethodInformation, + Order = hookAttribute.Order, + HookExecutor = GetHookExecutor(methodInfo), + FilePath = hookAttribute.File, + LineNumber = hookAttribute.Line, + Body = (context, token) => AsyncConvert.ConvertObject(methodInfo.InvokeStaticHook(context, token)), + }); + } + } } + return list; } - private void RegisterTestHook(HookAttribute hookAttribute, SourceGeneratedMethodInformation sourceGeneratedMethodInformation, MethodInfo methodInfo) + private protected override List> CollectAfterTestDiscoveryHooks() { - var type = sourceGeneratedMethodInformation.Class.Type; - - if (hookAttribute is BeforeAttribute) + var list = new List>(); + foreach (var type in ReflectionScanner.GetTypes()) { - BeforeTestHooks.GetOrAdd(type, _ => []).Add(new InstanceHookMethod + foreach (var methodInfo in type.GetMethods(BindingFlags) + .Where(x => !x.IsAbstract) + .Where(IsHook)) { - MethodInfo = sourceGeneratedMethodInformation, - Order = hookAttribute.Order, - HookExecutor = GetHookExecutor(methodInfo), - ClassType = type, - Body = (instance, context, token) => AsyncConvert.ConvertObject(methodInfo.InvokeInstanceHook(instance, context, token)), - }); + if (HasHookType(methodInfo, HookType.TestDiscovery, out var hookAttribute) && !(hookAttribute is BeforeAttribute or BeforeEveryAttribute)) + { + var sourceGeneratedMethodInformation = ReflectionToSourceModelHelpers.BuildTestMethod(type, methodInfo, methodInfo.Name); + list.Add(new AfterTestDiscoveryHookMethod + { + MethodInfo = sourceGeneratedMethodInformation, + Order = hookAttribute.Order, + HookExecutor = GetHookExecutor(methodInfo), + FilePath = hookAttribute.File, + LineNumber = hookAttribute.Line, + Body = (context, token) => AsyncConvert.ConvertObject(methodInfo.InvokeStaticHook(context, token)), + }); + } + } } - else if (hookAttribute is AfterAttribute) + return list; + } + + private protected override List> CollectAfterTestSessionHooks() + { + var list = new List>(); + foreach (var type in ReflectionScanner.GetTypes()) { - AfterTestHooks.GetOrAdd(type, _ => []).Add(new InstanceHookMethod + foreach (var methodInfo in type.GetMethods(BindingFlags) + .Where(x => !x.IsAbstract) + .Where(IsHook)) { - MethodInfo = sourceGeneratedMethodInformation, - Order = hookAttribute.Order, - HookExecutor = GetHookExecutor(methodInfo), - ClassType = type, - Body = (instance, context, token) => AsyncConvert.ConvertObject(methodInfo.InvokeInstanceHook(instance, context, token)), - }); + if (HasHookType(methodInfo, HookType.TestSession, out var hookAttribute) && !(hookAttribute is BeforeAttribute or BeforeEveryAttribute)) + { + var sourceGeneratedMethodInformation = ReflectionToSourceModelHelpers.BuildTestMethod(type, methodInfo, methodInfo.Name); + list.Add(new AfterTestSessionHookMethod + { + MethodInfo = sourceGeneratedMethodInformation, + Order = hookAttribute.Order, + HookExecutor = GetHookExecutor(methodInfo), + FilePath = hookAttribute.File, + LineNumber = hookAttribute.Line, + Body = (context, token) => AsyncConvert.ConvertObject(methodInfo.InvokeStaticHook(context, token)), + }); + } + } } - else if (hookAttribute is BeforeEveryAttribute) + return list; + } + + private protected override GetOnlyDictionary>> CollectAfterAssemblyHooks() + { + var dict = new GetOnlyDictionary>>(); + foreach (var type in ReflectionScanner.GetTypes()) { - BeforeEveryTestHooks.Add(new BeforeTestHookMethod + foreach (var methodInfo in type.GetMethods(BindingFlags) + .Where(x => !x.IsAbstract) + .Where(IsHook)) { - MethodInfo = sourceGeneratedMethodInformation, - Order = hookAttribute.Order, - HookExecutor = GetHookExecutor(methodInfo), - FilePath = hookAttribute.File, - LineNumber = hookAttribute.Line, - Body = (context, token) => AsyncConvert.ConvertObject(methodInfo.InvokeStaticHook(context, token)), - }); + if (HasHookType(methodInfo, HookType.Assembly, out var hookAttribute) && hookAttribute is AfterAttribute) + { + var sourceGeneratedMethodInformation = ReflectionToSourceModelHelpers.BuildTestMethod(type, methodInfo, methodInfo.Name); + var assembly = sourceGeneratedMethodInformation.Class.Type.Assembly; + + dict.GetOrAdd(assembly, _ => []).Add(new AfterAssemblyHookMethod + { + MethodInfo = sourceGeneratedMethodInformation, + Order = hookAttribute.Order, + HookExecutor = GetHookExecutor(methodInfo), + FilePath = hookAttribute.File, + LineNumber = hookAttribute.Line, + Body = (context, token) => AsyncConvert.ConvertObject(methodInfo.InvokeStaticHook(context, token)), + }); + } + } } - else + return dict; + } + + private protected override GetOnlyDictionary>> CollectAfterClassHooks() + { + var dict = new GetOnlyDictionary>>(); + foreach (var type in ReflectionScanner.GetTypes()) { - AfterEveryTestHooks.Add(new AfterTestHookMethod + foreach (var methodInfo in type.GetMethods(BindingFlags) + .Where(x => !x.IsAbstract) + .Where(IsHook)) { - MethodInfo = sourceGeneratedMethodInformation, - Order = hookAttribute.Order, - HookExecutor = GetHookExecutor(methodInfo), - FilePath = hookAttribute.File, - LineNumber = hookAttribute.Line, - Body = (context, token) => AsyncConvert.ConvertObject(methodInfo.InvokeStaticHook(context, token)), - }); + if (HasHookType(methodInfo, HookType.Class, out var hookAttribute) && hookAttribute is AfterAttribute) + { + var sourceGeneratedMethodInformation = ReflectionToSourceModelHelpers.BuildTestMethod(type, methodInfo, methodInfo.Name); + + dict.GetOrAdd(type, _ => []).Add(new AfterClassHookMethod + { + MethodInfo = sourceGeneratedMethodInformation, + Order = hookAttribute.Order, + HookExecutor = GetHookExecutor(methodInfo), + FilePath = hookAttribute.File, + LineNumber = hookAttribute.Line, + Body = (context, token) => AsyncConvert.ConvertObject(methodInfo.InvokeStaticHook(context, token)), + }); + } + } } + return dict; } - private bool HasHookType(MethodInfo methodInfo, HookType hookType, [NotNullWhen(true)] out HookAttribute? hookAttribute) + private protected override GetOnlyDictionary> CollectAfterTestHooks() { - hookAttribute = methodInfo.GetCustomAttributes() - .OfType() - .FirstOrDefault(x => IsHookType(x, hookType)); - - return hookAttribute is not null; + var dict = new GetOnlyDictionary>(); + foreach (var type in ReflectionScanner.GetTypes()) + { + foreach (var methodInfo in type.GetMethods(BindingFlags) + .Where(x => !x.IsAbstract) + .Where(IsHook)) + { + if (HasHookType(methodInfo, HookType.Test, out var hookAttribute) && hookAttribute is AfterAttribute) + { + var sourceGeneratedMethodInformation = ReflectionToSourceModelHelpers.BuildTestMethod(type, methodInfo, methodInfo.Name); + + dict.GetOrAdd(type, _ => []).Add(new InstanceHookMethod + { + MethodInfo = sourceGeneratedMethodInformation, + Order = hookAttribute.Order, + HookExecutor = GetHookExecutor(methodInfo), + ClassType = type, + Body = (instance, context, token) => AsyncConvert.ConvertObject(methodInfo.InvokeInstanceHook(instance, context, token)), + }); + } + } + } + return dict; } - private static bool IsHookType(Attribute x, HookType hookType) + private protected override List> CollectAfterEveryAssemblyHooks() { - return x switch + var list = new List>(); + foreach (var type in ReflectionScanner.GetTypes()) { - BeforeAttribute beforeAttribute when beforeAttribute.HookType == hookType => true, - BeforeEveryAttribute beforeEveryAttribute when beforeEveryAttribute.HookType == hookType => true, - AfterAttribute afterAttribute when afterAttribute.HookType == hookType => true, - _ => x is AfterEveryAttribute afterEveryAttribute && afterEveryAttribute.HookType == hookType - }; + foreach (var methodInfo in type.GetMethods(BindingFlags) + .Where(x => !x.IsAbstract) + .Where(IsHook)) + { + if (HasHookType(methodInfo, HookType.Assembly, out var hookAttribute) && hookAttribute is AfterEveryAttribute) + { + var sourceGeneratedMethodInformation = ReflectionToSourceModelHelpers.BuildTestMethod(type, methodInfo, methodInfo.Name); + list.Add(new AfterAssemblyHookMethod + { + MethodInfo = sourceGeneratedMethodInformation, + Order = hookAttribute.Order, + HookExecutor = GetHookExecutor(methodInfo), + FilePath = hookAttribute.File, + LineNumber = hookAttribute.Line, + Body = (context, token) => AsyncConvert.ConvertObject(methodInfo.InvokeStaticHook(context, token)), + }); + } + } + } + return list; } - private static IHookExecutor GetHookExecutor(MethodInfo arg) + private protected override List> CollectAfterEveryClassHooks() { - var customHookExecutorType = arg.GetCustomAttribute()?.HookExecutorType; - - if (customHookExecutorType is not null) + var list = new List>(); + foreach (var type in ReflectionScanner.GetTypes()) { - return (IHookExecutor)Activator.CreateInstance(customHookExecutorType)!; + foreach (var methodInfo in type.GetMethods(BindingFlags) + .Where(x => !x.IsAbstract) + .Where(IsHook)) + { + if (HasHookType(methodInfo, HookType.Class, out var hookAttribute) && hookAttribute is AfterEveryAttribute) + { + var sourceGeneratedMethodInformation = ReflectionToSourceModelHelpers.BuildTestMethod(type, methodInfo, methodInfo.Name); + list.Add(new AfterClassHookMethod + { + MethodInfo = sourceGeneratedMethodInformation, + Order = hookAttribute.Order, + HookExecutor = GetHookExecutor(methodInfo), + FilePath = hookAttribute.File, + LineNumber = hookAttribute.Line, + Body = (context, token) => AsyncConvert.ConvertObject(methodInfo.InvokeStaticHook(context, token)), + }); + } + } } - - return DefaultExecutor.Instance; + return list; } - private bool IsHook(MethodInfo arg) + private protected override List> CollectAfterEveryTestHooks() { - try - { - return arg.GetCustomAttributes() - .OfType() - .Any(); - } - catch + var list = new List>(); + foreach (var type in ReflectionScanner.GetTypes()) { - return false; + foreach (var methodInfo in type.GetMethods(BindingFlags) + .Where(x => !x.IsAbstract) + .Where(IsHook)) + { + if (HasHookType(methodInfo, HookType.Test, out var hookAttribute) && hookAttribute is AfterEveryAttribute) + { + var sourceGeneratedMethodInformation = ReflectionToSourceModelHelpers.BuildTestMethod(type, methodInfo, methodInfo.Name); + list.Add(new AfterTestHookMethod + { + MethodInfo = sourceGeneratedMethodInformation, + Order = hookAttribute.Order, + HookExecutor = GetHookExecutor(methodInfo), + FilePath = hookAttribute.File, + LineNumber = hookAttribute.Line, + Body = (context, token) => AsyncConvert.ConvertObject(methodInfo.InvokeStaticHook(context, token)), + }); + } + } } + return list; } -} \ No newline at end of file +} + diff --git a/TUnit.Engine/Services/ReflectionScanner.cs b/TUnit.Engine/Services/ReflectionScanner.cs index 9b985c246d..1cad74077d 100644 --- a/TUnit.Engine/Services/ReflectionScanner.cs +++ b/TUnit.Engine/Services/ReflectionScanner.cs @@ -24,4 +24,4 @@ public static HashSet GetTypes() }) .ToHashSet(); } -} \ No newline at end of file +} diff --git a/TUnit.Engine/Services/ReflectionTestsConstructor.cs b/TUnit.Engine/Services/ReflectionTestsConstructor.cs index a46b579a05..f9b038fe2e 100644 --- a/TUnit.Engine/Services/ReflectionTestsConstructor.cs +++ b/TUnit.Engine/Services/ReflectionTestsConstructor.cs @@ -8,6 +8,7 @@ using TUnit.Core.Enums; using TUnit.Core.Helpers; using TUnit.Core.Interfaces; +using TUnit.Engine.Extensions; using TUnit.Engine.Helpers; #pragma warning disable TUnitWIP0001 @@ -22,9 +23,10 @@ namespace TUnit.Engine.Services; [UnconditionalSuppressMessage("Trimming", "IL2055:Either the type on which the MakeGenericType is called can\'t be statically determined, or the type parameters to be used for generic arguments can\'t be statically determined.")] [UnconditionalSuppressMessage("Trimming", "IL2060:MakeGenericMethod call does not satisfy \'DynamicallyAccessedMembersAttribute\' in call to target method. The return value of the source method does not have matching annotations.")] [UnconditionalSuppressMessage("Trimming", "IL2111:Reflection")] -internal class ReflectionTestsConstructor(IExtension extension, - DependencyCollector dependencyCollector, - IServiceProvider serviceProvider) : BaseTestsConstructor(extension, dependencyCollector, serviceProvider) +internal class ReflectionTestsConstructor(IExtension extension, + DependencyCollector dependencyCollector, + ContextManager contextManager, + IServiceProvider serviceProvider) : BaseTestsConstructor(extension, dependencyCollector, contextManager, serviceProvider) { protected override DiscoveredTest[] DiscoverTests() { @@ -34,9 +36,9 @@ protected override DiscoveredTest[] DiscoverTests() throw new InvalidOperationException("Reflection tests are not supported with AOT or trimming enabled."); } #endif - + var allTypes = ReflectionScanner.GetTypes(); - + return DiscoverTestsInternal(allTypes) .Concat(DiscoverDynamicTests(allTypes)) .SelectMany(ConstructTests) @@ -54,9 +56,9 @@ private IEnumerable DiscoverTestsInternal(HashSet allTypes) foreach (var argument in GetArguments(type, null, propertyInfo, dataAttribute, DataGeneratorType.Property, () => [], ReflectionToSourceModelHelpers.BuildTestMethod(type, propertyInfo.GetMethod!, null), new TestBuilderContextAccessor(new TestBuilderContext())).Take(1)) { var value = argument()[0]; - + propertyInfo.SetValue(null, value); - + // TODO: // Make async if (value is IAsyncInitializer asyncInitializer) @@ -66,7 +68,7 @@ private IEnumerable DiscoverTestsInternal(HashSet allTypes) } } } - + var testMethods = type.GetMethods() .Where(x => !x.IsAbstract && IsTest(x)) .ToArray(); @@ -90,11 +92,11 @@ private IEnumerable DiscoverDynamicTests(HashSet allTypes) } var context = new DynamicTestBuilderContext(dynamicTestBuilderAttribute.File, dynamicTestBuilderAttribute.Line); - + var instance = Activator.CreateInstance(type)!; - + methodInfo.Invoke(instance, [context]); - + foreach (var contextTest in context.Tests) { yield return contextTest; @@ -106,24 +108,24 @@ private IEnumerable DiscoverDynamicTests(HashSet allTypes) private static IEnumerable Build(Type type, MethodInfo[] testMethods) { var testsBuilderDynamicTests = new List(); - + foreach (var testMethod in testMethods) { var testAttribute = testMethod.GetCustomAttribute()!; - + try { foreach (var typeDataAttribute in GetDataAttributes(type)) { var testInformation = ReflectionToSourceModelHelpers.BuildTestMethod(type, testMethod, testMethod.Name); - + foreach (var testDataAttribute in GetDataAttributes(testMethod)) { var testBuilderContextAccessor = new TestBuilderContextAccessor(new TestBuilderContext()); - + foreach (var classInstanceArguments in GetArguments(type, testMethod, null, typeDataAttribute, DataGeneratorType.ClassParameters, () => [], testInformation, testBuilderContextAccessor)) { - BuildTests(type, classInstanceArguments, testMethod, testDataAttribute, testsBuilderDynamicTests, testAttribute, testBuilderContextAccessor); + BuildTests(type, classInstanceArguments, typeDataAttribute, testMethod, testDataAttribute, testsBuilderDynamicTests, testAttribute, testBuilderContextAccessor); } } } @@ -143,7 +145,7 @@ private static IEnumerable Build(Type type, MethodInfo[] testMethod return testsBuilderDynamicTests; } - private static void BuildTests(Type type, Func classInstanceArguments, MethodInfo testMethod, IDataAttribute testDataAttribute, + private static void BuildTests(Type type, Func classInstanceArguments, IDataAttribute typeDataAttribute, MethodInfo testMethod, IDataAttribute testDataAttribute, List testsBuilderDynamicTests, BaseTestAttribute testAttribute, TestBuilderContextAccessor testBuilderContextAccessor) { try @@ -156,27 +158,35 @@ private static void BuildTests(Type type, Func classInstanceArguments ..type.GetCustomAttributes(), ..type.Assembly.GetCustomAttributes() ]; - + var repeatCount = allAttributes.OfType().FirstOrDefault()?.Times ?? 0; for (var index = 0; index < repeatCount + 1; index++) { - foreach (var testArguments in GetArguments(type, testMethod, null, testDataAttribute, DataGeneratorType.TestParameters, classInstanceArguments, testInformation, + var invokedClassInstanceArguments = classInstanceArguments(); + + foreach (var testArguments in GetArguments(type, testMethod, null, testDataAttribute, DataGeneratorType.TestParameters, () => invokedClassInstanceArguments, testInformation, testBuilderContextAccessor)) { - var propertyArgs = GetPropertyArgs(type, classInstanceArguments, testInformation, testBuilderContextAccessor) + var propertyArgs = GetPropertyArgs(type, invokedClassInstanceArguments, testInformation, testBuilderContextAccessor) .ToDictionary(p => p.PropertyInfo.Name, p => p.Args().ElementAtOrDefault(0)); - var testClassArguments = classInstanceArguments(); + if (typeDataAttribute is not ClassConstructorAttribute) + { + MapImplicitParameters(ref invokedClassInstanceArguments, testInformation.Class.Parameters); + } + var testMethodArguments = testArguments(); - + + MapImplicitParameters(ref testMethodArguments, testInformation.Parameters); + if (type.ContainsGenericParameters) { var classParametersTypes = testInformation.Class.Parameters.Select(p => p.Type).ToList(); - + var substitutedTypes = type.GetGenericArguments() .Select(pc => classParametersTypes.FindIndex(pt => pt == pc)) - .Select(i => testClassArguments[i]!.GetType()) + .Select(i => invokedClassInstanceArguments[i]!.GetType()) .ToArray(); type = type.MakeGenericType(substitutedTypes); @@ -189,14 +199,7 @@ private static void BuildTests(Type type, Func classInstanceArguments if (testMethod.ContainsGenericParameters) { - var testParametersTypes = testInformation.Parameters.Select(p => p.Type).ToList(); - - var substitutedTypes = testMethod.GetGenericArguments() - .Select(pc => testParametersTypes.FindIndex(pt => pt == pc)) - .Select(i => testMethodArguments[i]!.GetType()) - .ToArray(); - - testMethod = testMethod.MakeGenericMethod(substitutedTypes); + testMethod = GetRuntimeMethod(testMethod, testMethodArguments); } testsBuilderDynamicTests.Add(new UntypedDynamicTest(type, testMethod) @@ -205,13 +208,15 @@ private static void BuildTests(Type type, Func classInstanceArguments TestMethodArguments = testMethodArguments, Attributes = allAttributes, TestName = testMethod.Name, - TestClassArguments = testClassArguments, + TestClassArguments = invokedClassInstanceArguments ??= classInstanceArguments(), TestFilePath = testAttribute.File, TestLineNumber = testAttribute.Line, Properties = propertyArgs }); testBuilderContextAccessor.Current = new TestBuilderContext(); + + invokedClassInstanceArguments = classInstanceArguments(); } } } @@ -225,12 +230,233 @@ private static void BuildTests(Type type, Func classInstanceArguments Exception = e, TestClassType = type, }); - + testBuilderContextAccessor.Current = new TestBuilderContext(); } + } private static MethodInfo GetRuntimeMethod(MethodInfo methodInfo, object?[] arguments) + { + if (!methodInfo.IsGenericMethodDefinition) + { + return methodInfo; + } + + var typeArguments = methodInfo.GetGenericArguments(); + var parameters = methodInfo.GetParameters(); + var argumentsTypes = arguments.Select(x => x?.GetType()).ToArray(); + + // Create a mapping from type parameters to concrete types + var typeParameterMap = new Dictionary(); + + // First pass: map type parameters that directly correspond to parameter types + for (int i = 0; i < parameters.Length && i < argumentsTypes.Length; i++) + { + var parameterType = parameters[i].ParameterType; + var argumentType = argumentsTypes[i]; + + if (argumentType != null) + { + MapTypeParameters(parameterType, argumentType, typeParameterMap); + } + } + + // Second pass: resolve any remaining unmapped type parameters + List substituteTypes = []; + foreach (var typeArgument in typeArguments) + { + if (typeParameterMap.TryGetValue(typeArgument, out var mappedType)) + { + substituteTypes.Add(mappedType); + } + else + { + // If we can't map the type parameter, try to infer it from the parameter position + var parameterIndex = -1; + for (int i = 0; i < parameters.Length; i++) + { + if (parameters[i].ParameterType == typeArgument || + (parameters[i].ParameterType.IsGenericType && + parameters[i].ParameterType.GetGenericArguments().Contains(typeArgument))) + { + parameterIndex = i; + break; + } + } + + if (parameterIndex >= 0 && parameterIndex < argumentsTypes.Length && argumentsTypes[parameterIndex] != null) + { + var inferredType = argumentsTypes[parameterIndex]!; + + // Handle nullable types + if (parameters[parameterIndex].ParameterType.IsGenericType && + parameters[parameterIndex].ParameterType.GetGenericTypeDefinition() == typeof(Nullable<>)) + { + inferredType = Nullable.GetUnderlyingType(inferredType) ?? inferredType; + } + + substituteTypes.Add(inferredType); + } + else + { + throw new InvalidOperationException($"Cannot infer type for generic parameter '{typeArgument.Name}'. No matching argument found."); + } + } + } + + return methodInfo.MakeGenericMethod(substituteTypes.ToArray()); + } + + private static void MapTypeParameters(Type parameterType, Type argumentType, Dictionary typeParameterMap) + { + if (parameterType.IsGenericParameter) + { + // Direct mapping: T -> int, T -> string, etc. + if (!typeParameterMap.ContainsKey(parameterType)) + { + typeParameterMap[parameterType] = argumentType; + } + } + else if (parameterType.IsGenericType && argumentType.IsGenericType) + { + // Handle generic types: List -> List, Dictionary -> Dictionary, etc. + var parameterGenericDef = parameterType.GetGenericTypeDefinition(); + var argumentGenericDef = argumentType.GetGenericTypeDefinition(); + + if (parameterGenericDef == argumentGenericDef) + { + var parameterTypeArgs = parameterType.GetGenericArguments(); + var argumentTypeArgs = argumentType.GetGenericArguments(); + + for (int i = 0; i < Math.Min(parameterTypeArgs.Length, argumentTypeArgs.Length); i++) + { + MapTypeParameters(parameterTypeArgs[i], argumentTypeArgs[i], typeParameterMap); + } + } + } + else if (parameterType.IsGenericType && parameterType.GetGenericTypeDefinition() == typeof(Nullable<>)) + { + // Handle nullable types: T? -> int, T? -> int? + var underlyingParameterType = parameterType.GetGenericArguments()[0]; + var underlyingArgumentType = Nullable.GetUnderlyingType(argumentType) ?? argumentType; + MapTypeParameters(underlyingParameterType, underlyingArgumentType, typeParameterMap); + } } + + private static void MapImplicitParameters(ref object?[] arguments, SourceGeneratedParameterInformation[] parameters) + { + if (arguments.Length == parameters.Length) + { + if (parameters.Length > 0 && parameters.Last().IsParams + && arguments.Length > 0 && arguments.Last() is not IEnumerable) + { + var lastParameter = parameters.Last(); + + var underlyingType = lastParameter.Type.GetElementType() + ?? lastParameter.Type.GenericTypeArguments.FirstOrDefault() + ?? throw new InvalidOperationException("Cannot determine the underlying type of the params argument. Use an array to fix this."); + + var typedArray = Array.CreateInstance(underlyingType, 1); + + var value = CastHelper.Cast(underlyingType, arguments.Last()); + typedArray.SetValue(value, 0); + + arguments = [ + ..arguments.Take(arguments.Length - 1), + typedArray + ]; + return; + } + + return; + } + + if(parameters.Length == 0) + { + arguments = []; + return; + } + + if (arguments.Length < parameters.Length) + { + var missingParameters = parameters.Skip(arguments.Length).ToArray(); + + if (missingParameters.All(x => x.IsOptional)) + { + arguments = [ + ..arguments, + ..missingParameters.Select(x => x.DefaultValue) + ]; + return; + } + + if (parameters.LastOrDefault()?.Type == typeof(CancellationToken) + && arguments.LastOrDefault() is not CancellationToken) + { + // We'll add this later + return; + } + + throw new InvalidOperationException($"Not enough arguments provided to fulfil the parameters. Expected {parameters.Length}, but got {arguments.Length}."); + } + + if (arguments.Length > parameters.Length) + { + var lastParameter = parameters.Last(); + + if (lastParameter.IsParams) + { + var underlyingType = lastParameter.Type.GetElementType() + ?? lastParameter.Type.GenericTypeArguments.FirstOrDefault() + ?? throw new InvalidOperationException("Cannot determine the underlying type of the params argument. Use an array to fix this."); + + var argumentsBeforeParams = arguments.Take(parameters.Length - 1).ToArray(); + var argumentsAfterParams = arguments.Skip(argumentsBeforeParams.Length).ToArray(); + + if(argumentsAfterParams.All(x => x is null || IsConvertibleTo(x, underlyingType))) + { + var typedArray = Array.CreateInstance(underlyingType, argumentsAfterParams.Length); + + for (var i = 0; i < argumentsAfterParams.Length; i++) + { + typedArray.SetValue(CastHelper.Cast(underlyingType, argumentsAfterParams[i]), i); + } + + // We have a params argument, so we can just add the rest of the arguments + arguments = [ + ..argumentsBeforeParams, + typedArray + ]; + return; + } + + } + + arguments = arguments.Take(parameters.Length).ToArray(); + } } - private static IEnumerable<(PropertyInfo PropertyInfo, Func Args)> GetPropertyArgs(Type type, Func classInstanceArguments, + private static bool IsConvertibleTo(object x, Type underlyingType) + { + if (x.GetType().IsAssignableTo(underlyingType)) + { + return true; + } + + if (CastHelper.GetConversionMethod(x.GetType(), underlyingType) is not null) + { + return true; + } + + try + { + _ = Convert.ChangeType(x, underlyingType); + return true; + } + catch + { + return false; + } + } + + private static IEnumerable<(PropertyInfo PropertyInfo, Func Args)> GetPropertyArgs(Type type, object?[] classInstanceArguments, SourceGeneratedMethodInformation testInformation, TestBuilderContextAccessor testBuilderContextAccessor) { var properties = type.GetProperties() @@ -240,7 +466,7 @@ private static void BuildTests(Type type, Func classInstanceArguments foreach (var propertyInfo in properties) { var dataAttributes = GetDataAttributes(propertyInfo)[0]; - var args = GetArguments(type, null, propertyInfo, dataAttributes, DataGeneratorType.Property, classInstanceArguments, testInformation, testBuilderContextAccessor).ToArray(); + var args = GetArguments(type, null, propertyInfo, dataAttributes, DataGeneratorType.Property, () => classInstanceArguments, testInformation, testBuilderContextAccessor).ToArray(); yield return (propertyInfo, args[0]); } } @@ -250,7 +476,7 @@ private static void BuildTests(Type type, Func classInstanceArguments out Exception? exception) { exception = null; - + try { if (typeDataAttribute is ClassConstructorAttribute classConstructorAttribute) @@ -259,8 +485,8 @@ private static void BuildTests(Type type, Func classInstanceArguments } var args = classInstanceArguments.Select((x, i) => CastHelper.Cast(testInformation.Class.Parameters[i].Type, x)).ToArray(); - - var propertyArgs = GetPropertyArgs(type, () => args, testInformation, testBuilderContextAccessor) + + var propertyArgs = GetPropertyArgs(type, args, testInformation, testBuilderContextAccessor) .ToDictionary(p => p.PropertyInfo.Name, p => p.Args().ElementAtOrDefault(0)); return InstanceHelper.CreateInstance(testInformation.Class, args, propertyArgs, testBuilderContextAccessor.Current); @@ -281,11 +507,11 @@ private static object CreateByClassConstructor(Type type, ClassConstructorAttrib TestBuilderContext = new TestBuilderContext(), TestSessionId = string.Empty, }; - + var createMethod = typeof(IClassConstructor).GetMethod(nameof(IClassConstructor.Create))!.MakeGenericMethod(type); var instance = createMethod.Invoke(classConstructor, [metadata]); - + return instance!; } @@ -297,6 +523,8 @@ private static object CreateByClassConstructor(Type type, ClassConstructorAttrib SourceGeneratedMethodInformation testInformation, TestBuilderContextAccessor testBuilderContextAccessor) { + var classInstanceArgumentsInvoked = dataGeneratorType != DataGeneratorType.ClassParameters ? classInstanceArguments() : null; + if (testDataAttribute is IDataSourceGeneratorAttribute dataSourceGeneratorAttribute) { var memberAttributes = dataGeneratorType switch @@ -305,7 +533,7 @@ private static object CreateByClassConstructor(Type type, ClassConstructorAttrib DataGeneratorType.Property => [], _ => type.GetConstructors().FirstOrDefault(x => !x.IsStatic)?.GetParameters().SelectMany(x => x.GetCustomAttributes()) ?? [] }; - + var needsInstance = memberAttributes.Any(x => x is IAccessesInstanceData); var invoke = dataSourceGeneratorAttribute.GetType().GetMethod("GenerateDataSources")!.Invoke(testDataAttribute, [ @@ -313,7 +541,7 @@ private static object CreateByClassConstructor(Type type, ClassConstructorAttrib { Type = dataGeneratorType, TestInformation = testInformation, - ClassInstanceArguments = needsInstance ? classInstanceArguments() : null, + ClassInstanceArguments = classInstanceArgumentsInvoked, MembersToGenerate = dataGeneratorType switch { DataGeneratorType.TestParameters => method!.GetParameters() @@ -321,6 +549,7 @@ private static object CreateByClassConstructor(Type type, ClassConstructorAttrib { Name = x.Name!, Attributes = x.GetCustomAttributes().ToArray(), + ReflectionInfo = x, }).ToArray(), DataGeneratorType.ClassParameters => type.GetConstructors().FirstOrDefault(x => !x.IsStatic)? .GetParameters() @@ -328,6 +557,7 @@ private static object CreateByClassConstructor(Type type, ClassConstructorAttrib { Name = x.Name!, Attributes = x.GetCustomAttributes().ToArray(), + ReflectionInfo = x, }).ToArray() ?? [], DataGeneratorType.Property => [ @@ -342,13 +572,13 @@ private static object CreateByClassConstructor(Type type, ClassConstructorAttrib _ => throw new ArgumentOutOfRangeException(nameof(dataGeneratorType), dataGeneratorType, null) }, TestBuilderContext = testBuilderContextAccessor, - TestClassInstance = needsInstance ? CreateInstance(testDataAttribute, type, classInstanceArguments(), testInformation, testBuilderContextAccessor, out _) : null, + TestClassInstance = needsInstance ? CreateInstance(testDataAttribute, type, classInstanceArgumentsInvoked ?? classInstanceArguments(), testInformation, testBuilderContextAccessor, out _) : null, TestSessionId = string.Empty, } ]) as IEnumerable; var funcEnumerable = invoke?.Cast() ?? []; - + foreach (var func in funcEnumerable) { yield return () => @@ -375,11 +605,14 @@ private static object CreateByClassConstructor(Type type, ClassConstructorAttrib } else if (testDataAttribute is InstanceMethodDataSourceAttribute instanceMethodDataSourceAttribute) { - var instance = CreateInstance(testDataAttribute, type, classInstanceArguments(), testInformation, testBuilderContextAccessor, out var exception); - + var instance = CreateInstance(testDataAttribute, type, classInstanceArgumentsInvoked ?? classInstanceArguments(), testInformation, testBuilderContextAccessor, out var exception); + var methodDataSourceType = instanceMethodDataSourceAttribute.ClassProvidingDataSource ?? type; - var result = methodDataSourceType.GetMethod(instanceMethodDataSourceAttribute.MethodNameProvidingDataSource)?.Invoke(instance, []); + var result = methodDataSourceType.GetMethod( + name: instanceMethodDataSourceAttribute.MethodNameProvidingDataSource, + types: instanceMethodDataSourceAttribute.Arguments.Select(x => x?.GetType() ?? typeof(object)).ToArray()) + ?.Invoke(instance, instanceMethodDataSourceAttribute.Arguments); var enumerableResult = result is not string and IEnumerable enumerable ? enumerable.Cast().ToArray() @@ -389,8 +622,25 @@ private static object CreateByClassConstructor(Type type, ClassConstructorAttrib { yield return () => { + var parameterType = method?.GetParameters().ElementAtOrDefault(0)?.ParameterType; + + if (methodResult?.GetType().IsAssignableTo(parameterType) is true) + { + return [methodResult]; + } + if (FuncHelper.TryInvokeFunc(methodResult, out var funcResult)) { + if (funcResult?.GetType().IsAssignableTo(parameterType) is true) + { + return [funcResult]; + } + + if (dataGeneratorType == DataGeneratorType.Property) + { + return [funcResult]; + } + if (TupleHelper.TryParseTupleToObjectArray(funcResult, out var funcObjectArray)) { return funcObjectArray; @@ -399,6 +649,16 @@ private static object CreateByClassConstructor(Type type, ClassConstructorAttrib return funcResult as object?[] ?? [funcResult]; } + if (methodResult?.GetType().IsAssignableTo(parameterType) is true) + { + return [funcResult]; + } + + if (dataGeneratorType == DataGeneratorType.Property) + { + return [funcResult]; + } + if (TupleHelper.TryParseTupleToObjectArray(methodResult, out var objectArray)) { return objectArray; @@ -411,8 +671,8 @@ private static object CreateByClassConstructor(Type type, ClassConstructorAttrib else if (testDataAttribute is MethodDataSourceAttribute methodDataSourceAttribute) { var methodDataSourceType = methodDataSourceAttribute.ClassProvidingDataSource ?? type; - - var result = methodDataSourceType.GetMethod(methodDataSourceAttribute.MethodNameProvidingDataSource, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.FlattenHierarchy)!.Invoke(null, []) ?? Array.Empty(); + + var result = InvokeMethodDataSource(methodDataSourceType, methodDataSourceAttribute); var enumerableResult = result is not string and IEnumerable enumerable ? enumerable.Cast().ToArray() @@ -422,8 +682,25 @@ private static object CreateByClassConstructor(Type type, ClassConstructorAttrib { yield return () => { + var parameterType = method?.GetParameters().ElementAtOrDefault(0)?.ParameterType; + + if (methodResult?.GetType().IsAssignableTo(parameterType) is true) + { + return [methodResult]; + } + if (FuncHelper.TryInvokeFunc(methodResult, out var funcResult)) { + if (funcResult?.GetType().IsAssignableTo(parameterType) is true) + { + return [funcResult]; + } + + if (dataGeneratorType == DataGeneratorType.Property) + { + return [funcResult]; + } + if (TupleHelper.TryParseTupleToObjectArray(funcResult, out var funcObjectArray)) { return funcObjectArray; @@ -432,6 +709,16 @@ private static object CreateByClassConstructor(Type type, ClassConstructorAttrib return funcResult as object?[] ?? [funcResult]; } + if (methodResult?.GetType().IsAssignableTo(parameterType) is true) + { + return [funcResult]; + } + + if (dataGeneratorType == DataGeneratorType.Property) + { + return [funcResult]; + } + if (TupleHelper.TryParseTupleToObjectArray(methodResult, out var objectArray)) { return objectArray; @@ -451,6 +738,20 @@ private static object CreateByClassConstructor(Type type, ClassConstructorAttrib } } + private static object InvokeMethodDataSource(Type methodDataSourceType, MethodDataSourceAttribute methodDataSourceAttribute) + { + var bindingFlags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.FlattenHierarchy; + + return methodDataSourceType.GetMethod( + name: methodDataSourceAttribute.MethodNameProvidingDataSource, + bindingAttr: bindingFlags, + binder: null, + types: methodDataSourceAttribute.Arguments.Select(x => x?.GetType() ?? typeof(object)).ToArray(), + modifiers: null + )! + .Invoke(null, methodDataSourceAttribute.Arguments) ?? Array.Empty(); + } + private static IDataAttribute[] GetDataAttributes(MemberInfo memberInfo) { var dataAttributes = memberInfo.GetCustomAttributes() @@ -461,7 +762,7 @@ private static IDataAttribute[] GetDataAttributes(MemberInfo memberInfo) { return NoOpDataAttribute.Array; } - + return dataAttributes; } @@ -478,4 +779,4 @@ private bool IsTest(MethodInfo arg) return false; } } -} \ No newline at end of file +} diff --git a/TUnit.Engine/Services/SingleTestExecutor.cs b/TUnit.Engine/Services/SingleTestExecutor.cs index 75d4f92d67..b6e55fb3a9 100644 --- a/TUnit.Engine/Services/SingleTestExecutor.cs +++ b/TUnit.Engine/Services/SingleTestExecutor.cs @@ -1,7 +1,6 @@ using System.Diagnostics; using Microsoft.Testing.Platform.Extensions; using Microsoft.Testing.Platform.Extensions.Messages; -using Microsoft.Testing.Platform.Extensions.TestFramework; using Microsoft.Testing.Platform.Requests; using TUnit.Core; using TUnit.Core.Enums; @@ -97,7 +96,7 @@ private async ValueTask ExecuteTestInternalAsync(DiscoveredTest test, ITestExecu } TestContext.Current = testContext; - + await RunFirstTestEventReceivers(testContext); await ExecuteWithRetries(test, cleanUpExceptions); @@ -147,107 +146,105 @@ private async ValueTask ExecuteTestInternalAsync(DiscoveredTest test, ITestExecu private async Task RunFirstTestEventReceivers(TestContext testContext) { - ExecutionContextHelper.RestoreContext(await RunFirstTestInSessionEventReceivers(testContext)); - ExecutionContextHelper.RestoreContext(await RunFirstTestInAssemblyEventReceivers(testContext)); - ExecutionContextHelper.RestoreContext(await RunFirstTestInClassEventReceivers(testContext)); + await RunFirstTestInSessionEventReceivers(testContext); + + await RunFirstTestInAssemblyEventReceivers(testContext); + + await RunFirstTestInClassEventReceivers(testContext); } - private async Task RunFirstTestInSessionEventReceivers(TestContext testContext) + private async Task RunFirstTestInSessionEventReceivers(TestContext testContext) { - var testSessionContext = TestSessionContext.Current; + var testSessionContext = testContext.AssemblyContext.TestSessionContext; - if (testSessionContext == null) + if (testSessionContext.FirstTestStarted) { - return null; + return; } - if (!testSessionContext.FirstTestStarted) + await SessionEventsLock.WaitAsync(); + + try { - await SessionEventsLock.WaitAsync(); - try + if (testSessionContext.FirstTestStarted) { - if (!testSessionContext.FirstTestStarted) - { - foreach (var firstTestInAssemblyEventReceiver in testContext.GetFirstTestInTestSessionEventObjects()) - { - await firstTestInAssemblyEventReceiver.OnFirstTestInTestSession(testSessionContext, testContext); - ExecutionContextHelper.RestoreContext(testContext); - } - - testSessionContext.FirstTestStarted = true; - - return ExecutionContext.Capture(); - } + return; } - finally + + foreach (var firstTestInAssemblyEventReceiver in testContext.GetFirstTestInTestSessionEventObjects()) { - SessionEventsLock.Release(); + testContext.RestoreExecutionContext(); + await firstTestInAssemblyEventReceiver.OnFirstTestInTestSession(testSessionContext, testContext); } } - - return null; + finally + { + testSessionContext.FirstTestStarted = true; + SessionEventsLock.Release(); + } } - private async Task RunFirstTestInAssemblyEventReceivers(TestContext testContext) + private async Task RunFirstTestInAssemblyEventReceivers(TestContext testContext) { - var assemblyHookContext = assemblyHookOrchestrator.GetContext(testContext.TestDetails.TestClass.Type.Assembly); + var assemblyHookContext = testContext.AssemblyContext; - if (!assemblyHookContext.FirstTestStarted) + if (assemblyHookContext.FirstTestStarted) { - await AssemblyEventsLock.WaitAsync(); - try + return; + } + + await AssemblyEventsLock.WaitAsync(); + + try + { + if (assemblyHookContext.FirstTestStarted) { - if (!assemblyHookContext.FirstTestStarted) - { - foreach (var firstTestInAssemblyEventReceiver in testContext.GetFirstTestInAssemblyEventObjects()) - { - await firstTestInAssemblyEventReceiver.OnFirstTestInAssembly(assemblyHookContext, testContext); - ExecutionContextHelper.RestoreContext(testContext); - } - - assemblyHookContext.FirstTestStarted = true; - - return ExecutionContext.Capture(); - } + return; } - finally + + foreach (var firstTestInAssemblyEventReceiver in testContext.GetFirstTestInAssemblyEventObjects()) { - AssemblyEventsLock.Release(); + testContext.RestoreExecutionContext(); + + await firstTestInAssemblyEventReceiver.OnFirstTestInAssembly(assemblyHookContext, testContext); } } - - return null; + finally + { + assemblyHookContext.FirstTestStarted = true; + AssemblyEventsLock.Release(); + } } - private async Task RunFirstTestInClassEventReceivers(TestContext testContext) + private async Task RunFirstTestInClassEventReceivers(TestContext testContext) { - var classHookContext = classHookOrchestrator.GetContext(testContext.TestDetails.TestClass.Type); + var classHookContext = testContext.ClassContext; - if (!classHookContext.FirstTestStarted) + if (classHookContext.FirstTestStarted) { - await ClassEventsLock.WaitAsync(); - try + return; + } + + await ClassEventsLock.WaitAsync(); + + try + { + if (classHookContext.FirstTestStarted) { - if (!classHookContext.FirstTestStarted) - { - foreach (var firstTestInAssemblyEventReceiver in testContext.GetFirstTestInClassEventObjects()) - { - await firstTestInAssemblyEventReceiver.OnFirstTestInClass(classHookContext, testContext); - ExecutionContextHelper.RestoreContext(testContext); - } - - classHookContext.FirstTestStarted = true; - - return ExecutionContext.Capture(); - } + return; } - finally + + foreach (var firstTestInAssemblyEventReceiver in testContext.GetFirstTestInClassEventObjects()) { - ClassEventsLock.Release(); + testContext.RestoreExecutionContext(); + await firstTestInAssemblyEventReceiver.OnFirstTestInClass(classHookContext, testContext); } } - - return null; + finally + { + classHookContext.FirstTestStarted = true; + ClassEventsLock.Release(); + } } private ValueTask RegisterIfNotAlready(TestContext testContext) @@ -296,7 +293,7 @@ private async ValueTask ExecuteStaticAfterHooks(DiscoveredTest test, TestContext List cleanUpExceptions) { var afterClassHooks = classHookOrchestrator.CollectAfterHooks(testContext, test.TestContext.TestDetails.TestClass.Type); - var classHookContext = classHookOrchestrator.GetContext(test.TestContext.TestDetails.TestClass.Type); + var classHookContext = test.TestContext.ClassContext; ClassHookContext.Current = classHookContext; @@ -318,7 +315,7 @@ await RunHelpers.RunValueTaskSafelyAsync(() => ClassHookContext.Current = null; var afterAssemblyHooks = assemblyHookOrchestrator.CollectAfterHooks(testContext, test.TestContext.TestDetails.TestClass.Type.Assembly); - var assemblyHookContext = assemblyHookOrchestrator.GetContext(test.TestContext.TestDetails.TestClass.Type.Assembly); + var assemblyHookContext = test.TestContext.AssemblyContext; AssemblyHookContext.Current = assemblyHookContext; @@ -341,7 +338,7 @@ await RunHelpers.RunValueTaskSafelyAsync(() => if (instanceTracker.IsLastTest()) { - var testSessionContext = TestSessionContext.Current!; + var testSessionContext = assemblyHookContext.TestSessionContext!; foreach (var testEndEventsObject in testContext.GetLastTestInTestSessionEventObjects()) { diff --git a/TUnit.Engine/Services/SourceGeneratedHooksCollector.cs b/TUnit.Engine/Services/SourceGeneratedHooksCollector.cs index 0a1d0f5175..c267c77e6e 100644 --- a/TUnit.Engine/Services/SourceGeneratedHooksCollector.cs +++ b/TUnit.Engine/Services/SourceGeneratedHooksCollector.cs @@ -2,117 +2,195 @@ using TUnit.Core; using TUnit.Core.Data; using TUnit.Core.Hooks; -using TUnit.Core.Interfaces.SourceGenerator; namespace TUnit.Engine.Services; internal class SourceGeneratedHooksCollector(string sessionId) : HooksCollectorBase(sessionId) { - public override void CollectDiscoveryHooks() + private protected override List> CollectBeforeTestDiscoveryHooks() { - while (Sources.TestDiscoveryHookSources.TryDequeue(out var hookSource)) + var result = new List>(); + foreach (var hookSource in Sources.TestDiscoveryHookSources) { - foreach (var beforeHook in hookSource.CollectBeforeTestDiscoveryHooks(SessionId)) - { - BeforeTestDiscoveryHooks.Add(beforeHook); - } + result.AddRange(hookSource.CollectBeforeTestDiscoveryHooks(SessionId)); + } + return result; + } - foreach (var afterHook in hookSource.CollectAfterTestDiscoveryHooks(SessionId)) - { - AfterTestDiscoveryHooks.Add(afterHook); - } + private protected override List> CollectBeforeTestSessionHooks() + { + var result = new List>(); + + foreach (var hookSource in Sources.TestSessionHookSources) + { + result.AddRange(hookSource.CollectBeforeTestSessionHooks(SessionId)); } + + return result; } - public override void CollectionTestSessionHooks() + private protected override GetOnlyDictionary>> CollectBeforeAssemblyHooks() { - while (Sources.TestSessionHookSources.TryDequeue(out var hookSource)) + var dict = new GetOnlyDictionary>>(); + foreach (var hookSource in Sources.AssemblyHookSources) { - foreach (var beforeHook in hookSource.CollectBeforeTestSessionHooks(SessionId)) + foreach (var beforeHook in hookSource.CollectBeforeAssemblyHooks(SessionId)) { - BeforeTestSessionHooks.Add(beforeHook); + var list = dict.GetOrAdd(beforeHook.Assembly, _ => new List>()); + list.Add(beforeHook); } + } + return dict; + } - foreach (var afterHook in hookSource.CollectAfterTestSessionHooks(SessionId)) + private protected override GetOnlyDictionary>> CollectBeforeClassHooks() + { + var dict = new GetOnlyDictionary>>(); + foreach (var hookSource in Sources.ClassHookSources) + { + foreach (var beforeHook in hookSource.CollectBeforeClassHooks(SessionId)) { - AfterTestSessionHooks.Add(afterHook); + var list = dict.GetOrAdd(beforeHook.ClassType, _ => new List>()); + list.Add(beforeHook); } } + return dict; } - public override void CollectHooks() + private protected override GetOnlyDictionary> CollectBeforeTestHooks() { - while (Sources.TestHookSources.TryDequeue(out var hookSource)) + var dict = new GetOnlyDictionary>(); + foreach (var hookSource in Sources.TestHookSources) { foreach (var beforeHook in hookSource.CollectBeforeTestHooks(SessionId)) { - var beforeList = BeforeTestHooks.GetOrAdd(beforeHook.ClassType, _ => []); - beforeList.Add(beforeHook); + var list = dict.GetOrAdd(beforeHook.ClassType, _ => new List()); + list.Add(beforeHook); } + } + return dict; + } - foreach (var afterHook in hookSource.CollectAfterTestHooks(SessionId)) - { - var afterList = AfterTestHooks.GetOrAdd(afterHook.ClassType, _ => []); - afterList.Add(afterHook); - } - - foreach (var beforeHook in hookSource.CollectBeforeEveryTestHooks(SessionId)) - { - BeforeEveryTestHooks.Add(beforeHook); - } + private protected override List> CollectBeforeEveryAssemblyHooks() + { + var result = new List>(); + foreach (var hookSource in Sources.AssemblyHookSources) + { + result.AddRange(hookSource.CollectBeforeEveryAssemblyHooks(SessionId)); + } + return result; + } - foreach (var afterHook in hookSource.CollectAfterEveryTestHooks(SessionId)) - { - AfterEveryTestHooks.Add(afterHook); - } + private protected override List> CollectBeforeEveryClassHooks() + { + var result = new List>(); + foreach (var hookSource in Sources.ClassHookSources) + { + result.AddRange(hookSource.CollectBeforeEveryClassHooks(SessionId)); + } + return result; + } + + private protected override List> CollectBeforeEveryTestHooks() + { + var result = new List>(); + foreach (var hookSource in Sources.TestHookSources) + { + result.AddRange(hookSource.CollectBeforeEveryTestHooks(SessionId)); } + return result; + } - while (Sources.ClassHookSources.TryDequeue(out var hookSource)) + private protected override List> CollectAfterTestDiscoveryHooks() + { + var result = new List>(); + foreach (var hookSource in Sources.TestDiscoveryHookSources) { - foreach (var beforeHook in hookSource.CollectBeforeClassHooks(SessionId)) + result.AddRange(hookSource.CollectAfterTestDiscoveryHooks(SessionId)); + } + return result; + } + + private protected override List> CollectAfterTestSessionHooks() + { + var result = new List>(); + foreach (var hookSource in Sources.TestSessionHookSources) + { + result.AddRange(hookSource.CollectAfterTestSessionHooks(SessionId)); + } + return result; + } + + private protected override GetOnlyDictionary>> CollectAfterAssemblyHooks() + { + var dict = new GetOnlyDictionary>>(); + foreach (var hookSource in Sources.AssemblyHookSources) + { + foreach (var afterHook in hookSource.CollectAfterAssemblyHooks(SessionId)) { - var beforeList = BeforeClassHooks.GetOrAdd(beforeHook.ClassType, _ => []); - beforeList.Add(beforeHook); + var list = dict.GetOrAdd(afterHook.Assembly, _ => new List>()); + list.Add(afterHook); } + } + return dict; + } + private protected override GetOnlyDictionary>> CollectAfterClassHooks() + { + var dict = new GetOnlyDictionary>>(); + foreach (var hookSource in Sources.ClassHookSources) + { foreach (var afterHook in hookSource.CollectAfterClassHooks(SessionId)) { - var afterList = AfterClassHooks.GetOrAdd(afterHook.ClassType, _ => []); - afterList.Add(afterHook); - } - - foreach (var beforeHook in hookSource.CollectBeforeEveryClassHooks(SessionId)) - { - BeforeEveryClassHooks.Add(beforeHook); + var list = dict.GetOrAdd(afterHook.ClassType, _ => new List>()); + list.Add(afterHook); } + } + return dict; + } - foreach (var afterHook in hookSource.CollectAfterEveryClassHooks(SessionId)) + private protected override GetOnlyDictionary> CollectAfterTestHooks() + { + var dict = new GetOnlyDictionary>(); + foreach (var hookSource in Sources.TestHookSources) + { + foreach (var afterHook in hookSource.CollectAfterTestHooks(SessionId)) { - AfterEveryClassHooks.Add(afterHook); + var list = dict.GetOrAdd(afterHook.ClassType, _ => new List()); + list.Add(afterHook); } } + return dict; + } - while (Sources.AssemblyHookSources.TryDequeue(out var hookSource)) + private protected override List> CollectAfterEveryAssemblyHooks() + { + var result = new List>(); + foreach (var hookSource in Sources.AssemblyHookSources) { - foreach (var beforeHook in hookSource.CollectBeforeAssemblyHooks(SessionId)) - { - BeforeAssemblyHooks.GetOrAdd(beforeHook.Assembly, _ => []).Add(beforeHook); - } + result.AddRange(hookSource.CollectAfterEveryAssemblyHooks(SessionId)); + } + return result; + } - foreach (var afterHook in hookSource.CollectAfterAssemblyHooks(SessionId)) - { - AfterAssemblyHooks.GetOrAdd(afterHook.Assembly, _ => []).Add(afterHook); - } - - foreach (var beforeHook in hookSource.CollectBeforeEveryAssemblyHooks(SessionId)) - { - BeforeEveryAssemblyHooks.Add(beforeHook); - } + private protected override List> CollectAfterEveryClassHooks() + { + var result = new List>(); + foreach (var hookSource in Sources.ClassHookSources) + { + result.AddRange(hookSource.CollectAfterEveryClassHooks(SessionId)); + } + return result; + } - foreach (var afterHook in hookSource.CollectAfterEveryAssemblyHooks(SessionId)) - { - AfterEveryAssemblyHooks.Add(afterHook); - } + private protected override List> CollectAfterEveryTestHooks() + { + var result = new List>(); + foreach (var hookSource in Sources.TestHookSources) + { + result.AddRange(hookSource.CollectAfterEveryTestHooks(SessionId)); } + return result; } -} \ No newline at end of file +} + diff --git a/TUnit.Engine/Services/SourceGeneratedTestsConstructor.cs b/TUnit.Engine/Services/SourceGeneratedTestsConstructor.cs index 32493f38a1..673bc30c41 100644 --- a/TUnit.Engine/Services/SourceGeneratedTestsConstructor.cs +++ b/TUnit.Engine/Services/SourceGeneratedTestsConstructor.cs @@ -13,7 +13,8 @@ namespace TUnit.Engine.Services; internal class SourceGeneratedTestsConstructor(IExtension extension, TestsCollector testsCollector, DependencyCollector dependencyCollector, - IServiceProvider serviceProvider) : BaseTestsConstructor(extension, dependencyCollector, serviceProvider) + ContextManager contextManager, + IServiceProvider serviceProvider) : BaseTestsConstructor(extension, dependencyCollector, contextManager, serviceProvider) { protected override DiscoveredTest[] DiscoverTests() { diff --git a/TUnit.Engine/Services/TUnitTestDiscoverer.cs b/TUnit.Engine/Services/TUnitTestDiscoverer.cs index 2ed1c1a639..f048f89ff8 100644 --- a/TUnit.Engine/Services/TUnitTestDiscoverer.cs +++ b/TUnit.Engine/Services/TUnitTestDiscoverer.cs @@ -1,6 +1,4 @@ -using Microsoft.Testing.Platform.Extensions; -using Microsoft.Testing.Platform.Extensions.Messages; -using Microsoft.Testing.Platform.Extensions.TestFramework; +using Microsoft.Testing.Platform.Extensions.TestFramework; using Microsoft.Testing.Platform.Requests; using TUnit.Core; using TUnit.Core.Logging; @@ -30,7 +28,7 @@ public async Task FilterTests(ExecuteRequestContext context, Cance cancellationToken.ThrowIfCancellationRequested(); var allDiscoveredTests = GetTests(cancellationToken); - + var executionRequest = context.Request as TestExecutionRequest; var filteredTests = testFilterService.FilterTests(executionRequest, allDiscoveredTests); diff --git a/TUnit.Engine/Services/TestFilterService.cs b/TUnit.Engine/Services/TestFilterService.cs index 9a76691286..e029897ba9 100644 --- a/TUnit.Engine/Services/TestFilterService.cs +++ b/TUnit.Engine/Services/TestFilterService.cs @@ -58,6 +58,11 @@ public bool MatchesTest(ITestExecutionFilter? testExecutionFilter, DiscoveredTes _ => UnhandledFilter(testExecutionFilter) }; + if (!shouldRunTest) + { + discoveredTest.TestContext.ClassContext.RemoveTest(discoveredTest.TestContext); + } + return shouldRunTest; #pragma warning restore TPEXP } diff --git a/TUnit.Engine/Services/TestInvoker.cs b/TUnit.Engine/Services/TestInvoker.cs index f88a9ecacd..efa5b4a3f7 100644 --- a/TUnit.Engine/Services/TestInvoker.cs +++ b/TUnit.Engine/Services/TestInvoker.cs @@ -1,8 +1,6 @@ using TUnit.Core; using TUnit.Core.Extensions; using TUnit.Core.Helpers; -using TUnit.Core.Interfaces; -using TUnit.Core.Logging; using TUnit.Engine.Exceptions; using TUnit.Engine.Extensions; using TUnit.Engine.Helpers; @@ -23,7 +21,9 @@ public async Task Invoke(DiscoveredTest discoveredTest, CancellationToken cancel await onInitializeObject.InitializeAsync(); } - ExecutionContextHelper.RestoreContext(await testHookOrchestrator.ExecuteBeforeHooks(discoveredTest, cancellationToken)); + await testHookOrchestrator.ExecuteBeforeHooks(discoveredTest, cancellationToken); + + discoveredTest.TestContext.RestoreExecutionContext(); foreach (var testStartEventsObject in discoveredTest.TestContext.GetTestStartEventObjects()) { diff --git a/TUnit.Engine/Services/TestsExecutor.cs b/TUnit.Engine/Services/TestsExecutor.cs index a62bd67067..d1682f83e7 100644 --- a/TUnit.Engine/Services/TestsExecutor.cs +++ b/TUnit.Engine/Services/TestsExecutor.cs @@ -8,7 +8,6 @@ using TUnit.Core; using TUnit.Core.Helpers; using TUnit.Engine.CommandLineProviders; -using TUnit.Engine.Helpers; using TUnit.Engine.Hooks; using TUnit.Engine.Logging; using TUnit.Engine.Models; @@ -112,9 +111,13 @@ await Task.Run(async delegate { if (test.TestContext.SkipReason == null) { - ExecutionContextHelper.RestoreContext(await _assemblyHookOrchestrator.ExecuteBeforeAssemblyHooks(test.TestContext)); + await _assemblyHookOrchestrator.ExecuteBeforeAssemblyHooks(test.TestContext); + + test.TestContext.AssemblyContext.RestoreExecutionContext(); - ExecutionContextHelper.RestoreContext(await _classHookOrchestrator.ExecuteBeforeClassHooks(test.TestContext)); + await _classHookOrchestrator.ExecuteBeforeClassHooks(test.TestContext); + + test.TestContext.ClassContext.RestoreExecutionContext(); } await ProcessTest(test, filter, cancellationToken); @@ -142,9 +145,13 @@ private async Task ProcessCollection(IEnumerable queue, { if (test.TestContext.SkipReason == null) { - ExecutionContextHelper.RestoreContext(await _assemblyHookOrchestrator.ExecuteBeforeAssemblyHooks(test.TestContext)); + await _assemblyHookOrchestrator.ExecuteBeforeAssemblyHooks(test.TestContext); - ExecutionContextHelper.RestoreContext(await _classHookOrchestrator.ExecuteBeforeClassHooks(test.TestContext)); + test.TestContext.AssemblyContext.RestoreExecutionContext(); + + await _classHookOrchestrator.ExecuteBeforeClassHooks(test.TestContext); + + test.TestContext.ClassContext.RestoreExecutionContext(); } await ProcessTest(test, filter, token); @@ -155,9 +162,13 @@ await queue { if (test.TestContext.SkipReason != null) { - ExecutionContextHelper.RestoreContext(await _assemblyHookOrchestrator.ExecuteBeforeAssemblyHooks(test.TestContext)); + await _assemblyHookOrchestrator.ExecuteBeforeAssemblyHooks(test.TestContext); - ExecutionContextHelper.RestoreContext(await _classHookOrchestrator.ExecuteBeforeClassHooks(test.TestContext)); + test.TestContext.AssemblyContext.RestoreExecutionContext(); + + await _classHookOrchestrator.ExecuteBeforeClassHooks(test.TestContext); + + test.TestContext.ClassContext.RestoreExecutionContext(); } await ProcessTest(test, filter, cancellationToken); diff --git a/TUnit.Engine/TestRegistrar.cs b/TUnit.Engine/TestRegistrar.cs index 7c808406b0..3dc4e94164 100644 --- a/TUnit.Engine/TestRegistrar.cs +++ b/TUnit.Engine/TestRegistrar.cs @@ -1,11 +1,9 @@ -using System.Reflection; -using TUnit.Core; +using TUnit.Core; using TUnit.Core.Extensions; -using TUnit.Engine.Hooks; namespace TUnit.Engine; -internal class TestRegistrar(InstanceTracker instanceTracker, AssemblyHookOrchestrator assemblyHookOrchestrator, ClassHookOrchestrator classHookOrchestrator) +internal class TestRegistrar(InstanceTracker instanceTracker) { internal async ValueTask RegisterInstance(DiscoveredTest discoveredTest, Func onFailureToInitialize) { @@ -19,7 +17,7 @@ internal async ValueTask RegisterInstance(DiscoveredTest discoveredTest, Func Microsoft.Playwright.Assertions.SetDefaultExpectTimeout(timeout); diff --git a/TUnit.PublicAPI/Tests.Core_Library_Has_No_API_Changes.DotNet2_0.verified.txt b/TUnit.PublicAPI/Tests.Core_Library_Has_No_API_Changes.DotNet2_0.verified.txt index 1bf6a9b9c0..ce8339012b 100644 --- a/TUnit.PublicAPI/Tests.Core_Library_Has_No_API_Changes.DotNet2_0.verified.txt +++ b/TUnit.PublicAPI/Tests.Core_Library_Has_No_API_Changes.DotNet2_0.verified.txt @@ -57,11 +57,13 @@ namespace TUnit.Core } public class AssemblyHookContext : TUnit.Core.Context { - public System.Collections.Generic.IEnumerable AllTests { get; } + public System.Collections.Generic.IReadOnlyList AllTests { get; } public required System.Reflection.Assembly Assembly { get; init; } - public System.Collections.Generic.HashSet TestClasses { get; init; } + public System.Collections.Generic.IReadOnlyList TestClasses { get; } public int TestCount { get; } + public TUnit.Core.TestSessionContext TestSessionContext { get; } public new static TUnit.Core.AssemblyHookContext? Current { get; } + public void AddClass(TUnit.Core.ClassHookContext classHookContext) { } } public static class AsyncConvert { @@ -69,6 +71,7 @@ namespace TUnit.Core public static System.Threading.Tasks.ValueTask Convert(System.Func action) { } public static System.Threading.Tasks.ValueTask Convert(System.Func action) { } public static System.Threading.Tasks.ValueTask ConvertObject(object? invoke) { } + public static bool TryGetAwaitableTask(object awaitable, [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] out System.Threading.Tasks.Task? task) { } } public class AsyncEvent { @@ -109,6 +112,7 @@ namespace TUnit.Core } public class BeforeTestDiscoveryContext : TUnit.Core.Context { + public TUnit.Core.GlobalContext GlobalContext { get; } public required string? TestFilter { get; init; } public new static TUnit.Core.BeforeTestDiscoveryContext? Current { get; } } @@ -148,17 +152,22 @@ namespace TUnit.Core public ClassDataSourceAttribute(System.Type type, System.Type type2, System.Type type3) { } public ClassDataSourceAttribute(System.Type type, System.Type type2, System.Type type3, System.Type type4) { } public ClassDataSourceAttribute(System.Type type, System.Type type2, System.Type type3, System.Type type4, System.Type type5) { } - public string Key { get; set; } - public TUnit.Core.SharedType Shared { get; set; } + public string[] Keys { get; set; } + public TUnit.Core.SharedType[] Shared { get; set; } public override System.Collections.Generic.IEnumerable> GenerateDataSources(TUnit.Core.DataGeneratorMetadata dataGeneratorMetadata) { } + public System.Collections.Generic.IEnumerable GetKeys() { } + public System.Collections.Generic.IEnumerable GetSharedTypes() { } } [System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Method | System.AttributeTargets.Property, AllowMultiple=true)] public sealed class ClassDataSourceAttribute : TUnit.Core.DataSourceGeneratorAttribute { public ClassDataSourceAttribute() { } + public System.Type ClassType { get; } public string Key { get; set; } public TUnit.Core.SharedType Shared { get; set; } public override System.Collections.Generic.IEnumerable> GenerateDataSources(TUnit.Core.DataGeneratorMetadata dataGeneratorMetadata) { } + public System.Collections.Generic.IEnumerable GetKeys() { } + public System.Collections.Generic.IEnumerable GetSharedTypes() { } } [System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Method, AllowMultiple=true)] public sealed class ClassDataSourceAttribute : TUnit.Core.DataSourceGeneratorAttribute @@ -169,6 +178,8 @@ namespace TUnit.Core public string[] Keys { get; set; } public TUnit.Core.SharedType[] Shared { get; set; } public override System.Collections.Generic.IEnumerable>> GenerateDataSources(TUnit.Core.DataGeneratorMetadata dataGeneratorMetadata) { } + public System.Collections.Generic.IEnumerable GetKeys() { } + public System.Collections.Generic.IEnumerable GetSharedTypes() { } } [System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Method, AllowMultiple=true)] public sealed class ClassDataSourceAttribute : TUnit.Core.DataSourceGeneratorAttribute @@ -180,6 +191,8 @@ namespace TUnit.Core public string[] Keys { get; set; } public TUnit.Core.SharedType[] Shared { get; set; } public override System.Collections.Generic.IEnumerable>> GenerateDataSources(TUnit.Core.DataGeneratorMetadata dataGeneratorMetadata) { } + public System.Collections.Generic.IEnumerable GetKeys() { } + public System.Collections.Generic.IEnumerable GetSharedTypes() { } } [System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Method, AllowMultiple=true)] public sealed class ClassDataSourceAttribute : TUnit.Core.DataSourceGeneratorAttribute @@ -192,6 +205,8 @@ namespace TUnit.Core public string[] Keys { get; set; } public TUnit.Core.SharedType[] Shared { get; set; } public override System.Collections.Generic.IEnumerable>> GenerateDataSources(TUnit.Core.DataGeneratorMetadata dataGeneratorMetadata) { } + public System.Collections.Generic.IEnumerable GetKeys() { } + public System.Collections.Generic.IEnumerable GetSharedTypes() { } } [System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Method, AllowMultiple=true)] public sealed class ClassDataSourceAttribute : TUnit.Core.DataSourceGeneratorAttribute @@ -205,13 +220,17 @@ namespace TUnit.Core public string[] Keys { get; set; } public TUnit.Core.SharedType[] Shared { get; set; } public override System.Collections.Generic.IEnumerable>> GenerateDataSources(TUnit.Core.DataGeneratorMetadata dataGeneratorMetadata) { } + public System.Collections.Generic.IEnumerable GetKeys() { } + public System.Collections.Generic.IEnumerable GetSharedTypes() { } } public class ClassHookContext : TUnit.Core.Context { + public TUnit.Core.AssemblyHookContext AssemblyContext { get; } public required System.Type ClassType { get; init; } public int TestCount { get; } - public System.Collections.Generic.List Tests { get; init; } + public System.Collections.Generic.IReadOnlyList Tests { get; } public new static TUnit.Core.ClassHookContext? Current { get; } + public void AddTest(TUnit.Core.TestContext testContext) { } public override bool Equals(object? obj) { } public override int GetHashCode() { } } @@ -219,12 +238,14 @@ namespace TUnit.Core { public System.IO.TextWriter ErrorOutputWriter { get; } public System.IO.TextWriter OutputWriter { get; } + protected TUnit.Core.Context? Parent { get; } public static TUnit.Core.Context Current { get; } public void AddAsyncLocalValues() { } public void Dispose() { } public TUnit.Core.Logging.DefaultLogger GetDefaultLogger() { } public string GetErrorOutput() { } public string GetStandardOutput() { } + public void RestoreExecutionContext() { } } public class CultureExecutor : TUnit.Core.DedicatedThreadExecutor { @@ -746,6 +767,10 @@ namespace TUnit.Core public class SourceGeneratedParameterInformation : TUnit.Core.SourceGeneratedMemberInformation, System.IEquatable { public SourceGeneratedParameterInformation(System.Type Type) { } + public object? DefaultValue { get; } + public bool IsOptional { get; } + public bool IsParams { get; } + public required System.Reflection.ParameterInfo ReflectionInfo { get; set; } public override System.Type Type { get; init; } } [System.Diagnostics.DebuggerDisplay("{Type} {Name})")] @@ -758,6 +783,8 @@ namespace TUnit.Core { public SourceGeneratedPropertyInformation() { } public required bool IsStatic { get; init; } + public string? Key { get; init; } + public TUnit.Core.SharedType Shared { get; init; } public override required System.Type Type { get; init; } } public class SourceRegistrar @@ -769,6 +796,7 @@ namespace TUnit.Core public static void RegisterAssemblyHookSource(TUnit.Core.Interfaces.SourceGenerator.IAssemblyHookSource testSource) { } public static void RegisterClassHookSource(TUnit.Core.Interfaces.SourceGenerator.IClassHookSource testSource) { } public static void RegisterDynamic(TUnit.Core.Interfaces.SourceGenerator.IDynamicTestSource testSource) { } + public static void RegisterProperty() { } public static void RegisterTestDiscoveryHookSource(TUnit.Core.Interfaces.SourceGenerator.ITestDiscoveryHookSource testSource) { } public static void RegisterTestHookSource(TUnit.Core.Interfaces.SourceGenerator.ITestHookSource testSource) { } public static void RegisterTestSessionHookSource(TUnit.Core.Interfaces.SourceGenerator.ITestSessionHookSource testSource) { } @@ -797,7 +825,9 @@ namespace TUnit.Core { public readonly object Lock; public System.Collections.Generic.List ArgumentDisplayFormatters { get; } + public TUnit.Core.AssemblyHookContext AssemblyContext { get; } public System.Threading.CancellationToken CancellationToken { get; } + public TUnit.Core.ClassHookContext ClassContext { get; } public int CurrentRetryAttempt { get; } public TUnit.Core.TestContext[] Dependencies { get; } public TUnit.Core.TestContextEvents Events { get; } @@ -887,11 +917,13 @@ namespace TUnit.Core } public class TestDiscoveryContext : TUnit.Core.Context { - public System.Collections.Generic.IEnumerable AllTests { get; } + public System.Collections.Generic.IReadOnlyList AllTests { get; } public System.Collections.Generic.IEnumerable Assemblies { get; } + public TUnit.Core.BeforeTestDiscoveryContext BeforeTestDiscoveryContext { get; } public System.Collections.Generic.IEnumerable TestClasses { get; } public required string? TestFilter { get; init; } public new static TUnit.Core.TestDiscoveryContext? Current { get; } + public void AddTests(System.Collections.Generic.IEnumerable tests) { } } public abstract class TestMetadata : System.IEquatable { @@ -942,13 +974,15 @@ namespace TUnit.Core } public class TestSessionContext : TUnit.Core.Context { - public System.Collections.Generic.IEnumerable AllTests { get; } - public System.Collections.Generic.IEnumerable Assemblies { get; } + public System.Collections.Generic.IReadOnlyList AllTests { get; } + public System.Collections.Generic.IReadOnlyList Assemblies { get; } public required string Id { get; init; } - public System.Collections.Generic.IEnumerable TestClasses { get; } + public System.Collections.Generic.IReadOnlyList TestClasses { get; } + public TUnit.Core.BeforeTestDiscoveryContext TestDiscoveryContext { get; } public required string? TestFilter { get; init; } public new static TUnit.Core.TestSessionContext? Current { get; } public void AddArtifact(TUnit.Core.Artifact artifact) { } + public void AddAssembly(TUnit.Core.AssemblyHookContext assemblyHookContext) { } } [System.AttributeUsage(System.AttributeTargets.Assembly | System.AttributeTargets.Class | System.AttributeTargets.Method)] public class TimeoutAttribute : TUnit.Core.TUnitAttribute, TUnit.Core.Interfaces.IEventReceiver, TUnit.Core.Interfaces.ITestDiscoveryEventReceiver @@ -1194,6 +1228,7 @@ namespace TUnit.Core.Helpers { public static object? Cast(System.Type type, object? value) { } public static T? Cast(object? value) { } + public static System.Reflection.MethodInfo? GetConversionMethod(System.Type baseType, System.Type targetType) { } } [System.Diagnostics.DebuggerDisplay("Count = {CurrentCount}")] public class Counter @@ -1214,6 +1249,11 @@ namespace TUnit.Core.Helpers public MethodInfoRetriever() { } public static System.Reflection.MethodInfo GetMethodInfo(System.Type type, string methodName, int genericParameterCount, System.Type[] parameterTypes) { } } + public static class RobustParameterInfoRetriever + { + public static System.Reflection.ParameterInfo GetConstructorParameterInfo(System.Type type, System.Type[] parameterTypes, int parameterIndex, System.Type expectedType, string parameterName) { } + public static System.Reflection.ParameterInfo GetMethodParameterInfo(System.Type type, string methodName, int parameterIndex, System.Type[] parameterTypes, bool isStatic, int genericParameterCount) { } + } } namespace TUnit.Core.Hooks { diff --git a/TUnit.PublicAPI/Tests.Core_Library_Has_No_API_Changes.DotNet8_0.verified.txt b/TUnit.PublicAPI/Tests.Core_Library_Has_No_API_Changes.DotNet8_0.verified.txt index 7dbcff7b1e..0cd1e2d7da 100644 --- a/TUnit.PublicAPI/Tests.Core_Library_Has_No_API_Changes.DotNet8_0.verified.txt +++ b/TUnit.PublicAPI/Tests.Core_Library_Has_No_API_Changes.DotNet8_0.verified.txt @@ -57,11 +57,13 @@ namespace TUnit.Core } public class AssemblyHookContext : TUnit.Core.Context { - public System.Collections.Generic.IEnumerable AllTests { get; } + public System.Collections.Generic.IReadOnlyList AllTests { get; } public required System.Reflection.Assembly Assembly { get; init; } - public System.Collections.Generic.HashSet TestClasses { get; init; } + public System.Collections.Generic.IReadOnlyList TestClasses { get; } public int TestCount { get; } + public TUnit.Core.TestSessionContext TestSessionContext { get; } public new static TUnit.Core.AssemblyHookContext? Current { get; } + public void AddClass(TUnit.Core.ClassHookContext classHookContext) { } } public static class AsyncConvert { @@ -69,6 +71,10 @@ namespace TUnit.Core public static System.Threading.Tasks.ValueTask Convert(System.Func action) { } public static System.Threading.Tasks.ValueTask Convert(System.Func action) { } public static System.Threading.Tasks.ValueTask ConvertObject(object? invoke) { } + [System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2075:\'this\' argument does not satisfy \'DynamicallyAccessedMembersAttribute\' in " + + "call to target method. The return value of the source method does not have match" + + "ing annotations.")] + public static bool TryGetAwaitableTask(object awaitable, [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] out System.Threading.Tasks.Task? task) { } } public class AsyncEvent { @@ -109,6 +115,7 @@ namespace TUnit.Core } public class BeforeTestDiscoveryContext : TUnit.Core.Context { + public TUnit.Core.GlobalContext GlobalContext { get; } public required string? TestFilter { get; init; } public new static TUnit.Core.BeforeTestDiscoveryContext? Current { get; } } @@ -170,19 +177,24 @@ namespace TUnit.Core [System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2026:Members annotated with \'RequiresUnreferencedCodeAttribute\' require dynamic" + " access otherwise can break functionality when trimming application code", Justification="")] public ClassDataSourceAttribute([System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.None | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicConstructors | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties)] System.Type type, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.None | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicConstructors | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties)] System.Type type2, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.None | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicConstructors | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties)] System.Type type3, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.None | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicConstructors | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties)] System.Type type4, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.None | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicConstructors | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties)] System.Type type5) { } - public string Key { get; set; } - public TUnit.Core.SharedType Shared { get; set; } + public string[] Keys { get; set; } + public TUnit.Core.SharedType[] Shared { get; set; } [System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2062:The parameter of method has a DynamicallyAccessedMembersAttribute, but the" + " value passed to it can not be statically analyzed.")] public override System.Collections.Generic.IEnumerable> GenerateDataSources(TUnit.Core.DataGeneratorMetadata dataGeneratorMetadata) { } + public System.Collections.Generic.IEnumerable GetKeys() { } + public System.Collections.Generic.IEnumerable GetSharedTypes() { } } [System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Method | System.AttributeTargets.Property, AllowMultiple=true)] public sealed class ClassDataSourceAttribute<[System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.None | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicConstructors | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties)] T> : TUnit.Core.DataSourceGeneratorAttribute { public ClassDataSourceAttribute() { } + public System.Type ClassType { get; } public string Key { get; set; } public TUnit.Core.SharedType Shared { get; set; } public override System.Collections.Generic.IEnumerable> GenerateDataSources(TUnit.Core.DataGeneratorMetadata dataGeneratorMetadata) { } + public System.Collections.Generic.IEnumerable GetKeys() { } + public System.Collections.Generic.IEnumerable GetSharedTypes() { } } [System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Method, AllowMultiple=true)] public sealed class ClassDataSourceAttribute<[System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.None | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicConstructors | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties)] T1, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.None | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicConstructors | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties)] T2> : TUnit.Core.DataSourceGeneratorAttribute @@ -193,6 +205,8 @@ namespace TUnit.Core public string[] Keys { get; set; } public TUnit.Core.SharedType[] Shared { get; set; } public override System.Collections.Generic.IEnumerable>> GenerateDataSources(TUnit.Core.DataGeneratorMetadata dataGeneratorMetadata) { } + public System.Collections.Generic.IEnumerable GetKeys() { } + public System.Collections.Generic.IEnumerable GetSharedTypes() { } } [System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Method, AllowMultiple=true)] public sealed class ClassDataSourceAttribute<[System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.None | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicConstructors | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties)] T1, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.None | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicConstructors | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties)] T2, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.None | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicConstructors | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties)] T3> : TUnit.Core.DataSourceGeneratorAttribute @@ -204,6 +218,8 @@ namespace TUnit.Core public string[] Keys { get; set; } public TUnit.Core.SharedType[] Shared { get; set; } public override System.Collections.Generic.IEnumerable>> GenerateDataSources(TUnit.Core.DataGeneratorMetadata dataGeneratorMetadata) { } + public System.Collections.Generic.IEnumerable GetKeys() { } + public System.Collections.Generic.IEnumerable GetSharedTypes() { } } [System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Method, AllowMultiple=true)] public sealed class ClassDataSourceAttribute<[System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.None | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicConstructors | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties)] T1, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.None | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicConstructors | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties)] T2, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.None | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicConstructors | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties)] T3, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.None | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicConstructors | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties)] T4> : TUnit.Core.DataSourceGeneratorAttribute @@ -216,6 +232,8 @@ namespace TUnit.Core public string[] Keys { get; set; } public TUnit.Core.SharedType[] Shared { get; set; } public override System.Collections.Generic.IEnumerable>> GenerateDataSources(TUnit.Core.DataGeneratorMetadata dataGeneratorMetadata) { } + public System.Collections.Generic.IEnumerable GetKeys() { } + public System.Collections.Generic.IEnumerable GetSharedTypes() { } } [System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Method, AllowMultiple=true)] public sealed class ClassDataSourceAttribute<[System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.None | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicConstructors | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties)] T1, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.None | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicConstructors | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties)] T2, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.None | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicConstructors | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties)] T3, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.None | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicConstructors | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties)] T4, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.None | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicConstructors | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties)] T5> : TUnit.Core.DataSourceGeneratorAttribute @@ -229,13 +247,17 @@ namespace TUnit.Core public string[] Keys { get; set; } public TUnit.Core.SharedType[] Shared { get; set; } public override System.Collections.Generic.IEnumerable>> GenerateDataSources(TUnit.Core.DataGeneratorMetadata dataGeneratorMetadata) { } + public System.Collections.Generic.IEnumerable GetKeys() { } + public System.Collections.Generic.IEnumerable GetSharedTypes() { } } public class ClassHookContext : TUnit.Core.Context { + public TUnit.Core.AssemblyHookContext AssemblyContext { get; } public required System.Type ClassType { get; init; } public int TestCount { get; } - public System.Collections.Generic.List Tests { get; init; } + public System.Collections.Generic.IReadOnlyList Tests { get; } public new static TUnit.Core.ClassHookContext? Current { get; } + public void AddTest(TUnit.Core.TestContext testContext) { } public override bool Equals(object? obj) { } public override int GetHashCode() { } } @@ -243,12 +265,14 @@ namespace TUnit.Core { public System.IO.TextWriter ErrorOutputWriter { get; } public System.IO.TextWriter OutputWriter { get; } + protected TUnit.Core.Context? Parent { get; } public static TUnit.Core.Context Current { get; } public void AddAsyncLocalValues() { } public void Dispose() { } public TUnit.Core.Logging.DefaultLogger GetDefaultLogger() { } public string GetErrorOutput() { } public string GetStandardOutput() { } + public void RestoreExecutionContext() { } } public class CultureExecutor : TUnit.Core.DedicatedThreadExecutor { @@ -790,6 +814,10 @@ namespace TUnit.Core public class SourceGeneratedParameterInformation : TUnit.Core.SourceGeneratedMemberInformation, System.IEquatable { public SourceGeneratedParameterInformation([System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.None | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicConstructors | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicMethods | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.NonPublicMethods)] System.Type Type) { } + public object? DefaultValue { get; } + public bool IsOptional { get; } + public bool IsParams { get; } + public required System.Reflection.ParameterInfo ReflectionInfo { get; set; } public override System.Type Type { get; init; } } [System.Diagnostics.DebuggerDisplay("{Type} {Name})")] @@ -802,6 +830,8 @@ namespace TUnit.Core { public SourceGeneratedPropertyInformation() { } public required bool IsStatic { get; init; } + public string? Key { get; init; } + public TUnit.Core.SharedType Shared { get; init; } [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.None | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicConstructors | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicMethods | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.NonPublicMethods)] public override required System.Type Type { get; init; } } @@ -815,6 +845,7 @@ namespace TUnit.Core public static void RegisterAssemblyHookSource(TUnit.Core.Interfaces.SourceGenerator.IAssemblyHookSource testSource) { } public static void RegisterClassHookSource(TUnit.Core.Interfaces.SourceGenerator.IClassHookSource testSource) { } public static void RegisterDynamic(TUnit.Core.Interfaces.SourceGenerator.IDynamicTestSource testSource) { } + public static void RegisterProperty<[System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.None | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicConstructors | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties)] T>() { } public static void RegisterTestDiscoveryHookSource(TUnit.Core.Interfaces.SourceGenerator.ITestDiscoveryHookSource testSource) { } public static void RegisterTestHookSource(TUnit.Core.Interfaces.SourceGenerator.ITestHookSource testSource) { } public static void RegisterTestSessionHookSource(TUnit.Core.Interfaces.SourceGenerator.ITestSessionHookSource testSource) { } @@ -843,7 +874,9 @@ namespace TUnit.Core { public readonly object Lock; public System.Collections.Generic.List ArgumentDisplayFormatters { get; } + public TUnit.Core.AssemblyHookContext AssemblyContext { get; } public System.Threading.CancellationToken CancellationToken { get; } + public TUnit.Core.ClassHookContext ClassContext { get; } public int CurrentRetryAttempt { get; } public TUnit.Core.TestContext[] Dependencies { get; } public TUnit.Core.TestContextEvents Events { get; } @@ -934,11 +967,13 @@ namespace TUnit.Core } public class TestDiscoveryContext : TUnit.Core.Context { - public System.Collections.Generic.IEnumerable AllTests { get; } + public System.Collections.Generic.IReadOnlyList AllTests { get; } public System.Collections.Generic.IEnumerable Assemblies { get; } + public TUnit.Core.BeforeTestDiscoveryContext BeforeTestDiscoveryContext { get; } public System.Collections.Generic.IEnumerable TestClasses { get; } public required string? TestFilter { get; init; } public new static TUnit.Core.TestDiscoveryContext? Current { get; } + public void AddTests(System.Collections.Generic.IEnumerable tests) { } } public abstract class TestMetadata : System.IEquatable { @@ -991,13 +1026,15 @@ namespace TUnit.Core } public class TestSessionContext : TUnit.Core.Context { - public System.Collections.Generic.IEnumerable AllTests { get; } - public System.Collections.Generic.IEnumerable Assemblies { get; } + public System.Collections.Generic.IReadOnlyList AllTests { get; } + public System.Collections.Generic.IReadOnlyList Assemblies { get; } public required string Id { get; init; } - public System.Collections.Generic.IEnumerable TestClasses { get; } + public System.Collections.Generic.IReadOnlyList TestClasses { get; } + public TUnit.Core.BeforeTestDiscoveryContext TestDiscoveryContext { get; } public required string? TestFilter { get; init; } public new static TUnit.Core.TestSessionContext? Current { get; } public void AddArtifact(TUnit.Core.Artifact artifact) { } + public void AddAssembly(TUnit.Core.AssemblyHookContext assemblyHookContext) { } } [System.AttributeUsage(System.AttributeTargets.Assembly | System.AttributeTargets.Class | System.AttributeTargets.Method)] public class TimeoutAttribute : TUnit.Core.TUnitAttribute, TUnit.Core.Interfaces.IEventReceiver, TUnit.Core.Interfaces.ITestDiscoveryEventReceiver @@ -1256,6 +1293,7 @@ namespace TUnit.Core.Helpers public static object? Cast([System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicMethods)] System.Type type, object? value) { } [System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("", "IL2072")] public static T? Cast<[System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicMethods)] T>(object? value) { } + public static System.Reflection.MethodInfo? GetConversionMethod([System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicMethods)] System.Type baseType, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicMethods)] System.Type targetType) { } } [System.Diagnostics.DebuggerDisplay("Count = {CurrentCount}")] public class Counter @@ -1276,6 +1314,13 @@ namespace TUnit.Core.Helpers public MethodInfoRetriever() { } public static System.Reflection.MethodInfo GetMethodInfo([System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.None | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicMethods | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.NonPublicMethods)] System.Type type, string methodName, int genericParameterCount, System.Type[] parameterTypes) { } } + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Uses reflection to retrieve parameter information")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Uses reflection to retrieve parameter information")] + public static class RobustParameterInfoRetriever + { + public static System.Reflection.ParameterInfo GetConstructorParameterInfo([System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.None | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicConstructors | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.NonPublicConstructors)] System.Type type, System.Type[] parameterTypes, int parameterIndex, System.Type expectedType, string parameterName) { } + public static System.Reflection.ParameterInfo GetMethodParameterInfo([System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.None | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicMethods | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.NonPublicMethods)] System.Type type, string methodName, int parameterIndex, System.Type[] parameterTypes, bool isStatic, int genericParameterCount) { } + } } namespace TUnit.Core.Hooks { diff --git a/TUnit.PublicAPI/Tests.Core_Library_Has_No_API_Changes.DotNet9_0.verified.txt b/TUnit.PublicAPI/Tests.Core_Library_Has_No_API_Changes.DotNet9_0.verified.txt index 294afdf934..fdf14c404f 100644 --- a/TUnit.PublicAPI/Tests.Core_Library_Has_No_API_Changes.DotNet9_0.verified.txt +++ b/TUnit.PublicAPI/Tests.Core_Library_Has_No_API_Changes.DotNet9_0.verified.txt @@ -57,11 +57,13 @@ namespace TUnit.Core } public class AssemblyHookContext : TUnit.Core.Context { - public System.Collections.Generic.IEnumerable AllTests { get; } + public System.Collections.Generic.IReadOnlyList AllTests { get; } public required System.Reflection.Assembly Assembly { get; init; } - public System.Collections.Generic.HashSet TestClasses { get; init; } + public System.Collections.Generic.IReadOnlyList TestClasses { get; } public int TestCount { get; } + public TUnit.Core.TestSessionContext TestSessionContext { get; } public new static TUnit.Core.AssemblyHookContext? Current { get; } + public void AddClass(TUnit.Core.ClassHookContext classHookContext) { } } public static class AsyncConvert { @@ -69,6 +71,10 @@ namespace TUnit.Core public static System.Threading.Tasks.ValueTask Convert(System.Func action) { } public static System.Threading.Tasks.ValueTask Convert(System.Func action) { } public static System.Threading.Tasks.ValueTask ConvertObject(object? invoke) { } + [System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2075:\'this\' argument does not satisfy \'DynamicallyAccessedMembersAttribute\' in " + + "call to target method. The return value of the source method does not have match" + + "ing annotations.")] + public static bool TryGetAwaitableTask(object awaitable, [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] out System.Threading.Tasks.Task? task) { } } public class AsyncEvent { @@ -109,6 +115,7 @@ namespace TUnit.Core } public class BeforeTestDiscoveryContext : TUnit.Core.Context { + public TUnit.Core.GlobalContext GlobalContext { get; } public required string? TestFilter { get; init; } public new static TUnit.Core.BeforeTestDiscoveryContext? Current { get; } } @@ -170,19 +177,24 @@ namespace TUnit.Core [System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2026:Members annotated with \'RequiresUnreferencedCodeAttribute\' require dynamic" + " access otherwise can break functionality when trimming application code", Justification="")] public ClassDataSourceAttribute([System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.None | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicConstructors | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties)] System.Type type, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.None | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicConstructors | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties)] System.Type type2, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.None | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicConstructors | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties)] System.Type type3, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.None | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicConstructors | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties)] System.Type type4, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.None | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicConstructors | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties)] System.Type type5) { } - public string Key { get; set; } - public TUnit.Core.SharedType Shared { get; set; } + public string[] Keys { get; set; } + public TUnit.Core.SharedType[] Shared { get; set; } [System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2062:The parameter of method has a DynamicallyAccessedMembersAttribute, but the" + " value passed to it can not be statically analyzed.")] public override System.Collections.Generic.IEnumerable> GenerateDataSources(TUnit.Core.DataGeneratorMetadata dataGeneratorMetadata) { } + public System.Collections.Generic.IEnumerable GetKeys() { } + public System.Collections.Generic.IEnumerable GetSharedTypes() { } } [System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Method | System.AttributeTargets.Property, AllowMultiple=true)] public sealed class ClassDataSourceAttribute<[System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.None | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicConstructors | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties)] T> : TUnit.Core.DataSourceGeneratorAttribute { public ClassDataSourceAttribute() { } + public System.Type ClassType { get; } public string Key { get; set; } public TUnit.Core.SharedType Shared { get; set; } public override System.Collections.Generic.IEnumerable> GenerateDataSources(TUnit.Core.DataGeneratorMetadata dataGeneratorMetadata) { } + public System.Collections.Generic.IEnumerable GetKeys() { } + public System.Collections.Generic.IEnumerable GetSharedTypes() { } } [System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Method, AllowMultiple=true)] public sealed class ClassDataSourceAttribute<[System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.None | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicConstructors | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties)] T1, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.None | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicConstructors | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties)] T2> : TUnit.Core.DataSourceGeneratorAttribute @@ -193,6 +205,8 @@ namespace TUnit.Core public string[] Keys { get; set; } public TUnit.Core.SharedType[] Shared { get; set; } public override System.Collections.Generic.IEnumerable>> GenerateDataSources(TUnit.Core.DataGeneratorMetadata dataGeneratorMetadata) { } + public System.Collections.Generic.IEnumerable GetKeys() { } + public System.Collections.Generic.IEnumerable GetSharedTypes() { } } [System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Method, AllowMultiple=true)] public sealed class ClassDataSourceAttribute<[System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.None | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicConstructors | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties)] T1, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.None | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicConstructors | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties)] T2, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.None | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicConstructors | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties)] T3> : TUnit.Core.DataSourceGeneratorAttribute @@ -204,6 +218,8 @@ namespace TUnit.Core public string[] Keys { get; set; } public TUnit.Core.SharedType[] Shared { get; set; } public override System.Collections.Generic.IEnumerable>> GenerateDataSources(TUnit.Core.DataGeneratorMetadata dataGeneratorMetadata) { } + public System.Collections.Generic.IEnumerable GetKeys() { } + public System.Collections.Generic.IEnumerable GetSharedTypes() { } } [System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Method, AllowMultiple=true)] public sealed class ClassDataSourceAttribute<[System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.None | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicConstructors | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties)] T1, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.None | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicConstructors | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties)] T2, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.None | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicConstructors | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties)] T3, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.None | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicConstructors | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties)] T4> : TUnit.Core.DataSourceGeneratorAttribute @@ -216,6 +232,8 @@ namespace TUnit.Core public string[] Keys { get; set; } public TUnit.Core.SharedType[] Shared { get; set; } public override System.Collections.Generic.IEnumerable>> GenerateDataSources(TUnit.Core.DataGeneratorMetadata dataGeneratorMetadata) { } + public System.Collections.Generic.IEnumerable GetKeys() { } + public System.Collections.Generic.IEnumerable GetSharedTypes() { } } [System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Method, AllowMultiple=true)] public sealed class ClassDataSourceAttribute<[System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.None | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicConstructors | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties)] T1, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.None | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicConstructors | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties)] T2, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.None | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicConstructors | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties)] T3, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.None | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicConstructors | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties)] T4, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.None | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicConstructors | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties)] T5> : TUnit.Core.DataSourceGeneratorAttribute @@ -229,13 +247,17 @@ namespace TUnit.Core public string[] Keys { get; set; } public TUnit.Core.SharedType[] Shared { get; set; } public override System.Collections.Generic.IEnumerable>> GenerateDataSources(TUnit.Core.DataGeneratorMetadata dataGeneratorMetadata) { } + public System.Collections.Generic.IEnumerable GetKeys() { } + public System.Collections.Generic.IEnumerable GetSharedTypes() { } } public class ClassHookContext : TUnit.Core.Context { + public TUnit.Core.AssemblyHookContext AssemblyContext { get; } public required System.Type ClassType { get; init; } public int TestCount { get; } - public System.Collections.Generic.List Tests { get; init; } + public System.Collections.Generic.IReadOnlyList Tests { get; } public new static TUnit.Core.ClassHookContext? Current { get; } + public void AddTest(TUnit.Core.TestContext testContext) { } public override bool Equals(object? obj) { } public override int GetHashCode() { } } @@ -243,12 +265,14 @@ namespace TUnit.Core { public System.IO.TextWriter ErrorOutputWriter { get; } public System.IO.TextWriter OutputWriter { get; } + protected TUnit.Core.Context? Parent { get; } public static TUnit.Core.Context Current { get; } public void AddAsyncLocalValues() { } public void Dispose() { } public TUnit.Core.Logging.DefaultLogger GetDefaultLogger() { } public string GetErrorOutput() { } public string GetStandardOutput() { } + public void RestoreExecutionContext() { } } public class CultureExecutor : TUnit.Core.DedicatedThreadExecutor { @@ -790,6 +814,10 @@ namespace TUnit.Core public class SourceGeneratedParameterInformation : TUnit.Core.SourceGeneratedMemberInformation, System.IEquatable { public SourceGeneratedParameterInformation([System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.None | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicConstructors | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicMethods | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.NonPublicMethods)] System.Type Type) { } + public object? DefaultValue { get; } + public bool IsOptional { get; } + public bool IsParams { get; } + public required System.Reflection.ParameterInfo ReflectionInfo { get; set; } public override System.Type Type { get; init; } } [System.Diagnostics.DebuggerDisplay("{Type} {Name})")] @@ -802,6 +830,8 @@ namespace TUnit.Core { public SourceGeneratedPropertyInformation() { } public required bool IsStatic { get; init; } + public string? Key { get; init; } + public TUnit.Core.SharedType Shared { get; init; } [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.None | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicConstructors | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicMethods | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.NonPublicMethods)] public override required System.Type Type { get; init; } } @@ -815,6 +845,7 @@ namespace TUnit.Core public static void RegisterAssemblyHookSource(TUnit.Core.Interfaces.SourceGenerator.IAssemblyHookSource testSource) { } public static void RegisterClassHookSource(TUnit.Core.Interfaces.SourceGenerator.IClassHookSource testSource) { } public static void RegisterDynamic(TUnit.Core.Interfaces.SourceGenerator.IDynamicTestSource testSource) { } + public static void RegisterProperty<[System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.None | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicConstructors | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties)] T>() { } public static void RegisterTestDiscoveryHookSource(TUnit.Core.Interfaces.SourceGenerator.ITestDiscoveryHookSource testSource) { } public static void RegisterTestHookSource(TUnit.Core.Interfaces.SourceGenerator.ITestHookSource testSource) { } public static void RegisterTestSessionHookSource(TUnit.Core.Interfaces.SourceGenerator.ITestSessionHookSource testSource) { } @@ -843,7 +874,9 @@ namespace TUnit.Core { public readonly System.Threading.Lock Lock; public System.Collections.Generic.List ArgumentDisplayFormatters { get; } + public TUnit.Core.AssemblyHookContext AssemblyContext { get; } public System.Threading.CancellationToken CancellationToken { get; } + public TUnit.Core.ClassHookContext ClassContext { get; } public int CurrentRetryAttempt { get; } public TUnit.Core.TestContext[] Dependencies { get; } public TUnit.Core.TestContextEvents Events { get; } @@ -934,11 +967,13 @@ namespace TUnit.Core } public class TestDiscoveryContext : TUnit.Core.Context { - public System.Collections.Generic.IEnumerable AllTests { get; } + public System.Collections.Generic.IReadOnlyList AllTests { get; } public System.Collections.Generic.IEnumerable Assemblies { get; } + public TUnit.Core.BeforeTestDiscoveryContext BeforeTestDiscoveryContext { get; } public System.Collections.Generic.IEnumerable TestClasses { get; } public required string? TestFilter { get; init; } public new static TUnit.Core.TestDiscoveryContext? Current { get; } + public void AddTests(System.Collections.Generic.IEnumerable tests) { } } public abstract class TestMetadata : System.IEquatable { @@ -991,13 +1026,15 @@ namespace TUnit.Core } public class TestSessionContext : TUnit.Core.Context { - public System.Collections.Generic.IEnumerable AllTests { get; } - public System.Collections.Generic.IEnumerable Assemblies { get; } + public System.Collections.Generic.IReadOnlyList AllTests { get; } + public System.Collections.Generic.IReadOnlyList Assemblies { get; } public required string Id { get; init; } - public System.Collections.Generic.IEnumerable TestClasses { get; } + public System.Collections.Generic.IReadOnlyList TestClasses { get; } + public TUnit.Core.BeforeTestDiscoveryContext TestDiscoveryContext { get; } public required string? TestFilter { get; init; } public new static TUnit.Core.TestSessionContext? Current { get; } public void AddArtifact(TUnit.Core.Artifact artifact) { } + public void AddAssembly(TUnit.Core.AssemblyHookContext assemblyHookContext) { } } [System.AttributeUsage(System.AttributeTargets.Assembly | System.AttributeTargets.Class | System.AttributeTargets.Method)] public class TimeoutAttribute : TUnit.Core.TUnitAttribute, TUnit.Core.Interfaces.IEventReceiver, TUnit.Core.Interfaces.ITestDiscoveryEventReceiver @@ -1256,6 +1293,7 @@ namespace TUnit.Core.Helpers public static object? Cast([System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicMethods)] System.Type type, object? value) { } [System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("", "IL2072")] public static T? Cast<[System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicMethods)] T>(object? value) { } + public static System.Reflection.MethodInfo? GetConversionMethod([System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicMethods)] System.Type baseType, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicMethods)] System.Type targetType) { } } [System.Diagnostics.DebuggerDisplay("Count = {CurrentCount}")] public class Counter @@ -1276,6 +1314,13 @@ namespace TUnit.Core.Helpers public MethodInfoRetriever() { } public static System.Reflection.MethodInfo GetMethodInfo([System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.None | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicMethods | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.NonPublicMethods)] System.Type type, string methodName, int genericParameterCount, System.Type[] parameterTypes) { } } + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Uses reflection to retrieve parameter information")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Uses reflection to retrieve parameter information")] + public static class RobustParameterInfoRetriever + { + public static System.Reflection.ParameterInfo GetConstructorParameterInfo([System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.None | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicConstructors | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.NonPublicConstructors)] System.Type type, System.Type[] parameterTypes, int parameterIndex, System.Type expectedType, string parameterName) { } + public static System.Reflection.ParameterInfo GetMethodParameterInfo([System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.None | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicMethods | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.NonPublicMethods)] System.Type type, string methodName, int parameterIndex, System.Type[] parameterTypes, bool isStatic, int genericParameterCount) { } + } } namespace TUnit.Core.Hooks { diff --git a/TUnit.TestProject/Attributes/ClassDisplayNameAttribute.cs b/TUnit.TestProject/Attributes/ClassDisplayNameAttribute.cs index 71afd5e5f7..3a287d20b4 100644 --- a/TUnit.TestProject/Attributes/ClassDisplayNameAttribute.cs +++ b/TUnit.TestProject/Attributes/ClassDisplayNameAttribute.cs @@ -9,8 +9,8 @@ public class ClassDisplayNameAttribute : Attribute, ITestDiscoveryEventReceiver { public void OnTestDiscovery(DiscoveredTestContext discoveredTestContext) { - // discoveredTestContext.SetDisplayName($"{discoveredTestContext.TestDetails.TestClass.Name}.{discoveredTestContext.TestContext.GetTestDisplayName()}"); + discoveredTestContext.SetDisplayName($"{discoveredTestContext.TestDetails.TestClass.Name}.{discoveredTestContext.TestContext.GetTestDisplayName()}"); } - public int Order { get; } = 0; + public int Order => 0; } \ No newline at end of file diff --git a/TUnit.TestProject/Attributes/ExpectedPassEngineTest.cs b/TUnit.TestProject/Attributes/ExpectedPassEngineTest.cs new file mode 100644 index 0000000000..a5dc4e7ff1 --- /dev/null +++ b/TUnit.TestProject/Attributes/ExpectedPassEngineTest.cs @@ -0,0 +1,9 @@ +namespace TUnit.TestProject.Attributes; + +public class EngineTest(ExpectedResult expectedResult) : PropertyAttribute("EngineTest", expectedResult.ToString()); + +public enum ExpectedResult +{ + Pass, + Failure, +} \ No newline at end of file diff --git a/TUnit.TestProject/Bugs/1187/Tests.cs b/TUnit.TestProject/Bugs/1187/Tests.cs index 2b84120c66..244731dc5c 100644 --- a/TUnit.TestProject/Bugs/1187/Tests.cs +++ b/TUnit.TestProject/Bugs/1187/Tests.cs @@ -3,6 +3,7 @@ using TUnit.Assertions; using TUnit.Assertions.Extensions; using TUnit.Core.Interfaces; +using TUnit.TestProject.Attributes; namespace TUnit.TestProject.Bugs._1187; @@ -33,6 +34,7 @@ public async Task InitializeAsync() } } +[EngineTest(ExpectedResult.Pass)] [ClassDataSource(Shared = SharedType.None)] [MethodDataSource(nameof(Contexts))] public class Tests(Context ctx) diff --git a/TUnit.TestProject/Bugs/1304/Tests.cs b/TUnit.TestProject/Bugs/1304/Tests.cs index 93f821aa6d..8d5c4ddd73 100644 --- a/TUnit.TestProject/Bugs/1304/Tests.cs +++ b/TUnit.TestProject/Bugs/1304/Tests.cs @@ -1,10 +1,12 @@ using TUnit.Assertions; using TUnit.Assertions.AssertConditions.Throws; using TUnit.Assertions.Extensions; +using TUnit.TestProject.Attributes; using Vogen; namespace TUnit.TestProject.Bugs._1304; +[EngineTest(ExpectedResult.Pass)] public class Tests { [Test] @@ -20,7 +22,8 @@ public async Task TryParse_InvalidString_ReturnsFailure(string? input, Cancellat // Assert await Assert.That(success).IsFalse(); - await Assert.That(id).IsNull(); + await Assert.That(id.HasValue).IsFalse(); + await Assert.That(id.ToString()).IsEqualTo("[UNINITIALIZED]"); } [Test] @@ -46,7 +49,6 @@ public async Task TryParse_ValidString_ReturnsAccountId(string input) // Assert //using var _ = Assert.Multiple(); await Assert.That(success).IsTrue(); - await Assert.That(id.HasValue).IsTrue(); await Assert.That(id.ToString()).IsEqualTo(input); } } diff --git a/TUnit.TestProject/Bugs/1410/ReproTest.cs b/TUnit.TestProject/Bugs/1410/ReproTest.cs index a810b283f8..7152f9e7c5 100644 --- a/TUnit.TestProject/Bugs/1410/ReproTest.cs +++ b/TUnit.TestProject/Bugs/1410/ReproTest.cs @@ -1,8 +1,10 @@ using TUnit.Assertions; using TUnit.Assertions.Extensions; +using TUnit.TestProject.Attributes; namespace TUnit.TestProject.Bugs._1410; +[EngineTest(ExpectedResult.Pass)] [ClassDataSource(Shared = SharedType.PerTestSession)] public class ReproTest(SharedFixture fixture) { diff --git a/TUnit.TestProject/Bugs/1432/ConstantInBaseClassTests.cs b/TUnit.TestProject/Bugs/1432/ConstantInBaseClassTests.cs index 18ec216d10..439d1bc929 100644 --- a/TUnit.TestProject/Bugs/1432/ConstantInBaseClassTests.cs +++ b/TUnit.TestProject/Bugs/1432/ConstantInBaseClassTests.cs @@ -1,8 +1,10 @@ using TUnit.Assertions; using TUnit.Assertions.Extensions; +using TUnit.TestProject.Attributes; namespace TUnit.TestProject.Bugs._1432; +[EngineTest(ExpectedResult.Pass)] internal abstract class ConstantInBaseClassTestsBase { protected const string BaseValue = "Value"; diff --git a/TUnit.TestProject/Bugs/1432/ConstantsInInterpolatedStringsTests.cs b/TUnit.TestProject/Bugs/1432/ConstantsInInterpolatedStringsTests.cs index 41a186382a..156064bdaa 100644 --- a/TUnit.TestProject/Bugs/1432/ConstantsInInterpolatedStringsTests.cs +++ b/TUnit.TestProject/Bugs/1432/ConstantsInInterpolatedStringsTests.cs @@ -1,8 +1,10 @@ using TUnit.Assertions; using TUnit.Assertions.Extensions; +using TUnit.TestProject.Attributes; namespace TUnit.TestProject.Bugs._1432; +[EngineTest(ExpectedResult.Pass)] internal abstract class ConstantsInInterpolatedStringsTestsBase { protected const string BaseValue = "Value"; diff --git a/TUnit.TestProject/Bugs/1432/EnumMemberNamesTests.cs b/TUnit.TestProject/Bugs/1432/EnumMemberNamesTests.cs index bc73f30d5d..21056e3225 100644 --- a/TUnit.TestProject/Bugs/1432/EnumMemberNamesTests.cs +++ b/TUnit.TestProject/Bugs/1432/EnumMemberNamesTests.cs @@ -1,5 +1,8 @@ -namespace TUnit.TestProject.Bugs._1432; +using TUnit.TestProject.Attributes; +namespace TUnit.TestProject.Bugs._1432; + +[EngineTest(ExpectedResult.Pass)] public class EnumMemberNamesTests { [Test] diff --git a/TUnit.TestProject/Bugs/1538/Tests.cs b/TUnit.TestProject/Bugs/1538/Tests.cs index 5e384111d1..097d56d99e 100644 --- a/TUnit.TestProject/Bugs/1538/Tests.cs +++ b/TUnit.TestProject/Bugs/1538/Tests.cs @@ -1,5 +1,8 @@ -namespace TUnit.TestProject.Bugs._1538; +using TUnit.TestProject.Attributes; +namespace TUnit.TestProject.Bugs._1538; + +[EngineTest(ExpectedResult.Pass)] public class Tests { [Test] diff --git a/TUnit.TestProject/Bugs/1539/Tests.cs b/TUnit.TestProject/Bugs/1539/Tests.cs index 726181f464..0cedc71013 100644 --- a/TUnit.TestProject/Bugs/1539/Tests.cs +++ b/TUnit.TestProject/Bugs/1539/Tests.cs @@ -1,5 +1,8 @@ -namespace TUnit.TestProject.Bugs._1539; +using TUnit.TestProject.Attributes; +namespace TUnit.TestProject.Bugs._1539; + +[EngineTest(ExpectedResult.Pass)] public class Tests { [Test] diff --git a/TUnit.TestProject/Bugs/1570/Tests.cs b/TUnit.TestProject/Bugs/1570/Tests.cs index c0bc208c04..37da14cd82 100644 --- a/TUnit.TestProject/Bugs/1570/Tests.cs +++ b/TUnit.TestProject/Bugs/1570/Tests.cs @@ -1,9 +1,11 @@ using TUnit.Assertions; using TUnit.Assertions.Extensions; using TUnit.Core.Extensions; +using TUnit.TestProject.Attributes; namespace TUnit.TestProject.Bugs._1570; +[EngineTest(ExpectedResult.Pass)] [Arguments(1)] [Arguments(2)] [Arguments(3)] diff --git a/TUnit.TestProject/Bugs/1577/Tests.cs b/TUnit.TestProject/Bugs/1577/Tests.cs index b8487640ac..fc0de1c4b8 100644 --- a/TUnit.TestProject/Bugs/1577/Tests.cs +++ b/TUnit.TestProject/Bugs/1577/Tests.cs @@ -3,9 +3,11 @@ using System.Text.Json.Serialization.Metadata; using TUnit.Assertions; using TUnit.Assertions.Extensions; +using TUnit.TestProject.Attributes; namespace TUnit.TestProject.Bugs._1577; +[EngineTest(ExpectedResult.Pass)] public partial class Tests { public partial record MyRecordType(IEnumerable SomeEnumerable); diff --git a/TUnit.TestProject/Bugs/1589/MyTests.cs b/TUnit.TestProject/Bugs/1589/MyTests.cs index fdf2d21346..727c812849 100644 --- a/TUnit.TestProject/Bugs/1589/MyTests.cs +++ b/TUnit.TestProject/Bugs/1589/MyTests.cs @@ -1,8 +1,10 @@ using TUnit.Assertions; using TUnit.Assertions.Extensions; +using TUnit.TestProject.Attributes; namespace TUnit.TestProject.Bugs._1589; +[EngineTest(ExpectedResult.Pass)] [ClassDataSource(Shared = SharedType.None)] public class MyTests : BaseTests { diff --git a/TUnit.TestProject/Bugs/1594/MyTests.cs b/TUnit.TestProject/Bugs/1594/MyTests.cs index 3c4df6e175..447046df98 100644 --- a/TUnit.TestProject/Bugs/1594/MyTests.cs +++ b/TUnit.TestProject/Bugs/1594/MyTests.cs @@ -1,5 +1,8 @@ -namespace TUnit.TestProject.Bugs._1594; +using TUnit.TestProject.Attributes; +namespace TUnit.TestProject.Bugs._1594; + +[EngineTest(ExpectedResult.Pass)] [ClassDataSource(Shared = SharedType.None)] public class MyTests : ParentTests { diff --git a/TUnit.TestProject/Bugs/1603/MyTests.cs b/TUnit.TestProject/Bugs/1603/MyTests.cs index 26770fbf31..9a0abd4d98 100644 --- a/TUnit.TestProject/Bugs/1603/MyTests.cs +++ b/TUnit.TestProject/Bugs/1603/MyTests.cs @@ -1,5 +1,8 @@ -namespace TUnit.TestProject.Bugs._1603; +using TUnit.TestProject.Attributes; +namespace TUnit.TestProject.Bugs._1603; + +[EngineTest(ExpectedResult.Pass)] public abstract class ParentTests : GrandParentTests where TFixture : BaseFixture { diff --git a/TUnit.TestProject/Bugs/1603/Tests.cs b/TUnit.TestProject/Bugs/1603/Tests.cs index c09ec39ebb..8a3f21a2f9 100644 --- a/TUnit.TestProject/Bugs/1603/Tests.cs +++ b/TUnit.TestProject/Bugs/1603/Tests.cs @@ -1,8 +1,10 @@ using TUnit.Assertions; using TUnit.Assertions.Extensions; +using TUnit.TestProject.Attributes; namespace TUnit.TestProject.Bugs._1603; +[EngineTest(ExpectedResult.Pass)] public class Tests { [Test] diff --git a/TUnit.TestProject/Bugs/1692/Tests.cs b/TUnit.TestProject/Bugs/1692/Tests.cs index 98a2afee2e..76c003d8f1 100644 --- a/TUnit.TestProject/Bugs/1692/Tests.cs +++ b/TUnit.TestProject/Bugs/1692/Tests.cs @@ -1,8 +1,10 @@ using TUnit.Assertions; using TUnit.Assertions.Extensions; +using TUnit.TestProject.Attributes; namespace TUnit.TestProject.Bugs._1692; +[EngineTest(ExpectedResult.Pass)] public class Tests { private const string? NullContent = null; diff --git a/TUnit.TestProject/Bugs/1821/Tests.cs b/TUnit.TestProject/Bugs/1821/Tests.cs index 9055a05443..7c96641fc4 100644 --- a/TUnit.TestProject/Bugs/1821/Tests.cs +++ b/TUnit.TestProject/Bugs/1821/Tests.cs @@ -1,8 +1,10 @@ using TUnit.Assertions; using TUnit.Assertions.Extensions; +using TUnit.TestProject.Attributes; namespace TUnit.TestProject.Bugs._1821; +[EngineTest(ExpectedResult.Pass)] [ClassDataSource] public class Tests(MyData data) { diff --git a/TUnit.TestProject/Bugs/1836/Tests.cs b/TUnit.TestProject/Bugs/1836/Tests.cs index 39847383d3..0fb7e126d6 100644 --- a/TUnit.TestProject/Bugs/1836/Tests.cs +++ b/TUnit.TestProject/Bugs/1836/Tests.cs @@ -1,6 +1,7 @@ using TUnit.Assertions; using TUnit.Assertions.Extensions; using TUnit.Core.Interfaces; +using TUnit.TestProject.Attributes; namespace TUnit.TestProject.Bugs._1836; @@ -46,6 +47,7 @@ public ValueTask DisposeAsync() public int Order { get; } } +[EngineTest(ExpectedResult.Pass)] public class Tests { [ClassDataSource(Shared = SharedType.PerTestSession)] diff --git a/TUnit.TestProject/Bugs/1889/DerivedTest.cs b/TUnit.TestProject/Bugs/1889/DerivedTest.cs index e84b6e2cfc..dc26cb5043 100644 --- a/TUnit.TestProject/Bugs/1889/DerivedTest.cs +++ b/TUnit.TestProject/Bugs/1889/DerivedTest.cs @@ -1,6 +1,8 @@ -using TUnit.TestProject.Library.Bugs._1889; +using TUnit.TestProject.Attributes; +using TUnit.TestProject.Library.Bugs._1889; namespace TUnit.TestProject.Bugs._1889; +[EngineTest(ExpectedResult.Pass)] [InheritsTests] public class DerivedTest : BaseTest; \ No newline at end of file diff --git a/TUnit.TestProject/Bugs/1899/DerivedTest.cs b/TUnit.TestProject/Bugs/1899/DerivedTest.cs index c23c930cdf..30c869bb10 100644 --- a/TUnit.TestProject/Bugs/1899/DerivedTest.cs +++ b/TUnit.TestProject/Bugs/1899/DerivedTest.cs @@ -1,6 +1,8 @@ -using TUnit.TestProject.Library.Bugs._1899; +using TUnit.TestProject.Attributes; +using TUnit.TestProject.Library.Bugs._1899; namespace TUnit.TestProject.Bugs._1899; +[EngineTest(ExpectedResult.Pass)] [InheritsTests] public class DerivedTest: BaseClass; \ No newline at end of file diff --git a/TUnit.TestProject/Bugs/1914/AsyncHookTests.cs b/TUnit.TestProject/Bugs/1914/AsyncHookTests.cs index 1bcd4f0fe8..9e9cd71aa8 100644 --- a/TUnit.TestProject/Bugs/1914/AsyncHookTests.cs +++ b/TUnit.TestProject/Bugs/1914/AsyncHookTests.cs @@ -5,6 +5,7 @@ namespace TUnit.TestProject.Bugs._1914; +[EngineTest(ExpectedResult.Pass)] [SkipNetFramework("ExecutionContext.Restore is not supported on .NET Framework")] [UnconditionalSuppressMessage("Usage", "TUnit0042:Global hooks should not be mixed with test classes to avoid confusion. Place them in their own class.")] [UnconditionalSuppressMessage("Usage", "TUnit0047:Call `context.AddAsyncLocalValues`")] diff --git a/TUnit.TestProject/Bugs/1914/SyncHookTests.cs b/TUnit.TestProject/Bugs/1914/SyncHookTests.cs index d5681d9515..d2f06d7974 100644 --- a/TUnit.TestProject/Bugs/1914/SyncHookTests.cs +++ b/TUnit.TestProject/Bugs/1914/SyncHookTests.cs @@ -1,10 +1,10 @@ -using System.Diagnostics.CodeAnalysis; -using TUnit.Assertions; -using TUnit.Assertions.Extensions; +using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; using TUnit.TestProject.Attributes; namespace TUnit.TestProject.Bugs._1914; +[EngineTest(ExpectedResult.Pass)] [SkipNetFramework("ExecutionContext.Restore is not supported on .NET Framework")] [UnconditionalSuppressMessage("Usage", "TUnit0042:Global hooks should not be mixed with test classes to avoid confusion. Place them in their own class.")] [UnconditionalSuppressMessage("Usage", "TUnit0047:Call `context.AddAsyncLocalValues`")] diff --git a/TUnit.TestProject/Bugs/1924/Keyed/Tests.cs b/TUnit.TestProject/Bugs/1924/Keyed/Tests.cs index 7d4c413385..514cbab135 100644 --- a/TUnit.TestProject/Bugs/1924/Keyed/Tests.cs +++ b/TUnit.TestProject/Bugs/1924/Keyed/Tests.cs @@ -1,5 +1,8 @@ -namespace TUnit.TestProject.Bugs._1924.Keyed; +using TUnit.TestProject.Attributes; +namespace TUnit.TestProject.Bugs._1924.Keyed; + +[EngineTest(ExpectedResult.Pass)] public class BaseClass { [ClassDataSource(Shared = SharedType.Keyed, Key = "🔑")] diff --git a/TUnit.TestProject/Bugs/1924/None/Tests.cs b/TUnit.TestProject/Bugs/1924/None/Tests.cs index 1f94b4ec80..30d6e28f93 100644 --- a/TUnit.TestProject/Bugs/1924/None/Tests.cs +++ b/TUnit.TestProject/Bugs/1924/None/Tests.cs @@ -1,5 +1,8 @@ -namespace TUnit.TestProject.Bugs._1924.None; +using TUnit.TestProject.Attributes; +namespace TUnit.TestProject.Bugs._1924.None; + +[EngineTest(ExpectedResult.Pass)] public class BaseClass { [ClassDataSource] diff --git a/TUnit.TestProject/Bugs/1924/PerAssembly/Tests.cs b/TUnit.TestProject/Bugs/1924/PerAssembly/Tests.cs index 5518e3b0d8..16349b52fd 100644 --- a/TUnit.TestProject/Bugs/1924/PerAssembly/Tests.cs +++ b/TUnit.TestProject/Bugs/1924/PerAssembly/Tests.cs @@ -1,5 +1,8 @@ -namespace TUnit.TestProject.Bugs._1924.PerAssembly; +using TUnit.TestProject.Attributes; +namespace TUnit.TestProject.Bugs._1924.PerAssembly; + +[EngineTest(ExpectedResult.Pass)] public class BaseClass { [ClassDataSource(Shared = SharedType.PerAssembly)] diff --git a/TUnit.TestProject/Bugs/1924/PerClass/Tests.cs b/TUnit.TestProject/Bugs/1924/PerClass/Tests.cs index 867a39783b..fb4fa95619 100644 --- a/TUnit.TestProject/Bugs/1924/PerClass/Tests.cs +++ b/TUnit.TestProject/Bugs/1924/PerClass/Tests.cs @@ -1,5 +1,8 @@ -namespace TUnit.TestProject.Bugs._1924.PerClass; +using TUnit.TestProject.Attributes; +namespace TUnit.TestProject.Bugs._1924.PerClass; + +[EngineTest(ExpectedResult.Pass)] public class BaseClass { [ClassDataSource(Shared = SharedType.PerClass)] diff --git a/TUnit.TestProject/Bugs/1924/PerTestSession/Tests.cs b/TUnit.TestProject/Bugs/1924/PerTestSession/Tests.cs index e934416256..d83c246039 100644 --- a/TUnit.TestProject/Bugs/1924/PerTestSession/Tests.cs +++ b/TUnit.TestProject/Bugs/1924/PerTestSession/Tests.cs @@ -1,5 +1,8 @@ -namespace TUnit.TestProject.Bugs._1924.PerTestSession; +using TUnit.TestProject.Attributes; +namespace TUnit.TestProject.Bugs._1924.PerTestSession; + +[EngineTest(ExpectedResult.Pass)] public class BaseClass { [ClassDataSource(Shared = SharedType.PerTestSession)] diff --git a/TUnit.TestProject/Bugs/1939/Tests.cs b/TUnit.TestProject/Bugs/1939/Tests.cs index 22ec99cfc6..70a4fb3d77 100644 --- a/TUnit.TestProject/Bugs/1939/Tests.cs +++ b/TUnit.TestProject/Bugs/1939/Tests.cs @@ -1,8 +1,10 @@ using TUnit.Assertions; using TUnit.Assertions.Extensions; +using TUnit.TestProject.Attributes; namespace TUnit.TestProject.Bugs._1939; +[EngineTest(ExpectedResult.Pass)] [ClassDataSource] [ClassDataSource(Shared = SharedType.None)] [ClassDataSource(Shared = SharedType.Keyed, Key = "")] diff --git a/TUnit.TestProject/Bugs/2067/Tests.cs b/TUnit.TestProject/Bugs/2067/Tests.cs index 03c0b27c66..cc56f3c4af 100644 --- a/TUnit.TestProject/Bugs/2067/Tests.cs +++ b/TUnit.TestProject/Bugs/2067/Tests.cs @@ -1,8 +1,10 @@ using TUnit.Assertions; using TUnit.Assertions.Extensions; +using TUnit.TestProject.Attributes; namespace TUnit.TestProject.Bugs._2067; +[EngineTest(ExpectedResult.Pass)] [ClassDataSource(Shared = SharedType.PerTestSession)] [NotInParallel] public class Tests(DataClass dataClass) diff --git a/TUnit.TestProject/Bugs/2075/Tests.cs b/TUnit.TestProject/Bugs/2075/Tests.cs index 114a50831d..4d0fc12ac9 100644 --- a/TUnit.TestProject/Bugs/2075/Tests.cs +++ b/TUnit.TestProject/Bugs/2075/Tests.cs @@ -1,22 +1,25 @@ #if NET9_0_OR_GREATER -using Microsoft.AspNetCore.Mvc.Testing; using Microsoft.Extensions.DependencyInjection; using TUnit.Core.Interfaces; +using TUnit.TestProject.Attributes; namespace TUnit.TestProject.Bugs._2075; -public class WebApplicationFactory : WebApplicationFactory, IAsyncInitializer +public class ServiceProviderFactory : IAsyncInitializer { + public ServiceProvider ServiceProvider { get; } = new ServiceCollection() + .AddSingleton() + .AddSingleton() + .BuildServiceProvider(); + public Task InitializeAsync() { - _ = Server; - return Task.CompletedTask; } } -public class FromWebApplicationFactoryAttribute : NonTypedDataSourceGeneratorAttribute +public class FromServiceProviderFactoryAttribute : NonTypedDataSourceGeneratorAttribute, IAccessesInstanceData { public Task InitializeAsync() { @@ -30,14 +33,14 @@ public Task InitializeAsync() throw new Exception("ClassInstanceArguments is null"); } - if (dataGeneratorMetadata.ClassInstanceArguments.OfType>().FirstOrDefault() is not + if (dataGeneratorMetadata.ClassInstanceArguments.OfType().FirstOrDefault() is not { } webApplicationFactory) { throw new Exception("WebApplicationFactory is not part of the class constructor arguments"); } - - var serviceProvider = webApplicationFactory.Server.Services; - + + var serviceProvider = webApplicationFactory.ServiceProvider; + yield return () => { return dataGeneratorMetadata.MembersToGenerate.Select(x => ActivatorUtilities.GetServiceOrCreateInstance(serviceProvider, x.Type)).ToArray(); @@ -45,13 +48,14 @@ public Task InitializeAsync() } } -[ClassDataSource>(Shared = SharedType.PerTestSession)] -public class MyTests(WebApplicationFactory factory) +[EngineTest(ExpectedResult.Pass)] +[ClassDataSource(Shared = SharedType.PerTestSession)] +public class MyTests(ServiceProviderFactory factory) { - [FromWebApplicationFactory] + [FromServiceProviderFactory] public required DbContext DbContext { get; init; } - - [FromWebApplicationFactory] + + [FromServiceProviderFactory] public required IFirebaseClient FirebaseClient { get; init; } [Test] @@ -60,8 +64,6 @@ public void Test() } } -public class Program; - public class DbContext; public interface IFirebaseClient; diff --git a/TUnit.TestProject/Bugs/2083/Tests.cs b/TUnit.TestProject/Bugs/2083/Tests.cs index 5b96401b51..975fd01477 100644 --- a/TUnit.TestProject/Bugs/2083/Tests.cs +++ b/TUnit.TestProject/Bugs/2083/Tests.cs @@ -1,5 +1,8 @@ -namespace TUnit.TestProject.Bugs._2083; +using TUnit.TestProject.Attributes; +namespace TUnit.TestProject.Bugs._2083; + +[EngineTest(ExpectedResult.Pass)] public class Tests { [Test] diff --git a/TUnit.TestProject/Bugs/2085/Tests.cs b/TUnit.TestProject/Bugs/2085/Tests.cs index 8279e00257..eaa65b0f6a 100644 --- a/TUnit.TestProject/Bugs/2085/Tests.cs +++ b/TUnit.TestProject/Bugs/2085/Tests.cs @@ -1,8 +1,10 @@ using TUnit.Assertions; using TUnit.Assertions.Extensions; +using TUnit.TestProject.Attributes; namespace TUnit.TestProject.Bugs._2085; +[EngineTest(ExpectedResult.Pass)] public class Tests { [Test] diff --git a/TUnit.TestProject/Bugs/2112/Tests.cs b/TUnit.TestProject/Bugs/2112/Tests.cs index fa8a52c800..f1ec8a833a 100644 --- a/TUnit.TestProject/Bugs/2112/Tests.cs +++ b/TUnit.TestProject/Bugs/2112/Tests.cs @@ -1,5 +1,8 @@ -namespace TUnit.TestProject.Bugs._2112; +using TUnit.TestProject.Attributes; +namespace TUnit.TestProject.Bugs._2112; + +[EngineTest(ExpectedResult.Pass)] public class Tests { [Test] diff --git a/TUnit.TestProject/Bugs/2136/Tests.cs b/TUnit.TestProject/Bugs/2136/Tests.cs index e79f568424..73b2fcbd12 100644 --- a/TUnit.TestProject/Bugs/2136/Tests.cs +++ b/TUnit.TestProject/Bugs/2136/Tests.cs @@ -1,8 +1,10 @@ using TUnit.Assertions; using TUnit.Assertions.Extensions; +using TUnit.TestProject.Attributes; namespace TUnit.TestProject.Bugs._2136; +[EngineTest(ExpectedResult.Pass)] public class Tests { [Test] diff --git a/TUnit.TestProject/Bugs/2449/Tests.cs b/TUnit.TestProject/Bugs/2449/Tests.cs index 87e5dfe175..953eb28ec3 100644 --- a/TUnit.TestProject/Bugs/2449/Tests.cs +++ b/TUnit.TestProject/Bugs/2449/Tests.cs @@ -1,7 +1,9 @@ using TUnit.Core.Interfaces; +using TUnit.TestProject.Attributes; namespace TUnit.TestProject.Bugs._2449; +[EngineTest(ExpectedResult.Pass)] [ClassDataSource] public sealed class Tests(SampleDataClass arg) { diff --git a/TUnit.TestProject/Bugs/2481/Tests.cs b/TUnit.TestProject/Bugs/2481/Tests.cs index 025cb12a15..38c4ba7600 100644 --- a/TUnit.TestProject/Bugs/2481/Tests.cs +++ b/TUnit.TestProject/Bugs/2481/Tests.cs @@ -1,4 +1,6 @@ -namespace TUnit.TestProject.Bugs._2481; +using TUnit.TestProject.Attributes; + +namespace TUnit.TestProject.Bugs._2481; public class Tests { @@ -9,9 +11,7 @@ public class Tests public async Task Test() { var properties = TestContext.Current!.TestDetails.CustomProperties; - - await Assert.That(properties).HasCount().EqualTo(1); - + var array = properties["Group"].ToArray(); await Assert.That(array).HasCount().EqualTo(3) diff --git a/TUnit.TestProject/ClassDataSourceDisposal/Repro.cs b/TUnit.TestProject/ClassDataSourceDisposal/Repro.cs index df7eeffc8b..e590c3d074 100644 --- a/TUnit.TestProject/ClassDataSourceDisposal/Repro.cs +++ b/TUnit.TestProject/ClassDataSourceDisposal/Repro.cs @@ -1,5 +1,8 @@ -namespace TUnit.TestProject.ClassDataSourceDisposal; +using TUnit.TestProject.Attributes; +namespace TUnit.TestProject.ClassDataSourceDisposal; + +[EngineTest(ExpectedResult.Pass)] public class ReproFixtureBase : IDisposable { public ReproFixtureBase() diff --git a/TUnit.TestProject/ClassDataSourceDrivenTests.cs b/TUnit.TestProject/ClassDataSourceDrivenTests.cs index 37db61266d..76ac917745 100644 --- a/TUnit.TestProject/ClassDataSourceDrivenTests.cs +++ b/TUnit.TestProject/ClassDataSourceDrivenTests.cs @@ -1,9 +1,11 @@ using TUnit.Assertions; using TUnit.Assertions.Extensions; +using TUnit.TestProject.Attributes; using TUnit.TestProject.Library.Models; namespace TUnit.TestProject; +[EngineTest(ExpectedResult.Pass)] public class ClassDataSourceDrivenTests { [Test] diff --git a/TUnit.TestProject/ClassDataSourceDrivenTests2.cs b/TUnit.TestProject/ClassDataSourceDrivenTests2.cs index afecaa27a8..b960e4564e 100644 --- a/TUnit.TestProject/ClassDataSourceDrivenTests2.cs +++ b/TUnit.TestProject/ClassDataSourceDrivenTests2.cs @@ -1,5 +1,8 @@ +using TUnit.TestProject.Attributes; + namespace TUnit.TestProject; +[EngineTest(ExpectedResult.Pass)] [ClassDataSource] [ClassDataSource] public class ClassDataSourceDrivenTests2(ClassDataSourceDrivenTests2.Base @base) diff --git a/TUnit.TestProject/ClassDataSourceDrivenTestsSharedForClass.cs b/TUnit.TestProject/ClassDataSourceDrivenTestsSharedForClass.cs index cca8bd1e43..764e4b1b0e 100644 --- a/TUnit.TestProject/ClassDataSourceDrivenTestsSharedForClass.cs +++ b/TUnit.TestProject/ClassDataSourceDrivenTestsSharedForClass.cs @@ -1,7 +1,9 @@ +using TUnit.TestProject.Attributes; using TUnit.TestProject.Library.Models; namespace TUnit.TestProject; +[EngineTest(ExpectedResult.Pass)] public class ClassDataSourceDrivenTestsSharedForClass { [Test] diff --git a/TUnit.TestProject/ClassDataSourceDrivenTestsSharedKeyed.cs b/TUnit.TestProject/ClassDataSourceDrivenTestsSharedKeyed.cs index a81622ebfd..400b21eaf4 100644 --- a/TUnit.TestProject/ClassDataSourceDrivenTestsSharedKeyed.cs +++ b/TUnit.TestProject/ClassDataSourceDrivenTestsSharedKeyed.cs @@ -1,7 +1,9 @@ +using TUnit.TestProject.Attributes; using TUnit.TestProject.Library.Models; namespace TUnit.TestProject; +[EngineTest(ExpectedResult.Pass)] public class ClassDataSourceDrivenTestsSharedKeyed { [Test] diff --git a/TUnit.TestProject/ClassDataSourceDrivenTestsSharedKeyed2.cs b/TUnit.TestProject/ClassDataSourceDrivenTestsSharedKeyed2.cs index a30acaf1bd..b1527377cc 100644 --- a/TUnit.TestProject/ClassDataSourceDrivenTestsSharedKeyed2.cs +++ b/TUnit.TestProject/ClassDataSourceDrivenTestsSharedKeyed2.cs @@ -1,10 +1,12 @@ using System.Diagnostics.CodeAnalysis; using TUnit.Assertions; using TUnit.Assertions.Extensions; +using TUnit.TestProject.Attributes; using TUnit.TestProject.Library.Models; namespace TUnit.TestProject; +[EngineTest(ExpectedResult.Pass)] [ClassDataSource(Shared = SharedType.Keyed, Key = "🌲")] [UnconditionalSuppressMessage("Usage", "TUnit0018:Test methods should not assign instance data")] public class ClassDataSourceDrivenTestsSharedKeyed2 @@ -37,9 +39,14 @@ public async Task DataSource_Class_Generic(SomeAsyncDisposableClass value) MethodLevels.Add(value); } - [After(Class)] - public static async Task AssertAfter() + [After(Assembly)] + public static async Task AssertAfter(AssemblyHookContext assemblyHookContext) { + if(assemblyHookContext.TestClasses.Any(x => x.ClassType != typeof(ClassDataSourceDrivenTestsSharedKeyed3))) + { + return; // Skip if this class is not executed + } + await Assert.That(ClassLevels).IsNotEmpty(); await Assert.That(MethodLevels).IsNotEmpty(); diff --git a/TUnit.TestProject/ClassDataSourceDrivenTestsSharedKeyed3.cs b/TUnit.TestProject/ClassDataSourceDrivenTestsSharedKeyed3.cs index 9d9b0985d7..d3f19ab149 100644 --- a/TUnit.TestProject/ClassDataSourceDrivenTestsSharedKeyed3.cs +++ b/TUnit.TestProject/ClassDataSourceDrivenTestsSharedKeyed3.cs @@ -1,10 +1,12 @@ using System.Diagnostics.CodeAnalysis; using TUnit.Assertions; using TUnit.Assertions.Extensions; +using TUnit.TestProject.Attributes; using TUnit.TestProject.Library.Models; namespace TUnit.TestProject; +[EngineTest(ExpectedResult.Pass)] [ClassDataSource(Shared = SharedType.Keyed, Key = "🌲")] [UnconditionalSuppressMessage("Usage", "TUnit0018:Test methods should not assign instance data")] public class ClassDataSourceDrivenTestsSharedKeyed3 @@ -37,9 +39,14 @@ public async Task DataSource_Class_Generic(SomeAsyncDisposableClass value) MethodLevels.Add(value); } - [After(Class)] - public static async Task AssertAfter() + [After(Assembly)] + public static async Task AssertAfter(AssemblyHookContext assemblyHookContext) { + if(assemblyHookContext.TestClasses.Any(x => x.ClassType != typeof(ClassDataSourceDrivenTestsSharedKeyed3))) + { + return; // Skip if this class is not executed + } + await Assert.That(ClassLevels).IsNotEmpty(); await Assert.That(MethodLevels).IsNotEmpty(); diff --git a/TUnit.TestProject/ClassDataSourceDrivenTestsSharedNone.cs b/TUnit.TestProject/ClassDataSourceDrivenTestsSharedNone.cs index a672d36f39..d10dbbd394 100644 --- a/TUnit.TestProject/ClassDataSourceDrivenTestsSharedNone.cs +++ b/TUnit.TestProject/ClassDataSourceDrivenTestsSharedNone.cs @@ -1,7 +1,9 @@ +using TUnit.TestProject.Attributes; using TUnit.TestProject.Library.Models; namespace TUnit.TestProject; +[EngineTest(ExpectedResult.Pass)] public class ClassDataSourceDrivenTestsSharedNone { [Test] diff --git a/TUnit.TestProject/ClassHooks.cs b/TUnit.TestProject/ClassHooks.cs index 1b6dd37a4b..244d10791b 100644 --- a/TUnit.TestProject/ClassHooks.cs +++ b/TUnit.TestProject/ClassHooks.cs @@ -1,9 +1,11 @@ using TUnit.Assertions; using TUnit.Assertions.Extensions; using TUnit.Core.Enums; +using TUnit.TestProject.Attributes; namespace TUnit.TestProject; +[EngineTest(ExpectedResult.Pass)] public class ClassHooks { [Before(Class)] diff --git a/TUnit.TestProject/ClassHooksExecutionCountTests.cs b/TUnit.TestProject/ClassHooksExecutionCountTests.cs index 67ea87473b..2878ad8752 100644 --- a/TUnit.TestProject/ClassHooksExecutionCountTests.cs +++ b/TUnit.TestProject/ClassHooksExecutionCountTests.cs @@ -1,8 +1,10 @@ using TUnit.Assertions; using TUnit.Assertions.Extensions; +using TUnit.TestProject.Attributes; namespace TUnit.TestProject; +[EngineTest(ExpectedResult.Pass)] public class ClassHooksExecutionCountTests { private static int _beforeClassCalls; diff --git a/TUnit.TestProject/ClassTupleDataSourceDrivenTests.cs b/TUnit.TestProject/ClassTupleDataSourceDrivenTests.cs index 25992417ce..ec3f7c4cf3 100644 --- a/TUnit.TestProject/ClassTupleDataSourceDrivenTests.cs +++ b/TUnit.TestProject/ClassTupleDataSourceDrivenTests.cs @@ -1,5 +1,8 @@ -namespace TUnit.TestProject; +using TUnit.TestProject.Attributes; +namespace TUnit.TestProject; + +[EngineTest(ExpectedResult.Pass)] [MethodDataSource(nameof(TupleMethod))] [MethodDataSource(nameof(NamedTupleMethod))] public class ClassTupleDataSourceDrivenTests diff --git a/TUnit.TestProject/CleanUpTests.cs b/TUnit.TestProject/CleanUpTests.cs index fd87247fb5..4b98767721 100644 --- a/TUnit.TestProject/CleanUpTests.cs +++ b/TUnit.TestProject/CleanUpTests.cs @@ -1,4 +1,6 @@ -namespace TUnit.TestProject; +using TUnit.TestProject.Attributes; + +namespace TUnit.TestProject; public class CleanUpBase1 { @@ -45,6 +47,7 @@ public async Task AfterEach3() } } +[EngineTest(ExpectedResult.Pass)] public class CleanUpTests : CleanUpBase3, IDisposable { [After(Class)] diff --git a/TUnit.TestProject/ComplexDependsOn/BaseClass.cs b/TUnit.TestProject/ComplexDependsOn/BaseClass.cs index eaba2d9cb1..5a4629f179 100644 --- a/TUnit.TestProject/ComplexDependsOn/BaseClass.cs +++ b/TUnit.TestProject/ComplexDependsOn/BaseClass.cs @@ -1,5 +1,8 @@ -namespace TUnit.TestProject.ComplexDependsOn; +using TUnit.TestProject.Attributes; +namespace TUnit.TestProject.ComplexDependsOn; + +[EngineTest(ExpectedResult.Pass)] public class BaseClass { [Test] diff --git a/TUnit.TestProject/ComplexDependsOn2/Tests.cs b/TUnit.TestProject/ComplexDependsOn2/Tests.cs index f61754d2f5..58061cb72f 100644 --- a/TUnit.TestProject/ComplexDependsOn2/Tests.cs +++ b/TUnit.TestProject/ComplexDependsOn2/Tests.cs @@ -1,6 +1,9 @@ -#pragma warning disable +using TUnit.TestProject.Attributes; + +#pragma warning disable namespace TUnit.TestProject.ComplexDependsOn2; +[EngineTest(ExpectedResult.Pass)] public abstract class BaseClass { [Test] diff --git a/TUnit.TestProject/ConflictingDependsOnTests.cs b/TUnit.TestProject/ConflictingDependsOnTests.cs index b44c199500..32422cae77 100644 --- a/TUnit.TestProject/ConflictingDependsOnTests.cs +++ b/TUnit.TestProject/ConflictingDependsOnTests.cs @@ -1,7 +1,9 @@ using System.Diagnostics.CodeAnalysis; +using TUnit.TestProject.Attributes; namespace TUnit.TestProject; +[EngineTest(ExpectedResult.Failure)] [UnconditionalSuppressMessage("Usage", "TUnit0033:Conflicting DependsOn attributes")] public class ConflictingDependsOnTests { diff --git a/TUnit.TestProject/ConflictingDependsOnTests2.cs b/TUnit.TestProject/ConflictingDependsOnTests2.cs index 745bba1a8a..05a78d8b48 100644 --- a/TUnit.TestProject/ConflictingDependsOnTests2.cs +++ b/TUnit.TestProject/ConflictingDependsOnTests2.cs @@ -1,7 +1,9 @@ using System.Diagnostics.CodeAnalysis; +using TUnit.TestProject.Attributes; namespace TUnit.TestProject; +[EngineTest(ExpectedResult.Failure)] [UnconditionalSuppressMessage("Usage", "TUnit0033:Conflicting DependsOn attributes")] public class ConflictingDependsOnTests2 { diff --git a/TUnit.TestProject/ConflictingDependsOnTests3.cs b/TUnit.TestProject/ConflictingDependsOnTests3.cs index e77925e654..45c602ebcc 100644 --- a/TUnit.TestProject/ConflictingDependsOnTests3.cs +++ b/TUnit.TestProject/ConflictingDependsOnTests3.cs @@ -1,7 +1,9 @@ using System.Diagnostics.CodeAnalysis; +using TUnit.TestProject.Attributes; namespace TUnit.TestProject; +[EngineTest(ExpectedResult.Failure)] [UnconditionalSuppressMessage("Usage", "TUnit0033:Conflicting DependsOn attributes")] public class ConflictingDependsOnTests3 { diff --git a/TUnit.TestProject/ConsoleConcurrentTests.cs b/TUnit.TestProject/ConsoleConcurrentTests.cs index 528f15a218..c1403e9f4b 100644 --- a/TUnit.TestProject/ConsoleConcurrentTests.cs +++ b/TUnit.TestProject/ConsoleConcurrentTests.cs @@ -1,5 +1,8 @@ -namespace TUnit.TestProject; +using TUnit.TestProject.Attributes; +namespace TUnit.TestProject; + +[EngineTest(ExpectedResult.Pass)] public class ConsoleConcurrentTests { [Test, Repeat(25)] diff --git a/TUnit.TestProject/ConsoleTests.cs b/TUnit.TestProject/ConsoleTests.cs index 0d4d857666..fd4f377f09 100644 --- a/TUnit.TestProject/ConsoleTests.cs +++ b/TUnit.TestProject/ConsoleTests.cs @@ -1,10 +1,14 @@ -namespace TUnit.TestProject; +using TUnit.TestProject.Attributes; +namespace TUnit.TestProject; + +[EngineTest(ExpectedResult.Pass)] public class ConsoleTests { [Test] - public void Write_Source_Gen_Information() + public async Task Write_Source_Gen_Information() { Console.WriteLine(TestContext.Current!.TestDetails.TestMethod); + await Assert.That(TestContext.Current.GetStandardOutput()).IsEqualTo(TestContext.Current.TestDetails.TestMethod.ToString()); } } \ No newline at end of file diff --git a/TUnit.TestProject/ConstantArgumentsTests.cs b/TUnit.TestProject/ConstantArgumentsTests.cs index 21e66d0e40..bd196b3e6d 100644 --- a/TUnit.TestProject/ConstantArgumentsTests.cs +++ b/TUnit.TestProject/ConstantArgumentsTests.cs @@ -1,8 +1,10 @@ using TUnit.Assertions; using TUnit.Assertions.Extensions; +using TUnit.TestProject.Attributes; namespace TUnit.TestProject; +[EngineTest(ExpectedResult.Pass)] public class ConstantArgumentsTests { public const string DummyString = "123"; diff --git a/TUnit.TestProject/CultureTests.cs b/TUnit.TestProject/CultureTests.cs index 8ced3b3551..b9bde637fb 100644 --- a/TUnit.TestProject/CultureTests.cs +++ b/TUnit.TestProject/CultureTests.cs @@ -7,6 +7,7 @@ namespace TUnit.TestProject; +[EngineTest(ExpectedResult.Pass)] public class CultureTests { [Test, Culture("en-GB")] diff --git a/TUnit.TestProject/CustomAssertions/ProblemDetailsAssertion.cs b/TUnit.TestProject/CustomAssertions/ProblemDetailsAssertion.cs index 9a64e318e3..a8f4247b55 100644 --- a/TUnit.TestProject/CustomAssertions/ProblemDetailsAssertion.cs +++ b/TUnit.TestProject/CustomAssertions/ProblemDetailsAssertion.cs @@ -1,6 +1,5 @@ #if NET -using System.Net; using System.Net.Http.Json; using System.Runtime.CompilerServices; using System.Text.Json.Serialization; @@ -110,27 +109,4 @@ protected override ValueTask GetResult(ProblemDetails? actualVa } } -public class Tests -{ - [Test] - public async Task Test() - { - var response = new HttpResponseMessage(HttpStatusCode.Unauthorized) - { - Content = JsonContent.Create(new ProblemDetails - { - Title = "Invalid Authentication Token", - Detail = "No token provided" - }, ProblemDetailsSourceGenerationContext.Default.ProblemDetails) - }; - - await Assert.That(response) - .IsProblemDetails() - .And - .HasTitle("Invalid Authentication Token") - .And - .HasDetail("No token provided"); - } -} - #endif \ No newline at end of file diff --git a/TUnit.TestProject/CustomAssertions/Tests.cs b/TUnit.TestProject/CustomAssertions/Tests.cs new file mode 100644 index 0000000000..7e0e0646ef --- /dev/null +++ b/TUnit.TestProject/CustomAssertions/Tests.cs @@ -0,0 +1,31 @@ +#if NET +using System.Net; +using System.Net.Http.Json; +using TUnit.TestProject.Attributes; + +namespace TUnit.TestProject.CustomAssertions; + +[EngineTest(ExpectedResult.Pass)] +public class Tests +{ + [Test] + public async Task Test() + { + var response = new HttpResponseMessage(HttpStatusCode.Unauthorized) + { + Content = JsonContent.Create(new ProblemDetails + { + Title = "Invalid Authentication Token", + Detail = "No token provided" + }, ProblemDetailsSourceGenerationContext.Default.ProblemDetails) + }; + + await Assert.That(response) + .IsProblemDetails() + .And + .HasTitle("Invalid Authentication Token") + .And + .HasDetail("No token provided"); + } +} +#endif \ No newline at end of file diff --git a/TUnit.TestProject/CustomClassDisplayNameTests.cs b/TUnit.TestProject/CustomClassDisplayNameTests.cs index 63ea7de3af..fa2b7c299c 100644 --- a/TUnit.TestProject/CustomClassDisplayNameTests.cs +++ b/TUnit.TestProject/CustomClassDisplayNameTests.cs @@ -2,11 +2,13 @@ using TUnit.Assertions.Extensions; using TUnit.Core.Extensions; using TUnit.TestProject.AfterTests; +using TUnit.TestProject.Attributes; #pragma warning disable CS9113 // Parameter is unread. namespace TUnit.TestProject; +[EngineTest(ExpectedResult.Pass)] [ClassDataSource] [ClassDataSource] [ClassDataSource] @@ -16,7 +18,7 @@ public class CustomClassDisplayNameTests(Base1 base1) [Test] public async Task Test() { - await Assert.That(TestContext.Current!.GetTestDisplayName()).IsEqualTo("A super important test!"); + await Assert.That(TestContext.Current!.GetTestDisplayName()).IsEqualTo("CustomClassDisplayNameTests.Test"); } } diff --git a/TUnit.TestProject/CustomDisplayNameTests.cs b/TUnit.TestProject/CustomDisplayNameTests.cs index f0984b00fc..558a9bcf28 100644 --- a/TUnit.TestProject/CustomDisplayNameTests.cs +++ b/TUnit.TestProject/CustomDisplayNameTests.cs @@ -2,9 +2,11 @@ using TUnit.Assertions.Extensions; using TUnit.Core.Extensions; using TUnit.Core.Interfaces; +using TUnit.TestProject.Attributes; namespace TUnit.TestProject; +[EngineTest(ExpectedResult.Pass)] public class CustomDisplayNameTests { public const string SameClassConstant = "My constant"; diff --git a/TUnit.TestProject/CustomPropertyTests.cs b/TUnit.TestProject/CustomPropertyTests.cs index 6da44dbb33..209f8838ee 100644 --- a/TUnit.TestProject/CustomPropertyTests.cs +++ b/TUnit.TestProject/CustomPropertyTests.cs @@ -1,7 +1,9 @@ using System.Collections.Immutable; +using TUnit.TestProject.Attributes; namespace TUnit.TestProject; +[EngineTest(ExpectedResult.Pass)] [Property("ClassProperty", "ClassPropertyValue")] [ClassProperty] public class CustomPropertyTests diff --git a/TUnit.TestProject/DataDrivenTests.cs b/TUnit.TestProject/DataDrivenTests.cs index 42c65ecbc5..d949dbffa6 100644 --- a/TUnit.TestProject/DataDrivenTests.cs +++ b/TUnit.TestProject/DataDrivenTests.cs @@ -1,5 +1,8 @@ -namespace TUnit.TestProject; +using TUnit.TestProject.Attributes; +namespace TUnit.TestProject; + +[EngineTest(ExpectedResult.Pass)] public class DataDrivenTests { [Test] diff --git a/TUnit.TestProject/DataSourceClassCombinedWithDataSourceMethod.cs b/TUnit.TestProject/DataSourceClassCombinedWithDataSourceMethod.cs index 82a9a109b7..650d1eee3b 100644 --- a/TUnit.TestProject/DataSourceClassCombinedWithDataSourceMethod.cs +++ b/TUnit.TestProject/DataSourceClassCombinedWithDataSourceMethod.cs @@ -1,5 +1,8 @@ -namespace TUnit.TestProject; +using TUnit.TestProject.Attributes; +namespace TUnit.TestProject; + +[EngineTest(ExpectedResult.Pass)] [MethodDataSource(typeof(CommonTestData), nameof(CommonTestData.One))] [MethodDataSource(typeof(CommonTestData), nameof(CommonTestData.Two))] [MethodDataSource(typeof(CommonTestData), nameof(CommonTestData.Three))] diff --git a/TUnit.TestProject/DataSourceGeneratorTests.cs b/TUnit.TestProject/DataSourceGeneratorTests.cs index 408ee48c92..3264d50211 100644 --- a/TUnit.TestProject/DataSourceGeneratorTests.cs +++ b/TUnit.TestProject/DataSourceGeneratorTests.cs @@ -1,7 +1,10 @@  +using TUnit.TestProject.Attributes; + #pragma warning disable CS9113 // Parameter is unread. namespace TUnit.TestProject; +[EngineTest(ExpectedResult.Pass)] [AutoFixtureGenerator] [AutoFixtureGenerator] public class DataSourceGeneratorTests(int value, string value2, bool value3) @@ -19,7 +22,6 @@ public void GeneratedData_Method(int value) public void GeneratedData_Method2(int value, string value2, bool value3) { // Dummy method - Console.WriteLine(); } [Test] @@ -27,7 +29,6 @@ public void GeneratedData_Method2(int value, string value2, bool value3) public void GeneratedData_Method3(int value, string value2, bool value3) { // Dummy method - Console.WriteLine(); } public class AutoFixtureGeneratorAttribute : DataSourceGeneratorAttribute diff --git a/TUnit.TestProject/DeepNestedDependencyConflict.cs b/TUnit.TestProject/DeepNestedDependencyConflict.cs index b11cfe2195..f64fab3362 100644 --- a/TUnit.TestProject/DeepNestedDependencyConflict.cs +++ b/TUnit.TestProject/DeepNestedDependencyConflict.cs @@ -1,7 +1,9 @@ using System.Diagnostics.CodeAnalysis; +using TUnit.TestProject.Attributes; namespace TUnit.TestProject; +[EngineTest(ExpectedResult.Failure)] [UnconditionalSuppressMessage("Usage", "TUnit0033:Conflicting DependsOn attributes")] public class DeepNestedDependencyConflict { diff --git a/TUnit.TestProject/DependencyCountTests.cs b/TUnit.TestProject/DependencyCountTests.cs index 8a8dce448d..dbe9243197 100644 --- a/TUnit.TestProject/DependencyCountTests.cs +++ b/TUnit.TestProject/DependencyCountTests.cs @@ -1,5 +1,8 @@ -namespace TUnit.TestProject; +using TUnit.TestProject.Attributes; +namespace TUnit.TestProject; + +[EngineTest(ExpectedResult.Pass)] public class DependencyCountTests { [Test] diff --git a/TUnit.TestProject/DependsOnAndNotInParallelTests.cs b/TUnit.TestProject/DependsOnAndNotInParallelTests.cs index a9012257bc..6985e56771 100644 --- a/TUnit.TestProject/DependsOnAndNotInParallelTests.cs +++ b/TUnit.TestProject/DependsOnAndNotInParallelTests.cs @@ -1,5 +1,8 @@ -namespace TUnit.TestProject; +using TUnit.TestProject.Attributes; +namespace TUnit.TestProject; + +[EngineTest(ExpectedResult.Pass)] public class DependsOnAndNotInParallelTests { [Test, NotInParallel] diff --git a/TUnit.TestProject/DependsOnTests.cs b/TUnit.TestProject/DependsOnTests.cs index 2bda36807c..effea07670 100644 --- a/TUnit.TestProject/DependsOnTests.cs +++ b/TUnit.TestProject/DependsOnTests.cs @@ -1,8 +1,10 @@ using TUnit.Assertions; using TUnit.Assertions.Extensions; +using TUnit.TestProject.Attributes; namespace TUnit.TestProject; +[EngineTest(ExpectedResult.Pass)] public class DependsOnTests { private static DateTime _test1Start; diff --git a/TUnit.TestProject/DependsOnTests2.cs b/TUnit.TestProject/DependsOnTests2.cs index 80b5fee824..7a88709ac4 100644 --- a/TUnit.TestProject/DependsOnTests2.cs +++ b/TUnit.TestProject/DependsOnTests2.cs @@ -2,9 +2,11 @@ using TUnit.Assertions.AssertConditions.Throws; using TUnit.Assertions.Extensions; using TUnit.Core.Extensions; +using TUnit.TestProject.Attributes; namespace TUnit.TestProject; +[EngineTest(ExpectedResult.Pass)] public class DependsOnTests2 { private static DateTime _test1Start; diff --git a/TUnit.TestProject/DependsOnTests3.cs b/TUnit.TestProject/DependsOnTests3.cs index 9994a20166..0266a98418 100644 --- a/TUnit.TestProject/DependsOnTests3.cs +++ b/TUnit.TestProject/DependsOnTests3.cs @@ -1,9 +1,11 @@ using TUnit.Assertions; using TUnit.Assertions.Extensions; using TUnit.Core.Extensions; +using TUnit.TestProject.Attributes; namespace TUnit.TestProject; +[EngineTest(ExpectedResult.Pass)] public class DependsOnTests3 { private static DateTime _test1Start; diff --git a/TUnit.TestProject/DependsOnTestsWithClass.cs b/TUnit.TestProject/DependsOnTestsWithClass.cs index 3e1e561955..3394d6863a 100644 --- a/TUnit.TestProject/DependsOnTestsWithClass.cs +++ b/TUnit.TestProject/DependsOnTestsWithClass.cs @@ -1,5 +1,6 @@ using TUnit.Assertions; using TUnit.Assertions.Extensions; +using TUnit.TestProject.Attributes; namespace TUnit.TestProject; @@ -15,6 +16,7 @@ public async Task Test1() } } +[EngineTest(ExpectedResult.Pass)] public class DependsOnTestsWithClass { private static DateTime _test2Start; diff --git a/TUnit.TestProject/DependsOnTestsWithClass2.cs b/TUnit.TestProject/DependsOnTestsWithClass2.cs index d83e8775eb..82f6863846 100644 --- a/TUnit.TestProject/DependsOnTestsWithClass2.cs +++ b/TUnit.TestProject/DependsOnTestsWithClass2.cs @@ -1,5 +1,6 @@ using TUnit.Assertions; using TUnit.Assertions.Extensions; +using TUnit.TestProject.Attributes; namespace TUnit.TestProject; @@ -15,6 +16,7 @@ public async Task Test1() } } +[EngineTest(ExpectedResult.Pass)] public class DependsOnTestsWithClass2 { private static DateTime _test2Start; diff --git a/TUnit.TestProject/DependsOnTestsWithProceedOnFailure.cs b/TUnit.TestProject/DependsOnTestsWithProceedOnFailure.cs index ed63027291..75096c4605 100644 --- a/TUnit.TestProject/DependsOnTestsWithProceedOnFailure.cs +++ b/TUnit.TestProject/DependsOnTestsWithProceedOnFailure.cs @@ -1,5 +1,8 @@ -namespace TUnit.TestProject; +using TUnit.TestProject.Attributes; +namespace TUnit.TestProject; + +[EngineTest(ExpectedResult.Failure)] public class DependsOnTestsWithProceedOnFailure { [Test] diff --git a/TUnit.TestProject/DependsOnTestsWithoutProceedOnFailure.cs b/TUnit.TestProject/DependsOnTestsWithoutProceedOnFailure.cs index e7b69d1bdb..aaae66624d 100644 --- a/TUnit.TestProject/DependsOnTestsWithoutProceedOnFailure.cs +++ b/TUnit.TestProject/DependsOnTestsWithoutProceedOnFailure.cs @@ -1,5 +1,8 @@ -namespace TUnit.TestProject; +using TUnit.TestProject.Attributes; +namespace TUnit.TestProject; + +[EngineTest(ExpectedResult.Failure)] public class DependsOnTestsWithoutProceedOnFailure { [Test] diff --git a/TUnit.TestProject/DependsOnWithBaseTests.cs b/TUnit.TestProject/DependsOnWithBaseTests.cs index 757a68c9c9..e9bd1f6b62 100644 --- a/TUnit.TestProject/DependsOnWithBaseTests.cs +++ b/TUnit.TestProject/DependsOnWithBaseTests.cs @@ -1,8 +1,10 @@ using TUnit.Assertions; using TUnit.Assertions.Extensions; +using TUnit.TestProject.Attributes; namespace TUnit.TestProject; +[EngineTest(ExpectedResult.Pass)] [InheritsTests] public class DependsOnWithBaseTests : DependsOnBase { diff --git a/TUnit.TestProject/DisposableFieldTests.cs b/TUnit.TestProject/DisposableFieldTests.cs index 756cc5c0b1..463659c5b0 100644 --- a/TUnit.TestProject/DisposableFieldTests.cs +++ b/TUnit.TestProject/DisposableFieldTests.cs @@ -1,5 +1,8 @@ -namespace TUnit.TestProject; +using TUnit.TestProject.Attributes; +namespace TUnit.TestProject; + +[EngineTest(ExpectedResult.Pass)] public class DisposableFieldTests { private Stream? _stream; diff --git a/TUnit.TestProject/DisposablePropertyTests.cs b/TUnit.TestProject/DisposablePropertyTests.cs index 29ae520582..8b9f989750 100644 --- a/TUnit.TestProject/DisposablePropertyTests.cs +++ b/TUnit.TestProject/DisposablePropertyTests.cs @@ -1,5 +1,8 @@ -namespace TUnit.TestProject; +using TUnit.TestProject.Attributes; +namespace TUnit.TestProject; + +[EngineTest(ExpectedResult.Pass)] public class DisposablePropertyTests { #pragma warning disable TUnit0023 diff --git a/TUnit.TestProject/DisposedRepro.cs b/TUnit.TestProject/DisposedRepro.cs index 9860361849..ee65a4fbf8 100644 --- a/TUnit.TestProject/DisposedRepro.cs +++ b/TUnit.TestProject/DisposedRepro.cs @@ -1,4 +1,6 @@ -#pragma warning disable CS9113 // Parameter is unread. +using TUnit.TestProject.Attributes; + +#pragma warning disable CS9113 // Parameter is unread. namespace TUnit.TestProject; public abstract class DisposedReproTestBase : IDisposable @@ -19,6 +21,7 @@ public void Dispose() } } +[EngineTest(ExpectedResult.Pass)] [ClassDataSource] [NotInParallel] public sealed class DisposedRepro(Dummy2 dummy) : DisposedReproTestBase diff --git a/TUnit.TestProject/DummyReferenceTypeClass.cs b/TUnit.TestProject/DummyReferenceTypeClass.cs index 4624be27e2..eaeecd25a7 100644 --- a/TUnit.TestProject/DummyReferenceTypeClass.cs +++ b/TUnit.TestProject/DummyReferenceTypeClass.cs @@ -1,3 +1,9 @@ -namespace TUnit.TestProject; +using System.Diagnostics; -public class DummyReferenceTypeClass; \ No newline at end of file +namespace TUnit.TestProject; + +[DebuggerDisplay("{Id}")] +public class DummyReferenceTypeClass +{ + public string Id { get; } = Guid.NewGuid().ToString(); +} \ No newline at end of file diff --git a/TUnit.TestProject/DynamicTests/Basic.cs b/TUnit.TestProject/DynamicTests/Basic.cs index e281846f89..c73f71f5c2 100644 --- a/TUnit.TestProject/DynamicTests/Basic.cs +++ b/TUnit.TestProject/DynamicTests/Basic.cs @@ -1,5 +1,8 @@ -namespace TUnit.TestProject.DynamicTests; +using TUnit.TestProject.Attributes; +namespace TUnit.TestProject.DynamicTests; + +[EngineTest(ExpectedResult.Pass)] public class Basic { public void SomeMethod() diff --git a/TUnit.TestProject/DynamicTests/Basic2.cs b/TUnit.TestProject/DynamicTests/Basic2.cs index c99a95ab05..e30bbbf88b 100644 --- a/TUnit.TestProject/DynamicTests/Basic2.cs +++ b/TUnit.TestProject/DynamicTests/Basic2.cs @@ -1,9 +1,12 @@ using TUnit.Assertions; using TUnit.Assertions.Extensions; +using TUnit.TestProject.Attributes; + #pragma warning disable TUnitWIP0001 namespace TUnit.TestProject.DynamicTests; +[EngineTest(ExpectedResult.Pass)] public class Basic2 { [DynamicTestBuilder] diff --git a/TUnit.TestProject/DynamicTests/Runtime.cs b/TUnit.TestProject/DynamicTests/Runtime.cs index 95565ea654..1c349e594d 100644 --- a/TUnit.TestProject/DynamicTests/Runtime.cs +++ b/TUnit.TestProject/DynamicTests/Runtime.cs @@ -1,9 +1,11 @@ using TUnit.Core.Extensions; +using TUnit.TestProject.Attributes; #pragma warning disable WIP namespace TUnit.TestProject.DynamicTests; +[EngineTest(ExpectedResult.Pass)] [RunOnDiscovery] [Arguments(1, 2, 3)] [Arguments(101, 202, 303)] diff --git a/TUnit.TestProject/EnumTests.cs b/TUnit.TestProject/EnumTests.cs index 19c18e359d..0fcb0a20ef 100644 --- a/TUnit.TestProject/EnumTests.cs +++ b/TUnit.TestProject/EnumTests.cs @@ -3,6 +3,7 @@ namespace TUnit.TestProject; +[EngineTest(ExpectedResult.Pass)] public class EnumTests { [EnumGenerator] diff --git a/TUnit.TestProject/EnumerableDataSourceDrivenTests.cs b/TUnit.TestProject/EnumerableDataSourceDrivenTests.cs index f84a11d261..9fb9f9a5a9 100644 --- a/TUnit.TestProject/EnumerableDataSourceDrivenTests.cs +++ b/TUnit.TestProject/EnumerableDataSourceDrivenTests.cs @@ -1,22 +1,24 @@ using TUnit.Assertions; using TUnit.Assertions.Extensions; +using TUnit.TestProject.Attributes; namespace TUnit.TestProject; +[EngineTest(ExpectedResult.Pass)] public class EnumerableDataSourceDrivenTests { [Test] [MethodDataSource(nameof(SomeMethod))] public async Task DataSource_Method(int value) { - await Assert.That(value).IsEqualTo(1); + await Assert.That(value).IsBetween(1, 5).WithInclusiveBounds(); } [Test] [MethodDataSource(nameof(SomeMethod))] public async Task DataSource_Method2(int value) { - await Assert.That(value).IsEqualTo(1); + await Assert.That(value).IsBetween(1, 5).WithInclusiveBounds(); } [Test] diff --git a/TUnit.TestProject/EnumerableTupleDataSourceDrivenTests.cs b/TUnit.TestProject/EnumerableTupleDataSourceDrivenTests.cs index ca40828b0d..aea5eb399d 100644 --- a/TUnit.TestProject/EnumerableTupleDataSourceDrivenTests.cs +++ b/TUnit.TestProject/EnumerableTupleDataSourceDrivenTests.cs @@ -1,5 +1,8 @@ -namespace TUnit.TestProject; +using TUnit.TestProject.Attributes; +namespace TUnit.TestProject; + +[EngineTest(ExpectedResult.Pass)] public class EnumerableTupleDataSourceDrivenTests { [Test] diff --git a/TUnit.TestProject/ExternalEnumArgumentTest.cs b/TUnit.TestProject/ExternalEnumArgumentTest.cs index 706a653e2f..a9ec8673e0 100644 --- a/TUnit.TestProject/ExternalEnumArgumentTest.cs +++ b/TUnit.TestProject/ExternalEnumArgumentTest.cs @@ -1,7 +1,9 @@ using Polly.CircuitBreaker; +using TUnit.TestProject.Attributes; namespace TUnit.TestProject; +[EngineTest(ExpectedResult.Pass)] public class ExternalEnumArgumentTest { [Test] diff --git a/TUnit.TestProject/FailedInitializationTests.cs b/TUnit.TestProject/FailedInitializationTests.cs index 739412658d..f3fd8ad496 100644 --- a/TUnit.TestProject/FailedInitializationTests.cs +++ b/TUnit.TestProject/FailedInitializationTests.cs @@ -1,5 +1,8 @@ -namespace TUnit.TestProject; +using TUnit.TestProject.Attributes; +namespace TUnit.TestProject; + +[EngineTest(ExpectedResult.Failure)] public class FailedInitializationTests { [Test] diff --git a/TUnit.TestProject/FailedInitializationTests2.cs b/TUnit.TestProject/FailedInitializationTests2.cs index cd3e755691..4a1de5b515 100644 --- a/TUnit.TestProject/FailedInitializationTests2.cs +++ b/TUnit.TestProject/FailedInitializationTests2.cs @@ -1,7 +1,9 @@ using System.Diagnostics.CodeAnalysis; +using TUnit.TestProject.Attributes; namespace TUnit.TestProject; +[EngineTest(ExpectedResult.Failure)] [UnconditionalSuppressMessage("Usage", "TUnit0033:Conflicting DependsOn attributes")] public class FailedInitializationTests2 { diff --git a/TUnit.TestProject/GenericHooks.cs b/TUnit.TestProject/GenericHooks.cs index 8702d6fca4..4d47d4b960 100644 --- a/TUnit.TestProject/GenericHooks.cs +++ b/TUnit.TestProject/GenericHooks.cs @@ -1,5 +1,8 @@ -namespace TUnit.TestProject; +using TUnit.TestProject.Attributes; +namespace TUnit.TestProject; + +[EngineTest(ExpectedResult.Pass)] [Arguments(1)] [Arguments("Hello")] public class GenericHooks(T arg) diff --git a/TUnit.TestProject/GenericMethodTests.cs b/TUnit.TestProject/GenericMethodTests.cs index 25899a2e0e..e41109b061 100644 --- a/TUnit.TestProject/GenericMethodTests.cs +++ b/TUnit.TestProject/GenericMethodTests.cs @@ -1,5 +1,8 @@ -namespace TUnit.TestProject; +using TUnit.TestProject.Attributes; +namespace TUnit.TestProject; + +[EngineTest(ExpectedResult.Pass)] public class GenericMethodTests { [Test] diff --git a/TUnit.TestProject/GenericTests.cs b/TUnit.TestProject/GenericTests.cs index 41bf8d525d..ee9456c61d 100644 --- a/TUnit.TestProject/GenericTests.cs +++ b/TUnit.TestProject/GenericTests.cs @@ -3,9 +3,11 @@ using System.Numerics; using TUnit.Assertions; using TUnit.Assertions.Extensions; +using TUnit.TestProject.Attributes; namespace TUnit.TestProject; +[EngineTest(ExpectedResult.Pass)] public abstract class GenericTests where T : INumber { diff --git a/TUnit.TestProject/HumanizerDisplayNameTests.cs b/TUnit.TestProject/HumanizerDisplayNameTests.cs index ba4c994df0..1cbefd8d1f 100644 --- a/TUnit.TestProject/HumanizerDisplayNameTests.cs +++ b/TUnit.TestProject/HumanizerDisplayNameTests.cs @@ -1,8 +1,10 @@ using Humanizer; using TUnit.Core.Extensions; +using TUnit.TestProject.Attributes; namespace TUnit.TestProject; +[EngineTest(ExpectedResult.Pass)] [HumanizerDisplayName] public class HumanizerDisplayNameTests { diff --git a/TUnit.TestProject/IDisposableTests.cs b/TUnit.TestProject/IDisposableTests.cs index 3e86326a26..d263db8412 100644 --- a/TUnit.TestProject/IDisposableTests.cs +++ b/TUnit.TestProject/IDisposableTests.cs @@ -1,5 +1,8 @@ -namespace TUnit.TestProject; +using TUnit.TestProject.Attributes; +namespace TUnit.TestProject; + +[EngineTest(ExpectedResult.Pass)] public class DisposableTests : IDisposable { [Test] @@ -19,9 +22,24 @@ public async Task Three() { await Task.CompletedTask; } + + [After(Class)] + public static async Task AssertDisposed(ClassHookContext context) + { + foreach (var disposableTestse in context.Tests.Select(x => x.TestDetails.ClassInstance).OfType()) + { + await Assert.That(disposableTestse.IsDisposed).IsTrue(); + } + } public void Dispose() { + IsDisposed = true; + } + public bool IsDisposed + { + get; + private set; } } \ No newline at end of file diff --git a/TUnit.TestProject/InheritedTestsFromDifferentProjectTests.cs b/TUnit.TestProject/InheritedTestsFromDifferentProjectTests.cs index 14b7db4466..f79d49b8c7 100644 --- a/TUnit.TestProject/InheritedTestsFromDifferentProjectTests.cs +++ b/TUnit.TestProject/InheritedTestsFromDifferentProjectTests.cs @@ -1,5 +1,8 @@ -namespace TUnit.TestProject; +using TUnit.TestProject.Attributes; +namespace TUnit.TestProject; + +[EngineTest(ExpectedResult.Pass)] [InheritsTests] public class InheritedTestsFromDifferentProjectTests : Library.BaseTests { diff --git a/TUnit.TestProject/Inject_NonSharedInstance.cs b/TUnit.TestProject/Inject_NonSharedInstance.cs index b81e5db068..2eea7d9f8c 100644 --- a/TUnit.TestProject/Inject_NonSharedInstance.cs +++ b/TUnit.TestProject/Inject_NonSharedInstance.cs @@ -1,8 +1,10 @@ using TUnit.Assertions; using TUnit.Assertions.Extensions; +using TUnit.TestProject.Attributes; namespace TUnit.TestProject; +[EngineTest(ExpectedResult.Pass)] [ClassDataSource(Shared = SharedType.None), NotInParallel] public class InjectNonSharedInstance(DummyReferenceTypeClass dummyReferenceTypeClass) { diff --git a/TUnit.TestProject/Inject_SharedInstanceGlobally.cs b/TUnit.TestProject/Inject_SharedInstanceGlobally.cs index 292de328d6..04ea2e41ff 100644 --- a/TUnit.TestProject/Inject_SharedInstanceGlobally.cs +++ b/TUnit.TestProject/Inject_SharedInstanceGlobally.cs @@ -1,5 +1,6 @@ using TUnit.Assertions; using TUnit.Assertions.Extensions; +using TUnit.TestProject.Attributes; namespace TUnit.TestProject; @@ -8,6 +9,7 @@ public static class SharedInjectedGloballyContainer public static readonly List Instances = []; } +[EngineTest(ExpectedResult.Pass)] [ClassDataSource(Shared = SharedType.PerTestSession), NotInParallel] public class InjectSharedGlobally1(DummyReferenceTypeClass dummyReferenceTypeClass) { diff --git a/TUnit.TestProject/Inject_SharedInstancePerKey.cs b/TUnit.TestProject/Inject_SharedInstancePerKey.cs index 0df62f4eb0..a462084ded 100644 --- a/TUnit.TestProject/Inject_SharedInstancePerKey.cs +++ b/TUnit.TestProject/Inject_SharedInstancePerKey.cs @@ -1,74 +1,60 @@ using System.Collections.Concurrent; using TUnit.Assertions; using TUnit.Assertions.Extensions; +using TUnit.TestProject.Attributes; namespace TUnit.TestProject; public static class SharedInjectedKeyedContainer { public static readonly ConcurrentDictionary> InstancesPerKey = new(); + + public static async Task Check(string key, DummyReferenceTypeClass dummyReferenceTypeClass) + { + var list = SharedInjectedKeyedContainer.InstancesPerKey.GetOrAdd(key, _ => []); + + list.Add(dummyReferenceTypeClass); + + await Assert.That(list.Distinct()).HasSingleItem(); + } } +[EngineTest(ExpectedResult.Pass)] [ClassDataSource(Shared = SharedType.PerClass), NotInParallel] public class InjectSharedPerKey1(DummyReferenceTypeClass dummyReferenceTypeClass) { + public static string Key => TestContext.Current!.TestDetails.TestClass.Namespace + "." + TestContext.Current.TestDetails.TestClass.Name + "_" + TestContext.Current.TestDetails.TestName; + [Test, Repeat(5)] public async Task Test1() { - if (SharedInjectedKeyedContainer.InstancesPerKey.TryGetValue(TestContext.Current!.TestDetails.TestName, out var list) - && list.Any()) - { - await Assert.That(list).Contains(dummyReferenceTypeClass); - } - - foreach (var (key, value) in SharedInjectedKeyedContainer.InstancesPerKey.Where(x => x.Key != TestContext.Current.TestDetails.TestName)) - { - await Assert.That(list!).DoesNotContain(dummyReferenceTypeClass); - } - - list = SharedInjectedKeyedContainer.InstancesPerKey.GetOrAdd(TestContext.Current.TestDetails.TestName, _ => - []); - list.Add(dummyReferenceTypeClass); - await Assert.That(list.Distinct()).HasSingleItem(); + await SharedInjectedKeyedContainer.Check(Key, dummyReferenceTypeClass); } [Test, Repeat(5)] public async Task Test2() { - if (SharedInjectedKeyedContainer.InstancesPerKey.TryGetValue(TestContext.Current!.TestDetails.TestName, out var list) - && list.Any()) - { - await Assert.That(list).Contains(dummyReferenceTypeClass); - } - - foreach (var (key, value) in SharedInjectedKeyedContainer.InstancesPerKey.Where(x => x.Key != TestContext.Current.TestDetails.TestName)) - { - await Assert.That(list!).DoesNotContain(dummyReferenceTypeClass); - } - - list = SharedInjectedKeyedContainer.InstancesPerKey.GetOrAdd(TestContext.Current.TestDetails.TestName, _ => - []); - list.Add(dummyReferenceTypeClass); - await Assert.That(list.Distinct()).HasSingleItem(); + await SharedInjectedKeyedContainer.Check(Key, dummyReferenceTypeClass); } [Test, Repeat(5)] public async Task Test3() { - if (SharedInjectedKeyedContainer.InstancesPerKey.TryGetValue(TestContext.Current!.TestDetails.TestName, out var list) + if (SharedInjectedKeyedContainer.InstancesPerKey.TryGetValue(Key, out var list) && list.Any()) { await Assert.That(list).Contains(dummyReferenceTypeClass); } - - foreach (var (key, value) in SharedInjectedKeyedContainer.InstancesPerKey.Where(x => x.Key != TestContext.Current.TestDetails.TestName)) + + list = SharedInjectedKeyedContainer.InstancesPerKey.GetOrAdd(Key, _ => []); + + foreach (var (key, value) in SharedInjectedKeyedContainer.InstancesPerKey.Where(x => x.Key != Key)) { await Assert.That(list!).DoesNotContain(dummyReferenceTypeClass); } - - list = SharedInjectedKeyedContainer.InstancesPerKey.GetOrAdd(TestContext.Current.TestDetails.TestName, _ => - []); + list.Add(dummyReferenceTypeClass); + await Assert.That(list.Distinct()).HasSingleItem(); } } @@ -76,127 +62,65 @@ public async Task Test3() [ClassDataSource(Shared = SharedType.PerClass), NotInParallel] public class InjectSharedPerKey2(DummyReferenceTypeClass dummyReferenceTypeClass) { + public static string Key => TestContext.Current!.TestDetails.TestClass.Namespace + "." + TestContext.Current.TestDetails.TestClass.Name + "_" + TestContext.Current.TestDetails.TestName; + [Test, Repeat(5)] public async Task Test1() { - if (SharedInjectedKeyedContainer.InstancesPerKey.TryGetValue(TestContext.Current!.TestDetails.TestName, out var list) - && list.Any()) - { - await Assert.That(list).Contains(dummyReferenceTypeClass); - } - - foreach (var (key, value) in SharedInjectedKeyedContainer.InstancesPerKey.Where(x => x.Key != TestContext.Current.TestDetails.TestName)) - { - await Assert.That(list!).DoesNotContain(dummyReferenceTypeClass); - } - - list = SharedInjectedKeyedContainer.InstancesPerKey.GetOrAdd(TestContext.Current.TestDetails.TestName, _ => - []); - list.Add(dummyReferenceTypeClass); - await Assert.That(list.Distinct()).HasSingleItem(); + await SharedInjectedKeyedContainer.Check(Key, dummyReferenceTypeClass); } [Test, Repeat(5)] public async Task Test2() { - if (SharedInjectedKeyedContainer.InstancesPerKey.TryGetValue(TestContext.Current!.TestDetails.TestName, out var list) + if (SharedInjectedKeyedContainer.InstancesPerKey.TryGetValue(Key, out var list) && list.Any()) { await Assert.That(list).Contains(dummyReferenceTypeClass); } - foreach (var (key, value) in SharedInjectedKeyedContainer.InstancesPerKey.Where(x => x.Key != TestContext.Current.TestDetails.TestName)) + + + list = SharedInjectedKeyedContainer.InstancesPerKey.GetOrAdd(Key, _ => []); + + foreach (var (key, value) in SharedInjectedKeyedContainer.InstancesPerKey.Where(x => x.Key != Key)) { await Assert.That(list!).DoesNotContain(dummyReferenceTypeClass); } - - list = SharedInjectedKeyedContainer.InstancesPerKey.GetOrAdd(TestContext.Current.TestDetails.TestName, _ => - []); + list.Add(dummyReferenceTypeClass); + await Assert.That(list.Distinct()).HasSingleItem(); } [Test, Repeat(5)] public async Task Test3() { - if (SharedInjectedKeyedContainer.InstancesPerKey.TryGetValue(TestContext.Current!.TestDetails.TestName, out var list) - && list.Any()) - { - await Assert.That(list).Contains(dummyReferenceTypeClass); - } - - foreach (var (key, value) in SharedInjectedKeyedContainer.InstancesPerKey.Where(x => x.Key != TestContext.Current.TestDetails.TestName)) - { - await Assert.That(list!).DoesNotContain(dummyReferenceTypeClass); - } - - list = SharedInjectedKeyedContainer.InstancesPerKey.GetOrAdd(TestContext.Current.TestDetails.TestName, _ => - []); - list.Add(dummyReferenceTypeClass); - await Assert.That(list.Distinct()).HasSingleItem(); + await SharedInjectedKeyedContainer.Check(Key, dummyReferenceTypeClass); } } [ClassDataSource(Shared = SharedType.PerClass), NotInParallel] public class InjectSharedPerKey3(DummyReferenceTypeClass dummyReferenceTypeClass) { + public static string Key => TestContext.Current!.TestDetails.TestClass.Namespace + "." + TestContext.Current.TestDetails.TestClass.Name + "_" + + TestContext.Current.TestDetails.TestName; + [Test, Repeat(5)] public async Task Test1() { - if (SharedInjectedKeyedContainer.InstancesPerKey.TryGetValue(TestContext.Current!.TestDetails.TestName, out var list) - && list.Any()) - { - await Assert.That(list).Contains(dummyReferenceTypeClass); - } - - foreach (var (key, value) in SharedInjectedKeyedContainer.InstancesPerKey.Where(x => x.Key != TestContext.Current.TestDetails.TestName)) - { - await Assert.That(list!).DoesNotContain(dummyReferenceTypeClass); - } - - list = SharedInjectedKeyedContainer.InstancesPerKey.GetOrAdd(TestContext.Current.TestDetails.TestName, _ => - []); - list.Add(dummyReferenceTypeClass); - await Assert.That(list.Distinct()).HasSingleItem(); + await SharedInjectedKeyedContainer.Check(Key, dummyReferenceTypeClass); } [Test, Repeat(5)] public async Task Test2() { - if (SharedInjectedKeyedContainer.InstancesPerKey.TryGetValue(TestContext.Current!.TestDetails.TestName, out var list) - && list.Any()) - { - await Assert.That(list).Contains(dummyReferenceTypeClass); - } - - foreach (var (key, value) in SharedInjectedKeyedContainer.InstancesPerKey.Where(x => x.Key != TestContext.Current.TestDetails.TestName)) - { - await Assert.That(list!).DoesNotContain(dummyReferenceTypeClass); - } - - list = SharedInjectedKeyedContainer.InstancesPerKey.GetOrAdd(TestContext.Current.TestDetails.TestName, _ => - []); - list.Add(dummyReferenceTypeClass); - await Assert.That(list.Distinct()).HasSingleItem(); + await SharedInjectedKeyedContainer.Check(Key, dummyReferenceTypeClass); } [Test, Repeat(5)] public async Task Test3() { - if (SharedInjectedKeyedContainer.InstancesPerKey.TryGetValue(TestContext.Current!.TestDetails.TestName, out var list) - && list.Any()) - { - await Assert.That(list).Contains(dummyReferenceTypeClass); - } - - foreach (var (key, value) in SharedInjectedKeyedContainer.InstancesPerKey.Where(x => x.Key != TestContext.Current.TestDetails.TestName)) - { - await Assert.That(list!).DoesNotContain(dummyReferenceTypeClass); - } - - list = SharedInjectedKeyedContainer.InstancesPerKey.GetOrAdd(TestContext.Current.TestDetails.TestName, _ => - []); - list.Add(dummyReferenceTypeClass); - await Assert.That(list.Distinct()).HasSingleItem(); + await SharedInjectedKeyedContainer.Check(Key, dummyReferenceTypeClass); } } \ No newline at end of file diff --git a/TUnit.TestProject/Inject_SharedInstancePerTestClass.cs b/TUnit.TestProject/Inject_SharedInstancePerTestClass.cs index 6b84eaa53d..5a5c262995 100644 --- a/TUnit.TestProject/Inject_SharedInstancePerTestClass.cs +++ b/TUnit.TestProject/Inject_SharedInstancePerTestClass.cs @@ -1,5 +1,6 @@ using TUnit.Assertions; using TUnit.Assertions.Extensions; +using TUnit.TestProject.Attributes; namespace TUnit.TestProject; @@ -10,6 +11,7 @@ public static class SharedInjectedTypesContainer public static readonly List TestClass3Instances = []; } +[EngineTest(ExpectedResult.Pass)] [ClassDataSource(Shared = SharedType.PerClass), NotInParallel] public class InjectSharedPerType1(DummyReferenceTypeClass dummyReferenceTypeClass) { diff --git a/TUnit.TestProject/InjectedClassDataSourceWithAsyncInitializerTests.cs b/TUnit.TestProject/InjectedClassDataSourceWithAsyncInitializerTests.cs index cfe14e8732..6ae1590191 100644 --- a/TUnit.TestProject/InjectedClassDataSourceWithAsyncInitializerTests.cs +++ b/TUnit.TestProject/InjectedClassDataSourceWithAsyncInitializerTests.cs @@ -1,8 +1,11 @@ using TUnit.Core.Interfaces; +using TUnit.TestProject.Attributes; + #pragma warning disable CS9113 // Parameter is unread. namespace TUnit.TestProject; +[EngineTest(ExpectedResult.Pass)] [ClassDataSource(Shared = SharedType.Keyed, Key = "MyKey")] public class InjectedClassDataSourceWithAsyncInitializerTests(InjectedClassDataSourceWithAsyncInitializerTests.MyClass myClass) { diff --git a/TUnit.TestProject/KeyedNotInParallelTests.cs b/TUnit.TestProject/KeyedNotInParallelTests.cs index 3ee17ad5c6..a37031210a 100644 --- a/TUnit.TestProject/KeyedNotInParallelTests.cs +++ b/TUnit.TestProject/KeyedNotInParallelTests.cs @@ -1,9 +1,11 @@ using System.Collections.Concurrent; using TUnit.Assertions; using TUnit.Assertions.Extensions; +using TUnit.TestProject.Attributes; namespace TUnit.TestProject; +[EngineTest(ExpectedResult.Pass)] public class KeyedNotInParallelTests { private static readonly ConcurrentBag TestDateTimeRanges = []; diff --git a/TUnit.TestProject/LongFailures.cs b/TUnit.TestProject/LongFailures.cs index b9809ccde7..cad85f7504 100644 --- a/TUnit.TestProject/LongFailures.cs +++ b/TUnit.TestProject/LongFailures.cs @@ -1,5 +1,8 @@ -namespace TUnit.TestProject; +using TUnit.TestProject.Attributes; +namespace TUnit.TestProject; + +[EngineTest(ExpectedResult.Failure)] [Category("LongFailures")] public class LongFailures { diff --git a/TUnit.TestProject/MEDITest.cs b/TUnit.TestProject/MEDITest.cs index 7e27aeda54..a2b13d4526 100644 --- a/TUnit.TestProject/MEDITest.cs +++ b/TUnit.TestProject/MEDITest.cs @@ -3,6 +3,7 @@ using TUnit.Assertions; using TUnit.Assertions.Extensions; using TUnit.Core.Interfaces; +using TUnit.TestProject.Attributes; namespace TUnit.TestProject; @@ -28,6 +29,7 @@ private static IServiceProvider CreateServiceProvider() } } +[EngineTest(ExpectedResult.Pass)] [MicrosoftDependencyInjectionDataSource] [UnconditionalSuppressMessage("Usage", "TUnit0042:Global hooks should not be mixed with test classes to avoid confusion. Place them in their own class.")] public class MEDITest(MEDIClass mediClass) @@ -56,6 +58,7 @@ public static async Task CheckDisposed(TestSessionContext testSessionContext) { return; } + await Assert.That(mediClass.IsDisposed).IsTrue(); } } diff --git a/TUnit.TestProject/MatrixTests.cs b/TUnit.TestProject/MatrixTests.cs index f92abbb4db..bb097246a2 100644 --- a/TUnit.TestProject/MatrixTests.cs +++ b/TUnit.TestProject/MatrixTests.cs @@ -2,9 +2,11 @@ using TUnit.Assertions; using TUnit.Assertions.AssertionBuilders.Groups; using TUnit.Assertions.Extensions; +using TUnit.TestProject.Attributes; namespace TUnit.TestProject; +[EngineTest(ExpectedResult.Pass)] public class MatrixTests { [Test] diff --git a/TUnit.TestProject/MethodDataSourceDrivenTests.cs b/TUnit.TestProject/MethodDataSourceDrivenTests.cs index 9ece192ecc..249a0de4bd 100644 --- a/TUnit.TestProject/MethodDataSourceDrivenTests.cs +++ b/TUnit.TestProject/MethodDataSourceDrivenTests.cs @@ -2,9 +2,11 @@ using TUnit.Assertions; using TUnit.Assertions.Extensions; +using TUnit.TestProject.Attributes; namespace TUnit.TestProject; +[EngineTest(ExpectedResult.Pass)] public class MethodDataSourceDrivenTests { public const string MyString = "Hello World!"; diff --git a/TUnit.TestProject/MethodDataSourceDrivenWithCancellationTokenTests.cs b/TUnit.TestProject/MethodDataSourceDrivenWithCancellationTokenTests.cs index 4e271eddf9..a0eedd4b92 100644 --- a/TUnit.TestProject/MethodDataSourceDrivenWithCancellationTokenTests.cs +++ b/TUnit.TestProject/MethodDataSourceDrivenWithCancellationTokenTests.cs @@ -1,9 +1,11 @@ // ReSharper disable UseCollectionExpression using System.Diagnostics.CodeAnalysis; +using TUnit.TestProject.Attributes; namespace TUnit.TestProject; +[EngineTest(ExpectedResult.Pass)] [UnconditionalSuppressMessage("Usage", "TUnit0046:Return a `Func` rather than a ``")] public class MethodDataSourceDrivenWithCancellationTokenTests { diff --git a/TUnit.TestProject/MixedMatrixTests.cs b/TUnit.TestProject/MixedMatrixTests.cs index 8b0de91878..afd6bff112 100644 --- a/TUnit.TestProject/MixedMatrixTests.cs +++ b/TUnit.TestProject/MixedMatrixTests.cs @@ -2,9 +2,11 @@ using TUnit.Assertions; using TUnit.Assertions.AssertionBuilders.Groups; using TUnit.Assertions.Extensions; +using TUnit.TestProject.Attributes; namespace TUnit.TestProject; +[EngineTest(ExpectedResult.Pass)] public class MixedMatrixTests { [Test] diff --git a/TUnit.TestProject/MultipleClassDataSourceDrivenTests.cs b/TUnit.TestProject/MultipleClassDataSourceDrivenTests.cs index c515083442..369a4901f4 100644 --- a/TUnit.TestProject/MultipleClassDataSourceDrivenTests.cs +++ b/TUnit.TestProject/MultipleClassDataSourceDrivenTests.cs @@ -1,7 +1,10 @@ +using TUnit.TestProject.Attributes; + #pragma warning disable CS9113 // Parameter is unread. namespace TUnit.TestProject; +[EngineTest(ExpectedResult.Pass)] [ClassDataSource(Shared = [SharedType.None, SharedType.None, SharedType.None, SharedType.None, SharedType.None])] public class MultipleClassDataSourceDrivenTests( MultipleClassDataSourceDrivenTests.Inject1 inject1, diff --git a/TUnit.TestProject/MyTests.cs b/TUnit.TestProject/MyTests.cs deleted file mode 100644 index a16211e622..0000000000 --- a/TUnit.TestProject/MyTests.cs +++ /dev/null @@ -1,3 +0,0 @@ -namespace TUnit.TestProject; - -public class MyTests; \ No newline at end of file diff --git a/TUnit.TestProject/NameOfArgumentTests.cs b/TUnit.TestProject/NameOfArgumentTests.cs index ef8a157ec8..77e1f03333 100644 --- a/TUnit.TestProject/NameOfArgumentTests.cs +++ b/TUnit.TestProject/NameOfArgumentTests.cs @@ -1,11 +1,14 @@ -namespace TUnit.TestProject; +using TUnit.TestProject.Attributes; +namespace TUnit.TestProject; + +[EngineTest(ExpectedResult.Pass)] public class NameOfArgumentTests { [Test] [Arguments(nameof(TestName))] - public void TestName(string name) + public async Task TestName(string name) { - // Dummy method + await Assert.That(name).IsEqualTo("TestName"); } } \ No newline at end of file diff --git a/TUnit.TestProject/NestedBaseTests.cs b/TUnit.TestProject/NestedBaseTests.cs index 0f5589a4b0..834f1df1bb 100644 --- a/TUnit.TestProject/NestedBaseTests.cs +++ b/TUnit.TestProject/NestedBaseTests.cs @@ -1,8 +1,10 @@ using TUnit.Assertions; using TUnit.Assertions.Extensions; +using TUnit.TestProject.Attributes; namespace TUnit.TestProject; +[EngineTest(ExpectedResult.Pass)] public class NestedBaseTests : NestedBase1 { [Test] diff --git a/TUnit.TestProject/NestedClassDataSourceDrivenTests.cs b/TUnit.TestProject/NestedClassDataSourceDrivenTests.cs index 5173760f53..2bca47fafa 100644 --- a/TUnit.TestProject/NestedClassDataSourceDrivenTests.cs +++ b/TUnit.TestProject/NestedClassDataSourceDrivenTests.cs @@ -1,26 +1,65 @@ -using TUnit.Assertions; -using TUnit.Assertions.Extensions; +using System.Text.Json; +using System.Text.Json.Serialization.Metadata; using TUnit.Core.Interfaces; -using TUnit.TestProject.Library.Models; +using TUnit.TestProject.Attributes; namespace TUnit.TestProject; +[EngineTest(ExpectedResult.Pass)] public class NestedClassDataSourceDrivenTests { [Test] - [ClassDataSource] + [ClassDataSource(Shared = SharedType.PerClass)] public async Task DataSource_Class(SomeClass1 value) { + Console.WriteLine(value); + + await Assert.That(value.IsInitialized).IsTrue(); + await Assert.That(value.InnerClass.IsInitialized).IsTrue(); + await Assert.That(value.InnerClass.InnerClass.IsInitialized).IsTrue(); + + await Assert.That(value.IsDisposed).IsFalse(); + await Assert.That(value.InnerClass.IsDisposed).IsFalse(); + await Assert.That(value.InnerClass.InnerClass.IsDisposed).IsFalse(); + } + + [Test] + [ClassDataSource(Shared = SharedType.PerClass)] + [DependsOn(nameof(DataSource_Class))] + public async Task DataSource_Class2(SomeClass1 value) + { + Console.WriteLine(value); + + await Assert.That(value.IsInitialized).IsTrue(); + await Assert.That(value.InnerClass.IsInitialized).IsTrue(); + await Assert.That(value.InnerClass.InnerClass.IsInitialized).IsTrue(); + + await Assert.That(value.IsDisposed).IsFalse(); + await Assert.That(value.InnerClass.IsDisposed).IsFalse(); + await Assert.That(value.InnerClass.InnerClass.IsDisposed).IsFalse(); + } + + [Test] + [ClassDataSource(Shared = SharedType.PerClass)] + [DependsOn(nameof(DataSource_Class2))] + public async Task DataSource_Class3(SomeClass1 value) + { + Console.WriteLine(value); + await Assert.That(value.IsInitialized).IsTrue(); await Assert.That(value.InnerClass.IsInitialized).IsTrue(); await Assert.That(value.InnerClass.InnerClass.IsInitialized).IsTrue(); + + await Assert.That(value.IsDisposed).IsFalse(); + await Assert.That(value.InnerClass.IsDisposed).IsFalse(); + await Assert.That(value.InnerClass.InnerClass.IsDisposed).IsFalse(); } - public class SomeClass1 : IAsyncInitializer + public record SomeClass1 : IAsyncInitializer, IAsyncDisposable { [ClassDataSource(Shared = SharedType.PerAssembly)] public required SomeClass2 InnerClass { get; init; } - + public Task InitializeAsync() { IsInitialized = true; @@ -32,13 +71,21 @@ public bool IsInitialized get; private set; } + + public ValueTask DisposeAsync() + { + IsDisposed = true; + return default; + } + + public bool IsDisposed { get; set; } } - - public class SomeClass2 : IAsyncInitializer + + public record SomeClass2 : IAsyncInitializer, IAsyncDisposable { [ClassDataSource(Shared = SharedType.PerAssembly)] public required SomeClass3 InnerClass { get; init; } - + public Task InitializeAsync() { IsInitialized = true; @@ -50,9 +97,17 @@ public bool IsInitialized get; private set; } + + public ValueTask DisposeAsync() + { + IsDisposed = true; + return default; + } + + public bool IsDisposed { get; set; } } - - public class SomeClass3 : IAsyncInitializer + + public record SomeClass3 : IAsyncInitializer, IAsyncDisposable { public Task InitializeAsync() { @@ -65,5 +120,13 @@ public bool IsInitialized get; private set; } + + public ValueTask DisposeAsync() + { + IsDisposed = true; + return default; + } + + public bool IsDisposed { get; set; } } -} \ No newline at end of file +} diff --git a/TUnit.TestProject/NestedExceptionTests.cs b/TUnit.TestProject/NestedExceptionTests.cs index 8b26093aa7..42c3911839 100644 --- a/TUnit.TestProject/NestedExceptionTests.cs +++ b/TUnit.TestProject/NestedExceptionTests.cs @@ -1,5 +1,8 @@ -namespace TUnit.TestProject; +using TUnit.TestProject.Attributes; +namespace TUnit.TestProject; + +[EngineTest(ExpectedResult.Failure)] public class NestedExceptionTests { [Test] diff --git a/TUnit.TestProject/NotInParallelTests.cs b/TUnit.TestProject/NotInParallelTests.cs index b72bb67cfa..c5fc7fd251 100644 --- a/TUnit.TestProject/NotInParallelTests.cs +++ b/TUnit.TestProject/NotInParallelTests.cs @@ -1,9 +1,11 @@ using System.Collections.Concurrent; using TUnit.Assertions; using TUnit.Assertions.Extensions; +using TUnit.TestProject.Attributes; namespace TUnit.TestProject; +[EngineTest(ExpectedResult.Pass)] public class NotInParallelTests { private static readonly ConcurrentBag TestDateTimeRanges = []; diff --git a/TUnit.TestProject/NullableByteArgumentTests.cs b/TUnit.TestProject/NullableByteArgumentTests.cs index d0d908451c..4e1823bfde 100644 --- a/TUnit.TestProject/NullableByteArgumentTests.cs +++ b/TUnit.TestProject/NullableByteArgumentTests.cs @@ -1,5 +1,8 @@ -namespace TUnit.TestProject; +using TUnit.TestProject.Attributes; +namespace TUnit.TestProject; + +[EngineTest(ExpectedResult.Pass)] public class NullableByteArgumentTests { [Test] diff --git a/TUnit.TestProject/NumberArgumentTests.cs b/TUnit.TestProject/NumberArgumentTests.cs index 22e4771477..761407ec10 100644 --- a/TUnit.TestProject/NumberArgumentTests.cs +++ b/TUnit.TestProject/NumberArgumentTests.cs @@ -1,5 +1,8 @@ -namespace TUnit.TestProject; +using TUnit.TestProject.Attributes; +namespace TUnit.TestProject; + +[EngineTest(ExpectedResult.Pass)] public class NumberArgumentTests { [Test] diff --git a/TUnit.TestProject/OptionalArgumentsTests.cs b/TUnit.TestProject/OptionalArgumentsTests.cs index e2d84264b5..13c11f5872 100644 --- a/TUnit.TestProject/OptionalArgumentsTests.cs +++ b/TUnit.TestProject/OptionalArgumentsTests.cs @@ -1,5 +1,8 @@ -namespace TUnit.TestProject; +using TUnit.TestProject.Attributes; +namespace TUnit.TestProject; + +[EngineTest(ExpectedResult.Pass)] public class OptionalArgumentsTests { [Test] diff --git a/TUnit.TestProject/OrderedSetupTests/Base3.cs b/TUnit.TestProject/OrderedSetupTests/Base3.cs index bb77624a0a..44d93d3061 100644 --- a/TUnit.TestProject/OrderedSetupTests/Base3.cs +++ b/TUnit.TestProject/OrderedSetupTests/Base3.cs @@ -1,7 +1,9 @@ using System.Reflection; +using TUnit.TestProject.Attributes; namespace TUnit.TestProject.OrderedSetupTests; +[EngineTest(ExpectedResult.Pass)] #pragma warning disable public class Base3 { diff --git a/TUnit.TestProject/OrderedTests.cs b/TUnit.TestProject/OrderedTests.cs index ca7ccb2d79..47e2d6db3e 100644 --- a/TUnit.TestProject/OrderedTests.cs +++ b/TUnit.TestProject/OrderedTests.cs @@ -1,8 +1,10 @@ using TUnit.Assertions; using TUnit.Assertions.Extensions; +using TUnit.TestProject.Attributes; namespace TUnit.TestProject; +[EngineTest(ExpectedResult.Pass)] public class OrderedTests { private static readonly List RegisteredOrders = []; diff --git a/TUnit.TestProject/OverrideResultsTests.cs b/TUnit.TestProject/OverrideResultsTests.cs index 8bd50b4f58..49f541efb0 100644 --- a/TUnit.TestProject/OverrideResultsTests.cs +++ b/TUnit.TestProject/OverrideResultsTests.cs @@ -1,8 +1,10 @@ using TUnit.Core.Enums; using TUnit.Core.Interfaces; +using TUnit.TestProject.Attributes; namespace TUnit.TestProject; +[EngineTest(ExpectedResult.Pass)] public class OverrideResultsTests { [Test, OverridePass] diff --git a/TUnit.TestProject/ParallelLimiterTests.cs b/TUnit.TestProject/ParallelLimiterTests.cs index fd854d9894..716957cb77 100644 --- a/TUnit.TestProject/ParallelLimiterTests.cs +++ b/TUnit.TestProject/ParallelLimiterTests.cs @@ -1,7 +1,9 @@ -using TUnit.TestProject.Library.Models; +using TUnit.TestProject.Attributes; +using TUnit.TestProject.Library.Models; namespace TUnit.TestProject; +[EngineTest(ExpectedResult.Pass)] [ParallelLimiter] public class ParallelLimiterTests { diff --git a/TUnit.TestProject/ParallelTests.cs b/TUnit.TestProject/ParallelTests.cs index 52294f438d..ff36012377 100644 --- a/TUnit.TestProject/ParallelTests.cs +++ b/TUnit.TestProject/ParallelTests.cs @@ -1,9 +1,11 @@ using System.Collections.Concurrent; using TUnit.Assertions; using TUnit.Assertions.Extensions; +using TUnit.TestProject.Attributes; namespace TUnit.TestProject; +[EngineTest(ExpectedResult.Pass)] public class ParallelTests { private static readonly ConcurrentBag TestDateTimeRanges = []; @@ -19,23 +21,28 @@ public async Task TestOverlaps() [Test, Repeat(3)] public async Task Parallel_Test1() { - await Task.Delay(500); + await Task.Delay(5000); } [Test, Repeat(3)] public async Task Parallel_Test2() { - await Task.Delay(500); + await Task.Delay(5000); } [Test, Repeat(3)] public async Task Parallel_Test3() { - await Task.Delay(500); + await Task.Delay(5000); } private async Task AssertOverlaps() { + if (TestDateTimeRanges.Count < 5) + { + return; + } + foreach (var testDateTimeRange in TestDateTimeRanges) { await Assert.That(TestDateTimeRanges diff --git a/TUnit.TestProject/PassFailTests.cs b/TUnit.TestProject/PassFailTests.cs index 7008b551ea..8edd53964c 100644 --- a/TUnit.TestProject/PassFailTests.cs +++ b/TUnit.TestProject/PassFailTests.cs @@ -1,9 +1,12 @@ -namespace TUnit.TestProject; +using TUnit.TestProject.Attributes; + +namespace TUnit.TestProject; public class PassFailTests { [Test] [Category("Pass")] + [EngineTest(ExpectedResult.Pass)] public void Pass1() { // Dummy method @@ -16,6 +19,7 @@ public void Pass1() [Arguments(4)] [Arguments(5)] [Category("Pass")] + [EngineTest(ExpectedResult.Pass)] public void Pass2(int value) { // Dummy method @@ -30,6 +34,7 @@ public void Pass2(int value) [MethodDataSource(nameof(EnumerableData1))] [MethodDataSource(nameof(EnumerableData2))] [MethodDataSource(nameof(EnumerableData3))] + [EngineTest(ExpectedResult.Pass)] [Category("Pass")] public void Pass3(int value) { @@ -39,6 +44,7 @@ public void Pass3(int value) [Test] [MatrixDataSource] [Category("Pass")] + [EngineTest(ExpectedResult.Pass)] public void Pass4( [Matrix(1, 2, 3, 4, 5)] int value, [Matrix(1, 2, 3, 4)] int value2, @@ -49,6 +55,7 @@ public void Pass4( [Test] [Category("Fail")] + [EngineTest(ExpectedResult.Failure)] public void Fail1() { throw new Exception(); @@ -61,6 +68,7 @@ public void Fail1() [Arguments(4)] [Arguments(5)] [Category("Fail")] + [EngineTest(ExpectedResult.Failure)] public void Fail2(int value) { throw new Exception(); @@ -76,6 +84,7 @@ public void Fail2(int value) [MethodDataSource(nameof(EnumerableData2))] [MethodDataSource(nameof(EnumerableData3))] [Category("Fail")] + [EngineTest(ExpectedResult.Failure)] public void Fail3(int value) { throw new Exception(); @@ -84,6 +93,7 @@ public void Fail3(int value) [Test] [MatrixDataSource] [Category("Fail")] + [EngineTest(ExpectedResult.Failure)] public void Fail4( [Matrix(1, 2, 3, 4, 5)] int value, [Matrix(1, 2, 3, 4)] int value2, diff --git a/TUnit.TestProject/PropertySetterTests.cs b/TUnit.TestProject/PropertySetterTests.cs index 2b43df0cb1..e198652ad4 100644 --- a/TUnit.TestProject/PropertySetterTests.cs +++ b/TUnit.TestProject/PropertySetterTests.cs @@ -1,9 +1,11 @@ #pragma warning disable TUnit0042 using TUnit.Core.Interfaces; +using TUnit.TestProject.Attributes; namespace TUnit.TestProject; +[EngineTest(ExpectedResult.Pass)] [NotInParallel(nameof(PropertySetterTests))] public class PropertySetterTests { diff --git a/TUnit.TestProject/RepeatTests.cs b/TUnit.TestProject/RepeatTests.cs index a67333c948..7fd7b02ea9 100644 --- a/TUnit.TestProject/RepeatTests.cs +++ b/TUnit.TestProject/RepeatTests.cs @@ -1,5 +1,8 @@ -namespace TUnit.TestProject; +using TUnit.TestProject.Attributes; +namespace TUnit.TestProject; + +[EngineTest(ExpectedResult.Pass)] [Repeat(3)] public class RepeatTests { diff --git a/TUnit.TestProject/RetryTests.cs b/TUnit.TestProject/RetryTests.cs index 556e6dbbab..31ca1cd1ae 100644 --- a/TUnit.TestProject/RetryTests.cs +++ b/TUnit.TestProject/RetryTests.cs @@ -1,8 +1,10 @@ using TUnit.Assertions; using TUnit.Assertions.Extensions; +using TUnit.TestProject.Attributes; namespace TUnit.TestProject; +[EngineTest(ExpectedResult.Failure)] [Retry(3)] public class RetryTests { diff --git a/TUnit.TestProject/ReturnTypeTests.cs b/TUnit.TestProject/ReturnTypeTests.cs index dec5010c07..590ac50108 100644 --- a/TUnit.TestProject/ReturnTypeTests.cs +++ b/TUnit.TestProject/ReturnTypeTests.cs @@ -1,5 +1,8 @@ -namespace TUnit.TestProject; +using TUnit.TestProject.Attributes; +namespace TUnit.TestProject; + +[EngineTest(ExpectedResult.Pass)] public class ReturnTypeTests { [Test] diff --git a/TUnit.TestProject/STAThreadTests.cs b/TUnit.TestProject/STAThreadTests.cs index 7f4fbdaeb2..74ecd4f6cf 100644 --- a/TUnit.TestProject/STAThreadTests.cs +++ b/TUnit.TestProject/STAThreadTests.cs @@ -1,10 +1,11 @@ using System.Diagnostics.CodeAnalysis; -using TUnit.Assertions; -using TUnit.Assertions.Extensions; using TUnit.Core.Executors; +using TUnit.TestProject.Attributes; namespace TUnit.TestProject; +[EngineTest(ExpectedResult.Pass)] +[WindowsOnly] [UnconditionalSuppressMessage("Interoperability", "CA1416:Validate platform compatibility")] public class STAThreadTests { diff --git a/TUnit.TestProject/StringArgumentTests.cs b/TUnit.TestProject/StringArgumentTests.cs index 66ad8b2ae2..d48a25ca48 100644 --- a/TUnit.TestProject/StringArgumentTests.cs +++ b/TUnit.TestProject/StringArgumentTests.cs @@ -1,5 +1,8 @@ -namespace TUnit.TestProject; +using TUnit.TestProject.Attributes; +namespace TUnit.TestProject; + +[EngineTest(ExpectedResult.Pass)] public class StringArgumentTests { [Test] diff --git a/TUnit.TestProject/TUnit.TestProject.csproj b/TUnit.TestProject/TUnit.TestProject.csproj index 6f26724809..0b4b5491cd 100644 --- a/TUnit.TestProject/TUnit.TestProject.csproj +++ b/TUnit.TestProject/TUnit.TestProject.csproj @@ -57,10 +57,6 @@ - - - - diff --git a/TUnit.TestProject/TestArtifactTests.cs b/TUnit.TestProject/TestArtifactTests.cs index df76cfaeb4..4ec2030a70 100644 --- a/TUnit.TestProject/TestArtifactTests.cs +++ b/TUnit.TestProject/TestArtifactTests.cs @@ -1,5 +1,8 @@ -namespace TUnit.TestProject; +using TUnit.TestProject.Attributes; +namespace TUnit.TestProject; + +[EngineTest(ExpectedResult.Pass)] public class TestArtifactTests { [Test] diff --git a/TUnit.TestProject/TimeoutCancellationTokenTests.cs b/TUnit.TestProject/TimeoutCancellationTokenTests.cs index 2fb3f54fe0..9ca1cf7354 100644 --- a/TUnit.TestProject/TimeoutCancellationTokenTests.cs +++ b/TUnit.TestProject/TimeoutCancellationTokenTests.cs @@ -1,5 +1,6 @@ using TUnit.Assertions; using TUnit.Assertions.Extensions; +using TUnit.TestProject.Attributes; namespace TUnit.TestProject; @@ -13,6 +14,7 @@ public TimeoutCancellationTokenTests(int value) } [Test] + [EngineTest(ExpectedResult.Pass)] public async Task DefaultTest(CancellationToken cancellationToken) { await Task.Delay(TimeSpan.FromSeconds(5), cancellationToken); @@ -21,6 +23,7 @@ public async Task DefaultTest(CancellationToken cancellationToken) [Test] [Timeout(5_000)] [Category("Blah")] + [EngineTest(ExpectedResult.Failure)] public async Task BasicTest(CancellationToken cancellationToken) { await Task.Delay(TimeSpan.FromMinutes(1), cancellationToken); @@ -28,6 +31,7 @@ public async Task BasicTest(CancellationToken cancellationToken) [Test] [FiveSecondTimeout] + [EngineTest(ExpectedResult.Failure)] public async Task InheritedTimeoutAttribute(CancellationToken cancellationToken) { await Task.Delay(TimeSpan.FromMinutes(1), cancellationToken); @@ -36,6 +40,7 @@ public async Task InheritedTimeoutAttribute(CancellationToken cancellationToken) [Test] [Arguments(1)] [Timeout(5_000)] + [EngineTest(ExpectedResult.Failure)] public async Task DataTest(int value, CancellationToken cancellationToken) { await Assert.That(value).IsEqualTo(1); @@ -44,6 +49,7 @@ public async Task DataTest(int value, CancellationToken cancellationToken) [MethodDataSource(nameof(DataSource))] [Timeout(5_000)] + [EngineTest(ExpectedResult.Failure)] [Test] public async Task DataSourceTest(int value, CancellationToken cancellationToken) { @@ -54,6 +60,7 @@ public async Task DataSourceTest(int value, CancellationToken cancellationToken) [Test] [MatrixDataSource] [Timeout(5_000)] + [EngineTest(ExpectedResult.Failure)] [Category("Blah")] public async Task MatrixTest( [Matrix(1, 2, 3)] int value, diff --git a/TUnit.TestProject/TupleDataSourceDrivenTests.cs b/TUnit.TestProject/TupleDataSourceDrivenTests.cs index 7990acd73a..ed7d3eb5f4 100644 --- a/TUnit.TestProject/TupleDataSourceDrivenTests.cs +++ b/TUnit.TestProject/TupleDataSourceDrivenTests.cs @@ -1,5 +1,8 @@ -namespace TUnit.TestProject; +using TUnit.TestProject.Attributes; +namespace TUnit.TestProject; + +[EngineTest(ExpectedResult.Pass)] public class TupleDataSourceDrivenTests { [Test] diff --git a/TUnit.TestProject/UniqueBuilderContextsOnEnumerableDataGeneratorTests.cs b/TUnit.TestProject/UniqueBuilderContextsOnEnumerableDataGeneratorTests.cs index c76f24e4e7..597c01ab6d 100644 --- a/TUnit.TestProject/UniqueBuilderContextsOnEnumerableDataGeneratorTests.cs +++ b/TUnit.TestProject/UniqueBuilderContextsOnEnumerableDataGeneratorTests.cs @@ -1,7 +1,9 @@ using Shouldly; +using TUnit.TestProject.Attributes; namespace TUnit.TestProject; +[EngineTest(ExpectedResult.Pass)] public class UniqueBuilderContextsOnEnumerableDataGeneratorTests { [Test, UniqueBuilderContextsOnEnumerableDataGeneratorTestsGenerator] diff --git a/TUnit.TestProject/UniqueObjectsOnEnumerableDataGeneratorTests.cs b/TUnit.TestProject/UniqueObjectsOnEnumerableDataGeneratorTests.cs index 81b1d81a90..d4e9a3f2e5 100644 --- a/TUnit.TestProject/UniqueObjectsOnEnumerableDataGeneratorTests.cs +++ b/TUnit.TestProject/UniqueObjectsOnEnumerableDataGeneratorTests.cs @@ -1,8 +1,10 @@ using TUnit.Assertions; using TUnit.Assertions.Extensions; +using TUnit.TestProject.Attributes; namespace TUnit.TestProject; +[EngineTest(ExpectedResult.Pass)] [UniqueObjectsOnEnumerableDataGeneratorTestsGenerator] public class UniqueObjectsOnEnumerableDataGeneratorTests(object classValue) { diff --git a/TUnit.TestProject/WindowsOnlyAttribute.cs b/TUnit.TestProject/WindowsOnlyAttribute.cs new file mode 100644 index 0000000000..5157fe5280 --- /dev/null +++ b/TUnit.TestProject/WindowsOnlyAttribute.cs @@ -0,0 +1,17 @@ +namespace TUnit.TestProject; + +public class WindowsOnlyAttribute : SkipAttribute +{ + public WindowsOnlyAttribute() : base("This test is only applicable on Windows platforms.") + { + } + + public override Task ShouldSkip(BeforeTestContext context) + { + #if NET + return Task.FromResult(!OperatingSystem.IsWindows()); + #else + return Task.FromResult(false); + #endif + } +} diff --git a/TUnit.UnitTests/Services/DependencyCollectorTests.cs b/TUnit.UnitTests/Services/DependencyCollectorTests.cs index 60a0f2107f..2a723ae3c0 100644 --- a/TUnit.UnitTests/Services/DependencyCollectorTests.cs +++ b/TUnit.UnitTests/Services/DependencyCollectorTests.cs @@ -180,6 +180,28 @@ private DiscoveredTest CreateTest(string name, string? dependsOn = null) LazyClassInstance = resettableLazy, }; + var testDiscoveryContext = new BeforeTestDiscoveryContext() + { + TestFilter = "" + }; + var beforeTestDiscoveryContext = new TestDiscoveryContext(testDiscoveryContext) + { + TestFilter = "" + }; + var testSessionContext = new TestSessionContext(beforeTestDiscoveryContext) + { + TestFilter = "", + Id = "test-session-id", + }; + var assemblyHookContext = new AssemblyHookContext(testSessionContext) + { + Assembly = typeof(DependencyCollectorTests).Assembly + }; + var classContext = new ClassHookContext(assemblyHookContext) + { + ClassType = typeof(DependencyCollectorTests) + }; + return new DiscoveredTest(resettableLazy) { TestContext = new TestContext(Substitute.For(), @@ -198,7 +220,7 @@ private DiscoveredTest CreateTest(string name, string? dependsOn = null) TestMethodArguments = [], TestClassProperties = new Dictionary(), TestBuilderContext = new TestBuilderContext() - }), + }, classContext!), TestBody = (_, _) => default(ValueTask), }; } diff --git a/TUnit.UnitTests/TestExtensionsTests.cs b/TUnit.UnitTests/TestExtensionsTests.cs index 050274ed7f..be4470e241 100644 --- a/TUnit.UnitTests/TestExtensionsTests.cs +++ b/TUnit.UnitTests/TestExtensionsTests.cs @@ -102,10 +102,32 @@ private TestContext CreateTestContext< var constructor = typeof(TestContext).GetConstructor( BindingFlags.Instance | BindingFlags.NonPublic, null, - [typeof(IServiceProvider), typeof(TestDetails), typeof(TestMetadata)], + [typeof(IServiceProvider), typeof(TestDetails), typeof(TestMetadata), typeof(ClassHookContext)], [])!; + + var testDiscoveryContext = new BeforeTestDiscoveryContext() + { + TestFilter = "" + }; + var beforeTestDiscoveryContext = new TestDiscoveryContext(testDiscoveryContext) + { + TestFilter = "" + }; + var testSessionContext = new TestSessionContext(beforeTestDiscoveryContext) + { + TestFilter = "", + Id = "test-session-id", + }; + var assemblyHookContext = new AssemblyHookContext(testSessionContext) + { + Assembly = typeof(T).Assembly + }; + var classContext = new ClassHookContext(assemblyHookContext) + { + ClassType = typeof(T) + }; - return (TestContext)constructor.Invoke([null, testDetails, CreateDummyMetadata()]); + return (TestContext)constructor.Invoke([null, testDetails, CreateDummyMetadata(), classContext]); } private TestMetadata CreateDummyMetadata() diff --git a/global.json b/global.json new file mode 100644 index 0000000000..66690f8397 --- /dev/null +++ b/global.json @@ -0,0 +1,6 @@ +{ + "sdk": { + "version": "9.0.0", + "rollForward": "latestFeature" + } +}