diff --git a/TUnit.Core.SourceGenerator.Tests/!newname! b/TUnit.Core.SourceGenerator.Tests/!newname! deleted file mode 100644 index 06aed7c825..0000000000 --- a/TUnit.Core.SourceGenerator.Tests/!newname! +++ /dev/null @@ -1,575 +0,0 @@ -// -#pragma warning disable - -// -#pragma warning disable -#nullable enable -namespace TUnit.Generated; -internal sealed class Tests_GenericArgumentsTest_TestSource_GUID : global::TUnit.Core.Interfaces.SourceGenerator.ITestSource -{ - public async global::System.Collections.Generic.IAsyncEnumerable GetTestsAsync(string testSessionId, [global::System.Runtime.CompilerServices.EnumeratorCancellation] global::System.Threading.CancellationToken cancellationToken = default) - { - // Create generic metadata with concrete type registrations - var genericMetadata = new global::TUnit.Core.GenericTestMetadata - { - TestName = "GenericArgumentsTest", - TestClassType = typeof(global::TUnit.TestProject.Bugs._2136.Tests), - TestMethodName = "GenericArgumentsTest", - Dependencies = global::System.Array.Empty(), - AttributeFactory = () => - [ - new global::TUnit.Core.TestAttribute(), - new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass) - ], - DataSources = global::System.Array.Empty(), - ClassDataSources = global::System.Array.Empty(), - PropertyDataSources = global::System.Array.Empty(), - PropertyInjections = new global::TUnit.Core.PropertyInjectionData[] - { - }, - InheritanceDepth = 0, - FilePath = @"", - LineNumber = 8, - MethodMetadata = new global::TUnit.Core.MethodMetadata - { - Type = typeof(global::TUnit.TestProject.Bugs._2136.Tests), - TypeReference = global::TUnit.Core.TypeReference.CreateConcrete("TUnit.TestProject.Bugs._2136.Tests, TestsBase`1"), - Name = "GenericArgumentsTest", - GenericTypeCount = 1, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeReference = global::TUnit.Core.TypeReference.CreateConcrete("System.Threading.Tasks.Task, System.Private.CoreLib"), - Parameters = new global::TUnit.Core.ParameterMetadata[] - { - new global::TUnit.Core.ParameterMetadata(typeof(object)) - { - Name = "value", - TypeReference = global::TUnit.Core.TypeReference.CreateGenericParameter(0, true, "T"), - IsNullable = false, - ReflectionInfo = global::System.Linq.Enumerable.FirstOrDefault(typeof(global::TUnit.TestProject.Bugs._2136.Tests).GetMethods(global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.Instance | global::System.Reflection.BindingFlags.Static), m => m.Name == "GenericArgumentsTest" && m.GetParameters().Length == 2)?.GetParameters()[0]! - }, - new global::TUnit.Core.ParameterMetadata(typeof(string)) - { - Name = "expected", - TypeReference = global::TUnit.Core.TypeReference.CreateConcrete("string, System.Private.CoreLib"), - IsNullable = false, - ReflectionInfo = global::System.Linq.Enumerable.FirstOrDefault(typeof(global::TUnit.TestProject.Bugs._2136.Tests).GetMethods(global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.Instance | global::System.Reflection.BindingFlags.Static), m => m.Name == "GenericArgumentsTest" && m.GetParameters().Length == 2)?.GetParameters()[1]! - } - }, - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.Bugs._2136.Tests", () => - { - var classMetadata = new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.Bugs._2136.Tests), - TypeReference = global::TUnit.Core.TypeReference.CreateConcrete("TUnit.TestProject.Bugs._2136.Tests, TestsBase`1"), - Name = "Tests", - Namespace = "TUnit.TestProject.Bugs._2136", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", () => new global::TUnit.Core.AssemblyMetadata { Name = "TestsBase`1" }), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }; - // Set ClassMetadata and ContainingTypeMetadata references on properties to avoid circular dependency - foreach (var prop in classMetadata.Properties) - { - prop.ClassMetadata = classMetadata; - prop.ContainingTypeMetadata = classMetadata; - } - return classMetadata; - }) - }, - InstanceFactory = (typeArgs, args) => - { - return new global::TUnit.TestProject.Bugs._2136.Tests(); - }, - TestInvoker = async (instance, args) => - { - var instanceType = instance.GetType(); - var method = instanceType.GetMethod("GenericArgumentsTest", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.Instance); - if (method == null) - { - throw new global::System.InvalidOperationException($"Method 'GenericArgumentsTest' not found on type {instanceType.FullName}"); - } - // Make the method generic if it has type parameters - if (method.IsGenericMethodDefinition) - { - // Use the resolved generic types from the test context - var testContext = global::TUnit.Core.TestContext.Current; - var resolvedTypes = testContext?.TestDetails?.MethodGenericArguments; - if (resolvedTypes != null && resolvedTypes.Length > 0) - { - // Use the pre-resolved generic types - method = method.MakeGenericMethod(resolvedTypes); - } - else - { - // Fallback: infer type arguments from the actual argument types - var typeArgs = new global::System.Type[1]; - for (int i = 0; i < typeArgs.Length && i < args.Length; i++) - { - typeArgs[i] = args[i]?.GetType() ?? typeof(object); - } - method = method.MakeGenericMethod(typeArgs); - } - } - // Prepare method arguments - var methodArgs = new object?[args.Length]; - args.CopyTo(methodArgs, 0); - // Invoke the method - var result = method.Invoke(instance, methodArgs); - if (result is global::System.Threading.Tasks.Task task) - { - await task; - } - }, - ConcreteInstantiations = new global::System.Collections.Generic.Dictionary - { - [(typeof(bool).FullName ?? typeof(bool).Name)] = - new global::TUnit.Core.TestMetadata - { - TestName = "GenericArgumentsTest", - TestClassType = typeof(global::TUnit.TestProject.Bugs._2136.Tests), - TestMethodName = "GenericArgumentsTest", - GenericMethodTypeArguments = new global::System.Type[] { typeof(bool)}, - Dependencies = global::System.Array.Empty(), - AttributeFactory = () => - [ - new global::TUnit.Core.TestAttribute(), - new global::TUnit.Core.ArgumentsAttribute(true, "True"), - new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass) - ], - DataSources = new global::TUnit.Core.IDataSourceAttribute[] - { - new global::TUnit.Core.ArgumentsAttribute(true, "True"), - }, - ClassDataSources = new global::TUnit.Core.IDataSourceAttribute[] - { - }, - PropertyDataSources = global::System.Array.Empty(), - PropertyInjections = new global::TUnit.Core.PropertyInjectionData[] - { - }, - FilePath = @"", - LineNumber = 8, - InheritanceDepth = 0, - TestSessionId = testSessionId, - MethodMetadata = new global::TUnit.Core.MethodMetadata - { - Type = typeof(global::TUnit.TestProject.Bugs._2136.Tests), - TypeReference = global::TUnit.Core.TypeReference.CreateConcrete("TUnit.TestProject.Bugs._2136.Tests, TestsBase`1"), - Name = "GenericArgumentsTest", - GenericTypeCount = 1, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeReference = global::TUnit.Core.TypeReference.CreateConcrete("System.Threading.Tasks.Task, System.Private.CoreLib"), - Parameters = new global::TUnit.Core.ParameterMetadata[] - { - new global::TUnit.Core.ParameterMetadata(typeof(object)) - { - Name = "value", - TypeReference = global::TUnit.Core.TypeReference.CreateGenericParameter(0, true, "T"), - IsNullable = false, - ReflectionInfo = global::System.Linq.Enumerable.FirstOrDefault(typeof(global::TUnit.TestProject.Bugs._2136.Tests).GetMethods(global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.Instance | global::System.Reflection.BindingFlags.Static), m => m.Name == "GenericArgumentsTest" && m.GetParameters().Length == 2)?.GetParameters()[0]! - }, - new global::TUnit.Core.ParameterMetadata(typeof(string)) - { - Name = "expected", - TypeReference = global::TUnit.Core.TypeReference.CreateConcrete("string, System.Private.CoreLib"), - IsNullable = false, - ReflectionInfo = global::System.Linq.Enumerable.FirstOrDefault(typeof(global::TUnit.TestProject.Bugs._2136.Tests).GetMethods(global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.Instance | global::System.Reflection.BindingFlags.Static), m => m.Name == "GenericArgumentsTest" && m.GetParameters().Length == 2)?.GetParameters()[1]! - } - }, - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.Bugs._2136.Tests", () => - { - var classMetadata = new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.Bugs._2136.Tests), - TypeReference = global::TUnit.Core.TypeReference.CreateConcrete("TUnit.TestProject.Bugs._2136.Tests, TestsBase`1"), - Name = "Tests", - Namespace = "TUnit.TestProject.Bugs._2136", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", () => new global::TUnit.Core.AssemblyMetadata { Name = "TestsBase`1" }), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }; - // Set ClassMetadata and ContainingTypeMetadata references on properties to avoid circular dependency - foreach (var prop in classMetadata.Properties) - { - prop.ClassMetadata = classMetadata; - prop.ContainingTypeMetadata = classMetadata; - } - return classMetadata; - }) - }, - InstanceFactory = (typeArgs, args) => - { - return new global::TUnit.TestProject.Bugs._2136.Tests(); - }, - InvokeTypedTest = async (instance, args, cancellationToken) => - { - var typedInstance = (global::TUnit.TestProject.Bugs._2136.Tests)instance; - await global::TUnit.Core.AsyncConvert.Convert(() => typedInstance.GenericArgumentsTest((bool)args[0]!, (string)args[1]!)); - } - } - , - [(typeof(int).FullName ?? typeof(int).Name)] = - new global::TUnit.Core.TestMetadata - { - TestName = "GenericArgumentsTest", - TestClassType = typeof(global::TUnit.TestProject.Bugs._2136.Tests), - TestMethodName = "GenericArgumentsTest", - GenericMethodTypeArguments = new global::System.Type[] { typeof(int)}, - Dependencies = global::System.Array.Empty(), - AttributeFactory = () => - [ - new global::TUnit.Core.TestAttribute(), - new global::TUnit.Core.ArgumentsAttribute(1, "1"), - new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass) - ], - DataSources = new global::TUnit.Core.IDataSourceAttribute[] - { - new global::TUnit.Core.ArgumentsAttribute(1, "1"), - }, - ClassDataSources = new global::TUnit.Core.IDataSourceAttribute[] - { - }, - PropertyDataSources = global::System.Array.Empty(), - PropertyInjections = new global::TUnit.Core.PropertyInjectionData[] - { - }, - FilePath = @"", - LineNumber = 8, - InheritanceDepth = 0, - TestSessionId = testSessionId, - MethodMetadata = new global::TUnit.Core.MethodMetadata - { - Type = typeof(global::TUnit.TestProject.Bugs._2136.Tests), - TypeReference = global::TUnit.Core.TypeReference.CreateConcrete("TUnit.TestProject.Bugs._2136.Tests, TestsBase`1"), - Name = "GenericArgumentsTest", - GenericTypeCount = 1, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeReference = global::TUnit.Core.TypeReference.CreateConcrete("System.Threading.Tasks.Task, System.Private.CoreLib"), - Parameters = new global::TUnit.Core.ParameterMetadata[] - { - new global::TUnit.Core.ParameterMetadata(typeof(object)) - { - Name = "value", - TypeReference = global::TUnit.Core.TypeReference.CreateGenericParameter(0, true, "T"), - IsNullable = false, - ReflectionInfo = global::System.Linq.Enumerable.FirstOrDefault(typeof(global::TUnit.TestProject.Bugs._2136.Tests).GetMethods(global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.Instance | global::System.Reflection.BindingFlags.Static), m => m.Name == "GenericArgumentsTest" && m.GetParameters().Length == 2)?.GetParameters()[0]! - }, - new global::TUnit.Core.ParameterMetadata(typeof(string)) - { - Name = "expected", - TypeReference = global::TUnit.Core.TypeReference.CreateConcrete("string, System.Private.CoreLib"), - IsNullable = false, - ReflectionInfo = global::System.Linq.Enumerable.FirstOrDefault(typeof(global::TUnit.TestProject.Bugs._2136.Tests).GetMethods(global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.Instance | global::System.Reflection.BindingFlags.Static), m => m.Name == "GenericArgumentsTest" && m.GetParameters().Length == 2)?.GetParameters()[1]! - } - }, - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.Bugs._2136.Tests", () => - { - var classMetadata = new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.Bugs._2136.Tests), - TypeReference = global::TUnit.Core.TypeReference.CreateConcrete("TUnit.TestProject.Bugs._2136.Tests, TestsBase`1"), - Name = "Tests", - Namespace = "TUnit.TestProject.Bugs._2136", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", () => new global::TUnit.Core.AssemblyMetadata { Name = "TestsBase`1" }), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }; - // Set ClassMetadata and ContainingTypeMetadata references on properties to avoid circular dependency - foreach (var prop in classMetadata.Properties) - { - prop.ClassMetadata = classMetadata; - prop.ContainingTypeMetadata = classMetadata; - } - return classMetadata; - }) - }, - InstanceFactory = (typeArgs, args) => - { - return new global::TUnit.TestProject.Bugs._2136.Tests(); - }, - InvokeTypedTest = async (instance, args, cancellationToken) => - { - var typedInstance = (global::TUnit.TestProject.Bugs._2136.Tests)instance; - await global::TUnit.Core.AsyncConvert.Convert(() => typedInstance.GenericArgumentsTest((int)args[0]!, (string)args[1]!)); - } - } - , - [(typeof(double).FullName ?? typeof(double).Name)] = - new global::TUnit.Core.TestMetadata - { - TestName = "GenericArgumentsTest", - TestClassType = typeof(global::TUnit.TestProject.Bugs._2136.Tests), - TestMethodName = "GenericArgumentsTest", - GenericMethodTypeArguments = new global::System.Type[] { typeof(double)}, - Dependencies = global::System.Array.Empty(), - AttributeFactory = () => - [ - new global::TUnit.Core.TestAttribute(), - new global::TUnit.Core.ArgumentsAttribute(1.1, "1.1"), - new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass) - ], - DataSources = new global::TUnit.Core.IDataSourceAttribute[] - { - new global::TUnit.Core.ArgumentsAttribute(1.1, "1.1"), - }, - ClassDataSources = new global::TUnit.Core.IDataSourceAttribute[] - { - }, - PropertyDataSources = global::System.Array.Empty(), - PropertyInjections = new global::TUnit.Core.PropertyInjectionData[] - { - }, - FilePath = @"", - LineNumber = 8, - InheritanceDepth = 0, - TestSessionId = testSessionId, - MethodMetadata = new global::TUnit.Core.MethodMetadata - { - Type = typeof(global::TUnit.TestProject.Bugs._2136.Tests), - TypeReference = global::TUnit.Core.TypeReference.CreateConcrete("TUnit.TestProject.Bugs._2136.Tests, TestsBase`1"), - Name = "GenericArgumentsTest", - GenericTypeCount = 1, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeReference = global::TUnit.Core.TypeReference.CreateConcrete("System.Threading.Tasks.Task, System.Private.CoreLib"), - Parameters = new global::TUnit.Core.ParameterMetadata[] - { - new global::TUnit.Core.ParameterMetadata(typeof(object)) - { - Name = "value", - TypeReference = global::TUnit.Core.TypeReference.CreateGenericParameter(0, true, "T"), - IsNullable = false, - ReflectionInfo = global::System.Linq.Enumerable.FirstOrDefault(typeof(global::TUnit.TestProject.Bugs._2136.Tests).GetMethods(global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.Instance | global::System.Reflection.BindingFlags.Static), m => m.Name == "GenericArgumentsTest" && m.GetParameters().Length == 2)?.GetParameters()[0]! - }, - new global::TUnit.Core.ParameterMetadata(typeof(string)) - { - Name = "expected", - TypeReference = global::TUnit.Core.TypeReference.CreateConcrete("string, System.Private.CoreLib"), - IsNullable = false, - ReflectionInfo = global::System.Linq.Enumerable.FirstOrDefault(typeof(global::TUnit.TestProject.Bugs._2136.Tests).GetMethods(global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.Instance | global::System.Reflection.BindingFlags.Static), m => m.Name == "GenericArgumentsTest" && m.GetParameters().Length == 2)?.GetParameters()[1]! - } - }, - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.Bugs._2136.Tests", () => - { - var classMetadata = new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.Bugs._2136.Tests), - TypeReference = global::TUnit.Core.TypeReference.CreateConcrete("TUnit.TestProject.Bugs._2136.Tests, TestsBase`1"), - Name = "Tests", - Namespace = "TUnit.TestProject.Bugs._2136", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", () => new global::TUnit.Core.AssemblyMetadata { Name = "TestsBase`1" }), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }; - // Set ClassMetadata and ContainingTypeMetadata references on properties to avoid circular dependency - foreach (var prop in classMetadata.Properties) - { - prop.ClassMetadata = classMetadata; - prop.ContainingTypeMetadata = classMetadata; - } - return classMetadata; - }) - }, - InstanceFactory = (typeArgs, args) => - { - return new global::TUnit.TestProject.Bugs._2136.Tests(); - }, - InvokeTypedTest = async (instance, args, cancellationToken) => - { - var typedInstance = (global::TUnit.TestProject.Bugs._2136.Tests)instance; - await global::TUnit.Core.AsyncConvert.Convert(() => typedInstance.GenericArgumentsTest((double)args[0]!, (string)args[1]!)); - } - } - , - [(typeof(string).FullName ?? typeof(string).Name)] = - new global::TUnit.Core.TestMetadata - { - TestName = "GenericArgumentsTest", - TestClassType = typeof(global::TUnit.TestProject.Bugs._2136.Tests), - TestMethodName = "GenericArgumentsTest", - GenericMethodTypeArguments = new global::System.Type[] { typeof(string)}, - Dependencies = global::System.Array.Empty(), - AttributeFactory = () => - [ - new global::TUnit.Core.TestAttribute(), - new global::TUnit.Core.ArgumentsAttribute("hello", "hello"), - new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass) - ], - DataSources = new global::TUnit.Core.IDataSourceAttribute[] - { - new global::TUnit.Core.ArgumentsAttribute("hello", "hello"), - }, - ClassDataSources = new global::TUnit.Core.IDataSourceAttribute[] - { - }, - PropertyDataSources = global::System.Array.Empty(), - PropertyInjections = new global::TUnit.Core.PropertyInjectionData[] - { - }, - FilePath = @"", - LineNumber = 8, - InheritanceDepth = 0, - TestSessionId = testSessionId, - MethodMetadata = new global::TUnit.Core.MethodMetadata - { - Type = typeof(global::TUnit.TestProject.Bugs._2136.Tests), - TypeReference = global::TUnit.Core.TypeReference.CreateConcrete("TUnit.TestProject.Bugs._2136.Tests, TestsBase`1"), - Name = "GenericArgumentsTest", - GenericTypeCount = 1, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeReference = global::TUnit.Core.TypeReference.CreateConcrete("System.Threading.Tasks.Task, System.Private.CoreLib"), - Parameters = new global::TUnit.Core.ParameterMetadata[] - { - new global::TUnit.Core.ParameterMetadata(typeof(object)) - { - Name = "value", - TypeReference = global::TUnit.Core.TypeReference.CreateGenericParameter(0, true, "T"), - IsNullable = false, - ReflectionInfo = global::System.Linq.Enumerable.FirstOrDefault(typeof(global::TUnit.TestProject.Bugs._2136.Tests).GetMethods(global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.Instance | global::System.Reflection.BindingFlags.Static), m => m.Name == "GenericArgumentsTest" && m.GetParameters().Length == 2)?.GetParameters()[0]! - }, - new global::TUnit.Core.ParameterMetadata(typeof(string)) - { - Name = "expected", - TypeReference = global::TUnit.Core.TypeReference.CreateConcrete("string, System.Private.CoreLib"), - IsNullable = false, - ReflectionInfo = global::System.Linq.Enumerable.FirstOrDefault(typeof(global::TUnit.TestProject.Bugs._2136.Tests).GetMethods(global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.Instance | global::System.Reflection.BindingFlags.Static), m => m.Name == "GenericArgumentsTest" && m.GetParameters().Length == 2)?.GetParameters()[1]! - } - }, - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.Bugs._2136.Tests", () => - { - var classMetadata = new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.Bugs._2136.Tests), - TypeReference = global::TUnit.Core.TypeReference.CreateConcrete("TUnit.TestProject.Bugs._2136.Tests, TestsBase`1"), - Name = "Tests", - Namespace = "TUnit.TestProject.Bugs._2136", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", () => new global::TUnit.Core.AssemblyMetadata { Name = "TestsBase`1" }), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }; - // Set ClassMetadata and ContainingTypeMetadata references on properties to avoid circular dependency - foreach (var prop in classMetadata.Properties) - { - prop.ClassMetadata = classMetadata; - prop.ContainingTypeMetadata = classMetadata; - } - return classMetadata; - }) - }, - InstanceFactory = (typeArgs, args) => - { - return new global::TUnit.TestProject.Bugs._2136.Tests(); - }, - InvokeTypedTest = async (instance, args, cancellationToken) => - { - var typedInstance = (global::TUnit.TestProject.Bugs._2136.Tests)instance; - await global::TUnit.Core.AsyncConvert.Convert(() => typedInstance.GenericArgumentsTest((string)args[0]!, (string)args[1]!)); - } - } - , - [(typeof(global::TUnit.TestProject.Bugs._2136.MyEnum).FullName ?? typeof(global::TUnit.TestProject.Bugs._2136.MyEnum).Name)] = - new global::TUnit.Core.TestMetadata - { - TestName = "GenericArgumentsTest", - TestClassType = typeof(global::TUnit.TestProject.Bugs._2136.Tests), - TestMethodName = "GenericArgumentsTest", - GenericMethodTypeArguments = new global::System.Type[] { typeof(global::TUnit.TestProject.Bugs._2136.MyEnum)}, - Dependencies = global::System.Array.Empty(), - AttributeFactory = () => - [ - new global::TUnit.Core.TestAttribute(), - new global::TUnit.Core.ArgumentsAttribute(global::TUnit.TestProject.Bugs._2136.MyEnum.Item, "Item"), - new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass) - ], - DataSources = new global::TUnit.Core.IDataSourceAttribute[] - { - new global::TUnit.Core.ArgumentsAttribute(global::TUnit.TestProject.Bugs._2136.MyEnum.Item, "Item"), - }, - ClassDataSources = new global::TUnit.Core.IDataSourceAttribute[] - { - }, - PropertyDataSources = global::System.Array.Empty(), - PropertyInjections = new global::TUnit.Core.PropertyInjectionData[] - { - }, - FilePath = @"", - LineNumber = 8, - InheritanceDepth = 0, - TestSessionId = testSessionId, - MethodMetadata = new global::TUnit.Core.MethodMetadata - { - Type = typeof(global::TUnit.TestProject.Bugs._2136.Tests), - TypeReference = global::TUnit.Core.TypeReference.CreateConcrete("TUnit.TestProject.Bugs._2136.Tests, TestsBase`1"), - Name = "GenericArgumentsTest", - GenericTypeCount = 1, - ReturnType = typeof(global::System.Threading.Tasks.Task), - ReturnTypeReference = global::TUnit.Core.TypeReference.CreateConcrete("System.Threading.Tasks.Task, System.Private.CoreLib"), - Parameters = new global::TUnit.Core.ParameterMetadata[] - { - new global::TUnit.Core.ParameterMetadata(typeof(object)) - { - Name = "value", - TypeReference = global::TUnit.Core.TypeReference.CreateGenericParameter(0, true, "T"), - IsNullable = false, - ReflectionInfo = global::System.Linq.Enumerable.FirstOrDefault(typeof(global::TUnit.TestProject.Bugs._2136.Tests).GetMethods(global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.Instance | global::System.Reflection.BindingFlags.Static), m => m.Name == "GenericArgumentsTest" && m.GetParameters().Length == 2)?.GetParameters()[0]! - }, - new global::TUnit.Core.ParameterMetadata(typeof(string)) - { - Name = "expected", - TypeReference = global::TUnit.Core.TypeReference.CreateConcrete("string, System.Private.CoreLib"), - IsNullable = false, - ReflectionInfo = global::System.Linq.Enumerable.FirstOrDefault(typeof(global::TUnit.TestProject.Bugs._2136.Tests).GetMethods(global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.Instance | global::System.Reflection.BindingFlags.Static), m => m.Name == "GenericArgumentsTest" && m.GetParameters().Length == 2)?.GetParameters()[1]! - } - }, - Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.Bugs._2136.Tests", () => - { - var classMetadata = new global::TUnit.Core.ClassMetadata - { - Type = typeof(global::TUnit.TestProject.Bugs._2136.Tests), - TypeReference = global::TUnit.Core.TypeReference.CreateConcrete("TUnit.TestProject.Bugs._2136.Tests, TestsBase`1"), - Name = "Tests", - Namespace = "TUnit.TestProject.Bugs._2136", - Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", () => new global::TUnit.Core.AssemblyMetadata { Name = "TestsBase`1" }), - Parameters = global::System.Array.Empty(), - Properties = global::System.Array.Empty(), - Parent = null - }; - // Set ClassMetadata and ContainingTypeMetadata references on properties to avoid circular dependency - foreach (var prop in classMetadata.Properties) - { - prop.ClassMetadata = classMetadata; - prop.ContainingTypeMetadata = classMetadata; - } - return classMetadata; - }) - }, - InstanceFactory = (typeArgs, args) => - { - return new global::TUnit.TestProject.Bugs._2136.Tests(); - }, - InvokeTypedTest = async (instance, args, cancellationToken) => - { - var typedInstance = (global::TUnit.TestProject.Bugs._2136.Tests)instance; - await global::TUnit.Core.AsyncConvert.Convert(() => typedInstance.GenericArgumentsTest((global::TUnit.TestProject.Bugs._2136.MyEnum)args[0]!, (string)args[1]!)); - } - } - , - } - }; - genericMetadata.TestSessionId = testSessionId; - yield return genericMetadata; - yield break; - } -} -internal static class Tests_GenericArgumentsTest_ModuleInitializer_GUID -{ - [global::System.Runtime.CompilerServices.ModuleInitializer] - public static void Initialize() - { - global::TUnit.Core.SourceRegistrar.Register(typeof(global::TUnit.TestProject.Bugs._2136.Tests), new Tests_GenericArgumentsTest_TestSource_GUID()); - } -} diff --git a/TUnit.Core.SourceGenerator.Tests/DecimalArgumentTests.Test.verified.txt b/TUnit.Core.SourceGenerator.Tests/DecimalArgumentTests.Test.verified.txt new file mode 100644 index 0000000000..ad36bf82d6 --- /dev/null +++ b/TUnit.Core.SourceGenerator.Tests/DecimalArgumentTests.Test.verified.txt @@ -0,0 +1,1248 @@ +// +#pragma warning disable + +#nullable enable +namespace TUnit.Generated; +internal sealed class DecimalArgumentTests_Transfer_TestSource_GUID : global::TUnit.Core.Interfaces.SourceGenerator.ITestSource +{ + public async global::System.Collections.Generic.IAsyncEnumerable GetTestsAsync(string testSessionId, [global::System.Runtime.CompilerServices.EnumeratorCancellation] global::System.Threading.CancellationToken cancellationToken = default) + { + var metadata = new global::TUnit.Core.TestMetadata + { + TestName = "Transfer", + TestClassType = typeof(global::TUnit.TestProject.DecimalArgumentTests), + TestMethodName = "Transfer", + Dependencies = global::System.Array.Empty(), + AttributeFactory = () => + [ + new global::TUnit.Core.TestAttribute(), + new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass) + ], + DataSources = new global::TUnit.Core.IDataSourceAttribute[] + { + new global::TUnit.Core.ArgumentsAttribute(2_000m, 123_999.00000000000000001m), + new global::TUnit.Core.ArgumentsAttribute(2_000.00000000000000001m, 123_999m), + new global::TUnit.Core.ArgumentsAttribute(2_000.00000000000000001m, 123_999.00000000000000001m), + }, + ClassDataSources = global::System.Array.Empty(), + PropertyDataSources = global::System.Array.Empty(), + PropertyInjections = global::System.Array.Empty(), + InheritanceDepth = 0, + FilePath = @"", + LineNumber = 9, + MethodMetadata = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.DecimalArgumentTests), + TypeReference = global::TUnit.Core.TypeReference.CreateConcrete("TUnit.TestProject.DecimalArgumentTests, TestsBase`1"), + Name = "Transfer", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeReference = global::TUnit.Core.TypeReference.CreateConcrete("System.Threading.Tasks.Task, System.Private.CoreLib"), + Parameters = new global::TUnit.Core.ParameterMetadata[] + { + new global::TUnit.Core.ParameterMetadata(typeof(decimal)) + { + Name = "debit", + TypeReference = global::TUnit.Core.TypeReference.CreateConcrete("decimal, System.Private.CoreLib"), + IsNullable = false, + ReflectionInfo = typeof(global::TUnit.TestProject.DecimalArgumentTests).GetMethod("Transfer", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(decimal), typeof(decimal) }, null)!.GetParameters()[0] + }, + new global::TUnit.Core.ParameterMetadata(typeof(decimal)) + { + Name = "credit", + TypeReference = global::TUnit.Core.TypeReference.CreateConcrete("decimal, System.Private.CoreLib"), + IsNullable = false, + ReflectionInfo = typeof(global::TUnit.TestProject.DecimalArgumentTests).GetMethod("Transfer", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(decimal), typeof(decimal) }, null)!.GetParameters()[1] + } + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.DecimalArgumentTests", () => + { + var classMetadata = new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.DecimalArgumentTests), + TypeReference = global::TUnit.Core.TypeReference.CreateConcrete("TUnit.TestProject.DecimalArgumentTests, TestsBase`1"), + Name = "DecimalArgumentTests", + Namespace = "TUnit.TestProject", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", () => new global::TUnit.Core.AssemblyMetadata { Name = "TestsBase`1" }), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }; + foreach (var prop in classMetadata.Properties) + { + prop.ClassMetadata = classMetadata; + prop.ContainingTypeMetadata = classMetadata; + } + return classMetadata; + }) + }, + InstanceFactory = (typeArgs, args) => new global::TUnit.TestProject.DecimalArgumentTests(), + InvokeTypedTest = async (instance, args, cancellationToken) => + { + switch (args.Length) + { + case 2: + await instance.Transfer(TUnit.Core.Helpers.CastHelper.Cast(args[0]), TUnit.Core.Helpers.CastHelper.Cast(args[1])); + break; + default: + throw new global::System.ArgumentException($"Expected exactly 2 arguments, but got {args.Length}"); + } + }, + }; + metadata.UseRuntimeDataGeneration(testSessionId); + yield return metadata; + yield break; + } +} +internal static class DecimalArgumentTests_Transfer_ModuleInitializer_GUID +{ + [global::System.Runtime.CompilerServices.ModuleInitializer] + public static void Initialize() + { + global::TUnit.Core.SourceRegistrar.Register(typeof(global::TUnit.TestProject.DecimalArgumentTests), new DecimalArgumentTests_Transfer_TestSource_GUID()); + } +} + + +// ===== FILE SEPARATOR ===== + +// +#pragma warning disable + +#nullable enable +namespace TUnit.Generated; +internal sealed class DecimalArgumentTests_SimpleDecimal_TestSource_GUID : global::TUnit.Core.Interfaces.SourceGenerator.ITestSource +{ + public async global::System.Collections.Generic.IAsyncEnumerable GetTestsAsync(string testSessionId, [global::System.Runtime.CompilerServices.EnumeratorCancellation] global::System.Threading.CancellationToken cancellationToken = default) + { + var metadata = new global::TUnit.Core.TestMetadata + { + TestName = "SimpleDecimal", + TestClassType = typeof(global::TUnit.TestProject.DecimalArgumentTests), + TestMethodName = "SimpleDecimal", + Dependencies = global::System.Array.Empty(), + AttributeFactory = () => + [ + new global::TUnit.Core.TestAttribute(), + new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass) + ], + DataSources = new global::TUnit.Core.IDataSourceAttribute[] + { + new global::TUnit.Core.ArgumentsAttribute(123.456m), + }, + ClassDataSources = global::System.Array.Empty(), + PropertyDataSources = global::System.Array.Empty(), + PropertyInjections = global::System.Array.Empty(), + InheritanceDepth = 0, + FilePath = @"", + LineNumber = 29, + MethodMetadata = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.DecimalArgumentTests), + TypeReference = global::TUnit.Core.TypeReference.CreateConcrete("TUnit.TestProject.DecimalArgumentTests, TestsBase`1"), + Name = "SimpleDecimal", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeReference = global::TUnit.Core.TypeReference.CreateConcrete("System.Threading.Tasks.Task, System.Private.CoreLib"), + Parameters = new global::TUnit.Core.ParameterMetadata[] + { + new global::TUnit.Core.ParameterMetadata(typeof(decimal)) + { + Name = "value", + TypeReference = global::TUnit.Core.TypeReference.CreateConcrete("decimal, System.Private.CoreLib"), + IsNullable = false, + ReflectionInfo = typeof(global::TUnit.TestProject.DecimalArgumentTests).GetMethod("SimpleDecimal", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(decimal) }, null)!.GetParameters()[0] + } + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.DecimalArgumentTests", () => + { + var classMetadata = new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.DecimalArgumentTests), + TypeReference = global::TUnit.Core.TypeReference.CreateConcrete("TUnit.TestProject.DecimalArgumentTests, TestsBase`1"), + Name = "DecimalArgumentTests", + Namespace = "TUnit.TestProject", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", () => new global::TUnit.Core.AssemblyMetadata { Name = "TestsBase`1" }), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }; + foreach (var prop in classMetadata.Properties) + { + prop.ClassMetadata = classMetadata; + prop.ContainingTypeMetadata = classMetadata; + } + return classMetadata; + }) + }, + InstanceFactory = (typeArgs, args) => new global::TUnit.TestProject.DecimalArgumentTests(), + InvokeTypedTest = async (instance, args, cancellationToken) => + { + switch (args.Length) + { + case 1: + await instance.SimpleDecimal(TUnit.Core.Helpers.CastHelper.Cast(args[0])); + break; + default: + throw new global::System.ArgumentException($"Expected exactly 1 argument, but got {args.Length}"); + } + }, + }; + metadata.UseRuntimeDataGeneration(testSessionId); + yield return metadata; + yield break; + } +} +internal static class DecimalArgumentTests_SimpleDecimal_ModuleInitializer_GUID +{ + [global::System.Runtime.CompilerServices.ModuleInitializer] + public static void Initialize() + { + global::TUnit.Core.SourceRegistrar.Register(typeof(global::TUnit.TestProject.DecimalArgumentTests), new DecimalArgumentTests_SimpleDecimal_TestSource_GUID()); + } +} + + +// ===== FILE SEPARATOR ===== + +// +#pragma warning disable + +#nullable enable +namespace TUnit.Generated; +internal sealed class DecimalArgumentTests_SmallDecimal_TestSource_GUID : global::TUnit.Core.Interfaces.SourceGenerator.ITestSource +{ + public async global::System.Collections.Generic.IAsyncEnumerable GetTestsAsync(string testSessionId, [global::System.Runtime.CompilerServices.EnumeratorCancellation] global::System.Threading.CancellationToken cancellationToken = default) + { + var metadata = new global::TUnit.Core.TestMetadata + { + TestName = "SmallDecimal", + TestClassType = typeof(global::TUnit.TestProject.DecimalArgumentTests), + TestMethodName = "SmallDecimal", + Dependencies = global::System.Array.Empty(), + AttributeFactory = () => + [ + new global::TUnit.Core.TestAttribute(), + new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass) + ], + DataSources = new global::TUnit.Core.IDataSourceAttribute[] + { + new global::TUnit.Core.ArgumentsAttribute(0.00000000000000001m), + }, + ClassDataSources = global::System.Array.Empty(), + PropertyDataSources = global::System.Array.Empty(), + PropertyInjections = global::System.Array.Empty(), + InheritanceDepth = 0, + FilePath = @"", + LineNumber = 36, + MethodMetadata = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.DecimalArgumentTests), + TypeReference = global::TUnit.Core.TypeReference.CreateConcrete("TUnit.TestProject.DecimalArgumentTests, TestsBase`1"), + Name = "SmallDecimal", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeReference = global::TUnit.Core.TypeReference.CreateConcrete("System.Threading.Tasks.Task, System.Private.CoreLib"), + Parameters = new global::TUnit.Core.ParameterMetadata[] + { + new global::TUnit.Core.ParameterMetadata(typeof(decimal)) + { + Name = "value", + TypeReference = global::TUnit.Core.TypeReference.CreateConcrete("decimal, System.Private.CoreLib"), + IsNullable = false, + ReflectionInfo = typeof(global::TUnit.TestProject.DecimalArgumentTests).GetMethod("SmallDecimal", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(decimal) }, null)!.GetParameters()[0] + } + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.DecimalArgumentTests", () => + { + var classMetadata = new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.DecimalArgumentTests), + TypeReference = global::TUnit.Core.TypeReference.CreateConcrete("TUnit.TestProject.DecimalArgumentTests, TestsBase`1"), + Name = "DecimalArgumentTests", + Namespace = "TUnit.TestProject", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", () => new global::TUnit.Core.AssemblyMetadata { Name = "TestsBase`1" }), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }; + foreach (var prop in classMetadata.Properties) + { + prop.ClassMetadata = classMetadata; + prop.ContainingTypeMetadata = classMetadata; + } + return classMetadata; + }) + }, + InstanceFactory = (typeArgs, args) => new global::TUnit.TestProject.DecimalArgumentTests(), + InvokeTypedTest = async (instance, args, cancellationToken) => + { + switch (args.Length) + { + case 1: + await instance.SmallDecimal(TUnit.Core.Helpers.CastHelper.Cast(args[0])); + break; + default: + throw new global::System.ArgumentException($"Expected exactly 1 argument, but got {args.Length}"); + } + }, + }; + metadata.UseRuntimeDataGeneration(testSessionId); + yield return metadata; + yield break; + } +} +internal static class DecimalArgumentTests_SmallDecimal_ModuleInitializer_GUID +{ + [global::System.Runtime.CompilerServices.ModuleInitializer] + public static void Initialize() + { + global::TUnit.Core.SourceRegistrar.Register(typeof(global::TUnit.TestProject.DecimalArgumentTests), new DecimalArgumentTests_SmallDecimal_TestSource_GUID()); + } +} + + +// ===== FILE SEPARATOR ===== + +// +#pragma warning disable + +#nullable enable +namespace TUnit.Generated; +internal sealed class DecimalArgumentTests_MaxDecimal_TestSource_GUID : global::TUnit.Core.Interfaces.SourceGenerator.ITestSource +{ + public async global::System.Collections.Generic.IAsyncEnumerable GetTestsAsync(string testSessionId, [global::System.Runtime.CompilerServices.EnumeratorCancellation] global::System.Threading.CancellationToken cancellationToken = default) + { + var metadata = new global::TUnit.Core.TestMetadata + { + TestName = "MaxDecimal", + TestClassType = typeof(global::TUnit.TestProject.DecimalArgumentTests), + TestMethodName = "MaxDecimal", + Dependencies = global::System.Array.Empty(), + AttributeFactory = () => + [ + new global::TUnit.Core.TestAttribute(), + new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass) + ], + DataSources = new global::TUnit.Core.IDataSourceAttribute[] + { + new global::TUnit.Core.ArgumentsAttribute("79228162514264337593543950335"), + }, + ClassDataSources = global::System.Array.Empty(), + PropertyDataSources = global::System.Array.Empty(), + PropertyInjections = global::System.Array.Empty(), + InheritanceDepth = 0, + FilePath = @"", + LineNumber = 43, + MethodMetadata = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.DecimalArgumentTests), + TypeReference = global::TUnit.Core.TypeReference.CreateConcrete("TUnit.TestProject.DecimalArgumentTests, TestsBase`1"), + Name = "MaxDecimal", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeReference = global::TUnit.Core.TypeReference.CreateConcrete("System.Threading.Tasks.Task, System.Private.CoreLib"), + Parameters = new global::TUnit.Core.ParameterMetadata[] + { + new global::TUnit.Core.ParameterMetadata(typeof(decimal)) + { + Name = "value", + TypeReference = global::TUnit.Core.TypeReference.CreateConcrete("decimal, System.Private.CoreLib"), + IsNullable = false, + ReflectionInfo = typeof(global::TUnit.TestProject.DecimalArgumentTests).GetMethod("MaxDecimal", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(decimal) }, null)!.GetParameters()[0] + } + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.DecimalArgumentTests", () => + { + var classMetadata = new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.DecimalArgumentTests), + TypeReference = global::TUnit.Core.TypeReference.CreateConcrete("TUnit.TestProject.DecimalArgumentTests, TestsBase`1"), + Name = "DecimalArgumentTests", + Namespace = "TUnit.TestProject", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", () => new global::TUnit.Core.AssemblyMetadata { Name = "TestsBase`1" }), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }; + foreach (var prop in classMetadata.Properties) + { + prop.ClassMetadata = classMetadata; + prop.ContainingTypeMetadata = classMetadata; + } + return classMetadata; + }) + }, + InstanceFactory = (typeArgs, args) => new global::TUnit.TestProject.DecimalArgumentTests(), + InvokeTypedTest = async (instance, args, cancellationToken) => + { + switch (args.Length) + { + case 1: + await instance.MaxDecimal(TUnit.Core.Helpers.CastHelper.Cast(args[0])); + break; + default: + throw new global::System.ArgumentException($"Expected exactly 1 argument, but got {args.Length}"); + } + }, + }; + metadata.UseRuntimeDataGeneration(testSessionId); + yield return metadata; + yield break; + } +} +internal static class DecimalArgumentTests_MaxDecimal_ModuleInitializer_GUID +{ + [global::System.Runtime.CompilerServices.ModuleInitializer] + public static void Initialize() + { + global::TUnit.Core.SourceRegistrar.Register(typeof(global::TUnit.TestProject.DecimalArgumentTests), new DecimalArgumentTests_MaxDecimal_TestSource_GUID()); + } +} + + +// ===== FILE SEPARATOR ===== + +// +#pragma warning disable + +#nullable enable +namespace TUnit.Generated; +internal sealed class DecimalArgumentTests_MinDecimal_TestSource_GUID : global::TUnit.Core.Interfaces.SourceGenerator.ITestSource +{ + public async global::System.Collections.Generic.IAsyncEnumerable GetTestsAsync(string testSessionId, [global::System.Runtime.CompilerServices.EnumeratorCancellation] global::System.Threading.CancellationToken cancellationToken = default) + { + var metadata = new global::TUnit.Core.TestMetadata + { + TestName = "MinDecimal", + TestClassType = typeof(global::TUnit.TestProject.DecimalArgumentTests), + TestMethodName = "MinDecimal", + Dependencies = global::System.Array.Empty(), + AttributeFactory = () => + [ + new global::TUnit.Core.TestAttribute(), + new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass) + ], + DataSources = new global::TUnit.Core.IDataSourceAttribute[] + { + new global::TUnit.Core.ArgumentsAttribute("-79228162514264337593543950335"), + }, + ClassDataSources = global::System.Array.Empty(), + PropertyDataSources = global::System.Array.Empty(), + PropertyInjections = global::System.Array.Empty(), + InheritanceDepth = 0, + FilePath = @"", + LineNumber = 50, + MethodMetadata = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.DecimalArgumentTests), + TypeReference = global::TUnit.Core.TypeReference.CreateConcrete("TUnit.TestProject.DecimalArgumentTests, TestsBase`1"), + Name = "MinDecimal", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeReference = global::TUnit.Core.TypeReference.CreateConcrete("System.Threading.Tasks.Task, System.Private.CoreLib"), + Parameters = new global::TUnit.Core.ParameterMetadata[] + { + new global::TUnit.Core.ParameterMetadata(typeof(decimal)) + { + Name = "value", + TypeReference = global::TUnit.Core.TypeReference.CreateConcrete("decimal, System.Private.CoreLib"), + IsNullable = false, + ReflectionInfo = typeof(global::TUnit.TestProject.DecimalArgumentTests).GetMethod("MinDecimal", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(decimal) }, null)!.GetParameters()[0] + } + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.DecimalArgumentTests", () => + { + var classMetadata = new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.DecimalArgumentTests), + TypeReference = global::TUnit.Core.TypeReference.CreateConcrete("TUnit.TestProject.DecimalArgumentTests, TestsBase`1"), + Name = "DecimalArgumentTests", + Namespace = "TUnit.TestProject", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", () => new global::TUnit.Core.AssemblyMetadata { Name = "TestsBase`1" }), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }; + foreach (var prop in classMetadata.Properties) + { + prop.ClassMetadata = classMetadata; + prop.ContainingTypeMetadata = classMetadata; + } + return classMetadata; + }) + }, + InstanceFactory = (typeArgs, args) => new global::TUnit.TestProject.DecimalArgumentTests(), + InvokeTypedTest = async (instance, args, cancellationToken) => + { + switch (args.Length) + { + case 1: + await instance.MinDecimal(TUnit.Core.Helpers.CastHelper.Cast(args[0])); + break; + default: + throw new global::System.ArgumentException($"Expected exactly 1 argument, but got {args.Length}"); + } + }, + }; + metadata.UseRuntimeDataGeneration(testSessionId); + yield return metadata; + yield break; + } +} +internal static class DecimalArgumentTests_MinDecimal_ModuleInitializer_GUID +{ + [global::System.Runtime.CompilerServices.ModuleInitializer] + public static void Initialize() + { + global::TUnit.Core.SourceRegistrar.Register(typeof(global::TUnit.TestProject.DecimalArgumentTests), new DecimalArgumentTests_MinDecimal_TestSource_GUID()); + } +} + + +// ===== FILE SEPARATOR ===== + +// +#pragma warning disable + +#nullable enable +namespace TUnit.Generated; +internal sealed class DecimalArgumentTests_ExplicitDecimalValue_TestSource_GUID : global::TUnit.Core.Interfaces.SourceGenerator.ITestSource +{ + public async global::System.Collections.Generic.IAsyncEnumerable GetTestsAsync(string testSessionId, [global::System.Runtime.CompilerServices.EnumeratorCancellation] global::System.Threading.CancellationToken cancellationToken = default) + { + var metadata = new global::TUnit.Core.TestMetadata + { + TestName = "ExplicitDecimalValue", + TestClassType = typeof(global::TUnit.TestProject.DecimalArgumentTests), + TestMethodName = "ExplicitDecimalValue", + Dependencies = global::System.Array.Empty(), + AttributeFactory = () => + [ + new global::TUnit.Core.TestAttribute(), + new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass) + ], + DataSources = new global::TUnit.Core.IDataSourceAttribute[] + { + new global::TUnit.Core.ArgumentsAttribute("123.456"), + }, + ClassDataSources = global::System.Array.Empty(), + PropertyDataSources = global::System.Array.Empty(), + PropertyInjections = global::System.Array.Empty(), + InheritanceDepth = 0, + FilePath = @"", + LineNumber = 57, + MethodMetadata = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.DecimalArgumentTests), + TypeReference = global::TUnit.Core.TypeReference.CreateConcrete("TUnit.TestProject.DecimalArgumentTests, TestsBase`1"), + Name = "ExplicitDecimalValue", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeReference = global::TUnit.Core.TypeReference.CreateConcrete("System.Threading.Tasks.Task, System.Private.CoreLib"), + Parameters = new global::TUnit.Core.ParameterMetadata[] + { + new global::TUnit.Core.ParameterMetadata(typeof(decimal)) + { + Name = "value", + TypeReference = global::TUnit.Core.TypeReference.CreateConcrete("decimal, System.Private.CoreLib"), + IsNullable = false, + ReflectionInfo = typeof(global::TUnit.TestProject.DecimalArgumentTests).GetMethod("ExplicitDecimalValue", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(decimal) }, null)!.GetParameters()[0] + } + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.DecimalArgumentTests", () => + { + var classMetadata = new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.DecimalArgumentTests), + TypeReference = global::TUnit.Core.TypeReference.CreateConcrete("TUnit.TestProject.DecimalArgumentTests, TestsBase`1"), + Name = "DecimalArgumentTests", + Namespace = "TUnit.TestProject", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", () => new global::TUnit.Core.AssemblyMetadata { Name = "TestsBase`1" }), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }; + foreach (var prop in classMetadata.Properties) + { + prop.ClassMetadata = classMetadata; + prop.ContainingTypeMetadata = classMetadata; + } + return classMetadata; + }) + }, + InstanceFactory = (typeArgs, args) => new global::TUnit.TestProject.DecimalArgumentTests(), + InvokeTypedTest = async (instance, args, cancellationToken) => + { + switch (args.Length) + { + case 1: + await instance.ExplicitDecimalValue(TUnit.Core.Helpers.CastHelper.Cast(args[0])); + break; + default: + throw new global::System.ArgumentException($"Expected exactly 1 argument, but got {args.Length}"); + } + }, + }; + metadata.UseRuntimeDataGeneration(testSessionId); + yield return metadata; + yield break; + } +} +internal static class DecimalArgumentTests_ExplicitDecimalValue_ModuleInitializer_GUID +{ + [global::System.Runtime.CompilerServices.ModuleInitializer] + public static void Initialize() + { + global::TUnit.Core.SourceRegistrar.Register(typeof(global::TUnit.TestProject.DecimalArgumentTests), new DecimalArgumentTests_ExplicitDecimalValue_TestSource_GUID()); + } +} + + +// ===== FILE SEPARATOR ===== + +// +#pragma warning disable + +#nullable enable +namespace TUnit.Generated; +internal sealed class DecimalArgumentTests_MultipleDecimals_TestSource_GUID : global::TUnit.Core.Interfaces.SourceGenerator.ITestSource +{ + public async global::System.Collections.Generic.IAsyncEnumerable GetTestsAsync(string testSessionId, [global::System.Runtime.CompilerServices.EnumeratorCancellation] global::System.Threading.CancellationToken cancellationToken = default) + { + var metadata = new global::TUnit.Core.TestMetadata + { + TestName = "MultipleDecimals", + TestClassType = typeof(global::TUnit.TestProject.DecimalArgumentTests), + TestMethodName = "MultipleDecimals", + Dependencies = global::System.Array.Empty(), + AttributeFactory = () => + [ + new global::TUnit.Core.TestAttribute(), + new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass) + ], + DataSources = new global::TUnit.Core.IDataSourceAttribute[] + { + new global::TUnit.Core.ArgumentsAttribute(1.1m, 2.2m, 3.3m), + }, + ClassDataSources = global::System.Array.Empty(), + PropertyDataSources = global::System.Array.Empty(), + PropertyInjections = global::System.Array.Empty(), + InheritanceDepth = 0, + FilePath = @"", + LineNumber = 64, + MethodMetadata = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.DecimalArgumentTests), + TypeReference = global::TUnit.Core.TypeReference.CreateConcrete("TUnit.TestProject.DecimalArgumentTests, TestsBase`1"), + Name = "MultipleDecimals", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeReference = global::TUnit.Core.TypeReference.CreateConcrete("System.Threading.Tasks.Task, System.Private.CoreLib"), + Parameters = new global::TUnit.Core.ParameterMetadata[] + { + new global::TUnit.Core.ParameterMetadata(typeof(decimal)) + { + Name = "a", + TypeReference = global::TUnit.Core.TypeReference.CreateConcrete("decimal, System.Private.CoreLib"), + IsNullable = false, + ReflectionInfo = typeof(global::TUnit.TestProject.DecimalArgumentTests).GetMethod("MultipleDecimals", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(decimal), typeof(decimal), typeof(decimal) }, null)!.GetParameters()[0] + }, + new global::TUnit.Core.ParameterMetadata(typeof(decimal)) + { + Name = "b", + TypeReference = global::TUnit.Core.TypeReference.CreateConcrete("decimal, System.Private.CoreLib"), + IsNullable = false, + ReflectionInfo = typeof(global::TUnit.TestProject.DecimalArgumentTests).GetMethod("MultipleDecimals", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(decimal), typeof(decimal), typeof(decimal) }, null)!.GetParameters()[1] + }, + new global::TUnit.Core.ParameterMetadata(typeof(decimal)) + { + Name = "c", + TypeReference = global::TUnit.Core.TypeReference.CreateConcrete("decimal, System.Private.CoreLib"), + IsNullable = false, + ReflectionInfo = typeof(global::TUnit.TestProject.DecimalArgumentTests).GetMethod("MultipleDecimals", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(decimal), typeof(decimal), typeof(decimal) }, null)!.GetParameters()[2] + } + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.DecimalArgumentTests", () => + { + var classMetadata = new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.DecimalArgumentTests), + TypeReference = global::TUnit.Core.TypeReference.CreateConcrete("TUnit.TestProject.DecimalArgumentTests, TestsBase`1"), + Name = "DecimalArgumentTests", + Namespace = "TUnit.TestProject", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", () => new global::TUnit.Core.AssemblyMetadata { Name = "TestsBase`1" }), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }; + foreach (var prop in classMetadata.Properties) + { + prop.ClassMetadata = classMetadata; + prop.ContainingTypeMetadata = classMetadata; + } + return classMetadata; + }) + }, + InstanceFactory = (typeArgs, args) => new global::TUnit.TestProject.DecimalArgumentTests(), + InvokeTypedTest = async (instance, args, cancellationToken) => + { + switch (args.Length) + { + case 3: + await instance.MultipleDecimals(TUnit.Core.Helpers.CastHelper.Cast(args[0]), TUnit.Core.Helpers.CastHelper.Cast(args[1]), TUnit.Core.Helpers.CastHelper.Cast(args[2])); + break; + default: + throw new global::System.ArgumentException($"Expected exactly 3 arguments, but got {args.Length}"); + } + }, + }; + metadata.UseRuntimeDataGeneration(testSessionId); + yield return metadata; + yield break; + } +} +internal static class DecimalArgumentTests_MultipleDecimals_ModuleInitializer_GUID +{ + [global::System.Runtime.CompilerServices.ModuleInitializer] + public static void Initialize() + { + global::TUnit.Core.SourceRegistrar.Register(typeof(global::TUnit.TestProject.DecimalArgumentTests), new DecimalArgumentTests_MultipleDecimals_TestSource_GUID()); + } +} + + +// ===== FILE SEPARATOR ===== + +// +#pragma warning disable + +#nullable enable +namespace TUnit.Generated; +internal sealed class DecimalArgumentTests_Test_TestSource_GUID : global::TUnit.Core.Interfaces.SourceGenerator.ITestSource +{ + public async global::System.Collections.Generic.IAsyncEnumerable GetTestsAsync(string testSessionId, [global::System.Runtime.CompilerServices.EnumeratorCancellation] global::System.Threading.CancellationToken cancellationToken = default) + { + var metadata = new global::TUnit.Core.TestMetadata + { + TestName = "Test", + TestClassType = typeof(global::TUnit.TestProject.DecimalArgumentTests), + TestMethodName = "Test", + Dependencies = global::System.Array.Empty(), + AttributeFactory = () => + [ + new global::TUnit.Core.TestAttribute(), + new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass) + ], + DataSources = new global::TUnit.Core.IDataSourceAttribute[] + { + new global::TUnit.Core.ArgumentsAttribute(0.5m), + new global::TUnit.Core.ArgumentsAttribute(0.75m), + new global::TUnit.Core.ArgumentsAttribute(1m), + }, + ClassDataSources = global::System.Array.Empty(), + PropertyDataSources = global::System.Array.Empty(), + PropertyInjections = global::System.Array.Empty(), + InheritanceDepth = 0, + FilePath = @"", + LineNumber = 73, + MethodMetadata = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.DecimalArgumentTests), + TypeReference = global::TUnit.Core.TypeReference.CreateConcrete("TUnit.TestProject.DecimalArgumentTests, TestsBase`1"), + Name = "Test", + GenericTypeCount = 0, + ReturnType = typeof(void), + ReturnTypeReference = global::TUnit.Core.TypeReference.CreateConcrete("void, System.Private.CoreLib"), + Parameters = new global::TUnit.Core.ParameterMetadata[] + { + new global::TUnit.Core.ParameterMetadata(typeof(decimal)) + { + Name = "test", + TypeReference = global::TUnit.Core.TypeReference.CreateConcrete("decimal, System.Private.CoreLib"), + IsNullable = false, + ReflectionInfo = typeof(global::TUnit.TestProject.DecimalArgumentTests).GetMethod("Test", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(decimal) }, null)!.GetParameters()[0] + } + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.DecimalArgumentTests", () => + { + var classMetadata = new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.DecimalArgumentTests), + TypeReference = global::TUnit.Core.TypeReference.CreateConcrete("TUnit.TestProject.DecimalArgumentTests, TestsBase`1"), + Name = "DecimalArgumentTests", + Namespace = "TUnit.TestProject", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", () => new global::TUnit.Core.AssemblyMetadata { Name = "TestsBase`1" }), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }; + foreach (var prop in classMetadata.Properties) + { + prop.ClassMetadata = classMetadata; + prop.ContainingTypeMetadata = classMetadata; + } + return classMetadata; + }) + }, + InstanceFactory = (typeArgs, args) => new global::TUnit.TestProject.DecimalArgumentTests(), + InvokeTypedTest = async (instance, args, cancellationToken) => + { + switch (args.Length) + { + case 1: + instance.Test(TUnit.Core.Helpers.CastHelper.Cast(args[0])); + break; + default: + throw new global::System.ArgumentException($"Expected exactly 1 argument, but got {args.Length}"); + } + await global::System.Threading.Tasks.Task.CompletedTask; + }, + }; + metadata.UseRuntimeDataGeneration(testSessionId); + yield return metadata; + yield break; + } +} +internal static class DecimalArgumentTests_Test_ModuleInitializer_GUID +{ + [global::System.Runtime.CompilerServices.ModuleInitializer] + public static void Initialize() + { + global::TUnit.Core.SourceRegistrar.Register(typeof(global::TUnit.TestProject.DecimalArgumentTests), new DecimalArgumentTests_Test_TestSource_GUID()); + } +} + + +// ===== FILE SEPARATOR ===== + +// +#pragma warning disable + +#nullable enable +namespace TUnit.Generated; +internal sealed class DecimalArgumentTests_TransactionDiscountCalculations_TestSource_GUID : global::TUnit.Core.Interfaces.SourceGenerator.ITestSource +{ + public async global::System.Collections.Generic.IAsyncEnumerable GetTestsAsync(string testSessionId, [global::System.Runtime.CompilerServices.EnumeratorCancellation] global::System.Threading.CancellationToken cancellationToken = default) + { + var metadata = new global::TUnit.Core.TestMetadata + { + TestName = "TransactionDiscountCalculations", + TestClassType = typeof(global::TUnit.TestProject.DecimalArgumentTests), + TestMethodName = "TransactionDiscountCalculations", + Dependencies = global::System.Array.Empty(), + AttributeFactory = () => + [ + new global::TUnit.Core.TestAttribute(), + new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass) + ], + DataSources = new global::TUnit.Core.IDataSourceAttribute[] + { + new global::TUnit.Core.ArgumentsAttribute(50m, 75m, 70m, 5m, 0m, true), + new global::TUnit.Core.ArgumentsAttribute(70m, 75m, 70m, 5m, 5m, true), + new global::TUnit.Core.ArgumentsAttribute(70m, 75m, 70m, 5m, 0m, false), + }, + ClassDataSources = global::System.Array.Empty(), + PropertyDataSources = global::System.Array.Empty(), + PropertyInjections = global::System.Array.Empty(), + InheritanceDepth = 0, + FilePath = @"", + LineNumber = 82, + MethodMetadata = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.DecimalArgumentTests), + TypeReference = global::TUnit.Core.TypeReference.CreateConcrete("TUnit.TestProject.DecimalArgumentTests, TestsBase`1"), + Name = "TransactionDiscountCalculations", + GenericTypeCount = 0, + ReturnType = typeof(void), + ReturnTypeReference = global::TUnit.Core.TypeReference.CreateConcrete("void, System.Private.CoreLib"), + Parameters = new global::TUnit.Core.ParameterMetadata[] + { + new global::TUnit.Core.ParameterMetadata(typeof(decimal)) + { + Name = "amountPaying", + TypeReference = global::TUnit.Core.TypeReference.CreateConcrete("decimal, System.Private.CoreLib"), + IsNullable = false, + ReflectionInfo = typeof(global::TUnit.TestProject.DecimalArgumentTests).GetMethod("TransactionDiscountCalculations", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(decimal), typeof(decimal), typeof(decimal), typeof(decimal), typeof(decimal), typeof(bool) }, null)!.GetParameters()[0] + }, + new global::TUnit.Core.ParameterMetadata(typeof(decimal)) + { + Name = "invoiceBalance", + TypeReference = global::TUnit.Core.TypeReference.CreateConcrete("decimal, System.Private.CoreLib"), + IsNullable = false, + ReflectionInfo = typeof(global::TUnit.TestProject.DecimalArgumentTests).GetMethod("TransactionDiscountCalculations", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(decimal), typeof(decimal), typeof(decimal), typeof(decimal), typeof(decimal), typeof(bool) }, null)!.GetParameters()[1] + }, + new global::TUnit.Core.ParameterMetadata(typeof(decimal)) + { + Name = "invoiceBalanceDue", + TypeReference = global::TUnit.Core.TypeReference.CreateConcrete("decimal, System.Private.CoreLib"), + IsNullable = false, + ReflectionInfo = typeof(global::TUnit.TestProject.DecimalArgumentTests).GetMethod("TransactionDiscountCalculations", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(decimal), typeof(decimal), typeof(decimal), typeof(decimal), typeof(decimal), typeof(bool) }, null)!.GetParameters()[2] + }, + new global::TUnit.Core.ParameterMetadata(typeof(decimal)) + { + Name = "discountAmount", + TypeReference = global::TUnit.Core.TypeReference.CreateConcrete("decimal, System.Private.CoreLib"), + IsNullable = false, + ReflectionInfo = typeof(global::TUnit.TestProject.DecimalArgumentTests).GetMethod("TransactionDiscountCalculations", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(decimal), typeof(decimal), typeof(decimal), typeof(decimal), typeof(decimal), typeof(bool) }, null)!.GetParameters()[3] + }, + new global::TUnit.Core.ParameterMetadata(typeof(decimal)) + { + Name = "appliedDiscountAmount", + TypeReference = global::TUnit.Core.TypeReference.CreateConcrete("decimal, System.Private.CoreLib"), + IsNullable = false, + ReflectionInfo = typeof(global::TUnit.TestProject.DecimalArgumentTests).GetMethod("TransactionDiscountCalculations", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(decimal), typeof(decimal), typeof(decimal), typeof(decimal), typeof(decimal), typeof(bool) }, null)!.GetParameters()[4] + }, + new global::TUnit.Core.ParameterMetadata(typeof(bool)) + { + Name = "discountAllowedForUser", + TypeReference = global::TUnit.Core.TypeReference.CreateConcrete("bool, System.Private.CoreLib"), + IsNullable = false, + ReflectionInfo = typeof(global::TUnit.TestProject.DecimalArgumentTests).GetMethod("TransactionDiscountCalculations", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(decimal), typeof(decimal), typeof(decimal), typeof(decimal), typeof(decimal), typeof(bool) }, null)!.GetParameters()[5] + } + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.DecimalArgumentTests", () => + { + var classMetadata = new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.DecimalArgumentTests), + TypeReference = global::TUnit.Core.TypeReference.CreateConcrete("TUnit.TestProject.DecimalArgumentTests, TestsBase`1"), + Name = "DecimalArgumentTests", + Namespace = "TUnit.TestProject", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", () => new global::TUnit.Core.AssemblyMetadata { Name = "TestsBase`1" }), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }; + foreach (var prop in classMetadata.Properties) + { + prop.ClassMetadata = classMetadata; + prop.ContainingTypeMetadata = classMetadata; + } + return classMetadata; + }) + }, + InstanceFactory = (typeArgs, args) => new global::TUnit.TestProject.DecimalArgumentTests(), + InvokeTypedTest = async (instance, args, cancellationToken) => + { + switch (args.Length) + { + case 6: + instance.TransactionDiscountCalculations(TUnit.Core.Helpers.CastHelper.Cast(args[0]), TUnit.Core.Helpers.CastHelper.Cast(args[1]), TUnit.Core.Helpers.CastHelper.Cast(args[2]), TUnit.Core.Helpers.CastHelper.Cast(args[3]), TUnit.Core.Helpers.CastHelper.Cast(args[4]), TUnit.Core.Helpers.CastHelper.Cast(args[5])); + break; + default: + throw new global::System.ArgumentException($"Expected exactly 6 arguments, but got {args.Length}"); + } + await global::System.Threading.Tasks.Task.CompletedTask; + }, + }; + metadata.UseRuntimeDataGeneration(testSessionId); + yield return metadata; + yield break; + } +} +internal static class DecimalArgumentTests_TransactionDiscountCalculations_ModuleInitializer_GUID +{ + [global::System.Runtime.CompilerServices.ModuleInitializer] + public static void Initialize() + { + global::TUnit.Core.SourceRegistrar.Register(typeof(global::TUnit.TestProject.DecimalArgumentTests), new DecimalArgumentTests_TransactionDiscountCalculations_TestSource_GUID()); + } +} + + +// ===== FILE SEPARATOR ===== + +// +#pragma warning disable + +#nullable enable +namespace TUnit.Generated; +internal sealed class DecimalArgumentTests_Equality3_TestSource_GUID : global::TUnit.Core.Interfaces.SourceGenerator.ITestSource +{ + public async global::System.Collections.Generic.IAsyncEnumerable GetTestsAsync(string testSessionId, [global::System.Runtime.CompilerServices.EnumeratorCancellation] global::System.Threading.CancellationToken cancellationToken = default) + { + var metadata = new global::TUnit.Core.TestMetadata + { + TestName = "Equality3", + TestClassType = typeof(global::TUnit.TestProject.DecimalArgumentTests), + TestMethodName = "Equality3", + Dependencies = global::System.Array.Empty(), + AttributeFactory = () => + [ + new global::TUnit.Core.TestAttribute(), + new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass) + ], + DataSources = new global::TUnit.Core.IDataSourceAttribute[] + { + new global::TUnit.Core.ArgumentsAttribute(2_000.00000000000000001m), + }, + ClassDataSources = global::System.Array.Empty(), + PropertyDataSources = global::System.Array.Empty(), + PropertyInjections = global::System.Array.Empty(), + InheritanceDepth = 0, + FilePath = @"", + LineNumber = 91, + MethodMetadata = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.DecimalArgumentTests), + TypeReference = global::TUnit.Core.TypeReference.CreateConcrete("TUnit.TestProject.DecimalArgumentTests, TestsBase`1"), + Name = "Equality3", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeReference = global::TUnit.Core.TypeReference.CreateConcrete("System.Threading.Tasks.Task, System.Private.CoreLib"), + Parameters = new global::TUnit.Core.ParameterMetadata[] + { + new global::TUnit.Core.ParameterMetadata(typeof(decimal)) + { + Name = "credit", + TypeReference = global::TUnit.Core.TypeReference.CreateConcrete("decimal, System.Private.CoreLib"), + IsNullable = false, + ReflectionInfo = typeof(global::TUnit.TestProject.DecimalArgumentTests).GetMethod("Equality3", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(decimal) }, null)!.GetParameters()[0] + } + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.DecimalArgumentTests", () => + { + var classMetadata = new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.DecimalArgumentTests), + TypeReference = global::TUnit.Core.TypeReference.CreateConcrete("TUnit.TestProject.DecimalArgumentTests, TestsBase`1"), + Name = "DecimalArgumentTests", + Namespace = "TUnit.TestProject", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", () => new global::TUnit.Core.AssemblyMetadata { Name = "TestsBase`1" }), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }; + foreach (var prop in classMetadata.Properties) + { + prop.ClassMetadata = classMetadata; + prop.ContainingTypeMetadata = classMetadata; + } + return classMetadata; + }) + }, + InstanceFactory = (typeArgs, args) => new global::TUnit.TestProject.DecimalArgumentTests(), + InvokeTypedTest = async (instance, args, cancellationToken) => + { + switch (args.Length) + { + case 1: + await instance.Equality3(TUnit.Core.Helpers.CastHelper.Cast(args[0])); + break; + default: + throw new global::System.ArgumentException($"Expected exactly 1 argument, but got {args.Length}"); + } + }, + }; + metadata.UseRuntimeDataGeneration(testSessionId); + yield return metadata; + yield break; + } +} +internal static class DecimalArgumentTests_Equality3_ModuleInitializer_GUID +{ + [global::System.Runtime.CompilerServices.ModuleInitializer] + public static void Initialize() + { + global::TUnit.Core.SourceRegistrar.Register(typeof(global::TUnit.TestProject.DecimalArgumentTests), new DecimalArgumentTests_Equality3_TestSource_GUID()); + } +} + + +// ===== FILE SEPARATOR ===== + +// +#pragma warning disable + +#nullable enable +namespace TUnit.Generated; +internal sealed class DecimalArgumentTests_Equality4_TestSource_GUID : global::TUnit.Core.Interfaces.SourceGenerator.ITestSource +{ + public async global::System.Collections.Generic.IAsyncEnumerable GetTestsAsync(string testSessionId, [global::System.Runtime.CompilerServices.EnumeratorCancellation] global::System.Threading.CancellationToken cancellationToken = default) + { + var metadata = new global::TUnit.Core.TestMetadata + { + TestName = "Equality4", + TestClassType = typeof(global::TUnit.TestProject.DecimalArgumentTests), + TestMethodName = "Equality4", + Dependencies = global::System.Array.Empty(), + AttributeFactory = () => + [ + new global::TUnit.Core.TestAttribute(), + new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass) + ], + DataSources = new global::TUnit.Core.IDataSourceAttribute[] + { + new global::TUnit.Core.ArgumentsAttribute(123_999.00000000000000001m), + }, + ClassDataSources = global::System.Array.Empty(), + PropertyDataSources = global::System.Array.Empty(), + PropertyInjections = global::System.Array.Empty(), + InheritanceDepth = 0, + FilePath = @"", + LineNumber = 104, + MethodMetadata = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.DecimalArgumentTests), + TypeReference = global::TUnit.Core.TypeReference.CreateConcrete("TUnit.TestProject.DecimalArgumentTests, TestsBase`1"), + Name = "Equality4", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeReference = global::TUnit.Core.TypeReference.CreateConcrete("System.Threading.Tasks.Task, System.Private.CoreLib"), + Parameters = new global::TUnit.Core.ParameterMetadata[] + { + new global::TUnit.Core.ParameterMetadata(typeof(decimal)) + { + Name = "credit", + TypeReference = global::TUnit.Core.TypeReference.CreateConcrete("decimal, System.Private.CoreLib"), + IsNullable = false, + ReflectionInfo = typeof(global::TUnit.TestProject.DecimalArgumentTests).GetMethod("Equality4", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(decimal) }, null)!.GetParameters()[0] + } + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.DecimalArgumentTests", () => + { + var classMetadata = new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.DecimalArgumentTests), + TypeReference = global::TUnit.Core.TypeReference.CreateConcrete("TUnit.TestProject.DecimalArgumentTests, TestsBase`1"), + Name = "DecimalArgumentTests", + Namespace = "TUnit.TestProject", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", () => new global::TUnit.Core.AssemblyMetadata { Name = "TestsBase`1" }), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }; + foreach (var prop in classMetadata.Properties) + { + prop.ClassMetadata = classMetadata; + prop.ContainingTypeMetadata = classMetadata; + } + return classMetadata; + }) + }, + InstanceFactory = (typeArgs, args) => new global::TUnit.TestProject.DecimalArgumentTests(), + InvokeTypedTest = async (instance, args, cancellationToken) => + { + switch (args.Length) + { + case 1: + await instance.Equality4(TUnit.Core.Helpers.CastHelper.Cast(args[0])); + break; + default: + throw new global::System.ArgumentException($"Expected exactly 1 argument, but got {args.Length}"); + } + }, + }; + metadata.UseRuntimeDataGeneration(testSessionId); + yield return metadata; + yield break; + } +} +internal static class DecimalArgumentTests_Equality4_ModuleInitializer_GUID +{ + [global::System.Runtime.CompilerServices.ModuleInitializer] + public static void Initialize() + { + global::TUnit.Core.SourceRegistrar.Register(typeof(global::TUnit.TestProject.DecimalArgumentTests), new DecimalArgumentTests_Equality4_TestSource_GUID()); + } +} + + +// ===== FILE SEPARATOR ===== + +// +#pragma warning disable + +#nullable enable +namespace TUnit.Generated; +internal sealed class DecimalArgumentTests_TestMethod_TestSource_GUID : global::TUnit.Core.Interfaces.SourceGenerator.ITestSource +{ + public async global::System.Collections.Generic.IAsyncEnumerable GetTestsAsync(string testSessionId, [global::System.Runtime.CompilerServices.EnumeratorCancellation] global::System.Threading.CancellationToken cancellationToken = default) + { + var metadata = new global::TUnit.Core.TestMetadata + { + TestName = "TestMethod", + TestClassType = typeof(global::TUnit.TestProject.DecimalArgumentTests), + TestMethodName = "TestMethod", + Dependencies = global::System.Array.Empty(), + AttributeFactory = () => + [ + new global::TUnit.Core.TestAttribute(), + new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass) + ], + DataSources = new global::TUnit.Core.IDataSourceAttribute[] + { + new global::TUnit.Core.ArgumentsAttribute(42), + }, + ClassDataSources = global::System.Array.Empty(), + PropertyDataSources = global::System.Array.Empty(), + PropertyInjections = global::System.Array.Empty(), + InheritanceDepth = 0, + FilePath = @"", + LineNumber = 119, + MethodMetadata = new global::TUnit.Core.MethodMetadata + { + Type = typeof(global::TUnit.TestProject.DecimalArgumentTests), + TypeReference = global::TUnit.Core.TypeReference.CreateConcrete("TUnit.TestProject.DecimalArgumentTests, TestsBase`1"), + Name = "TestMethod", + GenericTypeCount = 0, + ReturnType = typeof(global::System.Threading.Tasks.Task), + ReturnTypeReference = global::TUnit.Core.TypeReference.CreateConcrete("System.Threading.Tasks.Task, System.Private.CoreLib"), + Parameters = new global::TUnit.Core.ParameterMetadata[] + { + new global::TUnit.Core.ParameterMetadata(typeof(decimal)) + { + Name = "batchingSize", + TypeReference = global::TUnit.Core.TypeReference.CreateConcrete("decimal, System.Private.CoreLib"), + IsNullable = false, + ReflectionInfo = typeof(global::TUnit.TestProject.DecimalArgumentTests).GetMethod("TestMethod", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(decimal) }, null)!.GetParameters()[0] + } + }, + Class = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.DecimalArgumentTests", () => + { + var classMetadata = new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.DecimalArgumentTests), + TypeReference = global::TUnit.Core.TypeReference.CreateConcrete("TUnit.TestProject.DecimalArgumentTests, TestsBase`1"), + Name = "DecimalArgumentTests", + Namespace = "TUnit.TestProject", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", () => new global::TUnit.Core.AssemblyMetadata { Name = "TestsBase`1" }), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }; + foreach (var prop in classMetadata.Properties) + { + prop.ClassMetadata = classMetadata; + prop.ContainingTypeMetadata = classMetadata; + } + return classMetadata; + }) + }, + InstanceFactory = (typeArgs, args) => new global::TUnit.TestProject.DecimalArgumentTests(), + InvokeTypedTest = async (instance, args, cancellationToken) => + { + switch (args.Length) + { + case 1: + await instance.TestMethod(TUnit.Core.Helpers.CastHelper.Cast(args[0])); + break; + default: + throw new global::System.ArgumentException($"Expected exactly 1 argument, but got {args.Length}"); + } + }, + }; + metadata.UseRuntimeDataGeneration(testSessionId); + yield return metadata; + yield break; + } +} +internal static class DecimalArgumentTests_TestMethod_ModuleInitializer_GUID +{ + [global::System.Runtime.CompilerServices.ModuleInitializer] + public static void Initialize() + { + global::TUnit.Core.SourceRegistrar.Register(typeof(global::TUnit.TestProject.DecimalArgumentTests), new DecimalArgumentTests_TestMethod_TestSource_GUID()); + } +} diff --git a/TUnit.Core.SourceGenerator.Tests/DecimalArgumentTests.cs b/TUnit.Core.SourceGenerator.Tests/DecimalArgumentTests.cs new file mode 100644 index 0000000000..12fe14f148 --- /dev/null +++ b/TUnit.Core.SourceGenerator.Tests/DecimalArgumentTests.cs @@ -0,0 +1,11 @@ +using TUnit.Core.SourceGenerator.Tests.Options; + +namespace TUnit.Core.SourceGenerator.Tests; + +internal class DecimalArgumentTests : TestsBase +{ + [Test] + public Task Test() => RunTest(Path.Combine(Git.RootDirectory.FullName, + "TUnit.TestProject", + "DecimalArgumentTests.cs"), _ => Task.CompletedTask); +} diff --git a/TUnit.Core.SourceGenerator/CodeGenerationHelpers.cs b/TUnit.Core.SourceGenerator/CodeGenerationHelpers.cs index edbb251573..2dd803c7d9 100644 --- a/TUnit.Core.SourceGenerator/CodeGenerationHelpers.cs +++ b/TUnit.Core.SourceGenerator/CodeGenerationHelpers.cs @@ -108,7 +108,8 @@ public static string GenerateAttributeInstantiation(AttributeData attr, Immutabl if (isDecimalType && syntaxArguments != null && syntaxIndex < syntaxArguments.Count) { - var originalText = syntaxArguments[syntaxIndex].Expression.ToString(); + var syntaxExpression = syntaxArguments[syntaxIndex].Expression; + var originalText = syntaxExpression.ToString(); syntaxIndex++; // Skip special handling for null values @@ -127,6 +128,15 @@ public static string GenerateAttributeInstantiation(AttributeData attr, Immutabl return TypedConstantParser.GetRawTypedConstantValue(v, paramType); } + // Check if it's a constant reference (identifier) rather than a literal + // Identifiers don't contain dots, parentheses, or other operators + if (syntaxExpression is NameSyntax) + { + // For constant references, use the actual value from TypedConstant + elementIndex++; + return TypedConstantParser.GetRawTypedConstantValue(v, paramType); + } + // For numeric literals, remove any suffix and add 'm' for decimal originalText = originalText.TrimEnd('d', 'D', 'f', 'F', 'l', 'L', 'u', 'U', 'm', 'M'); return $"{originalText}m"; @@ -151,7 +161,8 @@ public static string GenerateAttributeInstantiation(AttributeData attr, Immutabl if (isDecimalType && syntaxArguments != null && syntaxIndex < syntaxArguments.Count) { - var originalText = syntaxArguments[syntaxIndex].Expression.ToString(); + var syntaxExpression = syntaxArguments[syntaxIndex].Expression; + var originalText = syntaxExpression.ToString(); syntaxIndex++; // Skip special handling for null values @@ -166,6 +177,13 @@ public static string GenerateAttributeInstantiation(AttributeData attr, Immutabl syntaxIndex--; // Back up so normal processing can handle it argStrings.Add(TypedConstantParser.GetRawTypedConstantValue(arg, paramType)); } + // Check if it's a constant reference (identifier) rather than a literal + // Identifiers don't contain dots, parentheses, or other operators + else if (syntaxExpression is NameSyntax) + { + // For constant references, use the actual value from TypedConstant + argStrings.Add(TypedConstantParser.GetRawTypedConstantValue(arg, paramType)); + } else { // For numeric literals, remove any suffix and add 'm' for decimal @@ -188,7 +206,8 @@ public static string GenerateAttributeInstantiation(AttributeData attr, Immutabl if (paramType?.SpecialType == SpecialType.System_Decimal && syntaxArguments != null && syntaxIndex < syntaxArguments.Count) { - var originalText = syntaxArguments[syntaxIndex].Expression.ToString(); + var syntaxExpression = syntaxArguments[syntaxIndex].Expression; + var originalText = syntaxExpression.ToString(); syntaxIndex++; // Check if it's a string literal (starts and ends with quotes) if (originalText.StartsWith("\"") && originalText.EndsWith("\"")) @@ -197,6 +216,13 @@ public static string GenerateAttributeInstantiation(AttributeData attr, Immutabl syntaxIndex--; // Back up so normal processing can handle it argStrings.Add(TypedConstantParser.GetRawTypedConstantValue(arg, paramType)); } + // Check if it's a constant reference (identifier) rather than a literal + // Identifiers don't contain dots, parentheses, or other operators + else if (syntaxExpression is NameSyntax) + { + // For constant references, use the actual value from TypedConstant + argStrings.Add(TypedConstantParser.GetRawTypedConstantValue(arg, paramType)); + } else { // For numeric literals, remove any suffix and add 'm' for decimal diff --git a/TUnit.Core.SourceGenerator/CodeGenerators/Helpers/AotConversionHelper.cs b/TUnit.Core.SourceGenerator/CodeGenerators/Helpers/AotConversionHelper.cs index 9f12f20641..c0b7e1e445 100644 --- a/TUnit.Core.SourceGenerator/CodeGenerators/Helpers/AotConversionHelper.cs +++ b/TUnit.Core.SourceGenerator/CodeGenerators/Helpers/AotConversionHelper.cs @@ -49,9 +49,7 @@ public static class AotConversionHelper public static bool HasConversionOperators(ITypeSymbol type) { var members = type.GetMembers(); - return members.Any(m => m is IMethodSymbol method && - method.Name is "op_Implicit" or "op_Explicit" && - method.IsStatic); + return members.Any(m => m is IMethodSymbol { Name: "op_Implicit" or "op_Explicit", IsStatic: true }); } /// @@ -62,9 +60,7 @@ method.Name is "op_Implicit" or "op_Explicit" && var members = type.GetMembers(); foreach (var member in members) { - if (member is IMethodSymbol method && - method.Name is "op_Implicit" or "op_Explicit" && - method is { IsStatic: true, Parameters.Length: 1 }) + if (member is IMethodSymbol { Name: "op_Implicit" or "op_Explicit" } method and { IsStatic: true, Parameters.Length: 1 }) { yield return (method, method.ReturnType); } diff --git a/TUnit.Core.SourceGenerator/CodeGenerators/Helpers/FullyQualifiedWithGlobalPrefixRewriter.cs b/TUnit.Core.SourceGenerator/CodeGenerators/Helpers/FullyQualifiedWithGlobalPrefixRewriter.cs index b486ae5661..f1be5c5647 100644 --- a/TUnit.Core.SourceGenerator/CodeGenerators/Helpers/FullyQualifiedWithGlobalPrefixRewriter.cs +++ b/TUnit.Core.SourceGenerator/CodeGenerators/Helpers/FullyQualifiedWithGlobalPrefixRewriter.cs @@ -19,20 +19,13 @@ public override SyntaxNode VisitNamespaceDeclaration(NamespaceDeclarationSyntax var symbol = node.GetSymbolInfo(semanticModel); // Special handling for double/float special constants (NaN, PositiveInfinity, NegativeInfinity) - if (symbol is IFieldSymbol fieldSymbol && fieldSymbol.IsConst) + if (symbol is IFieldSymbol { IsConst: true, ContainingType.SpecialType: SpecialType.System_Double or SpecialType.System_Single, HasConstantValue: true } fieldSymbol) + // Get the constant value and use the helper to create the appropriate syntax { - var containingType = fieldSymbol.ContainingType; - if (containingType?.SpecialType is SpecialType.System_Double or SpecialType.System_Single) + var specialSyntax = SpecialFloatingPointValuesHelper.TryCreateSpecialFloatingPointSyntax(fieldSymbol.ConstantValue); + if (specialSyntax != null) { - // Get the constant value and use the helper to create the appropriate syntax - if (fieldSymbol.HasConstantValue) - { - var specialSyntax = SpecialFloatingPointValuesHelper.TryCreateSpecialFloatingPointSyntax(fieldSymbol.ConstantValue); - if (specialSyntax != null) - { - return specialSyntax; - } - } + return specialSyntax; } } diff --git a/TUnit.Core.SourceGenerator/Generators/AotConverterGenerator.cs b/TUnit.Core.SourceGenerator/Generators/AotConverterGenerator.cs index 6dff442031..958a97fa7e 100644 --- a/TUnit.Core.SourceGenerator/Generators/AotConverterGenerator.cs +++ b/TUnit.Core.SourceGenerator/Generators/AotConverterGenerator.cs @@ -82,8 +82,7 @@ public void Initialize(IncrementalGeneratorInitializationContext context) // Also skip if the target type of the conversion is not publicly accessible // (unless it's a built-in type) - if (targetType is INamedTypeSymbol namedTargetType && - namedTargetType.SpecialType == SpecialType.None && + if (targetType is INamedTypeSymbol { SpecialType: SpecialType.None } namedTargetType && namedTargetType.DeclaredAccessibility != Accessibility.Public) { return null; diff --git a/TUnit.Core.SourceGenerator/Generators/TestMetadataGenerator.cs b/TUnit.Core.SourceGenerator/Generators/TestMetadataGenerator.cs index 657a8c23f7..dc6433da53 100644 --- a/TUnit.Core.SourceGenerator/Generators/TestMetadataGenerator.cs +++ b/TUnit.Core.SourceGenerator/Generators/TestMetadataGenerator.cs @@ -127,7 +127,7 @@ private static void GenerateInheritedTestSources(SourceProductionContext context var (filePath, lineNumber) = GetTestMethodSourceLocation(method, testAttribute, classInfo); // If the method is from a generic base class, use the constructed version from the inheritance hierarchy - INamedTypeSymbol typeForMetadata = classInfo.TypeSymbol; + var typeForMetadata = classInfo.TypeSymbol; if (method.ContainingType.IsGenericType && method.ContainingType.IsDefinition) { // Find the constructed generic type in the inheritance chain @@ -711,10 +711,13 @@ private static void GenerateArgumentsAttributeWithParameterTypes(CodeWriter writ var formatter = new TypedConstantFormatter(); writer.Append($"new {attrTypeName}("); - if (attr.ConstructorArguments.Length == 1 && attr.ConstructorArguments[0].Kind == TypedConstantKind.Array) + if (attr.ConstructorArguments is + [ + { Kind: TypedConstantKind.Array } _ + ]) { var arrayValues = attr.ConstructorArguments[0].Values; - for (int i = 0; i < arrayValues.Length; i++) + for (var i = 0; i < arrayValues.Length; i++) { var targetType = i < testMethodParameters.Length ? testMethodParameters[i].Type : null; writer.Append(formatter.FormatForCode(arrayValues[i], targetType)); @@ -723,7 +726,7 @@ private static void GenerateArgumentsAttributeWithParameterTypes(CodeWriter writ } else { - for (int i = 0; i < attr.ConstructorArguments.Length; i++) + for (var i = 0; i < attr.ConstructorArguments.Length; i++) { var targetType = i < testMethodParameters.Length ? testMethodParameters[i].Type : null; writer.Append(formatter.FormatForCode(attr.ConstructorArguments[i], targetType)); @@ -751,18 +754,19 @@ private static void GenerateArgumentsAttributeWithParameterTypes(CodeWriter writ // Only process positional arguments (exclude named arguments) var positionalArgs = argumentList.Arguments.Where(a => a.NameEquals == null).ToList(); - for (int i = 0; i < positionalArgs.Count; i++) + for (var i = 0; i < positionalArgs.Count; i++) { var argumentSyntax = positionalArgs[i]; var expression = argumentSyntax.Expression; // Get target parameter type - ITypeSymbol? targetParameterType = i < testMethodParameters.Length + var targetParameterType = i < testMethodParameters.Length ? testMethodParameters[i].Type : null; // For decimal parameters, preserve source text and add 'm' suffix (only for numeric literals) - if (targetParameterType?.SpecialType == SpecialType.System_Decimal + if (expression is not IdentifierNameSyntax + && targetParameterType?.SpecialType == SpecialType.System_Decimal && expression.Kind() != SyntaxKind.StringLiteralExpression && expression.Kind() != SyntaxKind.NullLiteralExpression) { @@ -792,7 +796,7 @@ private static void GenerateArgumentsAttributeWithParameterTypes(CodeWriter writ writer.AppendLine("{"); writer.Indent(); - for (int i = 0; i < namedArgs.Count; i++) + for (var i = 0; i < namedArgs.Count; i++) { var namedArg = namedArgs[i]; var propertyName = namedArg.NameEquals!.Name.ToString(); @@ -1805,7 +1809,7 @@ private static void GenerateTypedInvokers(CodeWriter writer, TestMethodMetadata // Generate InvokeTypedTest for non-generic tests var isAsync = IsAsyncMethod(testMethod.MethodSymbol); - if (!testMethod.IsGenericType && !testMethod.IsGenericMethod) + if (testMethod is { IsGenericType: false, IsGenericMethod: false }) { GenerateConcreteTestInvoker(writer, testMethod, className, methodName, isAsync, hasCancellationToken, parametersFromArgs); } @@ -1828,7 +1832,10 @@ private static void GenerateConcreteTestInvoker(CodeWriter writer, TestMethodMet // Special case: Single tuple parameter (same as in TestInvoker) // If we have exactly one parameter that's a tuple type, we need to handle it specially // In source-generated mode, tuples are always unwrapped into their elements - if (parametersFromArgs.Length == 1 && parametersFromArgs[0].Type is INamedTypeSymbol { IsTupleType: true } singleTupleParam) + if (parametersFromArgs is + [ + { Type: INamedTypeSymbol { IsTupleType: true } singleTupleParam } + ]) { writer.AppendLine("// Special handling for single tuple parameter"); writer.AppendLine($"if (args.Length == {singleTupleParam.TupleElements.Length})"); diff --git a/TUnit.TestProject/DecimalArgumentTests.cs b/TUnit.TestProject/DecimalArgumentTests.cs index 5194dcd677..ceb9d8be36 100644 --- a/TUnit.TestProject/DecimalArgumentTests.cs +++ b/TUnit.TestProject/DecimalArgumentTests.cs @@ -113,4 +113,13 @@ public async Task Equality4(decimal credit) await Assert.That(credit).IsEqualTo(123_999.00000000000000001m); } + + private const int BatchSize = 42; + + [Test] + [Arguments(BatchSize)] + public async Task TestMethod(decimal batchingSize) + { + await Assert.That(batchingSize).IsEqualTo(BatchSize); + } }