diff --git a/src/TUnit.Analyzers/TestDataAnalyzer.cs b/src/TUnit.Analyzers/TestDataAnalyzer.cs index b266e502e63..050eeab0d32 100644 --- a/src/TUnit.Analyzers/TestDataAnalyzer.cs +++ b/src/TUnit.Analyzers/TestDataAnalyzer.cs @@ -434,14 +434,19 @@ private void CheckMethodDataSource(SymbolAnalysisContext context, // An overload that takes exactly the Arguments wins over one that also takes an injected trailing // CancellationToken, as it does at runtime, whatever order the overloads are declared in. + // A generic data method is skipped while a non-generic one exists: neither mode can call it without + // type arguments, so IEnumerable Rows() is used over IEnumerable Rows(). var dataSourceMethod = methodSymbols .FirstOrDefault(methodSymbol => methodSymbol.Name == methodName && + !methodSymbol.IsGenericMethod && ArgumentsMatchParameterTypes(context, argumentsForMethodCall, methodSymbol.Parameters.Select(p => p.Type))) ?? methodSymbols .FirstOrDefault(methodSymbol => methodSymbol.Name == methodName && + !methodSymbol.IsGenericMethod && ArgumentsMatchParameterTypes(context, argumentsForMethodCall, methodSymbol.Parameters.WithoutCancellationTokenParameter().Select(p => p.Type))) + ?? methodSymbols.FirstOrDefault(x => x.Name == methodName && !x.IsGenericMethod) ?? methodSymbols.FirstOrDefault(x => x.Name == methodName); // If no method found, check for properties or fields diff --git a/src/TUnit.Core.SourceGenerator/CodeGenerators/StaticPropertyInitializationGenerator.cs b/src/TUnit.Core.SourceGenerator/CodeGenerators/StaticPropertyInitializationGenerator.cs index 067bd3a0b23..ec32b5a46ec 100644 --- a/src/TUnit.Core.SourceGenerator/CodeGenerators/StaticPropertyInitializationGenerator.cs +++ b/src/TUnit.Core.SourceGenerator/CodeGenerators/StaticPropertyInitializationGenerator.cs @@ -396,7 +396,7 @@ private static void GenerateIndividualPropertyInitializer(CodeWriter writer, Pro writer.AppendLine($"Type = typeof({propertyData.Property.GloballyQualifiedType}),"); writer.AppendLine($"IsStatic = true,"); writer.AppendLine($"ReflectionInfo = typeof({typeName}).GetProperty(\"{propertyName}\", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.Static),"); - writer.AppendLine($"Getter = _ => {typeName}.{propertyName},"); + writer.AppendLine($"Getter = _ => {typeName}.{IdentifierHelper.Escape(propertyName)},"); writer.AppendLine("ClassMetadata = containingTypeMetadata,"); writer.AppendLine("ContainingTypeMetadata = containingTypeMetadata"); writer.Unindent(); @@ -439,7 +439,7 @@ private static void GenerateIndividualPropertyInitializer(CodeWriter writer, Pro writer.AppendLine("if (value != null)"); writer.AppendLine("{"); writer.Indent(); - writer.AppendLine($"{typeName}.{propertyName} = ({propertyData.Property.GloballyQualifiedType})value;"); + writer.AppendLine($"{typeName}.{IdentifierHelper.Escape(propertyName)} = ({propertyData.Property.GloballyQualifiedType})value;"); writer.Unindent(); writer.AppendLine("}"); writer.AppendLine(); diff --git a/src/TUnit.Core.SourceGenerator/Generators/TestMetadataGenerator.cs b/src/TUnit.Core.SourceGenerator/Generators/TestMetadataGenerator.cs index 2f752944e00..b9630bad97e 100644 --- a/src/TUnit.Core.SourceGenerator/Generators/TestMetadataGenerator.cs +++ b/src/TUnit.Core.SourceGenerator/Generators/TestMetadataGenerator.cs @@ -1680,6 +1680,19 @@ private static void AddUninferredTypeArgumentFailures(TestMethodMetadata testMet { foreach (var attribute in uncovered) { + if (attribute.AttributeClass?.Name == "MethodDataSourceAttribute" + && InferTypesFromMethodDataSourceRowType(testMethod, attribute) is { } rowTypes + && FindInaccessibleType(rowTypes, testMethod.CompilationContext.Compilation) is { } inaccessibleType) + { + violations.Add(new MethodConstraintViolation( + $"Could not infer the type arguments of generic test method '{methodName}' from data source [{DescribeDataSource(attribute)}]. " + + $"Its rows give the type argument '{inaccessibleType.ToDisplayString()}', which source-generated code cannot name because it is private or protected. " + + "Make that type internal or public, or list accessible type arguments with [GenerateGenericTest].", + RowSource: attribute, + AllMethodDataSources: false)); + continue; + } + violations.Add(new MethodConstraintViolation( $"Could not infer the type arguments of generic test method '{methodName}' from data source [{DescribeDataSource(attribute)}]. " + "Source-generated mode infers type arguments at compile time from the data source's declared type, not from the run-time type of its values, and that declared type does not determine them. " @@ -2533,7 +2546,7 @@ private static void GenerateDataSourceAttribute(CodeWriter writer, CompilationCo if (attrName == "global::TUnit.Core.MethodDataSourceAttribute") { - GenerateMethodDataSourceAttribute(writer, attr, typeSymbol); + GenerateMethodDataSourceAttribute(writer, attr, typeSymbol, compilationContext.Compilation); } else if (attrName == "global::TUnit.Core.ArgumentsAttribute") { @@ -2822,7 +2835,7 @@ private static bool TryGetDecimalLiteralText(ExpressionSyntax expression, out st return true; } - private static void GenerateMethodDataSourceAttribute(CodeWriter writer, AttributeData attr, INamedTypeSymbol typeSymbol) + private static void GenerateMethodDataSourceAttribute(CodeWriter writer, AttributeData attr, INamedTypeSymbol typeSymbol, Compilation compilation) { // Extract method name and target type string? methodName = null; @@ -2865,26 +2878,17 @@ private static void GenerateMethodDataSourceAttribute(CodeWriter writer, Attribu return; } - // Find the data source method, property, or field. - // Walk base types too: with [InheritsTests] (or a data member declared on a base class) - // the member may not be declared directly on the test class. Missing it here would emit - // a plain MethodDataSourceAttribute without a Factory, which falls back to - // Activator.CreateInstance at runtime and fails for classes without a parameterless - // constructor (https://github.com/thomhurst/TUnit/issues/6162). - ISymbol? dataSourceMember = null; - for (var searchType = targetType; searchType is not null; searchType = searchType.BaseType) - { - var members = searchType.GetMembers(methodName!); - if (members.Length > 0) - { - dataSourceMember = members[0]; - break; - } - } + // Find the data source method, property, or field. Generic type inference reads the same + // member (see InferTypesFromMethodDataSource), so the generated factory and the closed + // test method always agree on the row type. + var dataSourceMember = ResolveMethodDataSourceMember(targetType, methodName!, attr, compilation); var dataSourceMethod = dataSourceMember as IMethodSymbol; var dataSourceProperty = dataSourceMember as IPropertySymbol; + var dataSourceField = dataSourceMember as IFieldSymbol; - if (dataSourceMember == null || (dataSourceMethod == null && dataSourceProperty == null)) + if (dataSourceMember == null + || (dataSourceMethod == null && dataSourceProperty == null && dataSourceField == null) + || (dataSourceMethod == null && !CanReadDataSourceMember(dataSourceMember, compilation))) { // Still generate the attribute even if method not found - it will fail at runtime with proper error // Use CodeGenerationHelpers to properly handle any generics on the attribute @@ -2897,7 +2901,7 @@ private static void GenerateMethodDataSourceAttribute(CodeWriter writer, Attribu // We need to manually construct this to properly add the Factory property // Determine if the data source is static or instance-based - var isStatic = dataSourceMethod?.IsStatic ?? dataSourceProperty?.GetMethod?.IsStatic ?? true; + var isStatic = dataSourceMethod?.IsStatic ?? dataSourceProperty?.GetMethod?.IsStatic ?? dataSourceField?.IsStatic ?? true; // InstanceMethodDataSourceAttribute means "use the test class instance". If the // attribute explicitly targets a separate provider type, create that provider in @@ -2973,7 +2977,7 @@ private static void GenerateMethodDataSourceAttribute(CodeWriter writer, Attribu // a per-data-source compiler-generated state machine class (#6227). Only the per-test-unique // invocation is emitted, as a static lambda. writer.Append("Factory = static dataGeneratorMetadata => "); - EmitDataSourceFactoryInvocation(writer, dataSourceMember, targetType, usesTestClassInstance, hasArguments ? argumentsProperty.Value : (TypedConstant?)null); + EmitDataSourceFactoryInvocation(writer, dataSourceMember, targetType, usesTestClassInstance, hasArguments ? argumentsProperty.Value : (TypedConstant?)null, compilation); writer.AppendLine(","); writer.Unindent(); @@ -2986,13 +2990,17 @@ private static void GenerateMethodDataSourceAttribute(CodeWriter writer, Attribu /// member's declared return type (mirroring the previous inline-iterator branch order) /// and whether the member is static or instance-based. /// - private static void EmitDataSourceFactoryInvocation(CodeWriter writer, ISymbol dataSourceMember, ITypeSymbol targetType, bool usesTestClassInstance, TypedConstant? arguments) + private static void EmitDataSourceFactoryInvocation(CodeWriter writer, ISymbol dataSourceMember, ITypeSymbol targetType, bool usesTestClassInstance, TypedConstant? arguments, Compilation compilation) { var dataSourceMethod = dataSourceMember as IMethodSymbol; - var dataSourceProperty = dataSourceMember as IPropertySymbol; - var returnType = dataSourceMethod?.ReturnType ?? dataSourceProperty!.Type; - var isStatic = dataSourceMethod?.IsStatic ?? dataSourceProperty!.IsStatic; + var returnType = dataSourceMember switch + { + IMethodSymbol method => method.ReturnType, + IPropertySymbol property => property.Type, + _ => ((IFieldSymbol)dataSourceMember).Type + }; + var isStatic = dataSourceMember.IsStatic; var fullyQualifiedType = targetType.GloballyQualified(); string kind; @@ -3021,35 +3029,74 @@ private static void EmitDataSourceFactoryInvocation(CodeWriter writer, ISymbol d ? $"global::TUnit.Core.Helpers.DataSourceFactories.From{kind}" : $"global::TUnit.Core.Helpers.DataSourceFactories.FromInstance{kind}"; - var hasArguments = arguments != null && dataSourceMethod is { Parameters.Length: > 0 }; + // A method with parameters goes through BuildDataSourceCallArguments even without Arguments, so a + // CancellationToken or optional parameter is filled in as reflection mode's BuildInvokeArgs does. + var hasArguments = dataSourceMethod is { Parameters.Length: > 0 }; + + var receiver = isStatic + ? fullyQualifiedType + : usesTestClassInstance + ? $"(({fullyQualifiedType})instance)" + : $"new {fullyQualifiedType}()"; + var lambdaHeader = usesTestClassInstance ? "static instance =>" : "static () =>"; + var metadataArgument = usesTestClassInstance ? "dataGeneratorMetadata, " : ""; + + // A declared type such as object does not say whether the value is one row or many. Reflection mode, and the + // attribute's reflection fallback that read every field and every private or protected property before the + // generator could, decide from the runtime value, so these factories hand the value to that same logic + // instead of FromValue. Accessible properties and methods keep FromValue, as their generated code always has + // (https://github.com/thomhurst/TUnit/issues/7178). + var isAccessibleMember = dataSourceMethod != null || IsAccessibleDataSourceMember(dataSourceMember, compilation); + if (kind == "Value" && (dataSourceMember is IFieldSymbol || !isAccessibleMember)) + { + helper = isStatic || !usesTestClassInstance + ? "global::TUnit.Core.Helpers.DataSourceFactories.FromRuntimeValue" + : "global::TUnit.Core.Helpers.DataSourceFactories.FromInstanceRuntimeValue"; + metadataArgument = "dataGeneratorMetadata, "; + } + + if (!isAccessibleMember) + { + // The generated class cannot name a private or protected field or property, so the factory reads it by + // reflection. GetField/GetProperty on a typeof() with a constant name and binding flags is understood + // by the trimmer and the AOT compiler, which keep that member, so this works under native AOT + // without any trimming warning. The attribute's own reflection fallback finds the member from the + // test class type at run time, which neither of them can see. + var lookup = dataSourceMember is IFieldSymbol ? "GetField" : "GetProperty"; + var bindingFlags = (isStatic ? "global::System.Reflection.BindingFlags.Static" : "global::System.Reflection.BindingFlags.Instance") + + " | global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.DeclaredOnly"; + var target = isStatic ? "null" : usesTestClassInstance ? "instance" : $"new {fullyQualifiedType}()"; + var cast = kind is "Value" or "Enumerable" ? "" : $"({returnType.GloballyQualified()})"; + writer.Append($"{helper}({metadataArgument}{lambdaHeader} {cast}typeof({dataSourceMember.ContainingType.GloballyQualified()}).{lookup}(\"{dataSourceMember.Name}\", {bindingFlags})!.GetValue({target}))"); + return; + } string memberAccess; if (dataSourceMethod != null) { memberAccess = hasArguments - ? $"{dataSourceMethod.Name}({string.Join(", ", dataSourceMethod.Parameters.Select((p, i) => $"(({p.Type.GloballyQualified()})arguments[{i.ToString(CultureInfo.InvariantCulture)}])"))})" - : $"{dataSourceMethod.Name}()"; + ? $"{IdentifierHelper.Escape(dataSourceMethod.Name)}({BuildDataSourceCallArguments(dataSourceMethod, arguments ?? default, compilation)})" + : $"{IdentifierHelper.Escape(dataSourceMethod.Name)}()"; } else { - memberAccess = dataSourceProperty!.Name; + memberAccess = IdentifierHelper.Escape(dataSourceMember.Name); } - var receiver = isStatic - ? fullyQualifiedType - : usesTestClassInstance - ? $"(({fullyQualifiedType})instance)" - : $"new {fullyQualifiedType}()"; - var lambdaHeader = usesTestClassInstance ? "static instance =>" : "static () =>"; - var metadataArgument = usesTestClassInstance ? "dataGeneratorMetadata, " : ""; - if (hasArguments) { writer.AppendLine($"{helper}({metadataArgument}{lambdaHeader}"); writer.AppendLine("{"); writer.Indent(); writer.Append("var arguments = "); - WriteTypedConstant(writer, arguments!.Value); + if (arguments is { } suppliedArguments) + { + WriteTypedConstant(writer, suppliedArguments); + } + else + { + writer.Append("global::System.Array.Empty()"); + } writer.AppendLine(";"); writer.AppendLine($"return {receiver}.{memberAccess};"); writer.Unindent(); @@ -3061,6 +3108,43 @@ private static void EmitDataSourceFactoryInvocation(CodeWriter writer, ISymbol d } } + /// + /// Whether the generated class can read the data source field or property directly: the member and its getter + /// are accessible from the test assembly, so not private or protected. + /// + private static bool IsAccessibleDataSourceMember(ISymbol member, Compilation compilation) + { + return compilation.IsSymbolAccessibleWithin(member, compilation.Assembly) + && (member is not IPropertySymbol property + || (property.GetMethod is { } getter && compilation.IsSymbolAccessibleWithin(getter, compilation.Assembly))); + } + + /// + /// Whether a generated factory can read the data source field or property, directly or, for a private or + /// protected member, by reflection on its declaring type. That needs a declaring type that the generated class + /// can name without type parameters, a getter for a property, and a member type it can name when the factory + /// casts the value. Otherwise the attribute keeps its reflection fallback. + /// + private static bool CanReadDataSourceMember(ISymbol member, Compilation compilation) + { + if (member is IPropertySymbol { GetMethod: null } or IPropertySymbol { IsIndexer: true }) + { + return false; + } + + if (IsAccessibleDataSourceMember(member, compilation)) + { + return true; + } + + // EmitDataSourceFactoryInvocation casts the value for the async helpers, which take a typed delegate + var memberType = member is IPropertySymbol property ? property.Type : ((IFieldSymbol)member).Type; + var castsValue = IsAsyncEnumerable(memberType) || IsValueTask(memberType) || IsTask(memberType); + return compilation.IsSymbolAccessibleWithin(member.ContainingType, compilation.Assembly) + && !CodeGenerationHelpers.ContainsTypeParameter(member.ContainingType) + && (!castsValue || compilation.IsSymbolAccessibleWithin(memberType, compilation.Assembly)); + } + private static bool IsAsyncEnumerable(ITypeSymbol type) { return InterfaceHelper.IsAsyncEnumerable(type); @@ -3118,82 +3202,35 @@ private static bool IsEnumerable(ITypeSymbol type) return InterfaceHelper.IsEnumerable(type); } + private static readonly TypedConstantFormatter TypedConstantLiteralFormatter = new(); + + /// + /// Writes an attribute argument as a C# expression of the same type, so a boxed value keeps its type: + /// 1.5f stays a float and 16L a long, as in the attribute reflection mode reads. + /// private static void WriteTypedConstant(CodeWriter writer, TypedConstant constant) { - if (constant.IsNull) - { - writer.Append("null"); - return; - } - - switch (constant.Kind) + if (constant is { Kind: TypedConstantKind.Array, IsNull: false }) { - case TypedConstantKind.Primitive: - if (constant.Type?.SpecialType == SpecialType.System_String) - { - var stringValue = constant.Value.ToInvariantString() ?? ""; - var escapedValue = stringValue - .Replace("\\", "\\\\") - .Replace("\"", "\\\"") - .Replace("\r", "\\r") - .Replace("\n", "\\n") - .Replace("\t", "\\t"); - writer.Append($"\"{escapedValue}\""); - } - else if (constant.Type?.SpecialType == SpecialType.System_Char) - { - var charValue = constant.Value.ToInvariantString() ?? ""; - var escapedChar = charValue - .Replace("\\", "\\\\") - .Replace("'", "\\'") - .Replace("\r", "\\r") - .Replace("\n", "\\n") - .Replace("\t", "\\t"); - writer.Append($"'{escapedChar}'"); - } - else if (constant.Type?.SpecialType == SpecialType.System_Boolean) - { - writer.Append(constant.Value?.ToString()?.ToLowerInvariant() ?? "false"); - } - else - { - // Handle numeric types with InvariantCulture to ensure consistent formatting - if (constant.Value is IFormattable formattable) - { - writer.Append(formattable.ToString(null, CultureInfo.InvariantCulture)); - } - else - { - writer.Append(constant.Value.ToInvariantString() ?? "null"); - } - } - break; - - case TypedConstantKind.Type: - var type = constant.Value as ITypeSymbol; - writer.Append($"typeof({type?.GloballyQualified()})"); - break; - - case TypedConstantKind.Array: - var elementType = constant.Type is IArrayTypeSymbol arrayType - ? arrayType.ElementType.GloballyQualified() - : "object"; - writer.Append($"new {elementType}[] {{ "); - for (var i = 0; i < constant.Values.Length; i++) + var elementType = constant.Type is IArrayTypeSymbol arrayType + ? arrayType.ElementType.GloballyQualified() + : "object"; + writer.Append($"new {elementType}[] {{ "); + for (var i = 0; i < constant.Values.Length; i++) + { + WriteTypedConstant(writer, constant.Values[i]); + if (i < constant.Values.Length - 1) { - WriteTypedConstant(writer, constant.Values[i]); - if (i < constant.Values.Length - 1) - { - writer.Append(", "); - } + writer.Append(", "); } - writer.Append(" }"); - break; - - default: - writer.Append("null"); - break; + } + writer.Append(" }"); + return; } + + // No target type: each value is written as its own type, with a literal suffix or cast where needed, + // and enum values as enum members. + writer.Append(TypedConstantLiteralFormatter.FormatForCode(constant)); } private static void GeneratePropertyInjections(CodeWriter writer, INamedTypeSymbol typeSymbol, string className) @@ -7095,72 +7132,92 @@ private static void MapGenericTypeArguments(ITypeSymbol paramType, ITypeSymbol a return null; } + /// + /// Infers a generic test method's type arguments from a [MethodDataSource] member's declared row type. Returns + /// null when the row type does not determine them, or when one of them is a type the generated code cannot name, + /// such as a private nested row class read through a private property: closing the method over it would not + /// compile. then reports the rows as failed tests. + /// private static ITypeSymbol[]? InferTypesFromMethodDataSource(TestMethodMetadata testMethod, AttributeData mdsAttr) { - if (mdsAttr.ConstructorArguments.Length == 0) - { - return null; - } + var inferredTypes = InferTypesFromMethodDataSourceRowType(testMethod, mdsAttr); + return inferredTypes != null && FindInaccessibleType(inferredTypes, testMethod.CompilationContext.Compilation) == null + ? inferredTypes + : null; + } - // Get the method name from the attribute - if (mdsAttr.ConstructorArguments[0].Value is not string methodName) + /// + /// The first of that generated code in the test assembly cannot name, or null. + /// Accessibility of a constructed or array type includes its type arguments and element type. + /// + private static ITypeSymbol? FindInaccessibleType(ITypeSymbol[] types, Compilation compilation) + { + foreach (var type in types) { - return null; + if (type is not ITypeParameterSymbol && !compilation.IsSymbolAccessibleWithin(type, compilation.Assembly)) + { + return type; + } } - // Find the method in the test class, or in T for [MethodDataSource("Rows")] - var providerType = mdsAttr.AttributeClass is { IsGenericType: true, TypeArguments: [INamedTypeSymbol genericProvider] } - ? genericProvider - : testMethod.TypeSymbol; - var dataMethod = providerType.GetMembers(methodName) - .OfType() - .FirstOrDefault(m => m.IsStatic && m.Parameters.Length == 0); + return null; + } - if (dataMethod == null) + private static ITypeSymbol[]? InferTypesFromMethodDataSourceRowType(TestMethodMetadata testMethod, AttributeData mdsAttr) + { + if (mdsAttr.ConstructorArguments.Length == 0) { return null; } - // Check if the method returns IEnumerable> where T is a tuple - var returnType = dataMethod.ReturnType; - if (returnType is not INamedTypeSymbol namedReturnType) + // [MethodDataSource("Rows")], [MethodDataSource(typeof(Provider), "Rows")] or [MethodDataSource("Rows")] + INamedTypeSymbol providerType; + string methodName; + if (mdsAttr.ConstructorArguments is [{ Value: INamedTypeSymbol typeArgument }, { Value: string typedMethodName }]) { - return null; + providerType = typeArgument; + methodName = typedMethodName; } - - // Navigate through IEnumerable> - if (!namedReturnType.IsGenericType || namedReturnType.Name != "IEnumerable") + else if (mdsAttr.ConstructorArguments[0].Value is string attributeMethodName) { - return null; + providerType = mdsAttr.AttributeClass is { IsGenericType: true, TypeArguments: [INamedTypeSymbol genericProvider] } + ? genericProvider + : testMethod.TypeSymbol; + methodName = attributeMethodName; } - - var funcType = namedReturnType.TypeArguments[0] as INamedTypeSymbol; - if (funcType == null || funcType.Name != "Func" || funcType.TypeArguments.Length != 1) + else { return null; } - var tupleType = funcType.TypeArguments[0] as INamedTypeSymbol; - if (tupleType == null || !tupleType.IsTupleType) + var compilation = testMethod.CompilationContext.Compilation; + var dataSourceMember = ResolveMethodDataSourceMember(providerType, methodName, mdsAttr, compilation); + var rowType = dataSourceMember == null ? null : GetMethodDataSourceRowType(dataSourceMember, testMethod.CompilationContext.MethodDataSourceRowTypes, compilation); + if (rowType == null) { return null; } - // Extract the types from the tuple elements that correspond to the generic parameters. - // CancellationToken parameters are supplied by the engine, not by the row. + // Row values bind to the data parameters only; the engine supplies the CancellationToken. var testMethodParams = GetDataParameters(testMethod.MethodSymbol); var genericParams = testMethod.MethodSymbol.TypeParameters; var genericParamMap = new Dictionary(); - // Map tuple elements to method parameters to infer types - var tupleElements = tupleType.TupleElements; - for (var i = 0; i < testMethodParams.Length && i < tupleElements.Length; i++) + if (rowType is INamedTypeSymbol { IsTupleType: true } tupleType + && !(testMethodParams.Length == 1 && testMethodParams[0].Type.IsTupleType)) { - var paramType = testMethodParams[i].Type; - var tupleElementType = tupleElements[i].Type; - - // Process the parameter type to find generic references - ProcessTypeForGenerics(paramType, tupleElementType, genericParams, genericParamMap); + // A tuple row is spread across the test method's parameters + var tupleElements = tupleType.TupleElements; + for (var i = 0; i < testMethodParams.Length && i < tupleElements.Length; i++) + { + ProcessTypeForGenerics(testMethodParams[i].Type, tupleElements[i].Type, genericParams, genericParamMap); + } + } + else if (testMethodParams.Length > 0) + { + // Any other row is a single value for the first parameter. This includes typed arrays + // such as int[]: only object[] rows are spread (DataSourceHelpers.ToObjectArray). + ProcessTypeForGenerics(testMethodParams[0].Type, rowType, genericParams, genericParamMap); } // Build the result array in the correct order @@ -7177,6 +7234,419 @@ private static void MapGenericTypeArguments(ITypeSymbol paramType, ITypeSymbol a return inferredTypes; } + /// + /// Builds the argument list for calling a [MethodDataSource] method with its Arguments, which the + /// generated factory holds in an object[] named arguments. It accepts what + /// accepts, as reflection mode's binder and BuildInvokeArgs do: + /// + /// A value that needs a numeric or nullable conversion, such as an int passed to a long + /// parameter, is unboxed as its own type first. Casting the boxed value straight to the parameter type + /// would throw . + /// A missing optional parameter is left out so its default applies, and a missing + /// CancellationToken gets CancellationToken.None. Later parameters are passed by name. + /// + /// A missing required parameter is only reached when no overload accepts the Arguments + /// ( rejects such overloads, and TUnit0001 reports the mismatch at + /// compile time). The generated call then throws a descriptive + /// when the data source runs, instead of an . + /// A required parameter can follow a skipped optional one only in that same case: C# requires every + /// parameter after an optional one to be optional or params, so a parameter after a skipped one + /// is itself missing. + /// + private static string BuildDataSourceCallArguments(IMethodSymbol method, TypedConstant arguments, Compilation compilation) + { + var values = arguments is { Kind: TypedConstantKind.Array, IsNull: false } + ? arguments.Values + : ImmutableArray.Empty; + + var callArguments = new List(method.Parameters.Length); + var useNames = false; + for (var i = 0; i < method.Parameters.Length; i++) + { + var parameter = method.Parameters[i]; + var parameterType = parameter.Type.GloballyQualified(); + string value; + + if (i < values.Length) + { + var argumentType = values[i] is { IsNull: false, Type: { } type } ? type : null; + var conversion = argumentType == null || SymbolEqualityComparer.Default.Equals(argumentType, parameter.Type) + ? default + : compilation.ClassifyCommonConversion(argumentType, parameter.Type); + + value = IsInvokeConversion(conversion, argumentType, parameter.Type) && (conversion.IsNumeric || conversion.IsNullable) + ? $"(({parameterType})({argumentType!.GloballyQualified()})arguments[{i.ToString(CultureInfo.InvariantCulture)}])" + : $"(({parameterType})arguments[{i.ToString(CultureInfo.InvariantCulture)}])"; + } + else if (parameter.HasExplicitDefaultValue) + { + useNames = true; + continue; + } + else if (parameter.Type.IsCancellationToken()) + { + value = "global::System.Threading.CancellationToken.None"; + } + else + { + var message = $"[MethodDataSource] {method.ContainingType.Name}.{method.Name} needs a value for parameter '{parameter.Name}', " + + $"but its Arguments supply {values.Length.ToString(CultureInfo.InvariantCulture)}. " + + "Pass a value for every required parameter of the data method."; + value = $"(({parameterType})(arguments.Length > {i.ToString(CultureInfo.InvariantCulture)} ? arguments[{i.ToString(CultureInfo.InvariantCulture)}] " + + $": throw new global::System.InvalidOperationException({SymbolDisplay.FormatLiteral(message, quote: true)})))"; + } + + callArguments.Add(useNames ? $"@{parameter.Name}: {value}" : value); + } + + return string.Join(", ", callArguments); + } + + /// + /// Picks the member a [MethodDataSource] reads, mirroring reflection mode's + /// MethodDataSourceAttribute.ResolveDataSourceMethod: the first type in the hierarchy that + /// declares the name is searched, and among its methods the overload that accepts the attribute's + /// Arguments wins (exact argument types over implicit conversions). A property or field of + /// that name is used when no method applies. Both the generated factory and generic type inference + /// use this, so the closed test method always matches the rows the factory produces. + /// + private static ISymbol? ResolveMethodDataSourceMember(ITypeSymbol targetType, string memberName, AttributeData attr, Compilation compilation) + { + // Walk base types: with [InheritsTests] (or a data member declared on a base class) the member + // may not be declared directly on the test class. Missing it would emit a plain + // MethodDataSourceAttribute without a Factory (https://github.com/thomhurst/TUnit/issues/6162). + for (var searchType = targetType; searchType is not null; searchType = searchType.BaseType) + { + var members = searchType.GetMembers(memberName); + if (members.Length == 0) + { + continue; + } + + var argumentsProperty = attr.NamedArguments.FirstOrDefault(x => x.Key == "Arguments"); + var arguments = argumentsProperty is { Key: not null, Value: { IsNull: false, Kind: TypedConstantKind.Array } } + ? argumentsProperty.Value.Values + : ImmutableArray.Empty; + + IMethodSymbol? bestMethod = null; + IMethodSymbol? firstMethod = null; + var bestScore = -1; + foreach (var member in members) + { + if (member is not IMethodSymbol method) + { + continue; + } + + // A generic data method is never a fallback while a non-generic one exists: its type arguments + // cannot be inferred from the Arguments, and inference would close the test over its open T + if (firstMethod == null || (firstMethod.IsGenericMethod && !method.IsGenericMethod)) + { + firstMethod = method; + } + + var score = ScoreDataSourceOverload(method, arguments, compilation); + if (score > bestScore + || (score == bestScore && score >= 0 && IsMoreSpecificDataSourceOverload(method, bestMethod!, arguments.Length, compilation))) + { + // On a tie, the overload with the more specific parameter types wins, as with the reflection + // binder: Rows(long) beats Rows(object) for an int argument. + bestScore = score; + bestMethod = method; + } + } + + if (bestMethod != null) + { + return bestMethod; + } + + // No overload accepts the arguments: prefer a property or field, else keep the first + // method so the generated call reports the mismatch as before. Generic type inference may then + // read the row type of a method whose call fails. That is harmless: TUnit0001 reports Arguments + // that no overload accepts as a compile error, so this is reached only with it suppressed, and the + // data source then fails when it runs, as it does in reflection mode. Returning null instead would + // leave a generic test with no inferred type arguments, so it would disappear without an error. + foreach (var member in members) + { + if (member is IPropertySymbol or IFieldSymbol) + { + return member; + } + } + + return firstMethod ?? members[0]; + } + + return null; + } + + /// + /// Whether every parameter of that receives an argument converts implicitly to the + /// matching parameter of , and they differ. Mirrors IsMoreSpecific in + /// MethodDataSourceAttribute. + /// + private static bool IsMoreSpecificDataSourceOverload(IMethodSymbol candidate, IMethodSymbol other, int argumentCount, Compilation compilation) + { + // Only called for two overloads that both scored >= 0, and ScoreDataSourceOverload returns -1 when + // there are more arguments than parameters, so both have at least argumentCount parameters. Check it anyway: + // an exception here would surface as an opaque generator failure, and "not more specific" is a safe answer. + if (argumentCount > candidate.Parameters.Length || argumentCount > other.Parameters.Length) + { + return false; + } + + var anyDifferent = false; + for (var i = 0; i < argumentCount; i++) + { + var candidateType = candidate.Parameters[i].Type; + var otherType = other.Parameters[i].Type; + if (SymbolEqualityComparer.Default.Equals(candidateType, otherType)) + { + continue; + } + + if (compilation.ClassifyCommonConversion(candidateType, otherType) is not { IsImplicit: true, IsUserDefined: false }) + { + return false; + } + + anyDifferent = true; + } + + return anyDifferent; + } + + /// + /// Scores how well accepts the [MethodDataSource] Arguments: + /// -1 when it cannot be called with them, otherwise higher for exact argument types. + /// An overload with exactly one parameter per argument always outranks one that needs missing + /// parameters filled in, because reflection mode's binder only considers exact-count overloads. + /// It falls back to the method's name alone, which works when there is a single overload. + /// Missing trailing parameters must be optional or a CancellationToken, which is what reflection + /// mode's BuildInvokeArgs fills in and emits. + /// + private static int ScoreDataSourceOverload(IMethodSymbol method, ImmutableArray arguments, Compilation compilation) + { + var parameters = method.Parameters; + + // A generic data method needs type arguments the Arguments cannot supply. Reflection mode's binder skips it + // too, so IEnumerable Rows() wins over IEnumerable Rows() whichever is declared first. + if (method.IsGenericMethod || arguments.Length > parameters.Length) + { + return -1; + } + + // Each argument adds at most 2, so this base puts every exact-count overload above every other one + var score = arguments.Length == parameters.Length ? 2 * arguments.Length + 1 : 0; + for (var i = 0; i < parameters.Length; i++) + { + var parameterType = parameters[i].Type; + if (i >= arguments.Length) + { + if (!parameters[i].HasExplicitDefaultValue && !parameterType.IsCancellationToken()) + { + return -1; + } + + continue; + } + + var argument = arguments[i]; + if (argument.IsNull || argument.Type == null) + { + if (parameterType.IsValueType && parameterType.OriginalDefinition.SpecialType != SpecialType.System_Nullable_T) + { + return -1; + } + + continue; + } + + if (SymbolEqualityComparer.Default.Equals(argument.Type, parameterType)) + { + score += 2; + } + else if (IsInvokeConversion(compilation.ClassifyCommonConversion(argument.Type, parameterType), argument.Type, parameterType)) + { + score += 1; + } + else + { + return -1; + } + } + + return score; + } + + /// + /// Whether from a boxed argument to + /// is one that reflection mode's binder and MethodInfo.Invoke also make: + /// implicit reference and boxing conversions, built-in numeric widening other than to decimal, and + /// T to Nullable<T>. C# also converts int to decimal or long?, but + /// reflection cannot, so accepting them would make the two modes call different overloads: for 1, + /// Rows(object) in reflection mode and Rows(decimal) here. User-defined operators never apply. + /// Mirrors ScoreArguments in MethodDataSourceAttribute. + /// + private static bool IsInvokeConversion(Microsoft.CodeAnalysis.Operations.CommonConversion conversion, ITypeSymbol? argumentType, ITypeSymbol parameterType) + { + if (conversion is not { IsImplicit: true, IsUserDefined: false }) + { + return false; + } + + if (conversion.IsNullable) + { + return parameterType is INamedTypeSymbol { TypeArguments: [var underlying] } + && SymbolEqualityComparer.Default.Equals(underlying, argumentType); + } + + return !conversion.IsNumeric || parameterType.SpecialType != SpecialType.System_Decimal; + } + + /// + /// Returns the declared type of one data row produced by a [MethodDataSource] member, unwrapping the + /// shapes the generated factory enumerates: Task<T>/ValueTask<T>, then + /// IEnumerable<T> or arrays (or IAsyncEnumerable<T> when not task-wrapped), + /// then one Func<T>, one TestDataRow<T> and one Func<T> inside it, + /// matching what the runtime row reader invokes and unwraps. + /// Returns when the row type cannot say anything about the test's type + /// arguments (object or object[] rows, or a non-generic IEnumerable), since + /// those are only known at runtime. + /// + private static ITypeSymbol? GetMethodDataSourceRowType(ISymbol dataSourceMember, MethodDataSourceRowTypes wellKnown, Compilation compilation) + { + var type = dataSourceMember switch + { + IMethodSymbol method => method.ReturnType, + IPropertySymbol property => property.Type, + IFieldSymbol field => field.Type, + _ => null + }; + + if (type == null) + { + return null; + } + + // Looked up once per compilation, not per attribute + var taskType = wellKnown.TaskType; + var valueTaskType = wellKnown.ValueTaskType; + var funcType = wellKnown.FuncType; + var asyncEnumerableType = wellKnown.AsyncEnumerableType; + var testDataRowType = wellKnown.TestDataRowType; + + var isTaskWrapped = false; + if (type is INamedTypeSymbol { IsGenericType: true } namedTask + && (IsDefinition(namedTask, taskType) || IsDefinition(namedTask, valueTaskType))) + { + type = namedTask.TypeArguments[0]; + isTaskWrapped = true; + } + + if (type is IArrayTypeSymbol arrayType) + { + type = arrayType.ElementType; + } + else if (type.SpecialType != SpecialType.System_String && !type.IsTupleType) + { + // The Task/ValueTask factories only enumerate a synchronous IEnumerable; an awaited + // IAsyncEnumerable is passed through as one row, as in reflection mode. + if (!isTaskWrapped && GetGenericInterfaceArgument(type, asyncEnumerableType) is { } asyncElementType) + { + type = asyncElementType; + } + else if (type.IsIEnumerable(compilation, out var elementType)) + { + type = elementType; + } + else if (IsNonGenericEnumerable(type)) + { + // A non-generic IEnumerable is enumerated by the factory, but its items' types are unknown + return null; + } + } + + // Peel only the layers the row reader removes: DataSourceHelpers.ToObjectArray invokes one + // outer Func, then TestDataRowUnwrapper.UnwrapArray strips one TestDataRow and invokes one + // Func inside it. Anything nested deeper reaches the test as a value (e.g. a Func row + // from Func>), so inference must see that value's type too. + type = Unwrap(type, funcType); + if (TryUnwrap(type, testDataRowType, out var rowData)) + { + type = Unwrap(rowData, funcType); + } + + if (type.SpecialType == SpecialType.System_Object + || type is IArrayTypeSymbol { ElementType.SpecialType: SpecialType.System_Object }) + { + return null; + } + + return type; + + static bool IsDefinition(INamedTypeSymbol type, INamedTypeSymbol? definition) + => definition != null && SymbolEqualityComparer.Default.Equals(type.OriginalDefinition, definition); + + static ITypeSymbol Unwrap(ITypeSymbol type, INamedTypeSymbol? definition) + => TryUnwrap(type, definition, out var inner) ? inner : type; + + static bool TryUnwrap(ITypeSymbol type, INamedTypeSymbol? definition, out ITypeSymbol inner) + { + if (type is INamedTypeSymbol { IsGenericType: true } wrapper && IsDefinition(wrapper, definition)) + { + inner = wrapper.TypeArguments[0]; + return true; + } + + inner = type; + return false; + } + + static bool IsNonGenericEnumerable(ITypeSymbol type) + { + if (type.SpecialType == SpecialType.System_Collections_IEnumerable) + { + return true; + } + + foreach (var @interface in type.AllInterfaces) + { + if (@interface.SpecialType == SpecialType.System_Collections_IEnumerable) + { + return true; + } + } + + return false; + } + } + + private static ITypeSymbol? GetGenericInterfaceArgument(ITypeSymbol type, INamedTypeSymbol? interfaceDefinition) + { + if (interfaceDefinition == null) + { + return null; + } + + if (type is INamedTypeSymbol { IsGenericType: true } namedType + && SymbolEqualityComparer.Default.Equals(namedType.OriginalDefinition, interfaceDefinition)) + { + return namedType.TypeArguments[0]; + } + + foreach (var @interface in type.AllInterfaces) + { + if (SymbolEqualityComparer.Default.Equals(@interface.OriginalDefinition, interfaceDefinition)) + { + return @interface.TypeArguments[0]; + } + } + + return null; + } + private static ITypeSymbol[]? InferClassTypesFromMethodDataSource(TestMethodMetadata testMethod, AttributeData mdsAttr) { if (mdsAttr.ConstructorArguments.Length == 0) @@ -7283,6 +7753,15 @@ private static void ProcessTypeForGenerics(ITypeSymbol paramType, ITypeSymbol ac return; } + // Arrays such as T[] fed an int[] + if (paramType is IArrayTypeSymbol paramArray + && actualType is IArrayTypeSymbol actualArray + && paramArray.Rank == actualArray.Rank) + { + ProcessTypeForGenerics(paramArray.ElementType, actualArray.ElementType, genericParams, genericParamMap); + return; + } + // Check for generic types like IEnumerable, Func, etc. if (paramType is INamedTypeSymbol { IsGenericType: true } namedParamType && actualType is INamedTypeSymbol { IsGenericType: true } namedActualType && diff --git a/src/TUnit.Core.SourceGenerator/Helpers/IdentifierHelper.cs b/src/TUnit.Core.SourceGenerator/Helpers/IdentifierHelper.cs new file mode 100644 index 00000000000..6a64e6fa4af --- /dev/null +++ b/src/TUnit.Core.SourceGenerator/Helpers/IdentifierHelper.cs @@ -0,0 +1,13 @@ +using Microsoft.CodeAnalysis.CSharp; + +namespace TUnit.Core.SourceGenerator.Helpers; + +internal static class IdentifierHelper +{ + /// + /// A symbol's Name drops the @ of an escaped identifier, so a member named after a keyword, such as + /// @event, needs it back before generated code can access the member. + /// + public static string Escape(string name) + => SyntaxFacts.GetKeywordKind(name) != SyntaxKind.None ? "@" + name : name; +} diff --git a/src/TUnit.Core.SourceGenerator/Models/TestMethodMetadata.cs b/src/TUnit.Core.SourceGenerator/Models/TestMethodMetadata.cs index 8e742ec8368..8ab3f272392 100644 --- a/src/TUnit.Core.SourceGenerator/Models/TestMethodMetadata.cs +++ b/src/TUnit.Core.SourceGenerator/Models/TestMethodMetadata.cs @@ -6,7 +6,29 @@ namespace TUnit.Core.SourceGenerator.Models; -public record CompilationContext(CSharpCompilation Compilation, AttributeWriter AttributeWriter, WellKnownTypes WellKnownTypes); +public record CompilationContext(CSharpCompilation Compilation, AttributeWriter AttributeWriter, WellKnownTypes WellKnownTypes) +{ + private MethodDataSourceRowTypes? _methodDataSourceRowTypes; + + /// + /// The generic definitions used to unwrap [MethodDataSource] row types, looked up once per compilation + /// on first use. A race only repeats the lookups: both instances hold the same symbols. + /// + public MethodDataSourceRowTypes MethodDataSourceRowTypes => _methodDataSourceRowTypes ??= new MethodDataSourceRowTypes(Compilation); +} + +/// +/// The generic type definitions that wrap a [MethodDataSource] row. It holds symbols from one compilation, so, +/// like , it must never flow through the incremental pipeline. +/// +public sealed class MethodDataSourceRowTypes(Compilation compilation) +{ + public INamedTypeSymbol? TaskType { get; } = compilation.GetTypeByMetadataName("System.Threading.Tasks.Task`1"); + public INamedTypeSymbol? ValueTaskType { get; } = compilation.GetTypeByMetadataName("System.Threading.Tasks.ValueTask`1"); + public INamedTypeSymbol? FuncType { get; } = compilation.GetTypeByMetadataName("System.Func`1"); + public INamedTypeSymbol? AsyncEnumerableType { get; } = compilation.GetTypeByMetadataName("System.Collections.Generic.IAsyncEnumerable`1"); + public INamedTypeSymbol? TestDataRowType { get; } = compilation.GetTypeByMetadataName("TUnit.Core.TestDataRow`1"); +} /// /// Contains all the metadata about a test method discovered by the source generator. diff --git a/src/TUnit.Core.SourceGenerator/Utilities/MetadataGenerationHelper.cs b/src/TUnit.Core.SourceGenerator/Utilities/MetadataGenerationHelper.cs index 6322412370f..3da6969e05d 100644 --- a/src/TUnit.Core.SourceGenerator/Utilities/MetadataGenerationHelper.cs +++ b/src/TUnit.Core.SourceGenerator/Utilities/MetadataGenerationHelper.cs @@ -2,6 +2,7 @@ using System.Collections.Immutable; using Microsoft.CodeAnalysis; using TUnit.Core.SourceGenerator.Extensions; +using TUnit.Core.SourceGenerator.Helpers; namespace TUnit.Core.SourceGenerator.Utilities; @@ -331,13 +332,13 @@ private static string GetPropertyAccessor(INamedTypeSymbol namedTypeSymbol, IPro // Use reflection to get the value at runtime ? $"_ => typeof({namedTypeSymbol.GloballyQualified()}).GetProperty(\"{property.Name}\")?.GetValue(null)" // Use dynamic to avoid invalid cast to open generic type - : $"o => ((dynamic)o).{property.Name}"; + : $"o => ((dynamic)o).{IdentifierHelper.Escape(property.Name)}"; } var safeTypeName = namedTypeSymbol.GloballyQualified(); return property.IsStatic - ? $"_ => {safeTypeName}.{property.Name}" - : $"o => (({safeTypeName})o).{property.Name}"; + ? $"_ => {safeTypeName}.{IdentifierHelper.Escape(property.Name)}" + : $"o => (({safeTypeName})o).{IdentifierHelper.Escape(property.Name)}"; } /// diff --git a/src/TUnit.Core/Attributes/TestData/MethodDataSourceAttribute.cs b/src/TUnit.Core/Attributes/TestData/MethodDataSourceAttribute.cs index 7476434146e..e4abaacc9b1 100644 --- a/src/TUnit.Core/Attributes/TestData/MethodDataSourceAttribute.cs +++ b/src/TUnit.Core/Attributes/TestData/MethodDataSourceAttribute.cs @@ -269,6 +269,33 @@ internal InstanceMethodDataSourceAttribute ToInstanceVariant() yield break; } + var hasAnyItems = false; + await foreach (var row in GetRowsFromRuntimeValueAsync(methodResult, dataGeneratorMetadata)) + { + hasAnyItems = true; + yield return row; + } + + // If the source was empty, yield one empty result like NoDataSource does + // unless SkipIfEmpty is true, in which case we yield nothing (test will be skipped) + if (!hasAnyItems && !SkipIfEmpty) + { + yield return () => Task.FromResult([]); + } + } + + /// + /// Turns a data source's value into rows by its runtime type: an , a + /// or (awaited, then treated like its result), an + /// other than a string or tuple (one row per item), or a single row. + /// Used by the reflection fallback above and by the source-generated factory for a field, or a private or protected + /// property, whose declared type does not say which of these it holds, so both read such a member the same way. + /// An empty source yields nothing; the caller decides whether that becomes an empty row. + /// + [UnconditionalSuppressMessage("Trimming", "IL2072", Justification = "Method data sources require runtime discovery. AOT users should use Factory property.")] + [UnconditionalSuppressMessage("Trimming", "IL2075", Justification = "Method data sources require runtime discovery. AOT users should use Factory property.")] + internal static async IAsyncEnumerable>> GetRowsFromRuntimeValueAsync(object methodResult, DataGeneratorMetadata dataGeneratorMetadata) + { // ValueTask is neither a Task nor an IEnumerable, so normalise it to Task and let // the Task branch below await it, as the source-generated Factory does. if (TryConvertValueTaskToTask(methodResult) is { } valueTaskAsTask) @@ -284,22 +311,13 @@ internal InstanceMethodDataSourceAttribute ToInstanceVariant() // If it's IAsyncEnumerable, handle it specially if (IsAsyncEnumerable(methodResult.GetType())) { - var hasAnyItems = false; await foreach (var item in ConvertToAsyncEnumerable(methodResult)) { - hasAnyItems = true; yield return async () => { return await Task.FromResult(item.ToObjectArrayWithTypes(paramTypes)); }; } - - // If the async enumerable was empty, yield one empty result like NoDataSource does - // unless SkipIfEmpty is true, in which case we yield nothing (test will be skipped) - if (!hasAnyItems && !SkipIfEmpty) - { - yield return () => Task.FromResult([]); - } } // If it's Task else if (methodResult is Task task) @@ -309,22 +327,13 @@ internal InstanceMethodDataSourceAttribute ToInstanceVariant() if (taskResult is System.Collections.IEnumerable enumerable and not string && !DataSourceHelpers.IsTuple(taskResult)) { - var hasAnyItems = false; foreach (var item in enumerable) { - hasAnyItems = true; yield return async () => { return await Task.FromResult(item.ToObjectArrayWithTypes(paramTypes)); }; } - - // If the enumerable was empty, yield one empty result like NoDataSource does - // unless SkipIfEmpty is true, in which case we yield nothing (test will be skipped) - if (!hasAnyItems && !SkipIfEmpty) - { - yield return () => Task.FromResult([]); - } } else { @@ -338,19 +347,10 @@ internal InstanceMethodDataSourceAttribute ToInstanceVariant() // Tuples implement IEnumerable but should be treated as single values else if (methodResult is System.Collections.IEnumerable enumerable and not string && !DataSourceHelpers.IsTuple(methodResult)) { - var hasAnyItems = false; foreach (var item in enumerable) { - hasAnyItems = true; yield return () => Task.FromResult(item.ToObjectArrayWithTypes(paramTypes)); } - - // If the enumerable was empty, yield one empty result like NoDataSource does - // unless SkipIfEmpty is true, in which case we yield nothing (test will be skipped) - if (!hasAnyItems && !SkipIfEmpty) - { - yield return () => Task.FromResult([]); - } } else { @@ -371,12 +371,16 @@ internal InstanceMethodDataSourceAttribute ToInstanceVariant() // throw on SingleOrDefault. // // When any argument is null it has no runtime type, so it cannot be expressed in the binder's - // Type[]; we fall back to a name-only single-overload lookup (handled by the caller). + // Type[]. The overloads are then scored the way the source generator scores them (ScoreArguments): + // a null needs a reference or Nullable parameter, other arguments may use numeric widening, + // missing trailing parameters must be optional or a CancellationToken, and exact-count overloads and + // exact argument types rank higher. A single best overload is used. Otherwise we fall back to the + // caller's name-only lookup. // // With zero arguments the empty Type[] flows through the same binder path and selects the // parameterless overload directly — including when the name is shared with other-arity - // overloads, which the caller's name-only GetMethod(name, flags) would treat as ambiguous - // and silently return null for. + // overloads, which the caller's name-only GetMethod(name, flags) would reject as ambiguous + // with an AmbiguousMatchException. [UnconditionalSuppressMessage("Trimming", "IL2070", Justification = "Method data sources require runtime discovery. AOT users should use Factory property.")] private MethodInfo? ResolveDataSourceMethod([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods | DynamicallyAccessedMemberTypes.NonPublicMethods)] Type targetType) { @@ -392,8 +396,7 @@ internal InstanceMethodDataSourceAttribute ToInstanceVariant() if (argumentType is null) { // A null argument has no runtime type the binder can match on. - // Fall back to the name-only lookup performed by the caller. - return null; + return ResolveDataSourceMethodWithNullArgument(targetType, arguments); } argumentTypes[i] = argumentType; @@ -402,7 +405,190 @@ internal InstanceMethodDataSourceAttribute ToInstanceVariant() // Let the runtime binder pick the best overload for these exact argument types. // Ambiguous matches surface as AmbiguousMatchException (genuinely ambiguous code), // never as the spurious SingleOrDefault throw the old scan produced. - return targetType.GetMethod(MethodNameProvidingDataSource, BindingFlags, binder: null, argumentTypes, modifiers: null); + // Generic method definitions are skipped: the Arguments cannot supply their type arguments, so + // IEnumerable Rows() is used rather than an ambiguous match with IEnumerable Rows(), + // as the source generator does. +#if NET + return targetType.GetMethod(MethodNameProvidingDataSource, genericParameterCount: 0, BindingFlags, binder: null, argumentTypes, modifiers: null); +#else + List? candidates = null; + foreach (var method in targetType.GetMethods(BindingFlags)) + { + if (method.Name == MethodNameProvidingDataSource && !method.IsGenericMethodDefinition) + { + (candidates ??= []).Add(method); + } + } + + return candidates is null + ? null + : (MethodInfo?)Type.DefaultBinder.SelectMethod(BindingFlags, candidates.ToArray(), argumentTypes, modifiers: null); +#endif + } + + [UnconditionalSuppressMessage("Trimming", "IL2070", Justification = "Method data sources require runtime discovery. AOT users should use Factory property.")] + private MethodInfo? ResolveDataSourceMethodWithNullArgument([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods | DynamicallyAccessedMemberTypes.NonPublicMethods)] Type targetType, object?[] arguments) + { + var bestScore = -1; + var best = new List(); + foreach (var method in targetType.GetMethods(BindingFlags)) + { + if (method.Name != MethodNameProvidingDataSource || method.IsGenericMethodDefinition) + { + continue; + } + + var score = ScoreArguments(method.GetParameters(), arguments); + if (score < 0 || score < bestScore) + { + continue; + } + + if (score > bestScore) + { + best.Clear(); + bestScore = score; + } + + best.Add(method); + } + + // On a tie, the overload with the more specific parameter types wins, as with the binder and the source + // generator: Rows(string?, long) beats Rows(string?, object) for { null, 20 }. + foreach (var candidate in best) + { + var mostSpecific = true; + foreach (var other in best) + { + if (!ReferenceEquals(candidate, other) && !IsMoreSpecific(candidate.GetParameters(), other.GetParameters(), arguments.Length)) + { + mostSpecific = false; + break; + } + } + + if (mostSpecific) + { + return candidate; + } + } + + // Still ambiguous, or nothing accepts the arguments: the caller's name-only lookup reports it + return null; + } + + private static bool IsMoreSpecific(ParameterInfo[] candidate, ParameterInfo[] other, int argumentCount) + { + // Only called for overloads that ScoreArguments accepted, and it rejects any overload with fewer + // parameters than arguments, so both have at least argumentCount parameters. Check it anyway, as the + // generator's IsMoreSpecificDataSourceOverload does, so a broken invariant cannot index past the end. + if (argumentCount > candidate.Length || argumentCount > other.Length) + { + return false; + } + + var anyDifferent = false; + for (var i = 0; i < argumentCount; i++) + { + var candidateType = candidate[i].ParameterType; + var otherType = other[i].ParameterType; + if (candidateType == otherType) + { + continue; + } + + var otherUnderlying = Nullable.GetUnderlyingType(otherType) ?? otherType; + if (!otherType.IsAssignableFrom(candidateType) + && candidateType != otherUnderlying + && !IsNumericWidening(candidateType, otherUnderlying)) + { + return false; + } + + anyDifferent = true; + } + + return anyDifferent; + } + + /// + /// Scores how well a method accepts , as the source generator's + /// ScoreDataSourceOverload does: -1 when it cannot be called with them, otherwise higher for exact + /// argument types. An overload with one parameter per argument outranks one that needs missing optional or + /// parameters filled in by . + /// + private static int ScoreArguments(ParameterInfo[] parameters, object?[] arguments) + { + if (arguments.Length > parameters.Length) + { + return -1; + } + + // Each argument adds at most 2, so this base puts every exact-count overload above every other one + var score = arguments.Length == parameters.Length ? 2 * arguments.Length + 1 : 0; + for (var i = 0; i < parameters.Length; i++) + { + var parameterType = parameters[i].ParameterType; + if (i >= arguments.Length) + { + if (!parameters[i].HasDefaultValue && parameterType != typeof(CancellationToken)) + { + return -1; + } + + continue; + } + + if (arguments[i] is not { } argument) + { + if (parameterType.IsValueType && Nullable.GetUnderlyingType(parameterType) is null) + { + return -1; + } + + continue; + } + + var argumentType = argument.GetType(); + var underlyingParameterType = Nullable.GetUnderlyingType(parameterType) ?? parameterType; + if (argumentType == parameterType) + { + score += 2; + } + else if (parameterType.IsInstanceOfType(argument) + || argumentType == underlyingParameterType + || IsNumericWidening(argumentType, parameterType)) + { + score += 1; + } + else + { + return -1; + } + } + + return score; + } + + // The implicit numeric conversions C# allows, except to decimal, which MethodInfo.Invoke cannot apply. + // Invoke cannot widen into Nullable either (an int argument for a long? parameter throws), so callers + // pass the parameter type itself, not its underlying type. + private static bool IsNumericWidening(Type from, Type to) + { + var target = Type.GetTypeCode(to); + return Type.GetTypeCode(from) switch + { + TypeCode.SByte => target is TypeCode.Int16 or TypeCode.Int32 or TypeCode.Int64 or TypeCode.Single or TypeCode.Double, + TypeCode.Byte => target is TypeCode.Int16 or TypeCode.UInt16 or TypeCode.Int32 or TypeCode.UInt32 or TypeCode.Int64 or TypeCode.UInt64 or TypeCode.Single or TypeCode.Double, + TypeCode.Int16 => target is TypeCode.Int32 or TypeCode.Int64 or TypeCode.Single or TypeCode.Double, + TypeCode.UInt16 => target is TypeCode.Int32 or TypeCode.UInt32 or TypeCode.Int64 or TypeCode.UInt64 or TypeCode.Single or TypeCode.Double, + TypeCode.Char => target is TypeCode.UInt16 or TypeCode.Int32 or TypeCode.UInt32 or TypeCode.Int64 or TypeCode.UInt64 or TypeCode.Single or TypeCode.Double, + TypeCode.Int32 => target is TypeCode.Int64 or TypeCode.Single or TypeCode.Double, + TypeCode.UInt32 => target is TypeCode.Int64 or TypeCode.UInt64 or TypeCode.Single or TypeCode.Double, + TypeCode.Int64 or TypeCode.UInt64 => target is TypeCode.Single or TypeCode.Double, + TypeCode.Single => target is TypeCode.Double, + _ => false + } && !to.IsEnum && !from.IsEnum; } // MethodInfo.Invoke does not auto-fill optional parameters the way a C# call site does. diff --git a/src/TUnit.Core/Helpers/DataSourceFactories.cs b/src/TUnit.Core/Helpers/DataSourceFactories.cs index 33b46603c1e..3b7e91594fd 100644 --- a/src/TUnit.Core/Helpers/DataSourceFactories.cs +++ b/src/TUnit.Core/Helpers/DataSourceFactories.cs @@ -187,6 +187,45 @@ public static class DataSourceFactories } } + /// + /// A data source field, or a private or protected property that the generated code reads by reflection, whose + /// declared type does not say whether it holds one row or many, such as object. The value's runtime type decides, + /// as it does when has no factory and reads the member itself. + /// A null value is one row holding null, as gives. + /// + public static async IAsyncEnumerable>> FromRuntimeValue(DataGeneratorMetadata dataGeneratorMetadata, Func invoke) + { + if (invoke() is not { } result) + { + yield return NullValueRow; + yield break; + } + + await foreach (var row in MethodDataSourceAttribute.GetRowsFromRuntimeValueAsync(result, dataGeneratorMetadata)) + { + yield return row; + } + } + + /// Instance twin of . + public static async IAsyncEnumerable>> FromInstanceRuntimeValue(DataGeneratorMetadata dataGeneratorMetadata, Func invoke) + { + if (invoke(GetRequiredInstance(dataGeneratorMetadata)) is not { } result) + { + yield return NullValueRow; + yield break; + } + + await foreach (var row in MethodDataSourceAttribute.GetRowsFromRuntimeValueAsync(result, dataGeneratorMetadata)) + { + yield return row; + } + } + + // A null value is one row holding null, as FromValue gives for a member whose declared type picks it. Yielding + // nothing instead would become an empty row, so the test would fail for a missing argument. + private static readonly Func> NullValueRow = static () => Task.FromResult([null]); + private static object GetRequiredInstance(DataGeneratorMetadata dataGeneratorMetadata) { return dataGeneratorMetadata.TestClassInstance diff --git a/tests/TUnit.Analyzers.Tests/MethodDataSourceAnalyzerTests.cs b/tests/TUnit.Analyzers.Tests/MethodDataSourceAnalyzerTests.cs index f341f64a304..c51ab13f1b7 100644 --- a/tests/TUnit.Analyzers.Tests/MethodDataSourceAnalyzerTests.cs +++ b/tests/TUnit.Analyzers.Tests/MethodDataSourceAnalyzerTests.cs @@ -2778,4 +2778,56 @@ public void MyTest(int value) """ ); } + + [Test] + public async Task Non_Generic_Data_Method_Is_Used_Over_A_Generic_One_Declared_First() + { + // Neither mode can call Data() without type arguments, so the rows come from Data(). + await Verifier + .VerifyAnalyzerAsync( + """ + using System.Collections.Generic; + using TUnit.Core; + + public class MyClass + { + [{|#0:MethodDataSource(nameof(Data))|}] + [Test] + public void MyTest(string value) + { + } + + public static IEnumerable Data() => []; + public static IEnumerable Data() => [1]; + } + """, + + Verifier.Diagnostic(Rules.WrongArgumentTypeTestData) + .WithLocation(0) + .WithArguments("int", "string") + ); + } + + [Test] + public async Task Generic_Data_Method_Without_A_Non_Generic_Sibling_Is_Still_Found() + { + await Verifier + .VerifyAnalyzerAsync( + """ + using System.Collections.Generic; + using TUnit.Core; + + public class MyClass + { + [MethodDataSource(nameof(Data))] + [Test] + public void MyTest(int value) + { + } + + public static IEnumerable Data() => [1]; + } + """ + ); + } } diff --git a/tests/TUnit.Core.SourceGenerator.Tests/Bugs/7108/Tests7108.cs b/tests/TUnit.Core.SourceGenerator.Tests/Bugs/7108/Tests7108.cs new file mode 100644 index 00000000000..7caaa685f1e --- /dev/null +++ b/tests/TUnit.Core.SourceGenerator.Tests/Bugs/7108/Tests7108.cs @@ -0,0 +1,40 @@ +namespace TUnit.Core.SourceGenerator.Tests; + +internal class Tests7108 : TestsBase +{ + [Test] + public Task Test() => RunTest(Path.Combine( + Git.TestsDirectory.FullName, + "TUnit.TestProject", + "Bugs", + "_7108", + "GenericMethodNonTupleMethodDataSourceTests.cs"), + _ => Task.CompletedTask); + + [Test] + public Task Public_Object_Field() => RunTest(Path.Combine( + Git.TestsDirectory.FullName, + "TUnit.TestProject", + "Bugs", + "_7108", + "PublicObjectFieldDataSourceTests.cs"), + _ => Task.CompletedTask); + + [Test] + public Task Private_Row_Type() => RunTest(Path.Combine( + Git.TestsDirectory.FullName, + "TUnit.TestProject", + "Bugs", + "_7108", + "PrivateRowTypeDataSourceTests.cs"), + _ => Task.CompletedTask); + + [Test] + public Task Inherited_Protected_Member() => RunTest(Path.Combine( + Git.TestsDirectory.FullName, + "TUnit.TestProject", + "Bugs", + "_7108", + "InheritedProtectedMemberDataSourceTests.cs"), + _ => Task.CompletedTask); +} diff --git a/tests/TUnit.Core.SourceGenerator.Tests/ConflictingNamespaceTests.MethodDataSource_WithConflictingNamespace.DotNet10_0.verified.txt b/tests/TUnit.Core.SourceGenerator.Tests/ConflictingNamespaceTests.MethodDataSource_WithConflictingNamespace.DotNet10_0.verified.txt index f258d7cfc06..c78355ff0d4 100644 --- a/tests/TUnit.Core.SourceGenerator.Tests/ConflictingNamespaceTests.MethodDataSource_WithConflictingNamespace.DotNet10_0.verified.txt +++ b/tests/TUnit.Core.SourceGenerator.Tests/ConflictingNamespaceTests.MethodDataSource_WithConflictingNamespace.DotNet10_0.verified.txt @@ -253,12 +253,20 @@ internal static class TUnit_TestProject_MethodDataSourceDrivenTests__TestSource new global::TUnit.Core.MethodDataSourceAttribute("SomeMethod") { Arguments = new object[] { 5 }, - Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromValue(static () => global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod()), + Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromValue(static () => + { + var arguments = new object[] { 5 }; + return global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod(((int)arguments[0])); + }), }, new global::TUnit.Core.MethodDataSourceAttribute("SomeMethod") { Arguments = new object[] { 5 }, - Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromValue(static () => global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod()), + Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromValue(static () => + { + var arguments = new object[] { 5 }; + return global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod(((int)arguments[0])); + }), }, }, parameters: global::TUnit.Core.ParameterMetadataFactory.ForMethod(typeof(global::TUnit.TestProject.MethodDataSourceDrivenTests), "DataSource_Method3", false, new global::TUnit.Core.ParameterMetadata[] @@ -282,22 +290,38 @@ internal static class TUnit_TestProject_MethodDataSourceDrivenTests__TestSource new global::TUnit.Core.MethodDataSourceAttribute("SomeMethod") { Arguments = new object[] { "Hello World!", 5, true }, - Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromValue(static () => global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod()), + Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromValue(static () => + { + var arguments = new object[] { "Hello World!", 5, true }; + return global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod(((string)arguments[0]), ((int)arguments[1]), ((bool)arguments[2])); + }), }, new global::TUnit.Core.MethodDataSourceAttribute("SomeMethod") { Arguments = new object[] { "Hello World!", 6, true }, - Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromValue(static () => global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod()), + Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromValue(static () => + { + var arguments = new object[] { "Hello World!", 6, true }; + return global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod(((string)arguments[0]), ((int)arguments[1]), ((bool)arguments[2])); + }), }, new global::TUnit.Core.MethodDataSourceAttribute("SomeMethod") { Arguments = new object[] { "Hello World!", 7, true }, - Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromValue(static () => global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod()), + Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromValue(static () => + { + var arguments = new object[] { "Hello World!", 7, true }; + return global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod(((string)arguments[0]), ((int)arguments[1]), ((bool)arguments[2])); + }), }, new global::TUnit.Core.MethodDataSourceAttribute("SomeMethod") { Arguments = new object[] { "Hello World!", 8, true }, - Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromValue(static () => global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod()), + Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromValue(static () => + { + var arguments = new object[] { "Hello World!", 8, true }; + return global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod(((string)arguments[0]), ((int)arguments[1]), ((bool)arguments[2])); + }), }, }, parameters: global::TUnit.Core.ParameterMetadataFactory.ForMethod(typeof(global::TUnit.TestProject.MethodDataSourceDrivenTests), "DataSource_Method4", false, new global::TUnit.Core.ParameterMetadata[] diff --git a/tests/TUnit.Core.SourceGenerator.Tests/ConflictingNamespaceTests.MethodDataSource_WithConflictingNamespace.DotNet8_0.verified.txt b/tests/TUnit.Core.SourceGenerator.Tests/ConflictingNamespaceTests.MethodDataSource_WithConflictingNamespace.DotNet8_0.verified.txt index f258d7cfc06..c78355ff0d4 100644 --- a/tests/TUnit.Core.SourceGenerator.Tests/ConflictingNamespaceTests.MethodDataSource_WithConflictingNamespace.DotNet8_0.verified.txt +++ b/tests/TUnit.Core.SourceGenerator.Tests/ConflictingNamespaceTests.MethodDataSource_WithConflictingNamespace.DotNet8_0.verified.txt @@ -253,12 +253,20 @@ internal static class TUnit_TestProject_MethodDataSourceDrivenTests__TestSource new global::TUnit.Core.MethodDataSourceAttribute("SomeMethod") { Arguments = new object[] { 5 }, - Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromValue(static () => global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod()), + Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromValue(static () => + { + var arguments = new object[] { 5 }; + return global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod(((int)arguments[0])); + }), }, new global::TUnit.Core.MethodDataSourceAttribute("SomeMethod") { Arguments = new object[] { 5 }, - Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromValue(static () => global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod()), + Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromValue(static () => + { + var arguments = new object[] { 5 }; + return global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod(((int)arguments[0])); + }), }, }, parameters: global::TUnit.Core.ParameterMetadataFactory.ForMethod(typeof(global::TUnit.TestProject.MethodDataSourceDrivenTests), "DataSource_Method3", false, new global::TUnit.Core.ParameterMetadata[] @@ -282,22 +290,38 @@ internal static class TUnit_TestProject_MethodDataSourceDrivenTests__TestSource new global::TUnit.Core.MethodDataSourceAttribute("SomeMethod") { Arguments = new object[] { "Hello World!", 5, true }, - Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromValue(static () => global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod()), + Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromValue(static () => + { + var arguments = new object[] { "Hello World!", 5, true }; + return global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod(((string)arguments[0]), ((int)arguments[1]), ((bool)arguments[2])); + }), }, new global::TUnit.Core.MethodDataSourceAttribute("SomeMethod") { Arguments = new object[] { "Hello World!", 6, true }, - Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromValue(static () => global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod()), + Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromValue(static () => + { + var arguments = new object[] { "Hello World!", 6, true }; + return global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod(((string)arguments[0]), ((int)arguments[1]), ((bool)arguments[2])); + }), }, new global::TUnit.Core.MethodDataSourceAttribute("SomeMethod") { Arguments = new object[] { "Hello World!", 7, true }, - Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromValue(static () => global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod()), + Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromValue(static () => + { + var arguments = new object[] { "Hello World!", 7, true }; + return global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod(((string)arguments[0]), ((int)arguments[1]), ((bool)arguments[2])); + }), }, new global::TUnit.Core.MethodDataSourceAttribute("SomeMethod") { Arguments = new object[] { "Hello World!", 8, true }, - Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromValue(static () => global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod()), + Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromValue(static () => + { + var arguments = new object[] { "Hello World!", 8, true }; + return global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod(((string)arguments[0]), ((int)arguments[1]), ((bool)arguments[2])); + }), }, }, parameters: global::TUnit.Core.ParameterMetadataFactory.ForMethod(typeof(global::TUnit.TestProject.MethodDataSourceDrivenTests), "DataSource_Method4", false, new global::TUnit.Core.ParameterMetadata[] diff --git a/tests/TUnit.Core.SourceGenerator.Tests/ConflictingNamespaceTests.MethodDataSource_WithConflictingNamespace.DotNet9_0.verified.txt b/tests/TUnit.Core.SourceGenerator.Tests/ConflictingNamespaceTests.MethodDataSource_WithConflictingNamespace.DotNet9_0.verified.txt index f258d7cfc06..c78355ff0d4 100644 --- a/tests/TUnit.Core.SourceGenerator.Tests/ConflictingNamespaceTests.MethodDataSource_WithConflictingNamespace.DotNet9_0.verified.txt +++ b/tests/TUnit.Core.SourceGenerator.Tests/ConflictingNamespaceTests.MethodDataSource_WithConflictingNamespace.DotNet9_0.verified.txt @@ -253,12 +253,20 @@ internal static class TUnit_TestProject_MethodDataSourceDrivenTests__TestSource new global::TUnit.Core.MethodDataSourceAttribute("SomeMethod") { Arguments = new object[] { 5 }, - Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromValue(static () => global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod()), + Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromValue(static () => + { + var arguments = new object[] { 5 }; + return global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod(((int)arguments[0])); + }), }, new global::TUnit.Core.MethodDataSourceAttribute("SomeMethod") { Arguments = new object[] { 5 }, - Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromValue(static () => global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod()), + Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromValue(static () => + { + var arguments = new object[] { 5 }; + return global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod(((int)arguments[0])); + }), }, }, parameters: global::TUnit.Core.ParameterMetadataFactory.ForMethod(typeof(global::TUnit.TestProject.MethodDataSourceDrivenTests), "DataSource_Method3", false, new global::TUnit.Core.ParameterMetadata[] @@ -282,22 +290,38 @@ internal static class TUnit_TestProject_MethodDataSourceDrivenTests__TestSource new global::TUnit.Core.MethodDataSourceAttribute("SomeMethod") { Arguments = new object[] { "Hello World!", 5, true }, - Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromValue(static () => global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod()), + Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromValue(static () => + { + var arguments = new object[] { "Hello World!", 5, true }; + return global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod(((string)arguments[0]), ((int)arguments[1]), ((bool)arguments[2])); + }), }, new global::TUnit.Core.MethodDataSourceAttribute("SomeMethod") { Arguments = new object[] { "Hello World!", 6, true }, - Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromValue(static () => global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod()), + Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromValue(static () => + { + var arguments = new object[] { "Hello World!", 6, true }; + return global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod(((string)arguments[0]), ((int)arguments[1]), ((bool)arguments[2])); + }), }, new global::TUnit.Core.MethodDataSourceAttribute("SomeMethod") { Arguments = new object[] { "Hello World!", 7, true }, - Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromValue(static () => global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod()), + Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromValue(static () => + { + var arguments = new object[] { "Hello World!", 7, true }; + return global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod(((string)arguments[0]), ((int)arguments[1]), ((bool)arguments[2])); + }), }, new global::TUnit.Core.MethodDataSourceAttribute("SomeMethod") { Arguments = new object[] { "Hello World!", 8, true }, - Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromValue(static () => global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod()), + Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromValue(static () => + { + var arguments = new object[] { "Hello World!", 8, true }; + return global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod(((string)arguments[0]), ((int)arguments[1]), ((bool)arguments[2])); + }), }, }, parameters: global::TUnit.Core.ParameterMetadataFactory.ForMethod(typeof(global::TUnit.TestProject.MethodDataSourceDrivenTests), "DataSource_Method4", false, new global::TUnit.Core.ParameterMetadata[] diff --git a/tests/TUnit.Core.SourceGenerator.Tests/ConflictingNamespaceTests.MethodDataSource_WithConflictingNamespace.Net4_7.verified.txt b/tests/TUnit.Core.SourceGenerator.Tests/ConflictingNamespaceTests.MethodDataSource_WithConflictingNamespace.Net4_7.verified.txt index a89b4eb8688..c78355ff0d4 100644 --- a/tests/TUnit.Core.SourceGenerator.Tests/ConflictingNamespaceTests.MethodDataSource_WithConflictingNamespace.Net4_7.verified.txt +++ b/tests/TUnit.Core.SourceGenerator.Tests/ConflictingNamespaceTests.MethodDataSource_WithConflictingNamespace.Net4_7.verified.txt @@ -1,4 +1,4 @@ -// +// #pragma warning disable #nullable enable @@ -253,12 +253,20 @@ internal static class TUnit_TestProject_MethodDataSourceDrivenTests__TestSource new global::TUnit.Core.MethodDataSourceAttribute("SomeMethod") { Arguments = new object[] { 5 }, - Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromValue(static () => global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod()), + Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromValue(static () => + { + var arguments = new object[] { 5 }; + return global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod(((int)arguments[0])); + }), }, new global::TUnit.Core.MethodDataSourceAttribute("SomeMethod") { Arguments = new object[] { 5 }, - Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromValue(static () => global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod()), + Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromValue(static () => + { + var arguments = new object[] { 5 }; + return global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod(((int)arguments[0])); + }), }, }, parameters: global::TUnit.Core.ParameterMetadataFactory.ForMethod(typeof(global::TUnit.TestProject.MethodDataSourceDrivenTests), "DataSource_Method3", false, new global::TUnit.Core.ParameterMetadata[] @@ -282,22 +290,38 @@ internal static class TUnit_TestProject_MethodDataSourceDrivenTests__TestSource new global::TUnit.Core.MethodDataSourceAttribute("SomeMethod") { Arguments = new object[] { "Hello World!", 5, true }, - Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromValue(static () => global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod()), + Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromValue(static () => + { + var arguments = new object[] { "Hello World!", 5, true }; + return global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod(((string)arguments[0]), ((int)arguments[1]), ((bool)arguments[2])); + }), }, new global::TUnit.Core.MethodDataSourceAttribute("SomeMethod") { Arguments = new object[] { "Hello World!", 6, true }, - Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromValue(static () => global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod()), + Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromValue(static () => + { + var arguments = new object[] { "Hello World!", 6, true }; + return global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod(((string)arguments[0]), ((int)arguments[1]), ((bool)arguments[2])); + }), }, new global::TUnit.Core.MethodDataSourceAttribute("SomeMethod") { Arguments = new object[] { "Hello World!", 7, true }, - Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromValue(static () => global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod()), + Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromValue(static () => + { + var arguments = new object[] { "Hello World!", 7, true }; + return global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod(((string)arguments[0]), ((int)arguments[1]), ((bool)arguments[2])); + }), }, new global::TUnit.Core.MethodDataSourceAttribute("SomeMethod") { Arguments = new object[] { "Hello World!", 8, true }, - Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromValue(static () => global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod()), + Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromValue(static () => + { + var arguments = new object[] { "Hello World!", 8, true }; + return global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod(((string)arguments[0]), ((int)arguments[1]), ((bool)arguments[2])); + }), }, }, parameters: global::TUnit.Core.ParameterMetadataFactory.ForMethod(typeof(global::TUnit.TestProject.MethodDataSourceDrivenTests), "DataSource_Method4", false, new global::TUnit.Core.ParameterMetadata[] diff --git a/tests/TUnit.Core.SourceGenerator.Tests/MethodDataSourceDrivenTests.Test.verified.txt b/tests/TUnit.Core.SourceGenerator.Tests/MethodDataSourceDrivenTests.Test.verified.txt index f258d7cfc06..c78355ff0d4 100644 --- a/tests/TUnit.Core.SourceGenerator.Tests/MethodDataSourceDrivenTests.Test.verified.txt +++ b/tests/TUnit.Core.SourceGenerator.Tests/MethodDataSourceDrivenTests.Test.verified.txt @@ -253,12 +253,20 @@ internal static class TUnit_TestProject_MethodDataSourceDrivenTests__TestSource new global::TUnit.Core.MethodDataSourceAttribute("SomeMethod") { Arguments = new object[] { 5 }, - Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromValue(static () => global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod()), + Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromValue(static () => + { + var arguments = new object[] { 5 }; + return global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod(((int)arguments[0])); + }), }, new global::TUnit.Core.MethodDataSourceAttribute("SomeMethod") { Arguments = new object[] { 5 }, - Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromValue(static () => global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod()), + Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromValue(static () => + { + var arguments = new object[] { 5 }; + return global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod(((int)arguments[0])); + }), }, }, parameters: global::TUnit.Core.ParameterMetadataFactory.ForMethod(typeof(global::TUnit.TestProject.MethodDataSourceDrivenTests), "DataSource_Method3", false, new global::TUnit.Core.ParameterMetadata[] @@ -282,22 +290,38 @@ internal static class TUnit_TestProject_MethodDataSourceDrivenTests__TestSource new global::TUnit.Core.MethodDataSourceAttribute("SomeMethod") { Arguments = new object[] { "Hello World!", 5, true }, - Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromValue(static () => global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod()), + Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromValue(static () => + { + var arguments = new object[] { "Hello World!", 5, true }; + return global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod(((string)arguments[0]), ((int)arguments[1]), ((bool)arguments[2])); + }), }, new global::TUnit.Core.MethodDataSourceAttribute("SomeMethod") { Arguments = new object[] { "Hello World!", 6, true }, - Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromValue(static () => global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod()), + Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromValue(static () => + { + var arguments = new object[] { "Hello World!", 6, true }; + return global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod(((string)arguments[0]), ((int)arguments[1]), ((bool)arguments[2])); + }), }, new global::TUnit.Core.MethodDataSourceAttribute("SomeMethod") { Arguments = new object[] { "Hello World!", 7, true }, - Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromValue(static () => global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod()), + Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromValue(static () => + { + var arguments = new object[] { "Hello World!", 7, true }; + return global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod(((string)arguments[0]), ((int)arguments[1]), ((bool)arguments[2])); + }), }, new global::TUnit.Core.MethodDataSourceAttribute("SomeMethod") { Arguments = new object[] { "Hello World!", 8, true }, - Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromValue(static () => global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod()), + Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromValue(static () => + { + var arguments = new object[] { "Hello World!", 8, true }; + return global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod(((string)arguments[0]), ((int)arguments[1]), ((bool)arguments[2])); + }), }, }, parameters: global::TUnit.Core.ParameterMetadataFactory.ForMethod(typeof(global::TUnit.TestProject.MethodDataSourceDrivenTests), "DataSource_Method4", false, new global::TUnit.Core.ParameterMetadata[] diff --git a/tests/TUnit.Core.SourceGenerator.Tests/Tests7108.Inherited_Protected_Member.verified.txt b/tests/TUnit.Core.SourceGenerator.Tests/Tests7108.Inherited_Protected_Member.verified.txt new file mode 100644 index 00000000000..698c26566b2 --- /dev/null +++ b/tests/TUnit.Core.SourceGenerator.Tests/Tests7108.Inherited_Protected_Member.verified.txt @@ -0,0 +1,265 @@ +// +#pragma warning disable + +#nullable enable +namespace TUnit.Generated; +[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute] +[global::System.CodeDom.Compiler.GeneratedCode("TUnit", "VERSION_SCRUBBED")] +internal static class TUnit_TestProject_Bugs__7108_InheritedProtectedMemberDataSourceTests_Inherited_Protect_AB7B5348_TestSource +{ + private static readonly global::TUnit.Core.ClassMetadata __classMetadata = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.Bugs._7108.InheritedProtectedMemberDataSourceTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.Bugs._7108.InheritedProtectedMemberDataSourceTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.Bugs._7108.InheritedProtectedMemberDataSourceTests)), + Name = "InheritedProtectedMemberDataSourceTests", + Namespace = "TUnit.TestProject.Bugs._7108", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }); + private static readonly global::System.Type __classType = typeof(global::TUnit.TestProject.Bugs._7108.InheritedProtectedMemberDataSourceTests); + private static readonly global::TUnit.Core.MethodMetadata __mm_0 = global::TUnit.Core.MethodMetadataFactory.Create("Inherited_Protected_Property", __classType, typeof(global::System.Threading.Tasks.Task), __classMetadata, genericTypeCount: 1, parameters: global::TUnit.Core.ParameterMetadataFactory.ForGenericMethod(typeof(global::TUnit.TestProject.Bugs._7108.InheritedProtectedMemberDataSourceTests), "Inherited_Protected_Property", false, 1, new global::TUnit.Core.ParameterMetadata[] +{ +global::TUnit.Core.ParameterMetadataFactory.Create(typeof(object), "value", new global::TUnit.Core.GenericParameter(0, true, "T"), false) +})); + private static global::TUnit.TestProject.Bugs._7108.InheritedProtectedMemberDataSourceTests __CreateInstance_0(global::System.Type[] typeArgs, object?[] args) + { + return new global::TUnit.TestProject.Bugs._7108.InheritedProtectedMemberDataSourceTests(); + } + private static global::System.Threading.Tasks.ValueTask __Invoke_0(global::TUnit.TestProject.Bugs._7108.InheritedProtectedMemberDataSourceTests instance, int methodIndex, object?[] args, global::System.Threading.CancellationToken cancellationToken) + { + try + { + return new global::System.Threading.Tasks.ValueTask(instance.Inherited_Protected_Property(global::TUnit.Core.Helpers.CastHelper.Cast(args[0]))); + } + catch (global::System.Exception ex) + { + return new global::System.Threading.Tasks.ValueTask(global::System.Threading.Tasks.Task.FromException(ex)); + } + } + private static global::System.Attribute[] __Attributes_0(int groupIndex) + { + return new global::System.Attribute[] + { + new global::TUnit.Core.TestAttribute(), + new global::TUnit.Core.MethodDataSourceAttribute("BasePropertyRows"), + new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass) + }; + } + public static readonly global::TUnit.Core.TestEntry[] Entries_0 = new global::TUnit.Core.TestEntry[] + { + global::TUnit.Core.TestEntryFactory.Create( + methodName: "Inherited_Protected_Property", + fullyQualifiedName: "TUnit.TestProject.Bugs._7108.InheritedProtectedMemberDataSourceTests.Inherited_Protected_Property", + methodTypeArgumentsIdentity: "", + filePath: "", + lineNumber: 22, + hasDataSource: true, + testDataSources: new global::TUnit.Core.IDataSourceAttribute[] +{ + new global::TUnit.Core.MethodDataSourceAttribute("BasePropertyRows") + { + Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromEnumerable(static () => typeof(global::TUnit.TestProject.Bugs._7108.InheritedProtectedMemberDataSourceBase).GetProperty("BasePropertyRows", global::System.Reflection.BindingFlags.Static | global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.DeclaredOnly)!.GetValue(null)), + }, +}, + methodMetadata: __mm_0, + createInstance: __CreateInstance_0, + invokeBody: __Invoke_0, + methodIndex: 0, + createAttributes: __Attributes_0, + attributeGroupIndex: 0), + }; +} +internal static partial class TUnit_TestRegistration +{ + static readonly int _r_TUnit_TestProject_Bugs__7108_InheritedProtectedMemberDataSourceTests_Inherited_Protect_AB7B5348_TestSource_0 = global::TUnit.Core.SourceRegistrar.RegisterEntries(static () => TUnit_TestProject_Bugs__7108_InheritedProtectedMemberDataSourceTests_Inherited_Protect_AB7B5348_TestSource.Entries_0); +} + + +// ===== FILE SEPARATOR ===== + +// +#pragma warning disable + +#nullable enable +namespace TUnit.Generated; +[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute] +[global::System.CodeDom.Compiler.GeneratedCode("TUnit", "VERSION_SCRUBBED")] +internal static class TUnit_TestProject_Bugs__7108_InheritedProtectedMemberDataSourceTests_Inherited_Protect_9E654EA9_TestSource +{ + private static readonly global::TUnit.Core.ClassMetadata __classMetadata = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.Bugs._7108.InheritedProtectedMemberDataSourceTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.Bugs._7108.InheritedProtectedMemberDataSourceTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.Bugs._7108.InheritedProtectedMemberDataSourceTests)), + Name = "InheritedProtectedMemberDataSourceTests", + Namespace = "TUnit.TestProject.Bugs._7108", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }); + private static readonly global::System.Type __classType = typeof(global::TUnit.TestProject.Bugs._7108.InheritedProtectedMemberDataSourceTests); + private static readonly global::TUnit.Core.MethodMetadata __mm_0 = global::TUnit.Core.MethodMetadataFactory.Create("Inherited_Protected_Field", __classType, typeof(global::System.Threading.Tasks.Task), __classMetadata, genericTypeCount: 1, parameters: global::TUnit.Core.ParameterMetadataFactory.ForGenericMethod(typeof(global::TUnit.TestProject.Bugs._7108.InheritedProtectedMemberDataSourceTests), "Inherited_Protected_Field", false, 1, new global::TUnit.Core.ParameterMetadata[] +{ +global::TUnit.Core.ParameterMetadataFactory.Create(typeof(object), "value", new global::TUnit.Core.GenericParameter(0, true, "T"), false) +})); + private static global::TUnit.TestProject.Bugs._7108.InheritedProtectedMemberDataSourceTests __CreateInstance_0(global::System.Type[] typeArgs, object?[] args) + { + return new global::TUnit.TestProject.Bugs._7108.InheritedProtectedMemberDataSourceTests(); + } + private static global::System.Threading.Tasks.ValueTask __Invoke_0(global::TUnit.TestProject.Bugs._7108.InheritedProtectedMemberDataSourceTests instance, int methodIndex, object?[] args, global::System.Threading.CancellationToken cancellationToken) + { + try + { + return new global::System.Threading.Tasks.ValueTask(instance.Inherited_Protected_Field(global::TUnit.Core.Helpers.CastHelper.Cast(args[0]))); + } + catch (global::System.Exception ex) + { + return new global::System.Threading.Tasks.ValueTask(global::System.Threading.Tasks.Task.FromException(ex)); + } + } + private static global::System.Attribute[] __Attributes_0(int groupIndex) + { + return new global::System.Attribute[] + { + new global::TUnit.Core.TestAttribute(), + new global::TUnit.Core.MethodDataSourceAttribute("BaseFieldRows"), + new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass) + }; + } + public static readonly global::TUnit.Core.TestEntry[] Entries_0 = new global::TUnit.Core.TestEntry[] + { + global::TUnit.Core.TestEntryFactory.Create( + methodName: "Inherited_Protected_Field", + fullyQualifiedName: "TUnit.TestProject.Bugs._7108.InheritedProtectedMemberDataSourceTests.Inherited_Protected_Field", + methodTypeArgumentsIdentity: "", + filePath: "", + lineNumber: 30, + hasDataSource: true, + testDataSources: new global::TUnit.Core.IDataSourceAttribute[] +{ + new global::TUnit.Core.MethodDataSourceAttribute("BaseFieldRows") + { + Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromEnumerable(static () => typeof(global::TUnit.TestProject.Bugs._7108.InheritedProtectedMemberDataSourceBase).GetField("BaseFieldRows", global::System.Reflection.BindingFlags.Static | global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.DeclaredOnly)!.GetValue(null)), + }, +}, + methodMetadata: __mm_0, + createInstance: __CreateInstance_0, + invokeBody: __Invoke_0, + methodIndex: 0, + createAttributes: __Attributes_0, + attributeGroupIndex: 0), + }; +} +internal static partial class TUnit_TestRegistration +{ + static readonly int _r_TUnit_TestProject_Bugs__7108_InheritedProtectedMemberDataSourceTests_Inherited_Protect_9E654EA9_TestSource_0 = global::TUnit.Core.SourceRegistrar.RegisterEntries(static () => TUnit_TestProject_Bugs__7108_InheritedProtectedMemberDataSourceTests_Inherited_Protect_9E654EA9_TestSource.Entries_0); +} + + +// ===== FILE SEPARATOR ===== + +// +#pragma warning disable + +#nullable enable +namespace TUnit.Generated; +[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute] +[global::System.CodeDom.Compiler.GeneratedCode("TUnit", "VERSION_SCRUBBED")] +internal static class TUnit_TestProject_Bugs__7108_InheritedProtectedMemberDataSourceTests__TestSource +{ + private static readonly global::TUnit.Core.ClassMetadata __classMetadata = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.Bugs._7108.InheritedProtectedMemberDataSourceTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.Bugs._7108.InheritedProtectedMemberDataSourceTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.Bugs._7108.InheritedProtectedMemberDataSourceTests)), + Name = "InheritedProtectedMemberDataSourceTests", + Namespace = "TUnit.TestProject.Bugs._7108", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }); + private static readonly global::System.Type __classType = typeof(global::TUnit.TestProject.Bugs._7108.InheritedProtectedMemberDataSourceTests); + private static global::TUnit.TestProject.Bugs._7108.InheritedProtectedMemberDataSourceTests __CreateInstance(global::System.Type[] typeArgs, object?[] args) + { + return new global::TUnit.TestProject.Bugs._7108.InheritedProtectedMemberDataSourceTests(); + } + private static global::System.Threading.Tasks.ValueTask __Invoke(global::TUnit.TestProject.Bugs._7108.InheritedProtectedMemberDataSourceTests instance, int methodIndex, object?[] args, global::System.Threading.CancellationToken cancellationToken) + { + try + { + switch (methodIndex) + { + case 0: + { + switch (args.Length) + { + case 1: + { + return new global::System.Threading.Tasks.ValueTask(instance.Inherited_Protected_Object_Field_Yields_A_Row_Per_Element(global::TUnit.Core.Helpers.CastHelper.Cast(args[0]))); + } + default: + throw new global::System.ArgumentException($"Expected exactly 1 argument, but got {args.Length}"); + } + } + default: + throw new global::System.ArgumentOutOfRangeException(nameof(methodIndex)); + } + } + catch (global::System.Exception ex) + { + return new global::System.Threading.Tasks.ValueTask(global::System.Threading.Tasks.Task.FromException(ex)); + } + } + private static global::System.Attribute[] __Attributes(int groupIndex) + { + switch (groupIndex) + { + case 0: + { + return + [ + new global::TUnit.Core.TestAttribute(), + new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass) + ]; + } + default: + throw new global::System.ArgumentOutOfRangeException(nameof(groupIndex)); + } + } + private static readonly global::System.Func __createInstance = __CreateInstance; + private static readonly global::System.Func __invoke = __Invoke; + private static readonly global::System.Func __attributes = __Attributes; + public static readonly global::TUnit.Core.TestEntry[] Entries = new global::TUnit.Core.TestEntry[] + { + global::TUnit.Core.TestEntryFactory.CreateWithClassMetadata( + methodName: "Inherited_Protected_Object_Field_Yields_A_Row_Per_Element", + fullyQualifiedName: "TUnit.TestProject.Bugs._7108.InheritedProtectedMemberDataSourceTests.Inherited_Protected_Object_Field_Yields_A_Row_Per_Element", + filePath: "", + lineNumber: 38, + hasDataSource: true, + testDataSources: new global::TUnit.Core.IDataSourceAttribute[] +{ + new global::TUnit.Core.MethodDataSourceAttribute("BaseObjectFieldRows") + { + Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromRuntimeValue(dataGeneratorMetadata, static () => typeof(global::TUnit.TestProject.Bugs._7108.InheritedProtectedMemberDataSourceBase).GetField("BaseObjectFieldRows", global::System.Reflection.BindingFlags.Static | global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.DeclaredOnly)!.GetValue(null)), + }, +}, + returnType: typeof(global::System.Threading.Tasks.Task), + parameters: global::TUnit.Core.ParameterMetadataFactory.ForMethod(typeof(global::TUnit.TestProject.Bugs._7108.InheritedProtectedMemberDataSourceTests), "Inherited_Protected_Object_Field_Yields_A_Row_Per_Element", false, new global::TUnit.Core.ParameterMetadata[] + { + global::TUnit.Core.ParameterMetadataFactory.Create(typeof(int), "value", new global::TUnit.Core.ConcreteType(typeof(int)), false) + }), + classMetadata: __classMetadata, + createInstance: __createInstance, + invokeBody: __invoke, + methodIndex: 0, + createAttributes: __attributes, + attributeGroupIndex: 0), + }; +} +internal static partial class TUnit_TestRegistration +{ + static readonly int _r_TUnit_TestProject_Bugs__7108_InheritedProtectedMemberDataSourceTests__TestSource = global::TUnit.Core.SourceRegistrar.RegisterEntries(static () => TUnit_TestProject_Bugs__7108_InheritedProtectedMemberDataSourceTests__TestSource.Entries); +} diff --git a/tests/TUnit.Core.SourceGenerator.Tests/Tests7108.Private_Row_Type.verified.txt b/tests/TUnit.Core.SourceGenerator.Tests/Tests7108.Private_Row_Type.verified.txt new file mode 100644 index 00000000000..a68ef78e08b --- /dev/null +++ b/tests/TUnit.Core.SourceGenerator.Tests/Tests7108.Private_Row_Type.verified.txt @@ -0,0 +1,140 @@ +// +#pragma warning disable + +#nullable enable +namespace TUnit.Generated; +[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute] +[global::System.CodeDom.Compiler.GeneratedCode("TUnit", "VERSION_SCRUBBED")] +internal static class TUnit_TestProject_Bugs__7108_PrivateRowTypeDataSourceTests_Private_Row_Type_From_Property__T_TestSource +{ + private static readonly global::TUnit.Core.ClassMetadata __classMetadata = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.Bugs._7108.PrivateRowTypeDataSourceTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.Bugs._7108.PrivateRowTypeDataSourceTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.Bugs._7108.PrivateRowTypeDataSourceTests)), + Name = "PrivateRowTypeDataSourceTests", + Namespace = "TUnit.TestProject.Bugs._7108", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }); + private static readonly global::System.Type __classType = typeof(global::TUnit.TestProject.Bugs._7108.PrivateRowTypeDataSourceTests); + private static readonly global::TUnit.Core.MethodMetadata __mm_0 = global::TUnit.Core.MethodMetadataFactory.Create("Private_Row_Type_From_Property", __classType, typeof(global::System.Threading.Tasks.Task), __classMetadata, genericTypeCount: 1, parameters: global::TUnit.Core.ParameterMetadataFactory.ForGenericMethod(typeof(global::TUnit.TestProject.Bugs._7108.PrivateRowTypeDataSourceTests), "Private_Row_Type_From_Property", false, 1, new global::TUnit.Core.ParameterMetadata[] +{ +global::TUnit.Core.ParameterMetadataFactory.Create(typeof(object), "value", new global::TUnit.Core.GenericParameter(0, true, "T"), false) +})); + private static global::TUnit.TestProject.Bugs._7108.PrivateRowTypeDataSourceTests __CreateInstance_0(global::System.Type[] typeArgs, object?[] args) + { + return new global::TUnit.TestProject.Bugs._7108.PrivateRowTypeDataSourceTests(); + } + private static global::System.Threading.Tasks.ValueTask __Invoke_0(global::TUnit.TestProject.Bugs._7108.PrivateRowTypeDataSourceTests instance, int methodIndex, object?[] args, global::System.Threading.CancellationToken cancellationToken) + { + return new global::System.Threading.Tasks.ValueTask(global::System.Threading.Tasks.Task.FromException(new global::TUnit.Core.Exceptions.GenericTypeResolutionException("Could not infer the type arguments of generic test method 'Private_Row_Type_From_Property' from data source [MethodDataSource(nameof(PropertyRows))]. Its rows give the type argument 'TUnit.TestProject.Bugs._7108.PrivateRowTypeDataSourceTests.Row', which source-generated code cannot name because it is private or protected. Make that type internal or public, or list accessible type arguments with [GenerateGenericTest]."))); + } + private static global::System.Attribute[] __Attributes_0(int groupIndex) + { + return new global::System.Attribute[] + { + new global::TUnit.Core.TestAttribute(), + new global::TUnit.Core.MethodDataSourceAttribute("PropertyRows") + }; + } + public static readonly global::TUnit.Core.TestEntry[] Entries_0 = new global::TUnit.Core.TestEntry[] + { + global::TUnit.Core.TestEntryFactory.Create( + methodName: "Private_Row_Type_From_Property", + fullyQualifiedName: "TUnit.TestProject.Bugs._7108.PrivateRowTypeDataSourceTests.Private_Row_Type_From_Property", + filePath: "", + lineNumber: 20, + hasDataSource: true, + testDataSources: new global::TUnit.Core.IDataSourceAttribute[] +{ + global::TUnit.Core.GenericConstraintViolationDataSource.Create("Could not infer the type arguments of generic test method 'Private_Row_Type_From_Property' from data source [MethodDataSource(nameof(PropertyRows))]. Its rows give the type argument 'TUnit.TestProject.Bugs._7108.PrivateRowTypeDataSourceTests.Row', which source-generated code cannot name because it is private or protected. Make that type internal or public, or list accessible type arguments with [GenerateGenericTest].", new global::TUnit.Core.MethodDataSourceAttribute("PropertyRows") +{ + Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromEnumerable(static () => typeof(global::TUnit.TestProject.Bugs._7108.PrivateRowTypeDataSourceTests).GetProperty("PropertyRows", global::System.Reflection.BindingFlags.Static | global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.DeclaredOnly)!.GetValue(null)), +}), +}, + methodMetadata: __mm_0, + createInstance: __CreateInstance_0, + invokeBody: __Invoke_0, + methodIndex: 0, + createAttributes: __Attributes_0, + attributeGroupIndex: 0), + }; +} +internal static partial class TUnit_TestRegistration +{ + static readonly int _r_TUnit_TestProject_Bugs__7108_PrivateRowTypeDataSourceTests_Private_Row_Type_From_Property__T_TestSource_0 = global::TUnit.Core.SourceRegistrar.RegisterEntries(static () => TUnit_TestProject_Bugs__7108_PrivateRowTypeDataSourceTests_Private_Row_Type_From_Property__T_TestSource.Entries_0); +} + + +// ===== FILE SEPARATOR ===== + +// +#pragma warning disable + +#nullable enable +namespace TUnit.Generated; +[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute] +[global::System.CodeDom.Compiler.GeneratedCode("TUnit", "VERSION_SCRUBBED")] +internal static class TUnit_TestProject_Bugs__7108_PrivateRowTypeDataSourceTests_Private_Row_Type_From_Field__T_TestSource +{ + private static readonly global::TUnit.Core.ClassMetadata __classMetadata = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.Bugs._7108.PrivateRowTypeDataSourceTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.Bugs._7108.PrivateRowTypeDataSourceTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.Bugs._7108.PrivateRowTypeDataSourceTests)), + Name = "PrivateRowTypeDataSourceTests", + Namespace = "TUnit.TestProject.Bugs._7108", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }); + private static readonly global::System.Type __classType = typeof(global::TUnit.TestProject.Bugs._7108.PrivateRowTypeDataSourceTests); + private static readonly global::TUnit.Core.MethodMetadata __mm_0 = global::TUnit.Core.MethodMetadataFactory.Create("Private_Row_Type_From_Field", __classType, typeof(global::System.Threading.Tasks.Task), __classMetadata, genericTypeCount: 1, parameters: global::TUnit.Core.ParameterMetadataFactory.ForGenericMethod(typeof(global::TUnit.TestProject.Bugs._7108.PrivateRowTypeDataSourceTests), "Private_Row_Type_From_Field", false, 1, new global::TUnit.Core.ParameterMetadata[] +{ +global::TUnit.Core.ParameterMetadataFactory.Create(typeof(object), "value", new global::TUnit.Core.GenericParameter(0, true, "T"), false) +})); + private static global::TUnit.TestProject.Bugs._7108.PrivateRowTypeDataSourceTests __CreateInstance_0(global::System.Type[] typeArgs, object?[] args) + { + return new global::TUnit.TestProject.Bugs._7108.PrivateRowTypeDataSourceTests(); + } + private static global::System.Threading.Tasks.ValueTask __Invoke_0(global::TUnit.TestProject.Bugs._7108.PrivateRowTypeDataSourceTests instance, int methodIndex, object?[] args, global::System.Threading.CancellationToken cancellationToken) + { + return new global::System.Threading.Tasks.ValueTask(global::System.Threading.Tasks.Task.FromException(new global::TUnit.Core.Exceptions.GenericTypeResolutionException("Could not infer the type arguments of generic test method 'Private_Row_Type_From_Field' from data source [MethodDataSource(nameof(FieldRows))]. Its rows give the type argument 'TUnit.TestProject.Bugs._7108.PrivateRowTypeDataSourceTests.Row', which source-generated code cannot name because it is private or protected. Make that type internal or public, or list accessible type arguments with [GenerateGenericTest]."))); + } + private static global::System.Attribute[] __Attributes_0(int groupIndex) + { + return new global::System.Attribute[] + { + new global::TUnit.Core.TestAttribute(), + new global::TUnit.Core.MethodDataSourceAttribute("FieldRows") + }; + } + public static readonly global::TUnit.Core.TestEntry[] Entries_0 = new global::TUnit.Core.TestEntry[] + { + global::TUnit.Core.TestEntryFactory.Create( + methodName: "Private_Row_Type_From_Field", + fullyQualifiedName: "TUnit.TestProject.Bugs._7108.PrivateRowTypeDataSourceTests.Private_Row_Type_From_Field", + filePath: "", + lineNumber: 27, + hasDataSource: true, + testDataSources: new global::TUnit.Core.IDataSourceAttribute[] +{ + global::TUnit.Core.GenericConstraintViolationDataSource.Create("Could not infer the type arguments of generic test method 'Private_Row_Type_From_Field' from data source [MethodDataSource(nameof(FieldRows))]. Its rows give the type argument 'TUnit.TestProject.Bugs._7108.PrivateRowTypeDataSourceTests.Row', which source-generated code cannot name because it is private or protected. Make that type internal or public, or list accessible type arguments with [GenerateGenericTest].", new global::TUnit.Core.MethodDataSourceAttribute("FieldRows") +{ + Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromEnumerable(static () => typeof(global::TUnit.TestProject.Bugs._7108.PrivateRowTypeDataSourceTests).GetField("FieldRows", global::System.Reflection.BindingFlags.Static | global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.DeclaredOnly)!.GetValue(null)), +}), +}, + methodMetadata: __mm_0, + createInstance: __CreateInstance_0, + invokeBody: __Invoke_0, + methodIndex: 0, + createAttributes: __Attributes_0, + attributeGroupIndex: 0), + }; +} +internal static partial class TUnit_TestRegistration +{ + static readonly int _r_TUnit_TestProject_Bugs__7108_PrivateRowTypeDataSourceTests_Private_Row_Type_From_Field__T_TestSource_0 = global::TUnit.Core.SourceRegistrar.RegisterEntries(static () => TUnit_TestProject_Bugs__7108_PrivateRowTypeDataSourceTests_Private_Row_Type_From_Field__T_TestSource.Entries_0); +} diff --git a/tests/TUnit.Core.SourceGenerator.Tests/Tests7108.Public_Object_Field.verified.txt b/tests/TUnit.Core.SourceGenerator.Tests/Tests7108.Public_Object_Field.verified.txt new file mode 100644 index 00000000000..a7c59ad9841 --- /dev/null +++ b/tests/TUnit.Core.SourceGenerator.Tests/Tests7108.Public_Object_Field.verified.txt @@ -0,0 +1,139 @@ +// +#pragma warning disable + +#nullable enable +namespace TUnit.Generated; +[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute] +[global::System.CodeDom.Compiler.GeneratedCode("TUnit", "VERSION_SCRUBBED")] +internal static class TUnit_TestProject_Bugs__7108_PublicObjectFieldDataSourceTests__TestSource +{ + private static readonly global::TUnit.Core.ClassMetadata __classMetadata = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.Bugs._7108.PublicObjectFieldDataSourceTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.Bugs._7108.PublicObjectFieldDataSourceTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.Bugs._7108.PublicObjectFieldDataSourceTests)), + Name = "PublicObjectFieldDataSourceTests", + Namespace = "TUnit.TestProject.Bugs._7108", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }); + private static readonly global::System.Type __classType = typeof(global::TUnit.TestProject.Bugs._7108.PublicObjectFieldDataSourceTests); + private static global::TUnit.TestProject.Bugs._7108.PublicObjectFieldDataSourceTests __CreateInstance(global::System.Type[] typeArgs, object?[] args) + { + return new global::TUnit.TestProject.Bugs._7108.PublicObjectFieldDataSourceTests(); + } + private static global::System.Threading.Tasks.ValueTask __Invoke(global::TUnit.TestProject.Bugs._7108.PublicObjectFieldDataSourceTests instance, int methodIndex, object?[] args, global::System.Threading.CancellationToken cancellationToken) + { + try + { + switch (methodIndex) + { + case 0: + { + switch (args.Length) + { + case 1: + { + return new global::System.Threading.Tasks.ValueTask(instance.Static_Object_Field_Holding_An_Array_Yields_A_Row_Per_Element(global::TUnit.Core.Helpers.CastHelper.Cast(args[0]))); + } + default: + throw new global::System.ArgumentException($"Expected exactly 1 argument, but got {args.Length}"); + } + } + case 1: + { + switch (args.Length) + { + case 1: + { + return new global::System.Threading.Tasks.ValueTask(instance.Instance_Object_Field_Holding_An_Array_Yields_A_Row_Per_Element(global::TUnit.Core.Helpers.CastHelper.Cast(args[0]))); + } + default: + throw new global::System.ArgumentException($"Expected exactly 1 argument, but got {args.Length}"); + } + } + default: + throw new global::System.ArgumentOutOfRangeException(nameof(methodIndex)); + } + } + catch (global::System.Exception ex) + { + return new global::System.Threading.Tasks.ValueTask(global::System.Threading.Tasks.Task.FromException(ex)); + } + } + private static global::System.Attribute[] __Attributes(int groupIndex) + { + switch (groupIndex) + { + case 0: + { + return + [ + new global::TUnit.Core.TestAttribute(), + new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass) + ]; + } + default: + throw new global::System.ArgumentOutOfRangeException(nameof(groupIndex)); + } + } + private static readonly global::System.Func __createInstance = __CreateInstance; + private static readonly global::System.Func __invoke = __Invoke; + private static readonly global::System.Func __attributes = __Attributes; + public static readonly global::TUnit.Core.TestEntry[] Entries = new global::TUnit.Core.TestEntry[] + { + global::TUnit.Core.TestEntryFactory.CreateWithClassMetadata( + methodName: "Static_Object_Field_Holding_An_Array_Yields_A_Row_Per_Element", + fullyQualifiedName: "TUnit.TestProject.Bugs._7108.PublicObjectFieldDataSourceTests.Static_Object_Field_Holding_An_Array_Yields_A_Row_Per_Element", + filePath: "", + lineNumber: 16, + hasDataSource: true, + testDataSources: new global::TUnit.Core.IDataSourceAttribute[] +{ + new global::TUnit.Core.MethodDataSourceAttribute("StaticObjectFieldRows") + { + Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromRuntimeValue(dataGeneratorMetadata, static () => global::TUnit.TestProject.Bugs._7108.PublicObjectFieldDataSourceTests.StaticObjectFieldRows), + }, +}, + returnType: typeof(global::System.Threading.Tasks.Task), + parameters: global::TUnit.Core.ParameterMetadataFactory.ForMethod(typeof(global::TUnit.TestProject.Bugs._7108.PublicObjectFieldDataSourceTests), "Static_Object_Field_Holding_An_Array_Yields_A_Row_Per_Element", false, new global::TUnit.Core.ParameterMetadata[] + { + global::TUnit.Core.ParameterMetadataFactory.Create(typeof(int), "value", new global::TUnit.Core.ConcreteType(typeof(int)), false) + }), + classMetadata: __classMetadata, + createInstance: __createInstance, + invokeBody: __invoke, + methodIndex: 0, + createAttributes: __attributes, + attributeGroupIndex: 0), + global::TUnit.Core.TestEntryFactory.CreateWithClassMetadata( + methodName: "Instance_Object_Field_Holding_An_Array_Yields_A_Row_Per_Element", + fullyQualifiedName: "TUnit.TestProject.Bugs._7108.PublicObjectFieldDataSourceTests.Instance_Object_Field_Holding_An_Array_Yields_A_Row_Per_Element", + filePath: "", + lineNumber: 23, + hasDataSource: true, + testDataSources: new global::TUnit.Core.IDataSourceAttribute[] +{ + new global::TUnit.Core.InstanceMethodDataSourceAttribute("InstanceObjectFieldRows") + { + Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromInstanceRuntimeValue(dataGeneratorMetadata, static instance => ((global::TUnit.TestProject.Bugs._7108.PublicObjectFieldDataSourceTests)instance).InstanceObjectFieldRows), + }, +}, + returnType: typeof(global::System.Threading.Tasks.Task), + parameters: global::TUnit.Core.ParameterMetadataFactory.ForMethod(typeof(global::TUnit.TestProject.Bugs._7108.PublicObjectFieldDataSourceTests), "Instance_Object_Field_Holding_An_Array_Yields_A_Row_Per_Element", false, new global::TUnit.Core.ParameterMetadata[] + { + global::TUnit.Core.ParameterMetadataFactory.Create(typeof(int), "value", new global::TUnit.Core.ConcreteType(typeof(int)), false) + }), + classMetadata: __classMetadata, + createInstance: __createInstance, + invokeBody: __invoke, + methodIndex: 1, + createAttributes: __attributes, + attributeGroupIndex: 0), + }; +} +internal static partial class TUnit_TestRegistration +{ + static readonly int _r_TUnit_TestProject_Bugs__7108_PublicObjectFieldDataSourceTests__TestSource = global::TUnit.Core.SourceRegistrar.RegisterEntries(static () => TUnit_TestProject_Bugs__7108_PublicObjectFieldDataSourceTests__TestSource.Entries); +} diff --git a/tests/TUnit.Core.SourceGenerator.Tests/Tests7108.Test.verified.txt b/tests/TUnit.Core.SourceGenerator.Tests/Tests7108.Test.verified.txt new file mode 100644 index 00000000000..b3265daf7bb --- /dev/null +++ b/tests/TUnit.Core.SourceGenerator.Tests/Tests7108.Test.verified.txt @@ -0,0 +1,3442 @@ +// +#pragma warning disable + +#nullable enable +namespace TUnit.Generated; +[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute] +[global::System.CodeDom.Compiler.GeneratedCode("TUnit", "VERSION_SCRUBBED")] +internal static class TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Generic_Data_M_5130ED02_TestSource +{ + private static readonly global::TUnit.Core.ClassMetadata __classMetadata = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests)), + Name = "GenericMethodNonTupleMethodDataSourceTests", + Namespace = "TUnit.TestProject.Bugs._7108", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }); + private static readonly global::System.Type __classType = typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests); + private static readonly global::TUnit.Core.MethodMetadata __mm_0 = global::TUnit.Core.MethodMetadataFactory.Create("Generic_Data_Method_Overload_Is_Skipped", __classType, typeof(global::System.Threading.Tasks.Task), __classMetadata, genericTypeCount: 1, parameters: global::TUnit.Core.ParameterMetadataFactory.ForGenericMethod(typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests), "Generic_Data_Method_Overload_Is_Skipped", false, 1, new global::TUnit.Core.ParameterMetadata[] +{ +global::TUnit.Core.ParameterMetadataFactory.Create(typeof(object), "value", new global::TUnit.Core.GenericParameter(0, true, "T"), false) +})); + private static global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests __CreateInstance_0(global::System.Type[] typeArgs, object?[] args) + { + return new global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests(); + } + private static global::System.Threading.Tasks.ValueTask __Invoke_0(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests instance, int methodIndex, object?[] args, global::System.Threading.CancellationToken cancellationToken) + { + try + { + return new global::System.Threading.Tasks.ValueTask(instance.Generic_Data_Method_Overload_Is_Skipped(global::TUnit.Core.Helpers.CastHelper.Cast(args[0]))); + } + catch (global::System.Exception ex) + { + return new global::System.Threading.Tasks.ValueTask(global::System.Threading.Tasks.Task.FromException(ex)); + } + } + private static global::System.Attribute[] __Attributes_0(int groupIndex) + { + return new global::System.Attribute[] + { + new global::TUnit.Core.TestAttribute(), + new global::TUnit.Core.MethodDataSourceAttribute("GenericProviderRows"), + new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass) + }; + } + public static readonly global::TUnit.Core.TestEntry[] Entries_0 = new global::TUnit.Core.TestEntry[] + { + global::TUnit.Core.TestEntryFactory.Create( + methodName: "Generic_Data_Method_Overload_Is_Skipped", + fullyQualifiedName: "TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests.Generic_Data_Method_Overload_Is_Skipped", + methodTypeArgumentsIdentity: "", + filePath: "", + lineNumber: 247, + hasDataSource: true, + testDataSources: new global::TUnit.Core.IDataSourceAttribute[] +{ + new global::TUnit.Core.MethodDataSourceAttribute("GenericProviderRows") + { + Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromEnumerable(static () => global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests.GenericProviderRows()), + }, +}, + methodMetadata: __mm_0, + createInstance: __CreateInstance_0, + invokeBody: __Invoke_0, + methodIndex: 0, + createAttributes: __Attributes_0, + attributeGroupIndex: 0), + }; +} +internal static partial class TUnit_TestRegistration +{ + static readonly int _r_TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Generic_Data_M_5130ED02_TestSource_0 = global::TUnit.Core.SourceRegistrar.RegisterEntries(static () => TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Generic_Data_M_5130ED02_TestSource.Entries_0); +} + + +// ===== FILE SEPARATOR ===== + +// +#pragma warning disable + +#nullable enable +namespace TUnit.Generated; +[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute] +[global::System.CodeDom.Compiler.GeneratedCode("TUnit", "VERSION_SCRUBBED")] +internal static class TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Decimal_Overlo_9912F7B9_TestSource +{ + private static readonly global::TUnit.Core.ClassMetadata __classMetadata = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests)), + Name = "GenericMethodNonTupleMethodDataSourceTests", + Namespace = "TUnit.TestProject.Bugs._7108", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }); + private static readonly global::System.Type __classType = typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests); + private static readonly global::TUnit.Core.MethodMetadata __mm_0 = global::TUnit.Core.MethodMetadataFactory.Create("Decimal_Overload_Is_Not_Chosen_For_An_Int_Argument", __classType, typeof(global::System.Threading.Tasks.Task), __classMetadata, genericTypeCount: 1, parameters: global::TUnit.Core.ParameterMetadataFactory.ForGenericMethod(typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests), "Decimal_Overload_Is_Not_Chosen_For_An_Int_Argument", false, 1, new global::TUnit.Core.ParameterMetadata[] +{ +global::TUnit.Core.ParameterMetadataFactory.Create(typeof(object), "value", new global::TUnit.Core.GenericParameter(0, true, "T"), false) +})); + private static global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests __CreateInstance_0(global::System.Type[] typeArgs, object?[] args) + { + return new global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests(); + } + private static global::System.Threading.Tasks.ValueTask __Invoke_0(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests instance, int methodIndex, object?[] args, global::System.Threading.CancellationToken cancellationToken) + { + try + { + return new global::System.Threading.Tasks.ValueTask(instance.Decimal_Overload_Is_Not_Chosen_For_An_Int_Argument(global::TUnit.Core.Helpers.CastHelper.Cast(args[0]))); + } + catch (global::System.Exception ex) + { + return new global::System.Threading.Tasks.ValueTask(global::System.Threading.Tasks.Task.FromException(ex)); + } + } + private static global::System.Attribute[] __Attributes_0(int groupIndex) + { + return new global::System.Attribute[] + { + new global::TUnit.Core.TestAttribute(), + new global::TUnit.Core.MethodDataSourceAttribute("ObjectOrDecimalRows") +{Arguments = new object[] { 28 },}, + new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass) + }; + } + public static readonly global::TUnit.Core.TestEntry[] Entries_0 = new global::TUnit.Core.TestEntry[] + { + global::TUnit.Core.TestEntryFactory.Create( + methodName: "Decimal_Overload_Is_Not_Chosen_For_An_Int_Argument", + fullyQualifiedName: "TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests.Decimal_Overload_Is_Not_Chosen_For_An_Int_Argument", + methodTypeArgumentsIdentity: "", + filePath: "", + lineNumber: 255, + hasDataSource: true, + testDataSources: new global::TUnit.Core.IDataSourceAttribute[] +{ + new global::TUnit.Core.MethodDataSourceAttribute("ObjectOrDecimalRows") + { + Arguments = new object[] { 28 }, + Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromEnumerable(static () => + { + var arguments = new object[] { 28 }; + return global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests.ObjectOrDecimalRows(((object)arguments[0])); + }), + }, +}, + methodMetadata: __mm_0, + createInstance: __CreateInstance_0, + invokeBody: __Invoke_0, + methodIndex: 0, + createAttributes: __Attributes_0, + attributeGroupIndex: 0), + }; +} +internal static partial class TUnit_TestRegistration +{ + static readonly int _r_TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Decimal_Overlo_9912F7B9_TestSource_0 = global::TUnit.Core.SourceRegistrar.RegisterEntries(static () => TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Decimal_Overlo_9912F7B9_TestSource.Entries_0); +} + + +// ===== FILE SEPARATOR ===== + +// +#pragma warning disable + +#nullable enable +namespace TUnit.Generated; +[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute] +[global::System.CodeDom.Compiler.GeneratedCode("TUnit", "VERSION_SCRUBBED")] +internal static class TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Func_Row__T_TestSource +{ + private static readonly global::TUnit.Core.ClassMetadata __classMetadata = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests)), + Name = "GenericMethodNonTupleMethodDataSourceTests", + Namespace = "TUnit.TestProject.Bugs._7108", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }); + private static readonly global::System.Type __classType = typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests); + private static readonly global::TUnit.Core.MethodMetadata __mm_0 = global::TUnit.Core.MethodMetadataFactory.Create("Func_Row", __classType, typeof(global::System.Threading.Tasks.Task), __classMetadata, genericTypeCount: 1, parameters: global::TUnit.Core.ParameterMetadataFactory.ForGenericMethod(typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests), "Func_Row", false, 1, new global::TUnit.Core.ParameterMetadata[] +{ +global::TUnit.Core.ParameterMetadataFactory.Create(typeof(object), "value", new global::TUnit.Core.GenericParameter(0, true, "T"), false) +})); + private static global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests __CreateInstance_0(global::System.Type[] typeArgs, object?[] args) + { + return new global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests(); + } + private static global::System.Threading.Tasks.ValueTask __Invoke_0(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests instance, int methodIndex, object?[] args, global::System.Threading.CancellationToken cancellationToken) + { + try + { + return new global::System.Threading.Tasks.ValueTask(instance.Func_Row(global::TUnit.Core.Helpers.CastHelper.Cast(args[0]))); + } + catch (global::System.Exception ex) + { + return new global::System.Threading.Tasks.ValueTask(global::System.Threading.Tasks.Task.FromException(ex)); + } + } + private static global::System.Attribute[] __Attributes_0(int groupIndex) + { + return new global::System.Attribute[] + { + new global::TUnit.Core.TestAttribute(), + new global::TUnit.Core.MethodDataSourceAttribute("FuncRows"), + new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass) + }; + } + public static readonly global::TUnit.Core.TestEntry[] Entries_0 = new global::TUnit.Core.TestEntry[] + { + global::TUnit.Core.TestEntryFactory.Create( + methodName: "Func_Row", + fullyQualifiedName: "TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests.Func_Row", + methodTypeArgumentsIdentity: "", + filePath: "", + lineNumber: 263, + hasDataSource: true, + testDataSources: new global::TUnit.Core.IDataSourceAttribute[] +{ + new global::TUnit.Core.MethodDataSourceAttribute("FuncRows") + { + Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromEnumerable(static () => global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests.FuncRows()), + }, +}, + methodMetadata: __mm_0, + createInstance: __CreateInstance_0, + invokeBody: __Invoke_0, + methodIndex: 0, + createAttributes: __Attributes_0, + attributeGroupIndex: 0), + }; +} +internal static partial class TUnit_TestRegistration +{ + static readonly int _r_TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Func_Row__T_TestSource_0 = global::TUnit.Core.SourceRegistrar.RegisterEntries(static () => TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Func_Row__T_TestSource.Entries_0); +} + + +// ===== FILE SEPARATOR ===== + +// +#pragma warning disable + +#nullable enable +namespace TUnit.Generated; +[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute] +[global::System.CodeDom.Compiler.GeneratedCode("TUnit", "VERSION_SCRUBBED")] +internal static class TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Nested_Func_Ro_4C35B470_TestSource +{ + private static readonly global::TUnit.Core.ClassMetadata __classMetadata = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests)), + Name = "GenericMethodNonTupleMethodDataSourceTests", + Namespace = "TUnit.TestProject.Bugs._7108", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }); + private static readonly global::System.Type __classType = typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests); + private static readonly global::TUnit.Core.MethodMetadata __mm_0 = global::TUnit.Core.MethodMetadataFactory.Create("Nested_Func_Row_Passes_The_Inner_Func", __classType, typeof(global::System.Threading.Tasks.Task), __classMetadata, genericTypeCount: 1, parameters: global::TUnit.Core.ParameterMetadataFactory.ForGenericMethod(typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests), "Nested_Func_Row_Passes_The_Inner_Func", false, 1, new global::TUnit.Core.ParameterMetadata[] +{ +global::TUnit.Core.ParameterMetadataFactory.Create(typeof(object), "value", new global::TUnit.Core.GenericParameter(0, true, "T"), false) +})); + private static global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests __CreateInstance_0(global::System.Type[] typeArgs, object?[] args) + { + return new global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests(); + } + private static global::System.Threading.Tasks.ValueTask __Invoke_0(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests instance, int methodIndex, object?[] args, global::System.Threading.CancellationToken cancellationToken) + { + try + { + return new global::System.Threading.Tasks.ValueTask(instance.Nested_Func_Row_Passes_The_Inner_Func>(global::TUnit.Core.Helpers.CastHelper.Cast>(args[0]))); + } + catch (global::System.Exception ex) + { + return new global::System.Threading.Tasks.ValueTask(global::System.Threading.Tasks.Task.FromException(ex)); + } + } + private static global::System.Attribute[] __Attributes_0(int groupIndex) + { + return new global::System.Attribute[] + { + new global::TUnit.Core.TestAttribute(), + new global::TUnit.Core.MethodDataSourceAttribute("NestedFuncRows"), + new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass) + }; + } + public static readonly global::TUnit.Core.TestEntry[] Entries_0 = new global::TUnit.Core.TestEntry[] + { + global::TUnit.Core.TestEntryFactory.Create( + methodName: "Nested_Func_Row_Passes_The_Inner_Func>", + fullyQualifiedName: "TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests.Nested_Func_Row_Passes_The_Inner_Func>", + methodTypeArgumentsIdentity: ">", + filePath: "", + lineNumber: 271, + hasDataSource: true, + testDataSources: new global::TUnit.Core.IDataSourceAttribute[] +{ + new global::TUnit.Core.MethodDataSourceAttribute("NestedFuncRows") + { + Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromEnumerable(static () => global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests.NestedFuncRows()), + }, +}, + methodMetadata: __mm_0, + createInstance: __CreateInstance_0, + invokeBody: __Invoke_0, + methodIndex: 0, + createAttributes: __Attributes_0, + attributeGroupIndex: 0), + }; +} +internal static partial class TUnit_TestRegistration +{ + static readonly int _r_TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Nested_Func_Ro_4C35B470_TestSource_0 = global::TUnit.Core.SourceRegistrar.RegisterEntries(static () => TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Nested_Func_Ro_4C35B470_TestSource.Entries_0); +} + + +// ===== FILE SEPARATOR ===== + +// +#pragma warning disable + +#nullable enable +namespace TUnit.Generated; +[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute] +[global::System.CodeDom.Compiler.GeneratedCode("TUnit", "VERSION_SCRUBBED")] +internal static class TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Func_Of_Test_D_51B55E10_TestSource +{ + private static readonly global::TUnit.Core.ClassMetadata __classMetadata = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests)), + Name = "GenericMethodNonTupleMethodDataSourceTests", + Namespace = "TUnit.TestProject.Bugs._7108", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }); + private static readonly global::System.Type __classType = typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests); + private static readonly global::TUnit.Core.MethodMetadata __mm_0 = global::TUnit.Core.MethodMetadataFactory.Create("Func_Of_Test_Data_Row_Of_Func_Row", __classType, typeof(global::System.Threading.Tasks.Task), __classMetadata, genericTypeCount: 1, parameters: global::TUnit.Core.ParameterMetadataFactory.ForGenericMethod(typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests), "Func_Of_Test_Data_Row_Of_Func_Row", false, 1, new global::TUnit.Core.ParameterMetadata[] +{ +global::TUnit.Core.ParameterMetadataFactory.Create(typeof(object), "value", new global::TUnit.Core.GenericParameter(0, true, "T"), false) +})); + private static global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests __CreateInstance_0(global::System.Type[] typeArgs, object?[] args) + { + return new global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests(); + } + private static global::System.Threading.Tasks.ValueTask __Invoke_0(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests instance, int methodIndex, object?[] args, global::System.Threading.CancellationToken cancellationToken) + { + try + { + return new global::System.Threading.Tasks.ValueTask(instance.Func_Of_Test_Data_Row_Of_Func_Row(global::TUnit.Core.Helpers.CastHelper.Cast(args[0]))); + } + catch (global::System.Exception ex) + { + return new global::System.Threading.Tasks.ValueTask(global::System.Threading.Tasks.Task.FromException(ex)); + } + } + private static global::System.Attribute[] __Attributes_0(int groupIndex) + { + return new global::System.Attribute[] + { + new global::TUnit.Core.TestAttribute(), + new global::TUnit.Core.MethodDataSourceAttribute("FuncOfTestDataRowOfFuncRows"), + new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass) + }; + } + public static readonly global::TUnit.Core.TestEntry[] Entries_0 = new global::TUnit.Core.TestEntry[] + { + global::TUnit.Core.TestEntryFactory.Create( + methodName: "Func_Of_Test_Data_Row_Of_Func_Row", + fullyQualifiedName: "TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests.Func_Of_Test_Data_Row_Of_Func_Row", + methodTypeArgumentsIdentity: "", + filePath: "", + lineNumber: 280, + hasDataSource: true, + testDataSources: new global::TUnit.Core.IDataSourceAttribute[] +{ + new global::TUnit.Core.MethodDataSourceAttribute("FuncOfTestDataRowOfFuncRows") + { + Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromEnumerable(static () => global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests.FuncOfTestDataRowOfFuncRows()), + }, +}, + methodMetadata: __mm_0, + createInstance: __CreateInstance_0, + invokeBody: __Invoke_0, + methodIndex: 0, + createAttributes: __Attributes_0, + attributeGroupIndex: 0), + }; +} +internal static partial class TUnit_TestRegistration +{ + static readonly int _r_TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Func_Of_Test_D_51B55E10_TestSource_0 = global::TUnit.Core.SourceRegistrar.RegisterEntries(static () => TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Func_Of_Test_D_51B55E10_TestSource.Entries_0); +} + + +// ===== FILE SEPARATOR ===== + +// +#pragma warning disable + +#nullable enable +namespace TUnit.Generated; +[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute] +[global::System.CodeDom.Compiler.GeneratedCode("TUnit", "VERSION_SCRUBBED")] +internal static class TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Plain_Row__T_TestSource +{ + private static readonly global::TUnit.Core.ClassMetadata __classMetadata = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests)), + Name = "GenericMethodNonTupleMethodDataSourceTests", + Namespace = "TUnit.TestProject.Bugs._7108", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }); + private static readonly global::System.Type __classType = typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests); + private static readonly global::TUnit.Core.MethodMetadata __mm_0 = global::TUnit.Core.MethodMetadataFactory.Create("Plain_Row", __classType, typeof(global::System.Threading.Tasks.Task), __classMetadata, genericTypeCount: 1, parameters: global::TUnit.Core.ParameterMetadataFactory.ForGenericMethod(typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests), "Plain_Row", false, 1, new global::TUnit.Core.ParameterMetadata[] +{ +global::TUnit.Core.ParameterMetadataFactory.Create(typeof(object), "value", new global::TUnit.Core.GenericParameter(0, true, "T"), false) +})); + private static global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests __CreateInstance_0(global::System.Type[] typeArgs, object?[] args) + { + return new global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests(); + } + private static global::System.Threading.Tasks.ValueTask __Invoke_0(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests instance, int methodIndex, object?[] args, global::System.Threading.CancellationToken cancellationToken) + { + try + { + return new global::System.Threading.Tasks.ValueTask(instance.Plain_Row(global::TUnit.Core.Helpers.CastHelper.Cast(args[0]))); + } + catch (global::System.Exception ex) + { + return new global::System.Threading.Tasks.ValueTask(global::System.Threading.Tasks.Task.FromException(ex)); + } + } + private static global::System.Attribute[] __Attributes_0(int groupIndex) + { + return new global::System.Attribute[] + { + new global::TUnit.Core.TestAttribute(), + new global::TUnit.Core.MethodDataSourceAttribute("PlainRows"), + new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass) + }; + } + public static readonly global::TUnit.Core.TestEntry[] Entries_0 = new global::TUnit.Core.TestEntry[] + { + global::TUnit.Core.TestEntryFactory.Create( + methodName: "Plain_Row", + fullyQualifiedName: "TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests.Plain_Row", + methodTypeArgumentsIdentity: "", + filePath: "", + lineNumber: 288, + hasDataSource: true, + testDataSources: new global::TUnit.Core.IDataSourceAttribute[] +{ + new global::TUnit.Core.MethodDataSourceAttribute("PlainRows") + { + Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromEnumerable(static () => global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests.PlainRows()), + }, +}, + methodMetadata: __mm_0, + createInstance: __CreateInstance_0, + invokeBody: __Invoke_0, + methodIndex: 0, + createAttributes: __Attributes_0, + attributeGroupIndex: 0), + }; +} +internal static partial class TUnit_TestRegistration +{ + static readonly int _r_TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Plain_Row__T_TestSource_0 = global::TUnit.Core.SourceRegistrar.RegisterEntries(static () => TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Plain_Row__T_TestSource.Entries_0); +} + + +// ===== FILE SEPARATOR ===== + +// +#pragma warning disable + +#nullable enable +namespace TUnit.Generated; +[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute] +[global::System.CodeDom.Compiler.GeneratedCode("TUnit", "VERSION_SCRUBBED")] +internal static class TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Array_Row__T_TestSource +{ + private static readonly global::TUnit.Core.ClassMetadata __classMetadata = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests)), + Name = "GenericMethodNonTupleMethodDataSourceTests", + Namespace = "TUnit.TestProject.Bugs._7108", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }); + private static readonly global::System.Type __classType = typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests); + private static readonly global::TUnit.Core.MethodMetadata __mm_0 = global::TUnit.Core.MethodMetadataFactory.Create("Array_Row", __classType, typeof(global::System.Threading.Tasks.Task), __classMetadata, genericTypeCount: 1, parameters: global::TUnit.Core.ParameterMetadataFactory.ForGenericMethod(typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests), "Array_Row", false, 1, new global::TUnit.Core.ParameterMetadata[] +{ +global::TUnit.Core.ParameterMetadataFactory.Create(typeof(object), "value", new global::TUnit.Core.GenericParameter(0, true, "T"), false) +})); + private static global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests __CreateInstance_0(global::System.Type[] typeArgs, object?[] args) + { + return new global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests(); + } + private static global::System.Threading.Tasks.ValueTask __Invoke_0(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests instance, int methodIndex, object?[] args, global::System.Threading.CancellationToken cancellationToken) + { + try + { + return new global::System.Threading.Tasks.ValueTask(instance.Array_Row(global::TUnit.Core.Helpers.CastHelper.Cast(args[0]))); + } + catch (global::System.Exception ex) + { + return new global::System.Threading.Tasks.ValueTask(global::System.Threading.Tasks.Task.FromException(ex)); + } + } + private static global::System.Attribute[] __Attributes_0(int groupIndex) + { + return new global::System.Attribute[] + { + new global::TUnit.Core.TestAttribute(), + new global::TUnit.Core.MethodDataSourceAttribute("ArrayRows"), + new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass) + }; + } + public static readonly global::TUnit.Core.TestEntry[] Entries_0 = new global::TUnit.Core.TestEntry[] + { + global::TUnit.Core.TestEntryFactory.Create( + methodName: "Array_Row", + fullyQualifiedName: "TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests.Array_Row", + methodTypeArgumentsIdentity: "", + filePath: "", + lineNumber: 296, + hasDataSource: true, + testDataSources: new global::TUnit.Core.IDataSourceAttribute[] +{ + new global::TUnit.Core.MethodDataSourceAttribute("ArrayRows") + { + Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromEnumerable(static () => global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests.ArrayRows()), + }, +}, + methodMetadata: __mm_0, + createInstance: __CreateInstance_0, + invokeBody: __Invoke_0, + methodIndex: 0, + createAttributes: __Attributes_0, + attributeGroupIndex: 0), + }; +} +internal static partial class TUnit_TestRegistration +{ + static readonly int _r_TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Array_Row__T_TestSource_0 = global::TUnit.Core.SourceRegistrar.RegisterEntries(static () => TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Array_Row__T_TestSource.Entries_0); +} + + +// ===== FILE SEPARATOR ===== + +// +#pragma warning disable + +#nullable enable +namespace TUnit.Generated; +[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute] +[global::System.CodeDom.Compiler.GeneratedCode("TUnit", "VERSION_SCRUBBED")] +internal static class TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Async_Enumerable_Row__T_TestSource +{ + private static readonly global::TUnit.Core.ClassMetadata __classMetadata = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests)), + Name = "GenericMethodNonTupleMethodDataSourceTests", + Namespace = "TUnit.TestProject.Bugs._7108", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }); + private static readonly global::System.Type __classType = typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests); + private static readonly global::TUnit.Core.MethodMetadata __mm_0 = global::TUnit.Core.MethodMetadataFactory.Create("Async_Enumerable_Row", __classType, typeof(global::System.Threading.Tasks.Task), __classMetadata, genericTypeCount: 1, parameters: global::TUnit.Core.ParameterMetadataFactory.ForGenericMethod(typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests), "Async_Enumerable_Row", false, 1, new global::TUnit.Core.ParameterMetadata[] +{ +global::TUnit.Core.ParameterMetadataFactory.Create(typeof(object), "value", new global::TUnit.Core.GenericParameter(0, true, "T"), false) +})); + private static global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests __CreateInstance_0(global::System.Type[] typeArgs, object?[] args) + { + return new global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests(); + } + private static global::System.Threading.Tasks.ValueTask __Invoke_0(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests instance, int methodIndex, object?[] args, global::System.Threading.CancellationToken cancellationToken) + { + try + { + return new global::System.Threading.Tasks.ValueTask(instance.Async_Enumerable_Row(global::TUnit.Core.Helpers.CastHelper.Cast(args[0]))); + } + catch (global::System.Exception ex) + { + return new global::System.Threading.Tasks.ValueTask(global::System.Threading.Tasks.Task.FromException(ex)); + } + } + private static global::System.Attribute[] __Attributes_0(int groupIndex) + { + return new global::System.Attribute[] + { + new global::TUnit.Core.TestAttribute(), + new global::TUnit.Core.MethodDataSourceAttribute("AsyncRows"), + new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass) + }; + } + public static readonly global::TUnit.Core.TestEntry[] Entries_0 = new global::TUnit.Core.TestEntry[] + { + global::TUnit.Core.TestEntryFactory.Create( + methodName: "Async_Enumerable_Row", + fullyQualifiedName: "TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests.Async_Enumerable_Row", + methodTypeArgumentsIdentity: "", + filePath: "", + lineNumber: 304, + hasDataSource: true, + testDataSources: new global::TUnit.Core.IDataSourceAttribute[] +{ + new global::TUnit.Core.MethodDataSourceAttribute("AsyncRows") + { + Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromAsyncEnumerable(static () => global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests.AsyncRows()), + }, +}, + methodMetadata: __mm_0, + createInstance: __CreateInstance_0, + invokeBody: __Invoke_0, + methodIndex: 0, + createAttributes: __Attributes_0, + attributeGroupIndex: 0), + }; +} +internal static partial class TUnit_TestRegistration +{ + static readonly int _r_TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Async_Enumerable_Row__T_TestSource_0 = global::TUnit.Core.SourceRegistrar.RegisterEntries(static () => TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Async_Enumerable_Row__T_TestSource.Entries_0); +} + + +// ===== FILE SEPARATOR ===== + +// +#pragma warning disable + +#nullable enable +namespace TUnit.Generated; +[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute] +[global::System.CodeDom.Compiler.GeneratedCode("TUnit", "VERSION_SCRUBBED")] +internal static class TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Task_Row__T_TestSource +{ + private static readonly global::TUnit.Core.ClassMetadata __classMetadata = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests)), + Name = "GenericMethodNonTupleMethodDataSourceTests", + Namespace = "TUnit.TestProject.Bugs._7108", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }); + private static readonly global::System.Type __classType = typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests); + private static readonly global::TUnit.Core.MethodMetadata __mm_0 = global::TUnit.Core.MethodMetadataFactory.Create("Task_Row", __classType, typeof(global::System.Threading.Tasks.Task), __classMetadata, genericTypeCount: 1, parameters: global::TUnit.Core.ParameterMetadataFactory.ForGenericMethod(typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests), "Task_Row", false, 1, new global::TUnit.Core.ParameterMetadata[] +{ +global::TUnit.Core.ParameterMetadataFactory.Create(typeof(object), "value", new global::TUnit.Core.GenericParameter(0, true, "T"), false) +})); + private static global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests __CreateInstance_0(global::System.Type[] typeArgs, object?[] args) + { + return new global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests(); + } + private static global::System.Threading.Tasks.ValueTask __Invoke_0(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests instance, int methodIndex, object?[] args, global::System.Threading.CancellationToken cancellationToken) + { + try + { + return new global::System.Threading.Tasks.ValueTask(instance.Task_Row(global::TUnit.Core.Helpers.CastHelper.Cast(args[0]))); + } + catch (global::System.Exception ex) + { + return new global::System.Threading.Tasks.ValueTask(global::System.Threading.Tasks.Task.FromException(ex)); + } + } + private static global::System.Attribute[] __Attributes_0(int groupIndex) + { + return new global::System.Attribute[] + { + new global::TUnit.Core.TestAttribute(), + new global::TUnit.Core.MethodDataSourceAttribute("TaskRows"), + new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass) + }; + } + public static readonly global::TUnit.Core.TestEntry[] Entries_0 = new global::TUnit.Core.TestEntry[] + { + global::TUnit.Core.TestEntryFactory.Create( + methodName: "Task_Row", + fullyQualifiedName: "TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests.Task_Row", + methodTypeArgumentsIdentity: "", + filePath: "", + lineNumber: 312, + hasDataSource: true, + testDataSources: new global::TUnit.Core.IDataSourceAttribute[] +{ + new global::TUnit.Core.MethodDataSourceAttribute("TaskRows") + { + Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromTask(static () => global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests.TaskRows()), + }, +}, + methodMetadata: __mm_0, + createInstance: __CreateInstance_0, + invokeBody: __Invoke_0, + methodIndex: 0, + createAttributes: __Attributes_0, + attributeGroupIndex: 0), + }; +} +internal static partial class TUnit_TestRegistration +{ + static readonly int _r_TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Task_Row__T_TestSource_0 = global::TUnit.Core.SourceRegistrar.RegisterEntries(static () => TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Task_Row__T_TestSource.Entries_0); +} + + +// ===== FILE SEPARATOR ===== + +// +#pragma warning disable + +#nullable enable +namespace TUnit.Generated; +[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute] +[global::System.CodeDom.Compiler.GeneratedCode("TUnit", "VERSION_SCRUBBED")] +internal static class TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Test_Data_Row__T_TestSource +{ + private static readonly global::TUnit.Core.ClassMetadata __classMetadata = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests)), + Name = "GenericMethodNonTupleMethodDataSourceTests", + Namespace = "TUnit.TestProject.Bugs._7108", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }); + private static readonly global::System.Type __classType = typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests); + private static readonly global::TUnit.Core.MethodMetadata __mm_0 = global::TUnit.Core.MethodMetadataFactory.Create("Test_Data_Row", __classType, typeof(global::System.Threading.Tasks.Task), __classMetadata, genericTypeCount: 1, parameters: global::TUnit.Core.ParameterMetadataFactory.ForGenericMethod(typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests), "Test_Data_Row", false, 1, new global::TUnit.Core.ParameterMetadata[] +{ +global::TUnit.Core.ParameterMetadataFactory.Create(typeof(object), "value", new global::TUnit.Core.GenericParameter(0, true, "T"), false) +})); + private static global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests __CreateInstance_0(global::System.Type[] typeArgs, object?[] args) + { + return new global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests(); + } + private static global::System.Threading.Tasks.ValueTask __Invoke_0(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests instance, int methodIndex, object?[] args, global::System.Threading.CancellationToken cancellationToken) + { + try + { + return new global::System.Threading.Tasks.ValueTask(instance.Test_Data_Row(global::TUnit.Core.Helpers.CastHelper.Cast(args[0]))); + } + catch (global::System.Exception ex) + { + return new global::System.Threading.Tasks.ValueTask(global::System.Threading.Tasks.Task.FromException(ex)); + } + } + private static global::System.Attribute[] __Attributes_0(int groupIndex) + { + return new global::System.Attribute[] + { + new global::TUnit.Core.TestAttribute(), + new global::TUnit.Core.MethodDataSourceAttribute("TestDataRows"), + new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass) + }; + } + public static readonly global::TUnit.Core.TestEntry[] Entries_0 = new global::TUnit.Core.TestEntry[] + { + global::TUnit.Core.TestEntryFactory.Create( + methodName: "Test_Data_Row", + fullyQualifiedName: "TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests.Test_Data_Row", + methodTypeArgumentsIdentity: "", + filePath: "", + lineNumber: 320, + hasDataSource: true, + testDataSources: new global::TUnit.Core.IDataSourceAttribute[] +{ + new global::TUnit.Core.MethodDataSourceAttribute("TestDataRows") + { + Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromEnumerable(static () => global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests.TestDataRows()), + }, +}, + methodMetadata: __mm_0, + createInstance: __CreateInstance_0, + invokeBody: __Invoke_0, + methodIndex: 0, + createAttributes: __Attributes_0, + attributeGroupIndex: 0), + }; +} +internal static partial class TUnit_TestRegistration +{ + static readonly int _r_TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Test_Data_Row__T_TestSource_0 = global::TUnit.Core.SourceRegistrar.RegisterEntries(static () => TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Test_Data_Row__T_TestSource.Entries_0); +} + + +// ===== FILE SEPARATOR ===== + +// +#pragma warning disable + +#nullable enable +namespace TUnit.Generated; +[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute] +[global::System.CodeDom.Compiler.GeneratedCode("TUnit", "VERSION_SCRUBBED")] +internal static class TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Nested_Generic_543EB7D9_TestSource +{ + private static readonly global::TUnit.Core.ClassMetadata __classMetadata = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests)), + Name = "GenericMethodNonTupleMethodDataSourceTests", + Namespace = "TUnit.TestProject.Bugs._7108", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }); + private static readonly global::System.Type __classType = typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests); + private static readonly global::TUnit.Core.MethodMetadata __mm_0 = global::TUnit.Core.MethodMetadataFactory.Create("Nested_Generic_Row", __classType, typeof(global::System.Threading.Tasks.Task), __classMetadata, genericTypeCount: 1, parameters: global::TUnit.Core.ParameterMetadataFactory.ForGenericMethod(typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests), "Nested_Generic_Row", false, 1, new global::TUnit.Core.ParameterMetadata[] +{ +global::TUnit.Core.ParameterMetadataFactory.Create(typeof(object), "value", new global::TUnit.Core.ConstructedGeneric(typeof(global::System.Collections.Generic.List<>), [new global::TUnit.Core.GenericParameter(0, true, "T")]), false) +})); + private static global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests __CreateInstance_0(global::System.Type[] typeArgs, object?[] args) + { + return new global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests(); + } + private static global::System.Threading.Tasks.ValueTask __Invoke_0(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests instance, int methodIndex, object?[] args, global::System.Threading.CancellationToken cancellationToken) + { + try + { + return new global::System.Threading.Tasks.ValueTask(instance.Nested_Generic_Row(global::TUnit.Core.Helpers.CastHelper.Cast>(args[0]))); + } + catch (global::System.Exception ex) + { + return new global::System.Threading.Tasks.ValueTask(global::System.Threading.Tasks.Task.FromException(ex)); + } + } + private static global::System.Attribute[] __Attributes_0(int groupIndex) + { + return new global::System.Attribute[] + { + new global::TUnit.Core.TestAttribute(), + new global::TUnit.Core.MethodDataSourceAttribute("ListRows"), + new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass) + }; + } + public static readonly global::TUnit.Core.TestEntry[] Entries_0 = new global::TUnit.Core.TestEntry[] + { + global::TUnit.Core.TestEntryFactory.Create( + methodName: "Nested_Generic_Row", + fullyQualifiedName: "TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests.Nested_Generic_Row", + methodTypeArgumentsIdentity: "", + filePath: "", + lineNumber: 328, + hasDataSource: true, + testDataSources: new global::TUnit.Core.IDataSourceAttribute[] +{ + new global::TUnit.Core.MethodDataSourceAttribute("ListRows") + { + Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromEnumerable(static () => global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests.ListRows()), + }, +}, + methodMetadata: __mm_0, + createInstance: __CreateInstance_0, + invokeBody: __Invoke_0, + methodIndex: 0, + createAttributes: __Attributes_0, + attributeGroupIndex: 0), + }; +} +internal static partial class TUnit_TestRegistration +{ + static readonly int _r_TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Nested_Generic_543EB7D9_TestSource_0 = global::TUnit.Core.SourceRegistrar.RegisterEntries(static () => TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Nested_Generic_543EB7D9_TestSource.Entries_0); +} + + +// ===== FILE SEPARATOR ===== + +// +#pragma warning disable + +#nullable enable +namespace TUnit.Generated; +[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute] +[global::System.CodeDom.Compiler.GeneratedCode("TUnit", "VERSION_SCRUBBED")] +internal static class TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Plain_Tuple_Row__T1_T2_TestSource +{ + private static readonly global::TUnit.Core.ClassMetadata __classMetadata = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests)), + Name = "GenericMethodNonTupleMethodDataSourceTests", + Namespace = "TUnit.TestProject.Bugs._7108", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }); + private static readonly global::System.Type __classType = typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests); + private static readonly global::TUnit.Core.MethodMetadata __mm_0 = global::TUnit.Core.MethodMetadataFactory.Create("Plain_Tuple_Row", __classType, typeof(global::System.Threading.Tasks.Task), __classMetadata, genericTypeCount: 2, parameters: global::TUnit.Core.ParameterMetadataFactory.ForGenericMethod(typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests), "Plain_Tuple_Row", false, 2, new global::TUnit.Core.ParameterMetadata[] +{ +global::TUnit.Core.ParameterMetadataFactory.Create(typeof(object), "number", new global::TUnit.Core.GenericParameter(0, true, "T1"), false), +global::TUnit.Core.ParameterMetadataFactory.Create(typeof(object), "text", new global::TUnit.Core.GenericParameter(1, true, "T2"), false) +})); + private static global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests __CreateInstance_0(global::System.Type[] typeArgs, object?[] args) + { + return new global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests(); + } + private static global::System.Threading.Tasks.ValueTask __Invoke_0(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests instance, int methodIndex, object?[] args, global::System.Threading.CancellationToken cancellationToken) + { + try + { + return new global::System.Threading.Tasks.ValueTask(instance.Plain_Tuple_Row(global::TUnit.Core.Helpers.CastHelper.Cast(args[0]), global::TUnit.Core.Helpers.CastHelper.Cast(args[1]))); + } + catch (global::System.Exception ex) + { + return new global::System.Threading.Tasks.ValueTask(global::System.Threading.Tasks.Task.FromException(ex)); + } + } + private static global::System.Attribute[] __Attributes_0(int groupIndex) + { + return new global::System.Attribute[] + { + new global::TUnit.Core.TestAttribute(), + new global::TUnit.Core.MethodDataSourceAttribute("PlainTupleRows"), + new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass) + }; + } + public static readonly global::TUnit.Core.TestEntry[] Entries_0 = new global::TUnit.Core.TestEntry[] + { + global::TUnit.Core.TestEntryFactory.Create( + methodName: "Plain_Tuple_Row", + fullyQualifiedName: "TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests.Plain_Tuple_Row", + methodTypeArgumentsIdentity: "", + filePath: "", + lineNumber: 336, + hasDataSource: true, + testDataSources: new global::TUnit.Core.IDataSourceAttribute[] +{ + new global::TUnit.Core.MethodDataSourceAttribute("PlainTupleRows") + { + Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromEnumerable(static () => global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests.PlainTupleRows()), + }, +}, + methodMetadata: __mm_0, + createInstance: __CreateInstance_0, + invokeBody: __Invoke_0, + methodIndex: 0, + createAttributes: __Attributes_0, + attributeGroupIndex: 0), + }; +} +internal static partial class TUnit_TestRegistration +{ + static readonly int _r_TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Plain_Tuple_Row__T1_T2_TestSource_0 = global::TUnit.Core.SourceRegistrar.RegisterEntries(static () => TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Plain_Tuple_Row__T1_T2_TestSource.Entries_0); +} + + +// ===== FILE SEPARATOR ===== + +// +#pragma warning disable + +#nullable enable +namespace TUnit.Generated; +[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute] +[global::System.CodeDom.Compiler.GeneratedCode("TUnit", "VERSION_SCRUBBED")] +internal static class TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Data_Method_Wi_84F509B1_TestSource +{ + private static readonly global::TUnit.Core.ClassMetadata __classMetadata = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests)), + Name = "GenericMethodNonTupleMethodDataSourceTests", + Namespace = "TUnit.TestProject.Bugs._7108", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }); + private static readonly global::System.Type __classType = typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests); + private static readonly global::TUnit.Core.MethodMetadata __mm_0 = global::TUnit.Core.MethodMetadataFactory.Create("Data_Method_With_Arguments", __classType, typeof(global::System.Threading.Tasks.Task), __classMetadata, genericTypeCount: 1, parameters: global::TUnit.Core.ParameterMetadataFactory.ForGenericMethod(typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests), "Data_Method_With_Arguments", false, 1, new global::TUnit.Core.ParameterMetadata[] +{ +global::TUnit.Core.ParameterMetadataFactory.Create(typeof(object), "value", new global::TUnit.Core.GenericParameter(0, true, "T"), false) +})); + private static global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests __CreateInstance_0(global::System.Type[] typeArgs, object?[] args) + { + return new global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests(); + } + private static global::System.Threading.Tasks.ValueTask __Invoke_0(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests instance, int methodIndex, object?[] args, global::System.Threading.CancellationToken cancellationToken) + { + try + { + return new global::System.Threading.Tasks.ValueTask(instance.Data_Method_With_Arguments(global::TUnit.Core.Helpers.CastHelper.Cast(args[0]))); + } + catch (global::System.Exception ex) + { + return new global::System.Threading.Tasks.ValueTask(global::System.Threading.Tasks.Task.FromException(ex)); + } + } + private static global::System.Attribute[] __Attributes_0(int groupIndex) + { + return new global::System.Attribute[] + { + new global::TUnit.Core.TestAttribute(), + new global::TUnit.Core.MethodDataSourceAttribute("RowsWithArgument") +{Arguments = new object[] { 9 },}, + new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass) + }; + } + public static readonly global::TUnit.Core.TestEntry[] Entries_0 = new global::TUnit.Core.TestEntry[] + { + global::TUnit.Core.TestEntryFactory.Create( + methodName: "Data_Method_With_Arguments", + fullyQualifiedName: "TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests.Data_Method_With_Arguments", + methodTypeArgumentsIdentity: "", + filePath: "", + lineNumber: 346, + hasDataSource: true, + testDataSources: new global::TUnit.Core.IDataSourceAttribute[] +{ + new global::TUnit.Core.MethodDataSourceAttribute("RowsWithArgument") + { + Arguments = new object[] { 9 }, + Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromEnumerable(static () => + { + var arguments = new object[] { 9 }; + return global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests.RowsWithArgument(((int)arguments[0])); + }), + }, +}, + methodMetadata: __mm_0, + createInstance: __CreateInstance_0, + invokeBody: __Invoke_0, + methodIndex: 0, + createAttributes: __Attributes_0, + attributeGroupIndex: 0), + }; +} +internal static partial class TUnit_TestRegistration +{ + static readonly int _r_TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Data_Method_Wi_84F509B1_TestSource_0 = global::TUnit.Core.SourceRegistrar.RegisterEntries(static () => TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Data_Method_Wi_84F509B1_TestSource.Entries_0); +} + + +// ===== FILE SEPARATOR ===== + +// +#pragma warning disable + +#nullable enable +namespace TUnit.Generated; +[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute] +[global::System.CodeDom.Compiler.GeneratedCode("TUnit", "VERSION_SCRUBBED")] +internal static class TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Array_Element_Row__T___TestSource +{ + private static readonly global::TUnit.Core.ClassMetadata __classMetadata = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests)), + Name = "GenericMethodNonTupleMethodDataSourceTests", + Namespace = "TUnit.TestProject.Bugs._7108", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }); + private static readonly global::System.Type __classType = typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests); + private static readonly global::TUnit.Core.MethodMetadata __mm_0 = global::TUnit.Core.MethodMetadataFactory.Create("Array_Element_Row", __classType, typeof(global::System.Threading.Tasks.Task), __classMetadata, genericTypeCount: 1, parameters: global::TUnit.Core.ParameterMetadataFactory.ForGenericMethod(typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests), "Array_Element_Row", false, 1, new global::TUnit.Core.ParameterMetadata[] +{ +global::TUnit.Core.ParameterMetadataFactory.Create(typeof(object), "values", new global::TUnit.Core.ConcreteType(typeof(object)), false) +})); + private static global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests __CreateInstance_0(global::System.Type[] typeArgs, object?[] args) + { + return new global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests(); + } + private static global::System.Threading.Tasks.ValueTask __Invoke_0(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests instance, int methodIndex, object?[] args, global::System.Threading.CancellationToken cancellationToken) + { + try + { + switch (args.Length) + { + case 0: + { + return new global::System.Threading.Tasks.ValueTask(instance.Array_Element_Row(global::System.Array.Empty())); + } + case 1: + { + return new global::System.Threading.Tasks.ValueTask(instance.Array_Element_Row((args[0] is null ? null : args[0] is int[] arr ? arr : global::TUnit.Core.Helpers.CastHelper.ToTrailingArray(args[0])))); + } + case 2: + { + return new global::System.Threading.Tasks.ValueTask(instance.Array_Element_Row(new int[] { global::TUnit.Core.Helpers.CastHelper.Cast(args[0]), global::TUnit.Core.Helpers.CastHelper.Cast(args[1]) })); + } + case 3: + { + return new global::System.Threading.Tasks.ValueTask(instance.Array_Element_Row(new int[] { global::TUnit.Core.Helpers.CastHelper.Cast(args[0]), global::TUnit.Core.Helpers.CastHelper.Cast(args[1]), global::TUnit.Core.Helpers.CastHelper.Cast(args[2]) })); + } + case 4: + { + return new global::System.Threading.Tasks.ValueTask(instance.Array_Element_Row(new int[] { global::TUnit.Core.Helpers.CastHelper.Cast(args[0]), global::TUnit.Core.Helpers.CastHelper.Cast(args[1]), global::TUnit.Core.Helpers.CastHelper.Cast(args[2]), global::TUnit.Core.Helpers.CastHelper.Cast(args[3]) })); + } + case 5: + { + return new global::System.Threading.Tasks.ValueTask(instance.Array_Element_Row(new int[] { global::TUnit.Core.Helpers.CastHelper.Cast(args[0]), global::TUnit.Core.Helpers.CastHelper.Cast(args[1]), global::TUnit.Core.Helpers.CastHelper.Cast(args[2]), global::TUnit.Core.Helpers.CastHelper.Cast(args[3]), global::TUnit.Core.Helpers.CastHelper.Cast(args[4]) })); + } + case 6: + { + return new global::System.Threading.Tasks.ValueTask(instance.Array_Element_Row(new int[] { global::TUnit.Core.Helpers.CastHelper.Cast(args[0]), global::TUnit.Core.Helpers.CastHelper.Cast(args[1]), global::TUnit.Core.Helpers.CastHelper.Cast(args[2]), global::TUnit.Core.Helpers.CastHelper.Cast(args[3]), global::TUnit.Core.Helpers.CastHelper.Cast(args[4]), global::TUnit.Core.Helpers.CastHelper.Cast(args[5]) })); + } + default: + return new global::System.Threading.Tasks.ValueTask(instance.Array_Element_Row((args.Length > 0 ? global::System.Linq.Enumerable.ToArray(global::System.Linq.Enumerable.Select(global::System.Linq.Enumerable.Range(0, args.Length), i => global::TUnit.Core.Helpers.CastHelper.Cast(args[i]))) : global::System.Array.Empty()))); + } + } + catch (global::System.Exception ex) + { + return new global::System.Threading.Tasks.ValueTask(global::System.Threading.Tasks.Task.FromException(ex)); + } + } + private static global::System.Attribute[] __Attributes_0(int groupIndex) + { + return new global::System.Attribute[] + { + new global::TUnit.Core.TestAttribute(), + new global::TUnit.Core.MethodDataSourceAttribute("IntArrayRows"), + new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass) + }; + } + public static readonly global::TUnit.Core.TestEntry[] Entries_0 = new global::TUnit.Core.TestEntry[] + { + global::TUnit.Core.TestEntryFactory.Create( + methodName: "Array_Element_Row", + fullyQualifiedName: "TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests.Array_Element_Row", + methodTypeArgumentsIdentity: "", + filePath: "", + lineNumber: 354, + hasDataSource: true, + testDataSources: new global::TUnit.Core.IDataSourceAttribute[] +{ + new global::TUnit.Core.MethodDataSourceAttribute("IntArrayRows") + { + Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromEnumerable(static () => global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests.IntArrayRows()), + }, +}, + methodMetadata: __mm_0, + createInstance: __CreateInstance_0, + invokeBody: __Invoke_0, + methodIndex: 0, + createAttributes: __Attributes_0, + attributeGroupIndex: 0), + }; +} +internal static partial class TUnit_TestRegistration +{ + static readonly int _r_TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Array_Element_Row__T___TestSource_0 = global::TUnit.Core.SourceRegistrar.RegisterEntries(static () => TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Array_Element_Row__T___TestSource.Entries_0); +} + + +// ===== FILE SEPARATOR ===== + +// +#pragma warning disable + +#nullable enable +namespace TUnit.Generated; +[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute] +[global::System.CodeDom.Compiler.GeneratedCode("TUnit", "VERSION_SCRUBBED")] +internal static class TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Overload_Selec_9FEE4374_TestSource +{ + private static readonly global::TUnit.Core.ClassMetadata __classMetadata = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests)), + Name = "GenericMethodNonTupleMethodDataSourceTests", + Namespace = "TUnit.TestProject.Bugs._7108", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }); + private static readonly global::System.Type __classType = typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests); + private static readonly global::TUnit.Core.MethodMetadata __mm_0 = global::TUnit.Core.MethodMetadataFactory.Create("Overload_Selected_By_Arguments", __classType, typeof(global::System.Threading.Tasks.Task), __classMetadata, genericTypeCount: 1, parameters: global::TUnit.Core.ParameterMetadataFactory.ForGenericMethod(typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests), "Overload_Selected_By_Arguments", false, 1, new global::TUnit.Core.ParameterMetadata[] +{ +global::TUnit.Core.ParameterMetadataFactory.Create(typeof(object), "value", new global::TUnit.Core.GenericParameter(0, true, "T"), false) +})); + private static global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests __CreateInstance_0(global::System.Type[] typeArgs, object?[] args) + { + return new global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests(); + } + private static global::System.Threading.Tasks.ValueTask __Invoke_0(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests instance, int methodIndex, object?[] args, global::System.Threading.CancellationToken cancellationToken) + { + try + { + return new global::System.Threading.Tasks.ValueTask(instance.Overload_Selected_By_Arguments(global::TUnit.Core.Helpers.CastHelper.Cast(args[0]))); + } + catch (global::System.Exception ex) + { + return new global::System.Threading.Tasks.ValueTask(global::System.Threading.Tasks.Task.FromException(ex)); + } + } + private static global::System.Attribute[] __Attributes_0(int groupIndex) + { + return new global::System.Attribute[] + { + new global::TUnit.Core.TestAttribute(), + new global::TUnit.Core.MethodDataSourceAttribute("OverloadedRows") +{Arguments = new object[] { 12 },}, + new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass) + }; + } + public static readonly global::TUnit.Core.TestEntry[] Entries_0 = new global::TUnit.Core.TestEntry[] + { + global::TUnit.Core.TestEntryFactory.Create( + methodName: "Overload_Selected_By_Arguments", + fullyQualifiedName: "TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests.Overload_Selected_By_Arguments", + methodTypeArgumentsIdentity: "", + filePath: "", + lineNumber: 362, + hasDataSource: true, + testDataSources: new global::TUnit.Core.IDataSourceAttribute[] +{ + new global::TUnit.Core.MethodDataSourceAttribute("OverloadedRows") + { + Arguments = new object[] { 12 }, + Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromEnumerable(static () => + { + var arguments = new object[] { 12 }; + return global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests.OverloadedRows(((int)arguments[0])); + }), + }, +}, + methodMetadata: __mm_0, + createInstance: __CreateInstance_0, + invokeBody: __Invoke_0, + methodIndex: 0, + createAttributes: __Attributes_0, + attributeGroupIndex: 0), + }; +} +internal static partial class TUnit_TestRegistration +{ + static readonly int _r_TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Overload_Selec_9FEE4374_TestSource_0 = global::TUnit.Core.SourceRegistrar.RegisterEntries(static () => TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Overload_Selec_9FEE4374_TestSource.Entries_0); +} + + +// ===== FILE SEPARATOR ===== + +// +#pragma warning disable + +#nullable enable +namespace TUnit.Generated; +[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute] +[global::System.CodeDom.Compiler.GeneratedCode("TUnit", "VERSION_SCRUBBED")] +internal static class TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Parameterless__412471F0_TestSource +{ + private static readonly global::TUnit.Core.ClassMetadata __classMetadata = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests)), + Name = "GenericMethodNonTupleMethodDataSourceTests", + Namespace = "TUnit.TestProject.Bugs._7108", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }); + private static readonly global::System.Type __classType = typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests); + private static readonly global::TUnit.Core.MethodMetadata __mm_0 = global::TUnit.Core.MethodMetadataFactory.Create("Parameterless_Overload_Selected_Without_Arguments", __classType, typeof(global::System.Threading.Tasks.Task), __classMetadata, genericTypeCount: 1, parameters: global::TUnit.Core.ParameterMetadataFactory.ForGenericMethod(typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests), "Parameterless_Overload_Selected_Without_Arguments", false, 1, new global::TUnit.Core.ParameterMetadata[] +{ +global::TUnit.Core.ParameterMetadataFactory.Create(typeof(object), "value", new global::TUnit.Core.GenericParameter(0, true, "T"), false) +})); + private static global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests __CreateInstance_0(global::System.Type[] typeArgs, object?[] args) + { + return new global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests(); + } + private static global::System.Threading.Tasks.ValueTask __Invoke_0(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests instance, int methodIndex, object?[] args, global::System.Threading.CancellationToken cancellationToken) + { + try + { + return new global::System.Threading.Tasks.ValueTask(instance.Parameterless_Overload_Selected_Without_Arguments(global::TUnit.Core.Helpers.CastHelper.Cast(args[0]))); + } + catch (global::System.Exception ex) + { + return new global::System.Threading.Tasks.ValueTask(global::System.Threading.Tasks.Task.FromException(ex)); + } + } + private static global::System.Attribute[] __Attributes_0(int groupIndex) + { + return new global::System.Attribute[] + { + new global::TUnit.Core.TestAttribute(), + new global::TUnit.Core.MethodDataSourceAttribute("OverloadedRows"), + new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass) + }; + } + public static readonly global::TUnit.Core.TestEntry[] Entries_0 = new global::TUnit.Core.TestEntry[] + { + global::TUnit.Core.TestEntryFactory.Create( + methodName: "Parameterless_Overload_Selected_Without_Arguments", + fullyQualifiedName: "TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests.Parameterless_Overload_Selected_Without_Arguments", + methodTypeArgumentsIdentity: "", + filePath: "", + lineNumber: 370, + hasDataSource: true, + testDataSources: new global::TUnit.Core.IDataSourceAttribute[] +{ + new global::TUnit.Core.MethodDataSourceAttribute("OverloadedRows") + { + Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromEnumerable(static () => global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests.OverloadedRows()), + }, +}, + methodMetadata: __mm_0, + createInstance: __CreateInstance_0, + invokeBody: __Invoke_0, + methodIndex: 0, + createAttributes: __Attributes_0, + attributeGroupIndex: 0), + }; +} +internal static partial class TUnit_TestRegistration +{ + static readonly int _r_TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Parameterless__412471F0_TestSource_0 = global::TUnit.Core.SourceRegistrar.RegisterEntries(static () => TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Parameterless__412471F0_TestSource.Entries_0); +} + + +// ===== FILE SEPARATOR ===== + +// +#pragma warning disable + +#nullable enable +namespace TUnit.Generated; +[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute] +[global::System.CodeDom.Compiler.GeneratedCode("TUnit", "VERSION_SCRUBBED")] +internal static class TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Numeric_Argume_3E0DC70E_TestSource +{ + private static readonly global::TUnit.Core.ClassMetadata __classMetadata = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests)), + Name = "GenericMethodNonTupleMethodDataSourceTests", + Namespace = "TUnit.TestProject.Bugs._7108", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }); + private static readonly global::System.Type __classType = typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests); + private static readonly global::TUnit.Core.MethodMetadata __mm_0 = global::TUnit.Core.MethodMetadataFactory.Create("Numeric_Argument_Is_Widened", __classType, typeof(global::System.Threading.Tasks.Task), __classMetadata, genericTypeCount: 1, parameters: global::TUnit.Core.ParameterMetadataFactory.ForGenericMethod(typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests), "Numeric_Argument_Is_Widened", false, 1, new global::TUnit.Core.ParameterMetadata[] +{ +global::TUnit.Core.ParameterMetadataFactory.Create(typeof(object), "value", new global::TUnit.Core.GenericParameter(0, true, "T"), false) +})); + private static global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests __CreateInstance_0(global::System.Type[] typeArgs, object?[] args) + { + return new global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests(); + } + private static global::System.Threading.Tasks.ValueTask __Invoke_0(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests instance, int methodIndex, object?[] args, global::System.Threading.CancellationToken cancellationToken) + { + try + { + return new global::System.Threading.Tasks.ValueTask(instance.Numeric_Argument_Is_Widened(global::TUnit.Core.Helpers.CastHelper.Cast(args[0]))); + } + catch (global::System.Exception ex) + { + return new global::System.Threading.Tasks.ValueTask(global::System.Threading.Tasks.Task.FromException(ex)); + } + } + private static global::System.Attribute[] __Attributes_0(int groupIndex) + { + return new global::System.Attribute[] + { + new global::TUnit.Core.TestAttribute(), + new global::TUnit.Core.MethodDataSourceAttribute("WideningRows") +{Arguments = new object[] { 13 },}, + new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass) + }; + } + public static readonly global::TUnit.Core.TestEntry[] Entries_0 = new global::TUnit.Core.TestEntry[] + { + global::TUnit.Core.TestEntryFactory.Create( + methodName: "Numeric_Argument_Is_Widened", + fullyQualifiedName: "TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests.Numeric_Argument_Is_Widened", + methodTypeArgumentsIdentity: "", + filePath: "", + lineNumber: 378, + hasDataSource: true, + testDataSources: new global::TUnit.Core.IDataSourceAttribute[] +{ + new global::TUnit.Core.MethodDataSourceAttribute("WideningRows") + { + Arguments = new object[] { 13 }, + Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromEnumerable(static () => + { + var arguments = new object[] { 13 }; + return global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests.WideningRows(((long)(int)arguments[0])); + }), + }, +}, + methodMetadata: __mm_0, + createInstance: __CreateInstance_0, + invokeBody: __Invoke_0, + methodIndex: 0, + createAttributes: __Attributes_0, + attributeGroupIndex: 0), + }; +} +internal static partial class TUnit_TestRegistration +{ + static readonly int _r_TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Numeric_Argume_3E0DC70E_TestSource_0 = global::TUnit.Core.SourceRegistrar.RegisterEntries(static () => TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Numeric_Argume_3E0DC70E_TestSource.Entries_0); +} + + +// ===== FILE SEPARATOR ===== + +// +#pragma warning disable + +#nullable enable +namespace TUnit.Generated; +[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute] +[global::System.CodeDom.Compiler.GeneratedCode("TUnit", "VERSION_SCRUBBED")] +internal static class TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Float_Argument_691BF735_TestSource +{ + private static readonly global::TUnit.Core.ClassMetadata __classMetadata = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests)), + Name = "GenericMethodNonTupleMethodDataSourceTests", + Namespace = "TUnit.TestProject.Bugs._7108", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }); + private static readonly global::System.Type __classType = typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests); + private static readonly global::TUnit.Core.MethodMetadata __mm_0 = global::TUnit.Core.MethodMetadataFactory.Create("Float_Argument_Is_Widened_To_Double", __classType, typeof(global::System.Threading.Tasks.Task), __classMetadata, genericTypeCount: 1, parameters: global::TUnit.Core.ParameterMetadataFactory.ForGenericMethod(typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests), "Float_Argument_Is_Widened_To_Double", false, 1, new global::TUnit.Core.ParameterMetadata[] +{ +global::TUnit.Core.ParameterMetadataFactory.Create(typeof(object), "value", new global::TUnit.Core.GenericParameter(0, true, "T"), false) +})); + private static global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests __CreateInstance_0(global::System.Type[] typeArgs, object?[] args) + { + return new global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests(); + } + private static global::System.Threading.Tasks.ValueTask __Invoke_0(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests instance, int methodIndex, object?[] args, global::System.Threading.CancellationToken cancellationToken) + { + try + { + return new global::System.Threading.Tasks.ValueTask(instance.Float_Argument_Is_Widened_To_Double(global::TUnit.Core.Helpers.CastHelper.Cast(args[0]))); + } + catch (global::System.Exception ex) + { + return new global::System.Threading.Tasks.ValueTask(global::System.Threading.Tasks.Task.FromException(ex)); + } + } + private static global::System.Attribute[] __Attributes_0(int groupIndex) + { + return new global::System.Attribute[] + { + new global::TUnit.Core.TestAttribute(), + new global::TUnit.Core.MethodDataSourceAttribute("FloatWideningRows") +{Arguments = new object[] { 1.5f },}, + new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass) + }; + } + public static readonly global::TUnit.Core.TestEntry[] Entries_0 = new global::TUnit.Core.TestEntry[] + { + global::TUnit.Core.TestEntryFactory.Create( + methodName: "Float_Argument_Is_Widened_To_Double", + fullyQualifiedName: "TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests.Float_Argument_Is_Widened_To_Double", + methodTypeArgumentsIdentity: "", + filePath: "", + lineNumber: 386, + hasDataSource: true, + testDataSources: new global::TUnit.Core.IDataSourceAttribute[] +{ + new global::TUnit.Core.MethodDataSourceAttribute("FloatWideningRows") + { + Arguments = new object[] { 1.5f }, + Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromEnumerable(static () => + { + var arguments = new object[] { 1.5f }; + return global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests.FloatWideningRows(((double)(float)arguments[0])); + }), + }, +}, + methodMetadata: __mm_0, + createInstance: __CreateInstance_0, + invokeBody: __Invoke_0, + methodIndex: 0, + createAttributes: __Attributes_0, + attributeGroupIndex: 0), + }; +} +internal static partial class TUnit_TestRegistration +{ + static readonly int _r_TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Float_Argument_691BF735_TestSource_0 = global::TUnit.Core.SourceRegistrar.RegisterEntries(static () => TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Float_Argument_691BF735_TestSource.Entries_0); +} + + +// ===== FILE SEPARATOR ===== + +// +#pragma warning disable + +#nullable enable +namespace TUnit.Generated; +[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute] +[global::System.CodeDom.Compiler.GeneratedCode("TUnit", "VERSION_SCRUBBED")] +internal static class TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Long_Argument__897E728C_TestSource +{ + private static readonly global::TUnit.Core.ClassMetadata __classMetadata = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests)), + Name = "GenericMethodNonTupleMethodDataSourceTests", + Namespace = "TUnit.TestProject.Bugs._7108", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }); + private static readonly global::System.Type __classType = typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests); + private static readonly global::TUnit.Core.MethodMetadata __mm_0 = global::TUnit.Core.MethodMetadataFactory.Create("Long_Argument_Keeps_Its_Type", __classType, typeof(global::System.Threading.Tasks.Task), __classMetadata, genericTypeCount: 1, parameters: global::TUnit.Core.ParameterMetadataFactory.ForGenericMethod(typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests), "Long_Argument_Keeps_Its_Type", false, 1, new global::TUnit.Core.ParameterMetadata[] +{ +global::TUnit.Core.ParameterMetadataFactory.Create(typeof(object), "value", new global::TUnit.Core.GenericParameter(0, true, "T"), false) +})); + private static global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests __CreateInstance_0(global::System.Type[] typeArgs, object?[] args) + { + return new global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests(); + } + private static global::System.Threading.Tasks.ValueTask __Invoke_0(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests instance, int methodIndex, object?[] args, global::System.Threading.CancellationToken cancellationToken) + { + try + { + return new global::System.Threading.Tasks.ValueTask(instance.Long_Argument_Keeps_Its_Type(global::TUnit.Core.Helpers.CastHelper.Cast(args[0]))); + } + catch (global::System.Exception ex) + { + return new global::System.Threading.Tasks.ValueTask(global::System.Threading.Tasks.Task.FromException(ex)); + } + } + private static global::System.Attribute[] __Attributes_0(int groupIndex) + { + return new global::System.Attribute[] + { + new global::TUnit.Core.TestAttribute(), + new global::TUnit.Core.MethodDataSourceAttribute("LongRows") +{Arguments = new object[] { 16L },}, + new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass) + }; + } + public static readonly global::TUnit.Core.TestEntry[] Entries_0 = new global::TUnit.Core.TestEntry[] + { + global::TUnit.Core.TestEntryFactory.Create( + methodName: "Long_Argument_Keeps_Its_Type", + fullyQualifiedName: "TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests.Long_Argument_Keeps_Its_Type", + methodTypeArgumentsIdentity: "", + filePath: "", + lineNumber: 394, + hasDataSource: true, + testDataSources: new global::TUnit.Core.IDataSourceAttribute[] +{ + new global::TUnit.Core.MethodDataSourceAttribute("LongRows") + { + Arguments = new object[] { 16L }, + Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromEnumerable(static () => + { + var arguments = new object[] { 16L }; + return global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests.LongRows(((long)arguments[0])); + }), + }, +}, + methodMetadata: __mm_0, + createInstance: __CreateInstance_0, + invokeBody: __Invoke_0, + methodIndex: 0, + createAttributes: __Attributes_0, + attributeGroupIndex: 0), + }; +} +internal static partial class TUnit_TestRegistration +{ + static readonly int _r_TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Long_Argument__897E728C_TestSource_0 = global::TUnit.Core.SourceRegistrar.RegisterEntries(static () => TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Long_Argument__897E728C_TestSource.Entries_0); +} + + +// ===== FILE SEPARATOR ===== + +// +#pragma warning disable + +#nullable enable +namespace TUnit.Generated; +[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute] +[global::System.CodeDom.Compiler.GeneratedCode("TUnit", "VERSION_SCRUBBED")] +internal static class TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Argument_Is_Wr_4F209AE1_TestSource +{ + private static readonly global::TUnit.Core.ClassMetadata __classMetadata = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests)), + Name = "GenericMethodNonTupleMethodDataSourceTests", + Namespace = "TUnit.TestProject.Bugs._7108", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }); + private static readonly global::System.Type __classType = typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests); + private static readonly global::TUnit.Core.MethodMetadata __mm_0 = global::TUnit.Core.MethodMetadataFactory.Create("Argument_Is_Wrapped_In_Nullable", __classType, typeof(global::System.Threading.Tasks.Task), __classMetadata, genericTypeCount: 1, parameters: global::TUnit.Core.ParameterMetadataFactory.ForGenericMethod(typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests), "Argument_Is_Wrapped_In_Nullable", false, 1, new global::TUnit.Core.ParameterMetadata[] +{ +global::TUnit.Core.ParameterMetadataFactory.Create(typeof(object), "value", new global::TUnit.Core.GenericParameter(0, true, "T"), false) +})); + private static global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests __CreateInstance_0(global::System.Type[] typeArgs, object?[] args) + { + return new global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests(); + } + private static global::System.Threading.Tasks.ValueTask __Invoke_0(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests instance, int methodIndex, object?[] args, global::System.Threading.CancellationToken cancellationToken) + { + try + { + return new global::System.Threading.Tasks.ValueTask(instance.Argument_Is_Wrapped_In_Nullable(global::TUnit.Core.Helpers.CastHelper.Cast(args[0]))); + } + catch (global::System.Exception ex) + { + return new global::System.Threading.Tasks.ValueTask(global::System.Threading.Tasks.Task.FromException(ex)); + } + } + private static global::System.Attribute[] __Attributes_0(int groupIndex) + { + return new global::System.Attribute[] + { + new global::TUnit.Core.TestAttribute(), + new global::TUnit.Core.MethodDataSourceAttribute("NullableRows") +{Arguments = new object[] { 17 },}, + new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass) + }; + } + public static readonly global::TUnit.Core.TestEntry[] Entries_0 = new global::TUnit.Core.TestEntry[] + { + global::TUnit.Core.TestEntryFactory.Create( + methodName: "Argument_Is_Wrapped_In_Nullable", + fullyQualifiedName: "TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests.Argument_Is_Wrapped_In_Nullable", + methodTypeArgumentsIdentity: "", + filePath: "", + lineNumber: 402, + hasDataSource: true, + testDataSources: new global::TUnit.Core.IDataSourceAttribute[] +{ + new global::TUnit.Core.MethodDataSourceAttribute("NullableRows") + { + Arguments = new object[] { 17 }, + Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromEnumerable(static () => + { + var arguments = new object[] { 17 }; + return global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests.NullableRows(((int?)(int)arguments[0])); + }), + }, +}, + methodMetadata: __mm_0, + createInstance: __CreateInstance_0, + invokeBody: __Invoke_0, + methodIndex: 0, + createAttributes: __Attributes_0, + attributeGroupIndex: 0), + }; +} +internal static partial class TUnit_TestRegistration +{ + static readonly int _r_TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Argument_Is_Wr_4F209AE1_TestSource_0 = global::TUnit.Core.SourceRegistrar.RegisterEntries(static () => TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Argument_Is_Wr_4F209AE1_TestSource.Entries_0); +} + + +// ===== FILE SEPARATOR ===== + +// +#pragma warning disable + +#nullable enable +namespace TUnit.Generated; +[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute] +[global::System.CodeDom.Compiler.GeneratedCode("TUnit", "VERSION_SCRUBBED")] +internal static class TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Field_Data_Source__T_TestSource +{ + private static readonly global::TUnit.Core.ClassMetadata __classMetadata = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests)), + Name = "GenericMethodNonTupleMethodDataSourceTests", + Namespace = "TUnit.TestProject.Bugs._7108", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }); + private static readonly global::System.Type __classType = typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests); + private static readonly global::TUnit.Core.MethodMetadata __mm_0 = global::TUnit.Core.MethodMetadataFactory.Create("Field_Data_Source", __classType, typeof(global::System.Threading.Tasks.Task), __classMetadata, genericTypeCount: 1, parameters: global::TUnit.Core.ParameterMetadataFactory.ForGenericMethod(typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests), "Field_Data_Source", false, 1, new global::TUnit.Core.ParameterMetadata[] +{ +global::TUnit.Core.ParameterMetadataFactory.Create(typeof(object), "value", new global::TUnit.Core.GenericParameter(0, true, "T"), false) +})); + private static global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests __CreateInstance_0(global::System.Type[] typeArgs, object?[] args) + { + return new global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests(); + } + private static global::System.Threading.Tasks.ValueTask __Invoke_0(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests instance, int methodIndex, object?[] args, global::System.Threading.CancellationToken cancellationToken) + { + try + { + return new global::System.Threading.Tasks.ValueTask(instance.Field_Data_Source(global::TUnit.Core.Helpers.CastHelper.Cast(args[0]))); + } + catch (global::System.Exception ex) + { + return new global::System.Threading.Tasks.ValueTask(global::System.Threading.Tasks.Task.FromException(ex)); + } + } + private static global::System.Attribute[] __Attributes_0(int groupIndex) + { + return new global::System.Attribute[] + { + new global::TUnit.Core.TestAttribute(), + new global::TUnit.Core.MethodDataSourceAttribute("FieldRows"), + new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass) + }; + } + public static readonly global::TUnit.Core.TestEntry[] Entries_0 = new global::TUnit.Core.TestEntry[] + { + global::TUnit.Core.TestEntryFactory.Create( + methodName: "Field_Data_Source", + fullyQualifiedName: "TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests.Field_Data_Source", + methodTypeArgumentsIdentity: "", + filePath: "", + lineNumber: 410, + hasDataSource: true, + testDataSources: new global::TUnit.Core.IDataSourceAttribute[] +{ + new global::TUnit.Core.MethodDataSourceAttribute("FieldRows") + { + Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromEnumerable(static () => global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests.FieldRows), + }, +}, + methodMetadata: __mm_0, + createInstance: __CreateInstance_0, + invokeBody: __Invoke_0, + methodIndex: 0, + createAttributes: __Attributes_0, + attributeGroupIndex: 0), + }; +} +internal static partial class TUnit_TestRegistration +{ + static readonly int _r_TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Field_Data_Source__T_TestSource_0 = global::TUnit.Core.SourceRegistrar.RegisterEntries(static () => TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Field_Data_Source__T_TestSource.Entries_0); +} + + +// ===== FILE SEPARATOR ===== + +// +#pragma warning disable + +#nullable enable +namespace TUnit.Generated; +[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute] +[global::System.CodeDom.Compiler.GeneratedCode("TUnit", "VERSION_SCRUBBED")] +internal static class TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Private_Field__8CC69FC4_TestSource +{ + private static readonly global::TUnit.Core.ClassMetadata __classMetadata = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests)), + Name = "GenericMethodNonTupleMethodDataSourceTests", + Namespace = "TUnit.TestProject.Bugs._7108", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }); + private static readonly global::System.Type __classType = typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests); + private static readonly global::TUnit.Core.MethodMetadata __mm_0 = global::TUnit.Core.MethodMetadataFactory.Create("Private_Field_Data_Source", __classType, typeof(global::System.Threading.Tasks.Task), __classMetadata, genericTypeCount: 1, parameters: global::TUnit.Core.ParameterMetadataFactory.ForGenericMethod(typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests), "Private_Field_Data_Source", false, 1, new global::TUnit.Core.ParameterMetadata[] +{ +global::TUnit.Core.ParameterMetadataFactory.Create(typeof(object), "value", new global::TUnit.Core.GenericParameter(0, true, "T"), false) +})); + private static global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests __CreateInstance_0(global::System.Type[] typeArgs, object?[] args) + { + return new global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests(); + } + private static global::System.Threading.Tasks.ValueTask __Invoke_0(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests instance, int methodIndex, object?[] args, global::System.Threading.CancellationToken cancellationToken) + { + try + { + return new global::System.Threading.Tasks.ValueTask(instance.Private_Field_Data_Source(global::TUnit.Core.Helpers.CastHelper.Cast(args[0]))); + } + catch (global::System.Exception ex) + { + return new global::System.Threading.Tasks.ValueTask(global::System.Threading.Tasks.Task.FromException(ex)); + } + } + private static global::System.Attribute[] __Attributes_0(int groupIndex) + { + return new global::System.Attribute[] + { + new global::TUnit.Core.TestAttribute(), + new global::TUnit.Core.MethodDataSourceAttribute("PrivateFieldRows"), + new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass) + }; + } + public static readonly global::TUnit.Core.TestEntry[] Entries_0 = new global::TUnit.Core.TestEntry[] + { + global::TUnit.Core.TestEntryFactory.Create( + methodName: "Private_Field_Data_Source", + fullyQualifiedName: "TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests.Private_Field_Data_Source", + methodTypeArgumentsIdentity: "", + filePath: "", + lineNumber: 418, + hasDataSource: true, + testDataSources: new global::TUnit.Core.IDataSourceAttribute[] +{ + new global::TUnit.Core.MethodDataSourceAttribute("PrivateFieldRows") + { + Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromEnumerable(static () => typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests).GetField("PrivateFieldRows", global::System.Reflection.BindingFlags.Static | global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.DeclaredOnly)!.GetValue(null)), + }, +}, + methodMetadata: __mm_0, + createInstance: __CreateInstance_0, + invokeBody: __Invoke_0, + methodIndex: 0, + createAttributes: __Attributes_0, + attributeGroupIndex: 0), + }; +} +internal static partial class TUnit_TestRegistration +{ + static readonly int _r_TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Private_Field__8CC69FC4_TestSource_0 = global::TUnit.Core.SourceRegistrar.RegisterEntries(static () => TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Private_Field__8CC69FC4_TestSource.Entries_0); +} + + +// ===== FILE SEPARATOR ===== + +// +#pragma warning disable + +#nullable enable +namespace TUnit.Generated; +[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute] +[global::System.CodeDom.Compiler.GeneratedCode("TUnit", "VERSION_SCRUBBED")] +internal static class TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Private_Proper_A37DEB11_TestSource +{ + private static readonly global::TUnit.Core.ClassMetadata __classMetadata = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests)), + Name = "GenericMethodNonTupleMethodDataSourceTests", + Namespace = "TUnit.TestProject.Bugs._7108", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }); + private static readonly global::System.Type __classType = typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests); + private static readonly global::TUnit.Core.MethodMetadata __mm_0 = global::TUnit.Core.MethodMetadataFactory.Create("Private_Property_Data_Source", __classType, typeof(global::System.Threading.Tasks.Task), __classMetadata, genericTypeCount: 1, parameters: global::TUnit.Core.ParameterMetadataFactory.ForGenericMethod(typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests), "Private_Property_Data_Source", false, 1, new global::TUnit.Core.ParameterMetadata[] +{ +global::TUnit.Core.ParameterMetadataFactory.Create(typeof(object), "value", new global::TUnit.Core.GenericParameter(0, true, "T"), false) +})); + private static global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests __CreateInstance_0(global::System.Type[] typeArgs, object?[] args) + { + return new global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests(); + } + private static global::System.Threading.Tasks.ValueTask __Invoke_0(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests instance, int methodIndex, object?[] args, global::System.Threading.CancellationToken cancellationToken) + { + try + { + return new global::System.Threading.Tasks.ValueTask(instance.Private_Property_Data_Source(global::TUnit.Core.Helpers.CastHelper.Cast(args[0]))); + } + catch (global::System.Exception ex) + { + return new global::System.Threading.Tasks.ValueTask(global::System.Threading.Tasks.Task.FromException(ex)); + } + } + private static global::System.Attribute[] __Attributes_0(int groupIndex) + { + return new global::System.Attribute[] + { + new global::TUnit.Core.TestAttribute(), + new global::TUnit.Core.MethodDataSourceAttribute("PrivatePropertyRows"), + new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass) + }; + } + public static readonly global::TUnit.Core.TestEntry[] Entries_0 = new global::TUnit.Core.TestEntry[] + { + global::TUnit.Core.TestEntryFactory.Create( + methodName: "Private_Property_Data_Source", + fullyQualifiedName: "TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests.Private_Property_Data_Source", + methodTypeArgumentsIdentity: "", + filePath: "", + lineNumber: 426, + hasDataSource: true, + testDataSources: new global::TUnit.Core.IDataSourceAttribute[] +{ + new global::TUnit.Core.MethodDataSourceAttribute("PrivatePropertyRows") + { + Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromEnumerable(static () => typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests).GetProperty("PrivatePropertyRows", global::System.Reflection.BindingFlags.Static | global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.DeclaredOnly)!.GetValue(null)), + }, +}, + methodMetadata: __mm_0, + createInstance: __CreateInstance_0, + invokeBody: __Invoke_0, + methodIndex: 0, + createAttributes: __Attributes_0, + attributeGroupIndex: 0), + }; +} +internal static partial class TUnit_TestRegistration +{ + static readonly int _r_TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Private_Proper_A37DEB11_TestSource_0 = global::TUnit.Core.SourceRegistrar.RegisterEntries(static () => TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Private_Proper_A37DEB11_TestSource.Entries_0); +} + + +// ===== FILE SEPARATOR ===== + +// +#pragma warning disable + +#nullable enable +namespace TUnit.Generated; +[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute] +[global::System.CodeDom.Compiler.GeneratedCode("TUnit", "VERSION_SCRUBBED")] +internal static class TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_More_Specific__D52ECD65_TestSource +{ + private static readonly global::TUnit.Core.ClassMetadata __classMetadata = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests)), + Name = "GenericMethodNonTupleMethodDataSourceTests", + Namespace = "TUnit.TestProject.Bugs._7108", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }); + private static readonly global::System.Type __classType = typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests); + private static readonly global::TUnit.Core.MethodMetadata __mm_0 = global::TUnit.Core.MethodMetadataFactory.Create("More_Specific_Overload_Wins_A_Tie", __classType, typeof(global::System.Threading.Tasks.Task), __classMetadata, genericTypeCount: 1, parameters: global::TUnit.Core.ParameterMetadataFactory.ForGenericMethod(typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests), "More_Specific_Overload_Wins_A_Tie", false, 1, new global::TUnit.Core.ParameterMetadata[] +{ +global::TUnit.Core.ParameterMetadataFactory.Create(typeof(object), "value", new global::TUnit.Core.GenericParameter(0, true, "T"), false) +})); + private static global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests __CreateInstance_0(global::System.Type[] typeArgs, object?[] args) + { + return new global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests(); + } + private static global::System.Threading.Tasks.ValueTask __Invoke_0(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests instance, int methodIndex, object?[] args, global::System.Threading.CancellationToken cancellationToken) + { + try + { + return new global::System.Threading.Tasks.ValueTask(instance.More_Specific_Overload_Wins_A_Tie(global::TUnit.Core.Helpers.CastHelper.Cast(args[0]))); + } + catch (global::System.Exception ex) + { + return new global::System.Threading.Tasks.ValueTask(global::System.Threading.Tasks.Task.FromException(ex)); + } + } + private static global::System.Attribute[] __Attributes_0(int groupIndex) + { + return new global::System.Attribute[] + { + new global::TUnit.Core.TestAttribute(), + new global::TUnit.Core.MethodDataSourceAttribute("NonNullTieRows") +{Arguments = new object[] { 23 },}, + new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass) + }; + } + public static readonly global::TUnit.Core.TestEntry[] Entries_0 = new global::TUnit.Core.TestEntry[] + { + global::TUnit.Core.TestEntryFactory.Create( + methodName: "More_Specific_Overload_Wins_A_Tie", + fullyQualifiedName: "TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests.More_Specific_Overload_Wins_A_Tie", + methodTypeArgumentsIdentity: "", + filePath: "", + lineNumber: 448, + hasDataSource: true, + testDataSources: new global::TUnit.Core.IDataSourceAttribute[] +{ + new global::TUnit.Core.MethodDataSourceAttribute("NonNullTieRows") + { + Arguments = new object[] { 23 }, + Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromEnumerable(static () => + { + var arguments = new object[] { 23 }; + return global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests.NonNullTieRows(((long)(int)arguments[0])); + }), + }, +}, + methodMetadata: __mm_0, + createInstance: __CreateInstance_0, + invokeBody: __Invoke_0, + methodIndex: 0, + createAttributes: __Attributes_0, + attributeGroupIndex: 0), + }; +} +internal static partial class TUnit_TestRegistration +{ + static readonly int _r_TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_More_Specific__D52ECD65_TestSource_0 = global::TUnit.Core.SourceRegistrar.RegisterEntries(static () => TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_More_Specific__D52ECD65_TestSource.Entries_0); +} + + +// ===== FILE SEPARATOR ===== + +// +#pragma warning disable + +#nullable enable +namespace TUnit.Generated; +[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute] +[global::System.CodeDom.Compiler.GeneratedCode("TUnit", "VERSION_SCRUBBED")] +internal static class TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Argument_Liter_F4C0257B_TestSource +{ + private static readonly global::TUnit.Core.ClassMetadata __classMetadata = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests)), + Name = "GenericMethodNonTupleMethodDataSourceTests", + Namespace = "TUnit.TestProject.Bugs._7108", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }); + private static readonly global::System.Type __classType = typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests); + private static readonly global::TUnit.Core.MethodMetadata __mm_0 = global::TUnit.Core.MethodMetadataFactory.Create("Argument_Literals_Keep_Their_Values", __classType, typeof(global::System.Threading.Tasks.Task), __classMetadata, genericTypeCount: 1, parameters: global::TUnit.Core.ParameterMetadataFactory.ForGenericMethod(typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests), "Argument_Literals_Keep_Their_Values", false, 1, new global::TUnit.Core.ParameterMetadata[] +{ +global::TUnit.Core.ParameterMetadataFactory.Create(typeof(object), "value", new global::TUnit.Core.GenericParameter(0, true, "T"), false) +})); + private static global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests __CreateInstance_0(global::System.Type[] typeArgs, object?[] args) + { + return new global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests(); + } + private static global::System.Threading.Tasks.ValueTask __Invoke_0(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests instance, int methodIndex, object?[] args, global::System.Threading.CancellationToken cancellationToken) + { + try + { + return new global::System.Threading.Tasks.ValueTask(instance.Argument_Literals_Keep_Their_Values(global::TUnit.Core.Helpers.CastHelper.Cast(args[0]))); + } + catch (global::System.Exception ex) + { + return new global::System.Threading.Tasks.ValueTask(global::System.Threading.Tasks.Task.FromException(ex)); + } + } + private static global::System.Attribute[] __Attributes_0(int groupIndex) + { + return new global::System.Attribute[] + { + new global::TUnit.Core.TestAttribute(), + new global::TUnit.Core.MethodDataSourceAttribute("LiteralRows") +{Arguments = new object[] { '\0', "a\u2028b\"\\", double.NaN, 1E+20, float.PositiveInfinity, global::System.DayOfWeek.Friday},}, + new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass) + }; + } + public static readonly global::TUnit.Core.TestEntry[] Entries_0 = new global::TUnit.Core.TestEntry[] + { + global::TUnit.Core.TestEntryFactory.Create( + methodName: "Argument_Literals_Keep_Their_Values", + fullyQualifiedName: "TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests.Argument_Literals_Keep_Their_Values", + methodTypeArgumentsIdentity: "", + filePath: "", + lineNumber: 456, + hasDataSource: true, + testDataSources: new global::TUnit.Core.IDataSourceAttribute[] +{ + new global::TUnit.Core.MethodDataSourceAttribute("LiteralRows") + { + Arguments = new object[] { '\0', "a\u2028b\"\\", double.NaN, 1E+20d, float.PositiveInfinity, global::System.DayOfWeek.Friday }, + Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromEnumerable(static () => + { + var arguments = new object[] { '\0', "a\u2028b\"\\", double.NaN, 1E+20d, float.PositiveInfinity, global::System.DayOfWeek.Friday }; + return global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests.LiteralRows(((char)arguments[0]), ((string)arguments[1]), ((double)arguments[2]), ((double)arguments[3]), ((float)arguments[4]), ((global::System.DayOfWeek)arguments[5])); + }), + }, +}, + methodMetadata: __mm_0, + createInstance: __CreateInstance_0, + invokeBody: __Invoke_0, + methodIndex: 0, + createAttributes: __Attributes_0, + attributeGroupIndex: 0), + }; +} +internal static partial class TUnit_TestRegistration +{ + static readonly int _r_TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Argument_Liter_F4C0257B_TestSource_0 = global::TUnit.Core.SourceRegistrar.RegisterEntries(static () => TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Argument_Liter_F4C0257B_TestSource.Entries_0); +} + + +// ===== FILE SEPARATOR ===== + +// +#pragma warning disable + +#nullable enable +namespace TUnit.Generated; +[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute] +[global::System.CodeDom.Compiler.GeneratedCode("TUnit", "VERSION_SCRUBBED")] +internal static class TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Single_Tuple_P_99CCAFB3_TestSource +{ + private static readonly global::TUnit.Core.ClassMetadata __classMetadata = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests)), + Name = "GenericMethodNonTupleMethodDataSourceTests", + Namespace = "TUnit.TestProject.Bugs._7108", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }); + private static readonly global::System.Type __classType = typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests); + private static readonly global::TUnit.Core.MethodMetadata __mm_0 = global::TUnit.Core.MethodMetadataFactory.Create("Single_Tuple_Parameter_Is_Not_Spread", __classType, typeof(global::System.Threading.Tasks.Task), __classMetadata, genericTypeCount: 1, parameters: global::TUnit.Core.ParameterMetadataFactory.ForGenericMethod(typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests), "Single_Tuple_Parameter_Is_Not_Spread", false, 1, new global::TUnit.Core.ParameterMetadata[] +{ +global::TUnit.Core.ParameterMetadataFactory.Create(typeof(object), "pair", new global::TUnit.Core.ConstructedGeneric(typeof(global::System.ValueTuple<,>), [new global::TUnit.Core.GenericParameter(0, true, "T"), new global::TUnit.Core.GenericParameter(0, true, "T")]), false) +})); + private static global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests __CreateInstance_0(global::System.Type[] typeArgs, object?[] args) + { + return new global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests(); + } + private static global::System.Threading.Tasks.ValueTask __Invoke_0(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests instance, int methodIndex, object?[] args, global::System.Threading.CancellationToken cancellationToken) + { + try + { + // Special handling for single tuple parameter + if (args.Length == 2) + { + // Arguments are unwrapped tuple elements, reconstruct the tuple + return new global::System.Threading.Tasks.ValueTask(instance.Single_Tuple_Parameter_Is_Not_Spread((global::TUnit.Core.Helpers.CastHelper.Cast(args[0]), global::TUnit.Core.Helpers.CastHelper.Cast(args[1])))); + } + else if (args.Length == 1 && global::TUnit.Core.Helpers.DataSourceHelpers.IsTuple(args[0])) + { + // Rare case: tuple is wrapped as a single argument + return new global::System.Threading.Tasks.ValueTask(instance.Single_Tuple_Parameter_Is_Not_Spread(global::TUnit.Core.Helpers.CastHelper.Cast>(args[0]))); + } + else + { + throw new global::System.ArgumentException($"Expected 2 unwrapped elements or 1 wrapped tuple, but got {args.Length} arguments"); + } + } + catch (global::System.Exception ex) + { + return new global::System.Threading.Tasks.ValueTask(global::System.Threading.Tasks.Task.FromException(ex)); + } + } + private static global::System.Attribute[] __Attributes_0(int groupIndex) + { + return new global::System.Attribute[] + { + new global::TUnit.Core.TestAttribute(), + new global::TUnit.Core.MethodDataSourceAttribute("TupleParameterRows"), + new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass) + }; + } + public static readonly global::TUnit.Core.TestEntry[] Entries_0 = new global::TUnit.Core.TestEntry[] + { + global::TUnit.Core.TestEntryFactory.Create( + methodName: "Single_Tuple_Parameter_Is_Not_Spread", + fullyQualifiedName: "TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests.Single_Tuple_Parameter_Is_Not_Spread", + methodTypeArgumentsIdentity: "", + filePath: "", + lineNumber: 464, + hasDataSource: true, + testDataSources: new global::TUnit.Core.IDataSourceAttribute[] +{ + new global::TUnit.Core.MethodDataSourceAttribute("TupleParameterRows") + { + Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromEnumerable(static () => global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests.TupleParameterRows()), + }, +}, + methodMetadata: __mm_0, + createInstance: __CreateInstance_0, + invokeBody: __Invoke_0, + methodIndex: 0, + createAttributes: __Attributes_0, + attributeGroupIndex: 0), + }; +} +internal static partial class TUnit_TestRegistration +{ + static readonly int _r_TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Single_Tuple_P_99CCAFB3_TestSource_0 = global::TUnit.Core.SourceRegistrar.RegisterEntries(static () => TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Single_Tuple_P_99CCAFB3_TestSource.Entries_0); +} + + +// ===== FILE SEPARATOR ===== + +// +#pragma warning disable + +#nullable enable +namespace TUnit.Generated; +[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute] +[global::System.CodeDom.Compiler.GeneratedCode("TUnit", "VERSION_SCRUBBED")] +internal static class TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Cancellation_T_5B4E91F6_TestSource +{ + private static readonly global::TUnit.Core.ClassMetadata __classMetadata = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests)), + Name = "GenericMethodNonTupleMethodDataSourceTests", + Namespace = "TUnit.TestProject.Bugs._7108", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }); + private static readonly global::System.Type __classType = typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests); + private static readonly global::TUnit.Core.MethodMetadata __mm_0 = global::TUnit.Core.MethodMetadataFactory.Create("Cancellation_Token_Is_Passed_Without_Arguments", __classType, typeof(global::System.Threading.Tasks.Task), __classMetadata, genericTypeCount: 1, parameters: global::TUnit.Core.ParameterMetadataFactory.ForGenericMethod(typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests), "Cancellation_Token_Is_Passed_Without_Arguments", false, 1, new global::TUnit.Core.ParameterMetadata[] +{ +global::TUnit.Core.ParameterMetadataFactory.Create(typeof(object), "value", new global::TUnit.Core.GenericParameter(0, true, "T"), false) +})); + private static global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests __CreateInstance_0(global::System.Type[] typeArgs, object?[] args) + { + return new global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests(); + } + private static global::System.Threading.Tasks.ValueTask __Invoke_0(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests instance, int methodIndex, object?[] args, global::System.Threading.CancellationToken cancellationToken) + { + try + { + return new global::System.Threading.Tasks.ValueTask(instance.Cancellation_Token_Is_Passed_Without_Arguments(global::TUnit.Core.Helpers.CastHelper.Cast(args[0]))); + } + catch (global::System.Exception ex) + { + return new global::System.Threading.Tasks.ValueTask(global::System.Threading.Tasks.Task.FromException(ex)); + } + } + private static global::System.Attribute[] __Attributes_0(int groupIndex) + { + return new global::System.Attribute[] + { + new global::TUnit.Core.TestAttribute(), + new global::TUnit.Core.MethodDataSourceAttribute("CancellationTokenOnlyRows"), + new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass) + }; + } + public static readonly global::TUnit.Core.TestEntry[] Entries_0 = new global::TUnit.Core.TestEntry[] + { + global::TUnit.Core.TestEntryFactory.Create( + methodName: "Cancellation_Token_Is_Passed_Without_Arguments", + fullyQualifiedName: "TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests.Cancellation_Token_Is_Passed_Without_Arguments", + methodTypeArgumentsIdentity: "", + filePath: "", + lineNumber: 480, + hasDataSource: true, + testDataSources: new global::TUnit.Core.IDataSourceAttribute[] +{ + new global::TUnit.Core.MethodDataSourceAttribute("CancellationTokenOnlyRows") + { + Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromEnumerable(static () => + { + var arguments = global::System.Array.Empty(); + return global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests.CancellationTokenOnlyRows(global::System.Threading.CancellationToken.None); + }), + }, +}, + methodMetadata: __mm_0, + createInstance: __CreateInstance_0, + invokeBody: __Invoke_0, + methodIndex: 0, + createAttributes: __Attributes_0, + attributeGroupIndex: 0), + }; +} +internal static partial class TUnit_TestRegistration +{ + static readonly int _r_TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Cancellation_T_5B4E91F6_TestSource_0 = global::TUnit.Core.SourceRegistrar.RegisterEntries(static () => TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Cancellation_T_5B4E91F6_TestSource.Entries_0); +} + + +// ===== FILE SEPARATOR ===== + +// +#pragma warning disable + +#nullable enable +namespace TUnit.Generated; +[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute] +[global::System.CodeDom.Compiler.GeneratedCode("TUnit", "VERSION_SCRUBBED")] +internal static class TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Exact_Argument_6EF759A6_TestSource +{ + private static readonly global::TUnit.Core.ClassMetadata __classMetadata = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests)), + Name = "GenericMethodNonTupleMethodDataSourceTests", + Namespace = "TUnit.TestProject.Bugs._7108", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }); + private static readonly global::System.Type __classType = typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests); + private static readonly global::TUnit.Core.MethodMetadata __mm_0 = global::TUnit.Core.MethodMetadataFactory.Create("Exact_Argument_Type_Beats_Conversion", __classType, typeof(global::System.Threading.Tasks.Task), __classMetadata, genericTypeCount: 1, parameters: global::TUnit.Core.ParameterMetadataFactory.ForGenericMethod(typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests), "Exact_Argument_Type_Beats_Conversion", false, 1, new global::TUnit.Core.ParameterMetadata[] +{ +global::TUnit.Core.ParameterMetadataFactory.Create(typeof(object), "value", new global::TUnit.Core.GenericParameter(0, true, "T"), false) +})); + private static global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests __CreateInstance_0(global::System.Type[] typeArgs, object?[] args) + { + return new global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests(); + } + private static global::System.Threading.Tasks.ValueTask __Invoke_0(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests instance, int methodIndex, object?[] args, global::System.Threading.CancellationToken cancellationToken) + { + try + { + return new global::System.Threading.Tasks.ValueTask(instance.Exact_Argument_Type_Beats_Conversion(global::TUnit.Core.Helpers.CastHelper.Cast(args[0]))); + } + catch (global::System.Exception ex) + { + return new global::System.Threading.Tasks.ValueTask(global::System.Threading.Tasks.Task.FromException(ex)); + } + } + private static global::System.Attribute[] __Attributes_0(int groupIndex) + { + return new global::System.Attribute[] + { + new global::TUnit.Core.TestAttribute(), + new global::TUnit.Core.MethodDataSourceAttribute("ExactTypeRows") +{Arguments = new object[] { 15 },}, + new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass) + }; + } + public static readonly global::TUnit.Core.TestEntry[] Entries_0 = new global::TUnit.Core.TestEntry[] + { + global::TUnit.Core.TestEntryFactory.Create( + methodName: "Exact_Argument_Type_Beats_Conversion", + fullyQualifiedName: "TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests.Exact_Argument_Type_Beats_Conversion", + methodTypeArgumentsIdentity: "", + filePath: "", + lineNumber: 488, + hasDataSource: true, + testDataSources: new global::TUnit.Core.IDataSourceAttribute[] +{ + new global::TUnit.Core.MethodDataSourceAttribute("ExactTypeRows") + { + Arguments = new object[] { 15 }, + Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromEnumerable(static () => + { + var arguments = new object[] { 15 }; + return global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests.ExactTypeRows(((int)arguments[0])); + }), + }, +}, + methodMetadata: __mm_0, + createInstance: __CreateInstance_0, + invokeBody: __Invoke_0, + methodIndex: 0, + createAttributes: __Attributes_0, + attributeGroupIndex: 0), + }; +} +internal static partial class TUnit_TestRegistration +{ + static readonly int _r_TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Exact_Argument_6EF759A6_TestSource_0 = global::TUnit.Core.SourceRegistrar.RegisterEntries(static () => TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Exact_Argument_6EF759A6_TestSource.Entries_0); +} + + +// ===== FILE SEPARATOR ===== + +// +#pragma warning disable + +#nullable enable +namespace TUnit.Generated; +[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute] +[global::System.CodeDom.Compiler.GeneratedCode("TUnit", "VERSION_SCRUBBED")] +internal static class TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Exact_Paramete_BE46D359_TestSource +{ + private static readonly global::TUnit.Core.ClassMetadata __classMetadata = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests)), + Name = "GenericMethodNonTupleMethodDataSourceTests", + Namespace = "TUnit.TestProject.Bugs._7108", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }); + private static readonly global::System.Type __classType = typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests); + private static readonly global::TUnit.Core.MethodMetadata __mm_0 = global::TUnit.Core.MethodMetadataFactory.Create("Exact_Parameter_Count_Overload_Wins", __classType, typeof(global::System.Threading.Tasks.Task), __classMetadata, genericTypeCount: 1, parameters: global::TUnit.Core.ParameterMetadataFactory.ForGenericMethod(typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests), "Exact_Parameter_Count_Overload_Wins", false, 1, new global::TUnit.Core.ParameterMetadata[] +{ +global::TUnit.Core.ParameterMetadataFactory.Create(typeof(object), "value", new global::TUnit.Core.GenericParameter(0, true, "T"), false) +})); + private static global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests __CreateInstance_0(global::System.Type[] typeArgs, object?[] args) + { + return new global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests(); + } + private static global::System.Threading.Tasks.ValueTask __Invoke_0(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests instance, int methodIndex, object?[] args, global::System.Threading.CancellationToken cancellationToken) + { + try + { + return new global::System.Threading.Tasks.ValueTask(instance.Exact_Parameter_Count_Overload_Wins(global::TUnit.Core.Helpers.CastHelper.Cast(args[0]))); + } + catch (global::System.Exception ex) + { + return new global::System.Threading.Tasks.ValueTask(global::System.Threading.Tasks.Task.FromException(ex)); + } + } + private static global::System.Attribute[] __Attributes_0(int groupIndex) + { + return new global::System.Attribute[] + { + new global::TUnit.Core.TestAttribute(), + new global::TUnit.Core.MethodDataSourceAttribute("OptionalOverloadRows") +{Arguments = new object[] { "a", "b" },}, + new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass) + }; + } + public static readonly global::TUnit.Core.TestEntry[] Entries_0 = new global::TUnit.Core.TestEntry[] + { + global::TUnit.Core.TestEntryFactory.Create( + methodName: "Exact_Parameter_Count_Overload_Wins", + fullyQualifiedName: "TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests.Exact_Parameter_Count_Overload_Wins", + methodTypeArgumentsIdentity: "", + filePath: "", + lineNumber: 496, + hasDataSource: true, + testDataSources: new global::TUnit.Core.IDataSourceAttribute[] +{ + new global::TUnit.Core.MethodDataSourceAttribute("OptionalOverloadRows") + { + Arguments = new object[] { "a", "b" }, + Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromEnumerable(static () => + { + var arguments = new object[] { "a", "b" }; + return global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests.OptionalOverloadRows(((object)arguments[0]), ((object)arguments[1])); + }), + }, +}, + methodMetadata: __mm_0, + createInstance: __CreateInstance_0, + invokeBody: __Invoke_0, + methodIndex: 0, + createAttributes: __Attributes_0, + attributeGroupIndex: 0), + }; +} +internal static partial class TUnit_TestRegistration +{ + static readonly int _r_TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Exact_Paramete_BE46D359_TestSource_0 = global::TUnit.Core.SourceRegistrar.RegisterEntries(static () => TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Exact_Paramete_BE46D359_TestSource.Entries_0); +} + + +// ===== FILE SEPARATOR ===== + +// +#pragma warning disable + +#nullable enable +namespace TUnit.Generated; +[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute] +[global::System.CodeDom.Compiler.GeneratedCode("TUnit", "VERSION_SCRUBBED")] +internal static class TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Missing_Option_D6FF54ED_TestSource +{ + private static readonly global::TUnit.Core.ClassMetadata __classMetadata = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests)), + Name = "GenericMethodNonTupleMethodDataSourceTests", + Namespace = "TUnit.TestProject.Bugs._7108", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }); + private static readonly global::System.Type __classType = typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests); + private static readonly global::TUnit.Core.MethodMetadata __mm_0 = global::TUnit.Core.MethodMetadataFactory.Create("Missing_Optional_Parameter_Uses_Default", __classType, typeof(global::System.Threading.Tasks.Task), __classMetadata, genericTypeCount: 1, parameters: global::TUnit.Core.ParameterMetadataFactory.ForGenericMethod(typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests), "Missing_Optional_Parameter_Uses_Default", false, 1, new global::TUnit.Core.ParameterMetadata[] +{ +global::TUnit.Core.ParameterMetadataFactory.Create(typeof(object), "value", new global::TUnit.Core.GenericParameter(0, true, "T"), false) +})); + private static global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests __CreateInstance_0(global::System.Type[] typeArgs, object?[] args) + { + return new global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests(); + } + private static global::System.Threading.Tasks.ValueTask __Invoke_0(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests instance, int methodIndex, object?[] args, global::System.Threading.CancellationToken cancellationToken) + { + try + { + return new global::System.Threading.Tasks.ValueTask(instance.Missing_Optional_Parameter_Uses_Default(global::TUnit.Core.Helpers.CastHelper.Cast(args[0]))); + } + catch (global::System.Exception ex) + { + return new global::System.Threading.Tasks.ValueTask(global::System.Threading.Tasks.Task.FromException(ex)); + } + } + private static global::System.Attribute[] __Attributes_0(int groupIndex) + { + return new global::System.Attribute[] + { + new global::TUnit.Core.TestAttribute(), + new global::TUnit.Core.MethodDataSourceAttribute("OptionalParameterRows") +{Arguments = new object[] { "abc" },}, + new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass) + }; + } + public static readonly global::TUnit.Core.TestEntry[] Entries_0 = new global::TUnit.Core.TestEntry[] + { + global::TUnit.Core.TestEntryFactory.Create( + methodName: "Missing_Optional_Parameter_Uses_Default", + fullyQualifiedName: "TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests.Missing_Optional_Parameter_Uses_Default", + methodTypeArgumentsIdentity: "", + filePath: "", + lineNumber: 507, + hasDataSource: true, + testDataSources: new global::TUnit.Core.IDataSourceAttribute[] +{ + new global::TUnit.Core.MethodDataSourceAttribute("OptionalParameterRows") + { + Arguments = new object[] { "abc" }, + Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromEnumerable(static () => + { + var arguments = new object[] { "abc" }; + return global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests.OptionalParameterRows(((string)arguments[0])); + }), + }, +}, + methodMetadata: __mm_0, + createInstance: __CreateInstance_0, + invokeBody: __Invoke_0, + methodIndex: 0, + createAttributes: __Attributes_0, + attributeGroupIndex: 0), + }; +} +internal static partial class TUnit_TestRegistration +{ + static readonly int _r_TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Missing_Option_D6FF54ED_TestSource_0 = global::TUnit.Core.SourceRegistrar.RegisterEntries(static () => TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Missing_Option_D6FF54ED_TestSource.Entries_0); +} + + +// ===== FILE SEPARATOR ===== + +// +#pragma warning disable + +#nullable enable +namespace TUnit.Generated; +[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute] +[global::System.CodeDom.Compiler.GeneratedCode("TUnit", "VERSION_SCRUBBED")] +internal static class TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Missing_Cancel_30298F23_TestSource +{ + private static readonly global::TUnit.Core.ClassMetadata __classMetadata = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests)), + Name = "GenericMethodNonTupleMethodDataSourceTests", + Namespace = "TUnit.TestProject.Bugs._7108", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }); + private static readonly global::System.Type __classType = typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests); + private static readonly global::TUnit.Core.MethodMetadata __mm_0 = global::TUnit.Core.MethodMetadataFactory.Create("Missing_Cancellation_Token_Is_None", __classType, typeof(global::System.Threading.Tasks.Task), __classMetadata, genericTypeCount: 1, parameters: global::TUnit.Core.ParameterMetadataFactory.ForGenericMethod(typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests), "Missing_Cancellation_Token_Is_None", false, 1, new global::TUnit.Core.ParameterMetadata[] +{ +global::TUnit.Core.ParameterMetadataFactory.Create(typeof(object), "value", new global::TUnit.Core.GenericParameter(0, true, "T"), false) +})); + private static global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests __CreateInstance_0(global::System.Type[] typeArgs, object?[] args) + { + return new global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests(); + } + private static global::System.Threading.Tasks.ValueTask __Invoke_0(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests instance, int methodIndex, object?[] args, global::System.Threading.CancellationToken cancellationToken) + { + try + { + return new global::System.Threading.Tasks.ValueTask(instance.Missing_Cancellation_Token_Is_None(global::TUnit.Core.Helpers.CastHelper.Cast(args[0]))); + } + catch (global::System.Exception ex) + { + return new global::System.Threading.Tasks.ValueTask(global::System.Threading.Tasks.Task.FromException(ex)); + } + } + private static global::System.Attribute[] __Attributes_0(int groupIndex) + { + return new global::System.Attribute[] + { + new global::TUnit.Core.TestAttribute(), + new global::TUnit.Core.MethodDataSourceAttribute("CancellationTokenRows") +{Arguments = new object[] { 14 },}, + new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass) + }; + } + public static readonly global::TUnit.Core.TestEntry[] Entries_0 = new global::TUnit.Core.TestEntry[] + { + global::TUnit.Core.TestEntryFactory.Create( + methodName: "Missing_Cancellation_Token_Is_None", + fullyQualifiedName: "TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests.Missing_Cancellation_Token_Is_None", + methodTypeArgumentsIdentity: "", + filePath: "", + lineNumber: 515, + hasDataSource: true, + testDataSources: new global::TUnit.Core.IDataSourceAttribute[] +{ + new global::TUnit.Core.MethodDataSourceAttribute("CancellationTokenRows") + { + Arguments = new object[] { 14 }, + Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromEnumerable(static () => + { + var arguments = new object[] { 14 }; + return global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests.CancellationTokenRows(((int)arguments[0]), global::System.Threading.CancellationToken.None); + }), + }, +}, + methodMetadata: __mm_0, + createInstance: __CreateInstance_0, + invokeBody: __Invoke_0, + methodIndex: 0, + createAttributes: __Attributes_0, + attributeGroupIndex: 0), + }; +} +internal static partial class TUnit_TestRegistration +{ + static readonly int _r_TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Missing_Cancel_30298F23_TestSource_0 = global::TUnit.Core.SourceRegistrar.RegisterEntries(static () => TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Missing_Cancel_30298F23_TestSource.Entries_0); +} + + +// ===== FILE SEPARATOR ===== + +// +#pragma warning disable + +#nullable enable +namespace TUnit.Generated; +[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute] +[global::System.CodeDom.Compiler.GeneratedCode("TUnit", "VERSION_SCRUBBED")] +internal static class TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Null_Argument__E935BA59_TestSource +{ + private static readonly global::TUnit.Core.ClassMetadata __classMetadata = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests)), + Name = "GenericMethodNonTupleMethodDataSourceTests", + Namespace = "TUnit.TestProject.Bugs._7108", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }); + private static readonly global::System.Type __classType = typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests); + private static readonly global::TUnit.Core.MethodMetadata __mm_0 = global::TUnit.Core.MethodMetadataFactory.Create("Null_Argument_Skips_Value_Type_Overload", __classType, typeof(global::System.Threading.Tasks.Task), __classMetadata, genericTypeCount: 1, parameters: global::TUnit.Core.ParameterMetadataFactory.ForGenericMethod(typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests), "Null_Argument_Skips_Value_Type_Overload", false, 1, new global::TUnit.Core.ParameterMetadata[] +{ +global::TUnit.Core.ParameterMetadataFactory.Create(typeof(object), "value", new global::TUnit.Core.GenericParameter(0, true, "T"), false) +})); + private static global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests __CreateInstance_0(global::System.Type[] typeArgs, object?[] args) + { + return new global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests(); + } + private static global::System.Threading.Tasks.ValueTask __Invoke_0(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests instance, int methodIndex, object?[] args, global::System.Threading.CancellationToken cancellationToken) + { + try + { + return new global::System.Threading.Tasks.ValueTask(instance.Null_Argument_Skips_Value_Type_Overload(global::TUnit.Core.Helpers.CastHelper.Cast(args[0]))); + } + catch (global::System.Exception ex) + { + return new global::System.Threading.Tasks.ValueTask(global::System.Threading.Tasks.Task.FromException(ex)); + } + } + private static global::System.Attribute[] __Attributes_0(int groupIndex) + { + return new global::System.Attribute[] + { + new global::TUnit.Core.TestAttribute(), + new global::TUnit.Core.MethodDataSourceAttribute("NullRows") +{Arguments = new object?[] { null },}, + new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass) + }; + } + public static readonly global::TUnit.Core.TestEntry[] Entries_0 = new global::TUnit.Core.TestEntry[] + { + global::TUnit.Core.TestEntryFactory.Create( + methodName: "Null_Argument_Skips_Value_Type_Overload", + fullyQualifiedName: "TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests.Null_Argument_Skips_Value_Type_Overload", + methodTypeArgumentsIdentity: "", + filePath: "", + lineNumber: 524, + hasDataSource: true, + testDataSources: new global::TUnit.Core.IDataSourceAttribute[] +{ + new global::TUnit.Core.MethodDataSourceAttribute("NullRows") + { + Arguments = new object[] { null }, + Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromEnumerable(static () => + { + var arguments = new object[] { null }; + return global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests.NullRows(((string)arguments[0])); + }), + }, +}, + methodMetadata: __mm_0, + createInstance: __CreateInstance_0, + invokeBody: __Invoke_0, + methodIndex: 0, + createAttributes: __Attributes_0, + attributeGroupIndex: 0), + }; +} +internal static partial class TUnit_TestRegistration +{ + static readonly int _r_TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Null_Argument__E935BA59_TestSource_0 = global::TUnit.Core.SourceRegistrar.RegisterEntries(static () => TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Null_Argument__E935BA59_TestSource.Entries_0); +} + + +// ===== FILE SEPARATOR ===== + +// +#pragma warning disable + +#nullable enable +namespace TUnit.Generated; +[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute] +[global::System.CodeDom.Compiler.GeneratedCode("TUnit", "VERSION_SCRUBBED")] +internal static class TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Null_Argument__6BADA763_TestSource +{ + private static readonly global::TUnit.Core.ClassMetadata __classMetadata = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests)), + Name = "GenericMethodNonTupleMethodDataSourceTests", + Namespace = "TUnit.TestProject.Bugs._7108", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }); + private static readonly global::System.Type __classType = typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests); + private static readonly global::TUnit.Core.MethodMetadata __mm_0 = global::TUnit.Core.MethodMetadataFactory.Create("Null_Argument_With_Missing_Optional_Parameter", __classType, typeof(global::System.Threading.Tasks.Task), __classMetadata, genericTypeCount: 1, parameters: global::TUnit.Core.ParameterMetadataFactory.ForGenericMethod(typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests), "Null_Argument_With_Missing_Optional_Parameter", false, 1, new global::TUnit.Core.ParameterMetadata[] +{ +global::TUnit.Core.ParameterMetadataFactory.Create(typeof(object), "value", new global::TUnit.Core.GenericParameter(0, true, "T"), false) +})); + private static global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests __CreateInstance_0(global::System.Type[] typeArgs, object?[] args) + { + return new global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests(); + } + private static global::System.Threading.Tasks.ValueTask __Invoke_0(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests instance, int methodIndex, object?[] args, global::System.Threading.CancellationToken cancellationToken) + { + try + { + return new global::System.Threading.Tasks.ValueTask(instance.Null_Argument_With_Missing_Optional_Parameter(global::TUnit.Core.Helpers.CastHelper.Cast(args[0]))); + } + catch (global::System.Exception ex) + { + return new global::System.Threading.Tasks.ValueTask(global::System.Threading.Tasks.Task.FromException(ex)); + } + } + private static global::System.Attribute[] __Attributes_0(int groupIndex) + { + return new global::System.Attribute[] + { + new global::TUnit.Core.TestAttribute(), + new global::TUnit.Core.MethodDataSourceAttribute("NullOptionalRows") +{Arguments = new object?[] { null },}, + new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass) + }; + } + public static readonly global::TUnit.Core.TestEntry[] Entries_0 = new global::TUnit.Core.TestEntry[] + { + global::TUnit.Core.TestEntryFactory.Create( + methodName: "Null_Argument_With_Missing_Optional_Parameter", + fullyQualifiedName: "TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests.Null_Argument_With_Missing_Optional_Parameter", + methodTypeArgumentsIdentity: "", + filePath: "", + lineNumber: 532, + hasDataSource: true, + testDataSources: new global::TUnit.Core.IDataSourceAttribute[] +{ + new global::TUnit.Core.MethodDataSourceAttribute("NullOptionalRows") + { + Arguments = new object[] { null }, + Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromEnumerable(static () => + { + var arguments = new object[] { null }; + return global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests.NullOptionalRows(((string)arguments[0])); + }), + }, +}, + methodMetadata: __mm_0, + createInstance: __CreateInstance_0, + invokeBody: __Invoke_0, + methodIndex: 0, + createAttributes: __Attributes_0, + attributeGroupIndex: 0), + }; +} +internal static partial class TUnit_TestRegistration +{ + static readonly int _r_TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Null_Argument__6BADA763_TestSource_0 = global::TUnit.Core.SourceRegistrar.RegisterEntries(static () => TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Null_Argument__6BADA763_TestSource.Entries_0); +} + + +// ===== FILE SEPARATOR ===== + +// +#pragma warning disable + +#nullable enable +namespace TUnit.Generated; +[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute] +[global::System.CodeDom.Compiler.GeneratedCode("TUnit", "VERSION_SCRUBBED")] +internal static class TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Null_Argument__46B61ED4_TestSource +{ + private static readonly global::TUnit.Core.ClassMetadata __classMetadata = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests)), + Name = "GenericMethodNonTupleMethodDataSourceTests", + Namespace = "TUnit.TestProject.Bugs._7108", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }); + private static readonly global::System.Type __classType = typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests); + private static readonly global::TUnit.Core.MethodMetadata __mm_0 = global::TUnit.Core.MethodMetadataFactory.Create("Null_Argument_With_Widened_Argument", __classType, typeof(global::System.Threading.Tasks.Task), __classMetadata, genericTypeCount: 1, parameters: global::TUnit.Core.ParameterMetadataFactory.ForGenericMethod(typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests), "Null_Argument_With_Widened_Argument", false, 1, new global::TUnit.Core.ParameterMetadata[] +{ +global::TUnit.Core.ParameterMetadataFactory.Create(typeof(object), "value", new global::TUnit.Core.GenericParameter(0, true, "T"), false) +})); + private static global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests __CreateInstance_0(global::System.Type[] typeArgs, object?[] args) + { + return new global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests(); + } + private static global::System.Threading.Tasks.ValueTask __Invoke_0(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests instance, int methodIndex, object?[] args, global::System.Threading.CancellationToken cancellationToken) + { + try + { + return new global::System.Threading.Tasks.ValueTask(instance.Null_Argument_With_Widened_Argument(global::TUnit.Core.Helpers.CastHelper.Cast(args[0]))); + } + catch (global::System.Exception ex) + { + return new global::System.Threading.Tasks.ValueTask(global::System.Threading.Tasks.Task.FromException(ex)); + } + } + private static global::System.Attribute[] __Attributes_0(int groupIndex) + { + return new global::System.Attribute[] + { + new global::TUnit.Core.TestAttribute(), + new global::TUnit.Core.MethodDataSourceAttribute("NullWideningRows") +{Arguments = new object?[] { null, 20 },}, + new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass) + }; + } + public static readonly global::TUnit.Core.TestEntry[] Entries_0 = new global::TUnit.Core.TestEntry[] + { + global::TUnit.Core.TestEntryFactory.Create( + methodName: "Null_Argument_With_Widened_Argument", + fullyQualifiedName: "TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests.Null_Argument_With_Widened_Argument", + methodTypeArgumentsIdentity: "", + filePath: "", + lineNumber: 540, + hasDataSource: true, + testDataSources: new global::TUnit.Core.IDataSourceAttribute[] +{ + new global::TUnit.Core.MethodDataSourceAttribute("NullWideningRows") + { + Arguments = new object[] { null, 20 }, + Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromEnumerable(static () => + { + var arguments = new object[] { null, 20 }; + return global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests.NullWideningRows(((string)arguments[0]), ((long)(int)arguments[1])); + }), + }, +}, + methodMetadata: __mm_0, + createInstance: __CreateInstance_0, + invokeBody: __Invoke_0, + methodIndex: 0, + createAttributes: __Attributes_0, + attributeGroupIndex: 0), + }; +} +internal static partial class TUnit_TestRegistration +{ + static readonly int _r_TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Null_Argument__46B61ED4_TestSource_0 = global::TUnit.Core.SourceRegistrar.RegisterEntries(static () => TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Null_Argument__46B61ED4_TestSource.Entries_0); +} + + +// ===== FILE SEPARATOR ===== + +// +#pragma warning disable + +#nullable enable +namespace TUnit.Generated; +[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute] +[global::System.CodeDom.Compiler.GeneratedCode("TUnit", "VERSION_SCRUBBED")] +internal static class TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Null_Argument__2B35A4AF_TestSource +{ + private static readonly global::TUnit.Core.ClassMetadata __classMetadata = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests)), + Name = "GenericMethodNonTupleMethodDataSourceTests", + Namespace = "TUnit.TestProject.Bugs._7108", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }); + private static readonly global::System.Type __classType = typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests); + private static readonly global::TUnit.Core.MethodMetadata __mm_0 = global::TUnit.Core.MethodMetadataFactory.Create("Null_Argument_More_Specific_Overload_Wins_A_Tie", __classType, typeof(global::System.Threading.Tasks.Task), __classMetadata, genericTypeCount: 1, parameters: global::TUnit.Core.ParameterMetadataFactory.ForGenericMethod(typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests), "Null_Argument_More_Specific_Overload_Wins_A_Tie", false, 1, new global::TUnit.Core.ParameterMetadata[] +{ +global::TUnit.Core.ParameterMetadataFactory.Create(typeof(object), "value", new global::TUnit.Core.GenericParameter(0, true, "T"), false) +})); + private static global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests __CreateInstance_0(global::System.Type[] typeArgs, object?[] args) + { + return new global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests(); + } + private static global::System.Threading.Tasks.ValueTask __Invoke_0(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests instance, int methodIndex, object?[] args, global::System.Threading.CancellationToken cancellationToken) + { + try + { + return new global::System.Threading.Tasks.ValueTask(instance.Null_Argument_More_Specific_Overload_Wins_A_Tie(global::TUnit.Core.Helpers.CastHelper.Cast(args[0]))); + } + catch (global::System.Exception ex) + { + return new global::System.Threading.Tasks.ValueTask(global::System.Threading.Tasks.Task.FromException(ex)); + } + } + private static global::System.Attribute[] __Attributes_0(int groupIndex) + { + return new global::System.Attribute[] + { + new global::TUnit.Core.TestAttribute(), + new global::TUnit.Core.MethodDataSourceAttribute("TieRows") +{Arguments = new object?[] { null, 22 },}, + new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass) + }; + } + public static readonly global::TUnit.Core.TestEntry[] Entries_0 = new global::TUnit.Core.TestEntry[] + { + global::TUnit.Core.TestEntryFactory.Create( + methodName: "Null_Argument_More_Specific_Overload_Wins_A_Tie", + fullyQualifiedName: "TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests.Null_Argument_More_Specific_Overload_Wins_A_Tie", + methodTypeArgumentsIdentity: "", + filePath: "", + lineNumber: 548, + hasDataSource: true, + testDataSources: new global::TUnit.Core.IDataSourceAttribute[] +{ + new global::TUnit.Core.MethodDataSourceAttribute("TieRows") + { + Arguments = new object[] { null, 22 }, + Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromEnumerable(static () => + { + var arguments = new object[] { null, 22 }; + return global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests.TieRows(((string)arguments[0]), ((long)(int)arguments[1])); + }), + }, +}, + methodMetadata: __mm_0, + createInstance: __CreateInstance_0, + invokeBody: __Invoke_0, + methodIndex: 0, + createAttributes: __Attributes_0, + attributeGroupIndex: 0), + }; +} +internal static partial class TUnit_TestRegistration +{ + static readonly int _r_TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Null_Argument__2B35A4AF_TestSource_0 = global::TUnit.Core.SourceRegistrar.RegisterEntries(static () => TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Null_Argument__2B35A4AF_TestSource.Entries_0); +} + + +// ===== FILE SEPARATOR ===== + +// +#pragma warning disable + +#nullable enable +namespace TUnit.Generated; +[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute] +[global::System.CodeDom.Compiler.GeneratedCode("TUnit", "VERSION_SCRUBBED")] +internal static class TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Task_Of_Async__37D00835_TestSource +{ + private static readonly global::TUnit.Core.ClassMetadata __classMetadata = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests)), + Name = "GenericMethodNonTupleMethodDataSourceTests", + Namespace = "TUnit.TestProject.Bugs._7108", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }); + private static readonly global::System.Type __classType = typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests); + private static readonly global::TUnit.Core.MethodMetadata __mm_0 = global::TUnit.Core.MethodMetadataFactory.Create("Task_Of_Async_Enumerable_Is_One_Row", __classType, typeof(global::System.Threading.Tasks.Task), __classMetadata, genericTypeCount: 1, parameters: global::TUnit.Core.ParameterMetadataFactory.ForGenericMethod(typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests), "Task_Of_Async_Enumerable_Is_One_Row", false, 1, new global::TUnit.Core.ParameterMetadata[] +{ +global::TUnit.Core.ParameterMetadataFactory.Create(typeof(object), "value", new global::TUnit.Core.GenericParameter(0, true, "T"), false) +})); + private static global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests __CreateInstance_0(global::System.Type[] typeArgs, object?[] args) + { + return new global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests(); + } + private static global::System.Threading.Tasks.ValueTask __Invoke_0(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests instance, int methodIndex, object?[] args, global::System.Threading.CancellationToken cancellationToken) + { + try + { + return new global::System.Threading.Tasks.ValueTask(instance.Task_Of_Async_Enumerable_Is_One_Row>(global::TUnit.Core.Helpers.CastHelper.Cast>(args[0]))); + } + catch (global::System.Exception ex) + { + return new global::System.Threading.Tasks.ValueTask(global::System.Threading.Tasks.Task.FromException(ex)); + } + } + private static global::System.Attribute[] __Attributes_0(int groupIndex) + { + return new global::System.Attribute[] + { + new global::TUnit.Core.TestAttribute(), + new global::TUnit.Core.MethodDataSourceAttribute("TaskOfAsyncRows"), + new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass) + }; + } + public static readonly global::TUnit.Core.TestEntry[] Entries_0 = new global::TUnit.Core.TestEntry[] + { + global::TUnit.Core.TestEntryFactory.Create( + methodName: "Task_Of_Async_Enumerable_Is_One_Row>", + fullyQualifiedName: "TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests.Task_Of_Async_Enumerable_Is_One_Row>", + methodTypeArgumentsIdentity: ">", + filePath: "", + lineNumber: 557, + hasDataSource: true, + testDataSources: new global::TUnit.Core.IDataSourceAttribute[] +{ + new global::TUnit.Core.MethodDataSourceAttribute("TaskOfAsyncRows") + { + Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromTask(static () => global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests.TaskOfAsyncRows()), + }, +}, + methodMetadata: __mm_0, + createInstance: __CreateInstance_0, + invokeBody: __Invoke_0, + methodIndex: 0, + createAttributes: __Attributes_0, + attributeGroupIndex: 0), + }; +} +internal static partial class TUnit_TestRegistration +{ + static readonly int _r_TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Task_Of_Async__37D00835_TestSource_0 = global::TUnit.Core.SourceRegistrar.RegisterEntries(static () => TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests_Task_Of_Async__37D00835_TestSource.Entries_0); +} + + +// ===== FILE SEPARATOR ===== + +// +#pragma warning disable + +#nullable enable +namespace TUnit.Generated; +[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute] +[global::System.CodeDom.Compiler.GeneratedCode("TUnit", "VERSION_SCRUBBED")] +internal static class TUnit_TestProject_Bugs__7108_GenericSingleTupleWithCancellationTokenTests_Trailing_Tok_C7BE9774_TestSource +{ + private static readonly global::TUnit.Core.ClassMetadata __classMetadata = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.Bugs._7108.GenericSingleTupleWithCancellationTokenTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.Bugs._7108.GenericSingleTupleWithCancellationTokenTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.Bugs._7108.GenericSingleTupleWithCancellationTokenTests)), + Name = "GenericSingleTupleWithCancellationTokenTests", + Namespace = "TUnit.TestProject.Bugs._7108", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }); + private static readonly global::System.Type __classType = typeof(global::TUnit.TestProject.Bugs._7108.GenericSingleTupleWithCancellationTokenTests); + private static readonly global::TUnit.Core.MethodMetadata __mm_0 = global::TUnit.Core.MethodMetadataFactory.Create("Trailing_Token", __classType, typeof(global::System.Threading.Tasks.Task), __classMetadata, genericTypeCount: 1, parameters: global::TUnit.Core.ParameterMetadataFactory.ForGenericMethod(typeof(global::TUnit.TestProject.Bugs._7108.GenericSingleTupleWithCancellationTokenTests), "Trailing_Token", false, 1, new global::TUnit.Core.ParameterMetadata[] +{ +global::TUnit.Core.ParameterMetadataFactory.Create(typeof(object), "pair", new global::TUnit.Core.ConstructedGeneric(typeof(global::System.ValueTuple<,>), [new global::TUnit.Core.GenericParameter(0, true, "T"), new global::TUnit.Core.GenericParameter(0, true, "T")]), false), +global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::System.Threading.CancellationToken), "token", new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.CancellationToken)), false) +})); + private static global::TUnit.TestProject.Bugs._7108.GenericSingleTupleWithCancellationTokenTests __CreateInstance_0(global::System.Type[] typeArgs, object?[] args) + { + return new global::TUnit.TestProject.Bugs._7108.GenericSingleTupleWithCancellationTokenTests(); + } + private static global::System.Threading.Tasks.ValueTask __Invoke_0(global::TUnit.TestProject.Bugs._7108.GenericSingleTupleWithCancellationTokenTests instance, int methodIndex, object?[] args, global::System.Threading.CancellationToken cancellationToken) + { + try + { + var context = global::TUnit.Core.TestContext.Current; + // Special handling for single tuple parameter + if (args.Length == 2) + { + // Arguments are unwrapped tuple elements, reconstruct the tuple + return new global::System.Threading.Tasks.ValueTask(instance.Trailing_Token((global::TUnit.Core.Helpers.CastHelper.Cast(args[0]), global::TUnit.Core.Helpers.CastHelper.Cast(args[1])), cancellationToken)); + } + else if (args.Length == 1 && global::TUnit.Core.Helpers.DataSourceHelpers.IsTuple(args[0])) + { + // Rare case: tuple is wrapped as a single argument + return new global::System.Threading.Tasks.ValueTask(instance.Trailing_Token(global::TUnit.Core.Helpers.CastHelper.Cast>(args[0]), cancellationToken)); + } + else + { + throw new global::System.ArgumentException($"Expected 2 unwrapped elements or 1 wrapped tuple, but got {args.Length} arguments"); + } + } + catch (global::System.Exception ex) + { + return new global::System.Threading.Tasks.ValueTask(global::System.Threading.Tasks.Task.FromException(ex)); + } + } + private static global::System.Attribute[] __Attributes_0(int groupIndex) + { + return new global::System.Attribute[] + { + new global::TUnit.Core.TestAttribute(), + new global::TUnit.Core.MethodDataSourceAttribute("TupleParameterRows") + }; + } + public static readonly global::TUnit.Core.TestEntry[] Entries_0 = new global::TUnit.Core.TestEntry[] + { + global::TUnit.Core.TestEntryFactory.Create( + methodName: "Trailing_Token", + fullyQualifiedName: "TUnit.TestProject.Bugs._7108.GenericSingleTupleWithCancellationTokenTests.Trailing_Token", + methodTypeArgumentsIdentity: "", + filePath: "", + lineNumber: 578, + hasDataSource: true, + testDataSources: new global::TUnit.Core.IDataSourceAttribute[] +{ + new global::TUnit.Core.MethodDataSourceAttribute("TupleParameterRows") + { + Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromEnumerable(static () => global::TUnit.TestProject.Bugs._7108.GenericSingleTupleWithCancellationTokenTests.TupleParameterRows()), + }, +}, + methodMetadata: __mm_0, + createInstance: __CreateInstance_0, + invokeBody: __Invoke_0, + methodIndex: 0, + createAttributes: __Attributes_0, + attributeGroupIndex: 0), + }; +} +internal static partial class TUnit_TestRegistration +{ + static readonly int _r_TUnit_TestProject_Bugs__7108_GenericSingleTupleWithCancellationTokenTests_Trailing_Tok_C7BE9774_TestSource_0 = global::TUnit.Core.SourceRegistrar.RegisterEntries(static () => TUnit_TestProject_Bugs__7108_GenericSingleTupleWithCancellationTokenTests_Trailing_Tok_C7BE9774_TestSource.Entries_0); +} + + +// ===== FILE SEPARATOR ===== + +// +#pragma warning disable + +#nullable enable +namespace TUnit.Generated; +[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute] +[global::System.CodeDom.Compiler.GeneratedCode("TUnit", "VERSION_SCRUBBED")] +internal static class TUnit_TestProject_Bugs__7108_GenericSingleTupleWithCancellationTokenTests_Leading_Toke_BB064BDA_TestSource +{ + private static readonly global::TUnit.Core.ClassMetadata __classMetadata = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.Bugs._7108.GenericSingleTupleWithCancellationTokenTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.Bugs._7108.GenericSingleTupleWithCancellationTokenTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.Bugs._7108.GenericSingleTupleWithCancellationTokenTests)), + Name = "GenericSingleTupleWithCancellationTokenTests", + Namespace = "TUnit.TestProject.Bugs._7108", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }); + private static readonly global::System.Type __classType = typeof(global::TUnit.TestProject.Bugs._7108.GenericSingleTupleWithCancellationTokenTests); + private static readonly global::TUnit.Core.MethodMetadata __mm_0 = global::TUnit.Core.MethodMetadataFactory.Create("Leading_Token", __classType, typeof(global::System.Threading.Tasks.Task), __classMetadata, genericTypeCount: 1, parameters: global::TUnit.Core.ParameterMetadataFactory.ForGenericMethod(typeof(global::TUnit.TestProject.Bugs._7108.GenericSingleTupleWithCancellationTokenTests), "Leading_Token", false, 1, new global::TUnit.Core.ParameterMetadata[] +{ +global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::System.Threading.CancellationToken), "token", new global::TUnit.Core.ConcreteType(typeof(global::System.Threading.CancellationToken)), false), +global::TUnit.Core.ParameterMetadataFactory.Create(typeof(object), "pair", new global::TUnit.Core.ConstructedGeneric(typeof(global::System.ValueTuple<,>), [new global::TUnit.Core.GenericParameter(0, true, "T"), new global::TUnit.Core.GenericParameter(0, true, "T")]), false) +})); + private static global::TUnit.TestProject.Bugs._7108.GenericSingleTupleWithCancellationTokenTests __CreateInstance_0(global::System.Type[] typeArgs, object?[] args) + { + return new global::TUnit.TestProject.Bugs._7108.GenericSingleTupleWithCancellationTokenTests(); + } + private static global::System.Threading.Tasks.ValueTask __Invoke_0(global::TUnit.TestProject.Bugs._7108.GenericSingleTupleWithCancellationTokenTests instance, int methodIndex, object?[] args, global::System.Threading.CancellationToken cancellationToken) + { + try + { + var context = global::TUnit.Core.TestContext.Current; + // Special handling for single tuple parameter + if (args.Length == 2) + { + // Arguments are unwrapped tuple elements, reconstruct the tuple + return new global::System.Threading.Tasks.ValueTask(instance.Leading_Token(cancellationToken, (global::TUnit.Core.Helpers.CastHelper.Cast(args[0]), global::TUnit.Core.Helpers.CastHelper.Cast(args[1])))); + } + else if (args.Length == 1 && global::TUnit.Core.Helpers.DataSourceHelpers.IsTuple(args[0])) + { + // Rare case: tuple is wrapped as a single argument + return new global::System.Threading.Tasks.ValueTask(instance.Leading_Token(cancellationToken, global::TUnit.Core.Helpers.CastHelper.Cast>(args[0]))); + } + else + { + throw new global::System.ArgumentException($"Expected 2 unwrapped elements or 1 wrapped tuple, but got {args.Length} arguments"); + } + } + catch (global::System.Exception ex) + { + return new global::System.Threading.Tasks.ValueTask(global::System.Threading.Tasks.Task.FromException(ex)); + } + } + private static global::System.Attribute[] __Attributes_0(int groupIndex) + { + return new global::System.Attribute[] + { + new global::TUnit.Core.TestAttribute(), + new global::TUnit.Core.MethodDataSourceAttribute("TupleParameterRows") + }; + } + public static readonly global::TUnit.Core.TestEntry[] Entries_0 = new global::TUnit.Core.TestEntry[] + { + global::TUnit.Core.TestEntryFactory.Create( + methodName: "Leading_Token", + fullyQualifiedName: "TUnit.TestProject.Bugs._7108.GenericSingleTupleWithCancellationTokenTests.Leading_Token", + methodTypeArgumentsIdentity: "", + filePath: "", + lineNumber: 591, + hasDataSource: true, + testDataSources: new global::TUnit.Core.IDataSourceAttribute[] +{ + new global::TUnit.Core.MethodDataSourceAttribute("TupleParameterRows") + { + Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromEnumerable(static () => global::TUnit.TestProject.Bugs._7108.GenericSingleTupleWithCancellationTokenTests.TupleParameterRows()), + }, +}, + methodMetadata: __mm_0, + createInstance: __CreateInstance_0, + invokeBody: __Invoke_0, + methodIndex: 0, + createAttributes: __Attributes_0, + attributeGroupIndex: 0), + }; +} +internal static partial class TUnit_TestRegistration +{ + static readonly int _r_TUnit_TestProject_Bugs__7108_GenericSingleTupleWithCancellationTokenTests_Leading_Toke_BB064BDA_TestSource_0 = global::TUnit.Core.SourceRegistrar.RegisterEntries(static () => TUnit_TestProject_Bugs__7108_GenericSingleTupleWithCancellationTokenTests_Leading_Toke_BB064BDA_TestSource.Entries_0); +} + + +// ===== FILE SEPARATOR ===== + +// +#pragma warning disable + +#nullable enable +namespace TUnit.Generated; +[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute] +[global::System.CodeDom.Compiler.GeneratedCode("TUnit", "VERSION_SCRUBBED")] +internal static class TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests__TestSource +{ + private static readonly global::TUnit.Core.ClassMetadata __classMetadata = global::TUnit.Core.ClassMetadata.GetOrAdd("TestsBase`1:global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests", new global::TUnit.Core.ClassMetadata + { + Type = typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests), + TypeInfo = new global::TUnit.Core.ConcreteType(typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests)), + Name = "GenericMethodNonTupleMethodDataSourceTests", + Namespace = "TUnit.TestProject.Bugs._7108", + Assembly = global::TUnit.Core.AssemblyMetadata.GetOrAdd("TestsBase`1", "TestsBase`1"), + Parameters = global::System.Array.Empty(), + Properties = global::System.Array.Empty(), + Parent = null + }); + private static readonly global::System.Type __classType = typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests); + private static global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests __CreateInstance(global::System.Type[] typeArgs, object?[] args) + { + return new global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests(); + } + private static global::System.Threading.Tasks.ValueTask __Invoke(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests instance, int methodIndex, object?[] args, global::System.Threading.CancellationToken cancellationToken) + { + try + { + switch (methodIndex) + { + case 0: + { + switch (args.Length) + { + case 1: + { + return new global::System.Threading.Tasks.ValueTask(instance.Private_Object_Field_Holding_An_Array_Yields_A_Row_Per_Element(global::TUnit.Core.Helpers.CastHelper.Cast(args[0]))); + } + default: + throw new global::System.ArgumentException($"Expected exactly 1 argument, but got {args.Length}"); + } + } + case 1: + { + switch (args.Length) + { + case 1: + { + return new global::System.Threading.Tasks.ValueTask(instance.Private_Object_Property_Holding_An_Array_Yields_A_Row_Per_Element(global::TUnit.Core.Helpers.CastHelper.Cast(args[0]))); + } + default: + throw new global::System.ArgumentException($"Expected exactly 1 argument, but got {args.Length}"); + } + } + case 2: + { + // Special handling for single tuple parameter + if (args.Length == 2) + { + // Arguments are unwrapped tuple elements, reconstruct the tuple + return new global::System.Threading.Tasks.ValueTask(instance.NonGeneric_Single_Tuple_Parameter_Is_Not_Spread((global::TUnit.Core.Helpers.CastHelper.Cast(args[0]), global::TUnit.Core.Helpers.CastHelper.Cast(args[1])))); + } + else if (args.Length == 1 && global::TUnit.Core.Helpers.DataSourceHelpers.IsTuple(args[0])) + { + // Rare case: tuple is wrapped as a single argument + return new global::System.Threading.Tasks.ValueTask(instance.NonGeneric_Single_Tuple_Parameter_Is_Not_Spread(global::TUnit.Core.Helpers.CastHelper.Cast>(args[0]))); + } + else + { + throw new global::System.ArgumentException($"Expected 2 unwrapped elements or 1 wrapped tuple, but got {args.Length} arguments"); + } + } + default: + throw new global::System.ArgumentOutOfRangeException(nameof(methodIndex)); + } + } + catch (global::System.Exception ex) + { + return new global::System.Threading.Tasks.ValueTask(global::System.Threading.Tasks.Task.FromException(ex)); + } + } + private static global::System.Attribute[] __Attributes(int groupIndex) + { + switch (groupIndex) + { + case 0: + { + return + [ + new global::TUnit.Core.TestAttribute(), + new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass) + ]; + } + default: + throw new global::System.ArgumentOutOfRangeException(nameof(groupIndex)); + } + } + private static readonly global::System.Func __createInstance = __CreateInstance; + private static readonly global::System.Func __invoke = __Invoke; + private static readonly global::System.Func __attributes = __Attributes; + public static readonly global::TUnit.Core.TestEntry[] Entries = new global::TUnit.Core.TestEntry[] + { + global::TUnit.Core.TestEntryFactory.CreateWithClassMetadata( + methodName: "Private_Object_Field_Holding_An_Array_Yields_A_Row_Per_Element", + fullyQualifiedName: "TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests.Private_Object_Field_Holding_An_Array_Yields_A_Row_Per_Element", + filePath: "", + lineNumber: 434, + hasDataSource: true, + testDataSources: new global::TUnit.Core.IDataSourceAttribute[] +{ + new global::TUnit.Core.MethodDataSourceAttribute("PrivateObjectFieldRows") + { + Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromRuntimeValue(dataGeneratorMetadata, static () => typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests).GetField("PrivateObjectFieldRows", global::System.Reflection.BindingFlags.Static | global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.DeclaredOnly)!.GetValue(null)), + }, +}, + returnType: typeof(global::System.Threading.Tasks.Task), + parameters: global::TUnit.Core.ParameterMetadataFactory.ForMethod(typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests), "Private_Object_Field_Holding_An_Array_Yields_A_Row_Per_Element", false, new global::TUnit.Core.ParameterMetadata[] + { + global::TUnit.Core.ParameterMetadataFactory.Create(typeof(int), "value", new global::TUnit.Core.ConcreteType(typeof(int)), false) + }), + classMetadata: __classMetadata, + createInstance: __createInstance, + invokeBody: __invoke, + methodIndex: 0, + createAttributes: __attributes, + attributeGroupIndex: 0), + global::TUnit.Core.TestEntryFactory.CreateWithClassMetadata( + methodName: "Private_Object_Property_Holding_An_Array_Yields_A_Row_Per_Element", + fullyQualifiedName: "TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests.Private_Object_Property_Holding_An_Array_Yields_A_Row_Per_Element", + filePath: "", + lineNumber: 441, + hasDataSource: true, + testDataSources: new global::TUnit.Core.IDataSourceAttribute[] +{ + new global::TUnit.Core.MethodDataSourceAttribute("PrivateObjectPropertyRows") + { + Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromRuntimeValue(dataGeneratorMetadata, static () => typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests).GetProperty("PrivateObjectPropertyRows", global::System.Reflection.BindingFlags.Static | global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.DeclaredOnly)!.GetValue(null)), + }, +}, + returnType: typeof(global::System.Threading.Tasks.Task), + parameters: global::TUnit.Core.ParameterMetadataFactory.ForMethod(typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests), "Private_Object_Property_Holding_An_Array_Yields_A_Row_Per_Element", false, new global::TUnit.Core.ParameterMetadata[] + { + global::TUnit.Core.ParameterMetadataFactory.Create(typeof(int), "value", new global::TUnit.Core.ConcreteType(typeof(int)), false) + }), + classMetadata: __classMetadata, + createInstance: __createInstance, + invokeBody: __invoke, + methodIndex: 1, + createAttributes: __attributes, + attributeGroupIndex: 0), + global::TUnit.Core.TestEntryFactory.CreateWithClassMetadata( + methodName: "NonGeneric_Single_Tuple_Parameter_Is_Not_Spread", + fullyQualifiedName: "TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests.NonGeneric_Single_Tuple_Parameter_Is_Not_Spread", + filePath: "", + lineNumber: 473, + hasDataSource: true, + testDataSources: new global::TUnit.Core.IDataSourceAttribute[] +{ + new global::TUnit.Core.MethodDataSourceAttribute("TupleParameterRows") + { + Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromEnumerable(static () => global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests.TupleParameterRows()), + }, +}, + returnType: typeof(global::System.Threading.Tasks.Task), + parameters: global::TUnit.Core.ParameterMetadataFactory.ForMethod(typeof(global::TUnit.TestProject.Bugs._7108.GenericMethodNonTupleMethodDataSourceTests), "NonGeneric_Single_Tuple_Parameter_Is_Not_Spread", false, new global::TUnit.Core.ParameterMetadata[] + { + global::TUnit.Core.ParameterMetadataFactory.Create(typeof(global::System.ValueTuple), "pair", new global::TUnit.Core.ConcreteType(typeof(global::System.ValueTuple)), false) + }), + classMetadata: __classMetadata, + createInstance: __createInstance, + invokeBody: __invoke, + methodIndex: 2, + createAttributes: __attributes, + attributeGroupIndex: 0), + }; +} +internal static partial class TUnit_TestRegistration +{ + static readonly int _r_TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests__TestSource = global::TUnit.Core.SourceRegistrar.RegisterEntries(static () => TUnit_TestProject_Bugs__7108_GenericMethodNonTupleMethodDataSourceTests__TestSource.Entries); +} diff --git a/tests/TUnit.Engine.Tests/Issue7108Tests.cs b/tests/TUnit.Engine.Tests/Issue7108Tests.cs new file mode 100644 index 00000000000..e6c47f64795 --- /dev/null +++ b/tests/TUnit.Engine.Tests/Issue7108Tests.cs @@ -0,0 +1,162 @@ +using Shouldly; +using TUnit.Engine.Tests.Enums; + +namespace TUnit.Engine.Tests; + +/// +/// https://github.com/thomhurst/TUnit/issues/7108: a generic test method fed by a +/// [MethodDataSource] whose rows are not Func<tuple> must be discovered in both modes. +/// +public class Issue7108Tests(TestMode testMode) : InvokableTestBase(testMode) +{ + [Test] + public async Task Generic_Method_With_Non_Tuple_Method_Data_Source_Is_Discovered() + { + await RunTestsWithFilter( + "/*/TUnit.TestProject.Bugs._7108/GenericMethodNonTupleMethodDataSourceTests/*", + [ + result => result.ResultSummary.Outcome.ShouldBe("Completed"), + result => result.ResultSummary.Counters.Total.ShouldBe(41), + result => result.ResultSummary.Counters.Passed.ShouldBe(41), + result => result.ResultSummary.Counters.Failed.ShouldBe(0) + ]); + } + + /// + /// Runs one table of [MethodDataSource] overload scenarios in this mode. Each row names the overload + /// both modes must choose, so a drift between the generator's scorer and the reflection binder fails here. + /// + [Test] + public async Task Both_Modes_Choose_The_Same_Data_Source_Overload() + { + await RunTestsWithFilter( + "/*/TUnit.TestProject.Bugs._7108/DataSourceOverloadParityTests/*", + [ + result => result.ResultSummary.Outcome.ShouldBe("Completed"), + result => result.ResultSummary.Counters.Total.ShouldBe(25), + result => result.ResultSummary.Counters.Passed.ShouldBe(25), + result => result.ResultSummary.Counters.Failed.ShouldBe(0) + ]); + } + + /// + /// A private data source member on a generic class keeps the attribute's reflection fallback, because the + /// generated factory cannot name a declaring type with type parameters. Its rows must still arrive. + /// + [Test] + public async Task Private_Member_On_A_Generic_Class_Still_Supplies_Rows() + { + await RunTestsWithFilter( + "/*/TUnit.TestProject.Bugs._7108/GenericClassPrivateMemberDataSourceTests*/*/*", + [ + result => result.ResultSummary.Outcome.ShouldBe("Completed"), + result => result.ResultSummary.Counters.Total.ShouldBe(2), + result => result.ResultSummary.Counters.Passed.ShouldBe(2), + result => result.ResultSummary.Counters.Failed.ShouldBe(0) + ]); + } + + /// + /// A public field declared as object that holds an array gives one row per element in both modes. Before + /// this PR every field went through the attribute's reflection fallback, which decides from the runtime value; the + /// generated factory for a field must keep doing so rather than pass the whole array as one argument. + /// + [Test] + public async Task Public_Object_Field_Holding_An_Array_Yields_A_Row_Per_Element() + { + await RunTestsWithFilter( + "/*/TUnit.TestProject.Bugs._7108/PublicObjectFieldDataSourceTests/*", + [ + result => result.ResultSummary.Outcome.ShouldBe("Completed"), + result => result.ResultSummary.Counters.Total.ShouldBe(4), + result => result.ResultSummary.Counters.Passed.ShouldBe(4), + result => result.ResultSummary.Counters.Failed.ShouldBe(0) + ]); + } + + /// + /// Fields, properties and methods named after C# keywords (e.g. @event) must be escaped in generated code. + /// + [Test] + public async Task Keyword_Named_Data_Source_Members_Compile_And_Run() + { + await RunTestsWithFilter( + "/*/TUnit.TestProject.Bugs._7108/KeywordNamedDataSourceTests/*", + [ + result => result.ResultSummary.Outcome.ShouldBe("Completed"), + result => result.ResultSummary.Counters.Total.ShouldBe(6), + result => result.ResultSummary.Counters.Passed.ShouldBe(6), + result => result.ResultSummary.Counters.Failed.ShouldBe(0) + ]); + } + + /// + /// Rows of a private nested type would close the generic test over a type that generated code cannot name. + /// Reflection mode runs them. Source-generated mode must still compile, and reports each test as a failure + /// that names the type and the fix. + /// + [Test] + public async Task Private_Row_Type_Compiles_And_Is_Reported_In_Source_Generated_Mode() + { + await RunTestsWithFilter( + "/*/TUnit.TestProject.Bugs._7108/PrivateRowTypeDataSourceTests/*", + testMode == TestMode.Reflection + ? + [ + result => result.ResultSummary.Counters.Total.ShouldBe(2), + result => result.ResultSummary.Counters.Passed.ShouldBe(2), + ] + : + [ + result => result.ResultSummary.Counters.Total.ShouldBe(2), + result => result.ResultSummary.Counters.Failed.ShouldBe(2), + result => result.Results.ShouldAllBe(x => x.Output!.ErrorInfo!.Message!.Contains( + "Its rows give the type argument 'TUnit.TestProject.Bugs._7108.PrivateRowTypeDataSourceTests.Row', which source-generated code cannot name")), + ]); + } + + /// + /// Protected data source members declared on a base class, read through the generated factory's reflection on + /// the declaring type, supply their rows in both modes, including an object-typed field split by its value. + /// + [Test] + public async Task Inherited_Protected_Members_Supply_Rows() + { + await RunTestsWithFilter( + "/*/TUnit.TestProject.Bugs._7108/InheritedProtectedMemberDataSourceTests/*", + [ + result => result.ResultSummary.Outcome.ShouldBe("Completed"), + result => result.ResultSummary.Counters.Total.ShouldBe(4), + result => result.ResultSummary.Counters.Passed.ShouldBe(4), + result => result.ResultSummary.Counters.Failed.ShouldBe(0) + ]); + } + + /// + /// With TUnit0001 suppressed and no overload accepting the Arguments, the generic test is still discovered and + /// fails when its data method is called, in both modes, instead of disappearing. + /// + [Test] + public async Task Generic_Test_Without_A_Matching_Overload_Fails_Instead_Of_Vanishing() + { + await RunTestsWithFilter( + "/*/TUnit.TestProject.Bugs._7108/NoMatchingOverloadDataSourceTests/*", + [ + result => result.ResultSummary.Counters.Total.ShouldBe(1), + result => result.ResultSummary.Counters.Failed.ShouldBe(1), + ]); + } + + [Test] + public async Task Single_Tuple_Parameter_Keeps_The_CancellationToken_At_Its_Declared_Position() + { + await RunTestsWithFilter( + "/*/TUnit.TestProject.Bugs._7108/GenericSingleTupleWithCancellationTokenTests/*", + [ + result => result.ResultSummary.Outcome.ShouldBe("Completed"), + result => result.ResultSummary.Counters.Total.ShouldBe(2), + result => result.ResultSummary.Counters.Passed.ShouldBe(2), + result => result.ResultSummary.Counters.Failed.ShouldBe(0) + ]); + } +} diff --git a/tests/TUnit.PublicAPI/Tests.Core_Library_Has_No_API_Changes.DotNet10_0.verified.txt b/tests/TUnit.PublicAPI/Tests.Core_Library_Has_No_API_Changes.DotNet10_0.verified.txt index a4eed786870..6a5930110c9 100644 --- a/tests/TUnit.PublicAPI/Tests.Core_Library_Has_No_API_Changes.DotNet10_0.verified.txt +++ b/tests/TUnit.PublicAPI/Tests.Core_Library_Has_No_API_Changes.DotNet10_0.verified.txt @@ -2331,12 +2331,16 @@ namespace .Helpers public static .<<.>> FromInstanceAsyncEnumerable(.DataGeneratorMetadata dataGeneratorMetadata, > invoke) { } [.(typeof(..d__6))] public static .<<.>> FromInstanceEnumerable(.DataGeneratorMetadata dataGeneratorMetadata, invoke) { } + [.(typeof(..d__11))] + public static .<<.>> FromInstanceRuntimeValue(.DataGeneratorMetadata dataGeneratorMetadata, invoke) { } [.(typeof(..d__7))] public static .<<.>> FromInstanceTask(.DataGeneratorMetadata dataGeneratorMetadata, > invoke) { } [.(typeof(..d__5))] public static .<<.>> FromInstanceValue(.DataGeneratorMetadata dataGeneratorMetadata, invoke) { } [.(typeof(..d__8))] public static .<<.>> FromInstanceValueTask(.DataGeneratorMetadata dataGeneratorMetadata, > invoke) { } + [.(typeof(..d__10))] + public static .<<.>> FromRuntimeValue(.DataGeneratorMetadata dataGeneratorMetadata, invoke) { } [.(typeof(..d__2))] public static .<<.>> FromTask(<.> invoke) { } [.(typeof(..d__0))] diff --git a/tests/TUnit.PublicAPI/Tests.Core_Library_Has_No_API_Changes.DotNet8_0.verified.txt b/tests/TUnit.PublicAPI/Tests.Core_Library_Has_No_API_Changes.DotNet8_0.verified.txt index 06808895a97..6de8243177e 100644 --- a/tests/TUnit.PublicAPI/Tests.Core_Library_Has_No_API_Changes.DotNet8_0.verified.txt +++ b/tests/TUnit.PublicAPI/Tests.Core_Library_Has_No_API_Changes.DotNet8_0.verified.txt @@ -2331,12 +2331,16 @@ namespace .Helpers public static .<<.>> FromInstanceAsyncEnumerable(.DataGeneratorMetadata dataGeneratorMetadata, > invoke) { } [.(typeof(..d__6))] public static .<<.>> FromInstanceEnumerable(.DataGeneratorMetadata dataGeneratorMetadata, invoke) { } + [.(typeof(..d__11))] + public static .<<.>> FromInstanceRuntimeValue(.DataGeneratorMetadata dataGeneratorMetadata, invoke) { } [.(typeof(..d__7))] public static .<<.>> FromInstanceTask(.DataGeneratorMetadata dataGeneratorMetadata, > invoke) { } [.(typeof(..d__5))] public static .<<.>> FromInstanceValue(.DataGeneratorMetadata dataGeneratorMetadata, invoke) { } [.(typeof(..d__8))] public static .<<.>> FromInstanceValueTask(.DataGeneratorMetadata dataGeneratorMetadata, > invoke) { } + [.(typeof(..d__10))] + public static .<<.>> FromRuntimeValue(.DataGeneratorMetadata dataGeneratorMetadata, invoke) { } [.(typeof(..d__2))] public static .<<.>> FromTask(<.> invoke) { } [.(typeof(..d__0))] diff --git a/tests/TUnit.PublicAPI/Tests.Core_Library_Has_No_API_Changes.DotNet9_0.verified.txt b/tests/TUnit.PublicAPI/Tests.Core_Library_Has_No_API_Changes.DotNet9_0.verified.txt index 625056b3499..626ea986b84 100644 --- a/tests/TUnit.PublicAPI/Tests.Core_Library_Has_No_API_Changes.DotNet9_0.verified.txt +++ b/tests/TUnit.PublicAPI/Tests.Core_Library_Has_No_API_Changes.DotNet9_0.verified.txt @@ -2331,12 +2331,16 @@ namespace .Helpers public static .<<.>> FromInstanceAsyncEnumerable(.DataGeneratorMetadata dataGeneratorMetadata, > invoke) { } [.(typeof(..d__6))] public static .<<.>> FromInstanceEnumerable(.DataGeneratorMetadata dataGeneratorMetadata, invoke) { } + [.(typeof(..d__11))] + public static .<<.>> FromInstanceRuntimeValue(.DataGeneratorMetadata dataGeneratorMetadata, invoke) { } [.(typeof(..d__7))] public static .<<.>> FromInstanceTask(.DataGeneratorMetadata dataGeneratorMetadata, > invoke) { } [.(typeof(..d__5))] public static .<<.>> FromInstanceValue(.DataGeneratorMetadata dataGeneratorMetadata, invoke) { } [.(typeof(..d__8))] public static .<<.>> FromInstanceValueTask(.DataGeneratorMetadata dataGeneratorMetadata, > invoke) { } + [.(typeof(..d__10))] + public static .<<.>> FromRuntimeValue(.DataGeneratorMetadata dataGeneratorMetadata, invoke) { } [.(typeof(..d__2))] public static .<<.>> FromTask(<.> invoke) { } [.(typeof(..d__0))] diff --git a/tests/TUnit.PublicAPI/Tests.Core_Library_Has_No_API_Changes.Net4_7.verified.txt b/tests/TUnit.PublicAPI/Tests.Core_Library_Has_No_API_Changes.Net4_7.verified.txt index b9b31286c09..4432b57c883 100644 --- a/tests/TUnit.PublicAPI/Tests.Core_Library_Has_No_API_Changes.Net4_7.verified.txt +++ b/tests/TUnit.PublicAPI/Tests.Core_Library_Has_No_API_Changes.Net4_7.verified.txt @@ -2272,12 +2272,16 @@ namespace .Helpers public static .<<.>> FromInstanceAsyncEnumerable(.DataGeneratorMetadata dataGeneratorMetadata, > invoke) { } [.(typeof(..d__6))] public static .<<.>> FromInstanceEnumerable(.DataGeneratorMetadata dataGeneratorMetadata, invoke) { } + [.(typeof(..d__11))] + public static .<<.>> FromInstanceRuntimeValue(.DataGeneratorMetadata dataGeneratorMetadata, invoke) { } [.(typeof(..d__7))] public static .<<.>> FromInstanceTask(.DataGeneratorMetadata dataGeneratorMetadata, > invoke) { } [.(typeof(..d__5))] public static .<<.>> FromInstanceValue(.DataGeneratorMetadata dataGeneratorMetadata, invoke) { } [.(typeof(..d__8))] public static .<<.>> FromInstanceValueTask(.DataGeneratorMetadata dataGeneratorMetadata, > invoke) { } + [.(typeof(..d__10))] + public static .<<.>> FromRuntimeValue(.DataGeneratorMetadata dataGeneratorMetadata, invoke) { } [.(typeof(..d__2))] public static .<<.>> FromTask(<.> invoke) { } [.(typeof(..d__0))] diff --git a/tests/TUnit.TestProject/Bugs/_7108/DataSourceOverloadParityTests.cs b/tests/TUnit.TestProject/Bugs/_7108/DataSourceOverloadParityTests.cs new file mode 100644 index 00000000000..b5aaf315ade --- /dev/null +++ b/tests/TUnit.TestProject/Bugs/_7108/DataSourceOverloadParityTests.cs @@ -0,0 +1,290 @@ +using TUnit.TestProject.Attributes; + +namespace TUnit.TestProject.Bugs._7108; + +/// +/// A table of [MethodDataSource] overload scenarios. Source-gen mode picks the overload with +/// ScoreDataSourceOverload in the generator, and reflection mode with the runtime binder and +/// MethodDataSourceAttribute.ResolveDataSourceMethodWithNullArgument. Each attribute is one row: +/// its first argument names the overload both modes must choose, and every overload yields +/// (expected, its own signature). Issue7108Tests runs the table in both modes, so a divergence between +/// the two resolvers fails the row in the mode that drifted. The test methods are not generic, so the +/// rows exercise the factory that every non-generic [MethodDataSource] test uses. +/// +[EngineTest(ExpectedResult.Pass)] +public class DataSourceOverloadParityTests +{ + public static IEnumerable<(string, string)> Count(string expected) + { + yield return (expected, "Count(string)"); + } + + public static IEnumerable<(string, string)> Count(string expected, int value) + { + yield return (expected, "Count(string, int)"); + } + + public static IEnumerable<(string, string)> Exact(string expected, long value) + { + yield return (expected, "Exact(string, long)"); + } + + public static IEnumerable<(string, string)> Exact(string expected, int value) + { + yield return (expected, "Exact(string, int)"); + } + + public static IEnumerable<(string, string)> Widening(string expected, string value) + { + yield return (expected, "Widening(string, string)"); + } + + public static IEnumerable<(string, string)> Widening(string expected, long value) + { + yield return (expected, "Widening(string, long)"); + } + + public static IEnumerable<(string, string)> Specific(string expected, object value) + { + yield return (expected, "Specific(string, object)"); + } + + public static IEnumerable<(string, string)> Specific(string expected, long value) + { + yield return (expected, "Specific(string, long)"); + } + + public static IEnumerable<(string, string)> FloatToDouble(string expected, string value) + { + yield return (expected, "FloatToDouble(string, string)"); + } + + public static IEnumerable<(string, string)> FloatToDouble(string expected, double value) + { + yield return (expected, "FloatToDouble(string, double)"); + } + + public static IEnumerable<(string, string)> LongExact(string expected, int value) + { + yield return (expected, "LongExact(string, int)"); + } + + public static IEnumerable<(string, string)> LongExact(string expected, long value) + { + yield return (expected, "LongExact(string, long)"); + } + + public static IEnumerable<(string, string)> NullableParameter(string expected, string value) + { + yield return (expected, "NullableParameter(string, string)"); + } + + public static IEnumerable<(string, string)> NullableParameter(string expected, int? value) + { + yield return (expected, "NullableParameter(string, int?)"); + } + + public static IEnumerable<(string, string)> EnumParameter(string expected, int value) + { + yield return (expected, "EnumParameter(string, int)"); + } + + public static IEnumerable<(string, string)> EnumParameter(string expected, DayOfWeek value) + { + yield return (expected, "EnumParameter(string, DayOfWeek)"); + } + + public static IEnumerable<(string, string)> Character(string expected, int value) + { + yield return (expected, "Character(string, int)"); + } + + public static IEnumerable<(string, string)> Character(string expected, char value) + { + yield return (expected, "Character(string, char)"); + } + + public static IEnumerable<(string, string)> ExactCount(string expected, object first, object second) + { + yield return (expected, "ExactCount(string, object, object)"); + } + + public static IEnumerable<(string, string)> ExactCount(string expected, string first, string second, int count = 1) + { + yield return (expected, "ExactCount(string, string, string, int)"); + } + + public static IEnumerable<(string, string)> Null(string expected, int value) + { + yield return (expected, "Null(string, int)"); + } + + public static IEnumerable<(string, string)> Null(string expected, string? value) + { + yield return (expected, "Null(string, string?)"); + } + + public static IEnumerable<(string, string)> NullTie(string expected, string? text, object value) + { + yield return (expected, "NullTie(string, string?, object)"); + } + + public static IEnumerable<(string, string)> NullTie(string expected, string? text, long value) + { + yield return (expected, "NullTie(string, string?, long)"); + } + + public static IEnumerable<(string, string)> NullOptional(string expected, int count) + { + yield return (expected, "NullOptional(string, int)"); + } + + public static IEnumerable<(string, string)> NullOptional(string expected, string? text, int count = 1) + { + yield return (expected, "NullOptional(string, string?, int)"); + } + + public static IEnumerable<(string, string)> Optional(string expected, string text, int count = 2) + { + yield return (expected, "Optional(string, string, int)"); + } + + public static IEnumerable<(string, string)> NullToNullable(string expected, int value) + { + yield return (expected, "NullToNullable(string, int)"); + } + + public static IEnumerable<(string, string)> NullToNullable(string expected, int? value) + { + yield return (expected, "NullToNullable(string, int?)"); + } + + // A generic overload is declared first: its T parameter cannot take an Arguments value in either mode + public static IEnumerable<(string, string)> GenericOverload(string expected, T value) + { + yield return (expected, "GenericOverload(string, T)"); + } + + public static IEnumerable<(string, string)> GenericOverload(string expected, int value) + { + yield return (expected, "GenericOverload(string, int)"); + } + + public static IEnumerable<(string, string)> Params(string expected, params int[] values) + { + yield return (expected, "Params(string, params int[])"); + } + + public static IEnumerable<(string, string)> Params(string expected, int value) + { + yield return (expected, "Params(string, int)"); + } + + public static IEnumerable<(string, string)> Token(string expected, int value, CancellationToken cancellationToken) + { + yield return (expected, "Token(string, int, CancellationToken)"); + } + + // C# converts an int to decimal or long?, but reflection's binder and MethodInfo.Invoke cannot, so the object + // overload declared first wins in both modes + public static IEnumerable<(string, string)> ObjectOrDecimal(string expected, object value) + { + yield return (expected, "ObjectOrDecimal(string, object)"); + } + + public static IEnumerable<(string, string)> ObjectOrDecimal(string expected, decimal value) + { + yield return (expected, "ObjectOrDecimal(string, decimal)"); + } + + public static IEnumerable<(string, string)> ObjectOrNullableLong(string expected, object value) + { + yield return (expected, "ObjectOrNullableLong(string, object)"); + } + + public static IEnumerable<(string, string)> ObjectOrNullableLong(string expected, long? value) + { + yield return (expected, "ObjectOrNullableLong(string, long?)"); + } + + public static IEnumerable<(string, string)> NullObjectOrNullableLong(string expected, string? text, object value) + { + yield return (expected, "NullObjectOrNullableLong(string, string?, object)"); + } + + public static IEnumerable<(string, string)> NullObjectOrNullableLong(string expected, string? text, long? value) + { + yield return (expected, "NullObjectOrNullableLong(string, string?, long?)"); + } + + // A generic method definition declared first takes the same parameters, but reflection cannot invoke it + // without type arguments, so both modes call the non-generic overload + public static IEnumerable<(string, string)> GenericFirst(string expected) + { + yield return (expected, "GenericFirst(string)"); + } + + public static IEnumerable<(string, string)> GenericFirst(string expected) + { + yield return (expected, "GenericFirst(string)"); + } + + [Test] + [MethodDataSource(nameof(Count), Arguments = new object[] { "Count(string)" })] + [MethodDataSource(nameof(Count), Arguments = new object[] { "Count(string, int)", 1 })] + [MethodDataSource(nameof(Exact), Arguments = new object[] { "Exact(string, int)", 1 })] + [MethodDataSource(nameof(Widening), Arguments = new object[] { "Widening(string, long)", 1 })] + [MethodDataSource(nameof(Specific), Arguments = new object[] { "Specific(string, long)", 1 })] + [MethodDataSource(nameof(FloatToDouble), Arguments = new object[] { "FloatToDouble(string, double)", 1.5f })] + [MethodDataSource(nameof(LongExact), Arguments = new object[] { "LongExact(string, long)", 1L })] + [MethodDataSource(nameof(NullableParameter), Arguments = new object[] { "NullableParameter(string, int?)", 1 })] + [MethodDataSource(nameof(EnumParameter), Arguments = new object[] { "EnumParameter(string, DayOfWeek)", DayOfWeek.Friday })] + [MethodDataSource(nameof(Character), Arguments = new object[] { "Character(string, char)", 'a' })] + [MethodDataSource(nameof(ExactCount), Arguments = new object[] { "ExactCount(string, object, object)", "a", "b" })] + [MethodDataSource(nameof(GenericOverload), Arguments = new object[] { "GenericOverload(string, int)", 1 })] + // A static overload hidden with `new` on a derived provider: both modes call the derived one + [MethodDataSource(typeof(DataSourceOverloadParityDerivedProvider), nameof(DataSourceOverloadParityDerivedProvider.Hidden), Arguments = new object[] { "Derived.Hidden(string, int)", 1 })] + // Loose values for a params parameter are rejected by TUnit0001, so the array is passed as one argument + [MethodDataSource(nameof(Params), Arguments = new object[] { "Params(string, params int[])", new[] { 1, 2 } })] + [MethodDataSource(nameof(Params), Arguments = new object[] { "Params(string, int)", 1 })] + [MethodDataSource(nameof(ObjectOrDecimal), Arguments = new object[] { "ObjectOrDecimal(string, object)", 1 })] + [MethodDataSource(nameof(ObjectOrNullableLong), Arguments = new object[] { "ObjectOrNullableLong(string, object)", 1 })] + [MethodDataSource(nameof(GenericFirst), Arguments = new object[] { "GenericFirst(string)" })] + public async Task Chosen_Overload(string expected, string chosen) + { + await Assert.That(chosen).IsEqualTo(expected); + } + + // TUnit0001 requires one argument per parameter and does not yet match a null argument (#7168). + // With it suppressed, both modes still bind these rows at runtime. +#pragma warning disable TUnit0001 + [Test] + [MethodDataSource(nameof(Null), Arguments = new object?[] { "Null(string, string?)", null })] + [MethodDataSource(nameof(NullToNullable), Arguments = new object?[] { "NullToNullable(string, int?)", null })] + [MethodDataSource(nameof(NullTie), Arguments = new object?[] { "NullTie(string, string?, long)", null, 1 })] + [MethodDataSource(nameof(NullObjectOrNullableLong), Arguments = new object?[] { "NullObjectOrNullableLong(string, string?, object)", null, 1 })] + [MethodDataSource(nameof(NullOptional), Arguments = new object?[] { "NullOptional(string, string?, int)", null })] + [MethodDataSource(nameof(Optional), Arguments = new object[] { "Optional(string, string, int)", "a" })] + [MethodDataSource(nameof(Token), Arguments = new object[] { "Token(string, int, CancellationToken)", 1 })] + public async Task Chosen_Overload_With_Missing_Or_Null_Arguments(string expected, string chosen) + { + await Assert.That(chosen).IsEqualTo(expected); + } +#pragma warning restore TUnit0001 +} + +public class DataSourceOverloadParityBaseProvider +{ + public static IEnumerable<(string, string)> Hidden(string expected, int value) + { + yield return (expected, "Base.Hidden(string, int)"); + } +} + +public class DataSourceOverloadParityDerivedProvider : DataSourceOverloadParityBaseProvider +{ + public new static IEnumerable<(string, string)> Hidden(string expected, int value) + { + yield return (expected, "Derived.Hidden(string, int)"); + } +} diff --git a/tests/TUnit.TestProject/Bugs/_7108/GenericClassPrivateMemberDataSourceTests.cs b/tests/TUnit.TestProject/Bugs/_7108/GenericClassPrivateMemberDataSourceTests.cs new file mode 100644 index 00000000000..20c1874c6e8 --- /dev/null +++ b/tests/TUnit.TestProject/Bugs/_7108/GenericClassPrivateMemberDataSourceTests.cs @@ -0,0 +1,34 @@ +using TUnit.TestProject.Attributes; + +namespace TUnit.TestProject.Bugs._7108; + +/// +/// A private data source field or property declared on a generic class. The generated factory cannot read +/// it by reflection on a declaring type that has type parameters, so the attribute keeps its reflection +/// fallback. The rows must still reach the tests in both modes (#7108). +/// A generic method on a generic class is not covered here: it does not compile in source-gen mode yet (#7117). +/// +[EngineTest(ExpectedResult.Pass)] +[GenerateGenericTest(typeof(string))] +public class GenericClassPrivateMemberDataSourceTests +{ + private static readonly int[] PrivateFieldRows = [51]; + + private static IEnumerable PrivatePropertyRows => [52]; + + [Test] + [MethodDataSource(nameof(PrivateFieldRows))] + public async Task Private_Field(int value) + { + await Assert.That(value).IsEqualTo(51); + await Assert.That(typeof(TClass)).IsEqualTo(typeof(string)); + } + + [Test] + [MethodDataSource(nameof(PrivatePropertyRows))] + public async Task Private_Property(int value) + { + await Assert.That(value).IsEqualTo(52); + await Assert.That(typeof(TClass)).IsEqualTo(typeof(string)); + } +} diff --git a/tests/TUnit.TestProject/Bugs/_7108/GenericMethodNonTupleMethodDataSourceTests.cs b/tests/TUnit.TestProject/Bugs/_7108/GenericMethodNonTupleMethodDataSourceTests.cs new file mode 100644 index 00000000000..0799de990c3 --- /dev/null +++ b/tests/TUnit.TestProject/Bugs/_7108/GenericMethodNonTupleMethodDataSourceTests.cs @@ -0,0 +1,601 @@ +using TUnit.TestProject.Attributes; + +namespace TUnit.TestProject.Bugs._7108; + +/// +/// https://github.com/thomhurst/TUnit/issues/7108: source-gen mode only inferred a generic test +/// method's type arguments from IEnumerable<Func<(...)>> data sources, so every other +/// row shape dropped the test silently. Each test here must be discovered in both modes. +/// +[EngineTest(ExpectedResult.Pass)] +public class GenericMethodNonTupleMethodDataSourceTests +{ + public static IEnumerable> FuncRows() + { + yield return () => 1; + } + + public static IEnumerable PlainRows() + { + yield return 2; + } + + public static string[] ArrayRows() => ["three"]; + + public static async IAsyncEnumerable AsyncRows() + { + await Task.Yield(); + yield return 4; + } + + public static Task> TaskRows() => Task.FromResult>([5]); + + public static IEnumerable> TestDataRows() + { + yield return new TestDataRow(6); + } + + public static IEnumerable>> NestedFuncRows() + { + yield return () => () => 45; + } + + public static IEnumerable>>> FuncOfTestDataRowOfFuncRows() + { + yield return () => new TestDataRow>(() => 46); + } + + public static IEnumerable> ListRows() + { + yield return [7]; + } + + public static IEnumerable<(int, string)> PlainTupleRows() + { + yield return (8, "eight"); + } + + public static IEnumerable RowsWithArgument(int value) + { + yield return value; + } + + public static IEnumerable IntArrayRows() + { + yield return [10, 11]; + } + + // Declared before the parameterless overload: Arguments must pick this one, as reflection mode does + public static IEnumerable OverloadedRows(int value) + { + yield return value.ToString(System.Globalization.CultureInfo.InvariantCulture); + } + + public static IEnumerable OverloadedRows() + { + yield return -1; + } + + public static Task> TaskOfAsyncRows() => Task.FromResult(AsyncRows()); + + // Arguments = { 13 } is an int: the long overload is picked, as reflection's binder widens int to long + public static IEnumerable WideningRows() + { + yield return "parameterless"; + } + + public static IEnumerable WideningRows(long value) + { + yield return value; + } + + // Declared before the int overload: an exact argument type beats an implicit conversion + public static IEnumerable FloatWideningRows(double value) + { + yield return value; + } + + public static IEnumerable LongRows(long value) + { + yield return value; + } + + public static IEnumerable NullRows(int value) + { + yield return value; + } + + public static IEnumerable NullRows(string? value) + { + yield return value ?? "null"; + } + + public static IEnumerable NullableRows(int? value) + { + yield return value ?? -1; + } + + public static readonly int[] FieldRows = [19]; + + private static readonly int[] PrivateFieldRows = [21]; + + private static IEnumerable PrivatePropertyRows => [31]; + + // Declared as object, so only the runtime value says these are two rows + private static readonly object PrivateObjectFieldRows = new[] { 41, 42 }; + + private static object PrivateObjectPropertyRows => new[] { 43, 44 }; + + public static IEnumerable<(int, int)> TupleParameterRows() + { + yield return (25, 26); + } + + public static IEnumerable LiteralRows(char character, string text, double notANumber, double large, float infinity, DayOfWeek day) + { + var allMatch = character == '\0' + && text == "a\u2028b\"\\" + && double.IsNaN(notANumber) + && large == 1E+20 + && float.IsPositiveInfinity(infinity) + && day == DayOfWeek.Friday; + yield return allMatch ? 24 : -1; + } + + public static IEnumerable TieRows(string? text, object value) + { + yield return "object"; + } + + public static IEnumerable TieRows(string? text, long value) + { + yield return value; + } + + public static IEnumerable NonNullTieRows(object value) + { + yield return "object"; + } + + public static IEnumerable NonNullTieRows(long value) + { + yield return value; + } + + public static IEnumerable CancellationTokenOnlyRows(CancellationToken cancellationToken) + { + yield return 18; + } + + public static IEnumerable NullOptionalRows(int count) + { + yield return count; + } + + public static IEnumerable NullOptionalRows(string? text, int count = 1) + { + yield return (text ?? "null") + count; + } + + public static IEnumerable NullWideningRows(int first, int second) + { + yield return "int"; + } + + public static IEnumerable NullWideningRows(string? text, long number) + { + yield return number; + } + + public static IEnumerable ExactTypeRows(long value) + { + yield return "long"; + } + + public static IEnumerable ExactTypeRows(int value) + { + yield return value; + } + + // Reflection only binds overloads with one parameter per argument, so two strings pick (object, object) + public static IEnumerable OptionalOverloadRows(object first, object second) + { + yield return $"{first}{second}"; + } + + public static IEnumerable OptionalOverloadRows(string first, string second, int count = 1) + { + yield return count; + } + + // A single overload with a missing optional parameter gets its default + public static IEnumerable OptionalParameterRows(string text, int count = 2) + { + yield return text.Length + count; + } + + // A single overload with a missing CancellationToken gets CancellationToken.None + public static IEnumerable CancellationTokenRows(int value, CancellationToken cancellationToken) + { + yield return cancellationToken.CanBeCanceled ? -value : value; + } + + // A generic data method declared first cannot be called without type arguments, so both modes use the + // non-generic overload. Inferring T from the generic one's open T emitted code that did not compile. + public static IEnumerable GenericProviderRows() + { + yield break; + } + + public static IEnumerable GenericProviderRows() + { + yield return 27; + } + + // Reflection cannot pass an int to a decimal parameter, so both modes call the object overload for 28, + // although C# would convert it + public static IEnumerable ObjectOrDecimalRows(object value) + { + yield return value.ToString()!; + } + + public static IEnumerable ObjectOrDecimalRows(decimal value) + { + yield return value; + } + + [Test] + [MethodDataSource(nameof(GenericProviderRows))] + public async Task Generic_Data_Method_Overload_Is_Skipped(T value) + { + await Assert.That(typeof(T)).IsEqualTo(typeof(int)); + await Assert.That(value).IsEqualTo((T)(object)27); + } + + [Test] + [MethodDataSource(nameof(ObjectOrDecimalRows), Arguments = new object[] { 28 })] + public async Task Decimal_Overload_Is_Not_Chosen_For_An_Int_Argument(T value) + { + await Assert.That(typeof(T)).IsEqualTo(typeof(string)); + await Assert.That(value).IsEqualTo((T)(object)"28"); + } + + [Test] + [MethodDataSource(nameof(FuncRows))] + public async Task Func_Row(T value) + { + await Assert.That(typeof(T)).IsEqualTo(typeof(int)); + await Assert.That(value).IsEqualTo((T)(object)1); + } + + [Test] + [MethodDataSource(nameof(NestedFuncRows))] + public async Task Nested_Func_Row_Passes_The_Inner_Func(T value) + { + // Only the outer Func is invoked, so the row value is the inner Func + await Assert.That(typeof(T)).IsEqualTo(typeof(Func)); + await Assert.That(((Func)(object)value!)()).IsEqualTo(45); + } + + [Test] + [MethodDataSource(nameof(FuncOfTestDataRowOfFuncRows))] + public async Task Func_Of_Test_Data_Row_Of_Func_Row(T value) + { + await Assert.That(typeof(T)).IsEqualTo(typeof(int)); + await Assert.That(value).IsEqualTo((T)(object)46); + } + + [Test] + [MethodDataSource(nameof(PlainRows))] + public async Task Plain_Row(T value) + { + await Assert.That(typeof(T)).IsEqualTo(typeof(int)); + await Assert.That(value).IsEqualTo((T)(object)2); + } + + [Test] + [MethodDataSource(nameof(ArrayRows))] + public async Task Array_Row(T value) + { + await Assert.That(typeof(T)).IsEqualTo(typeof(string)); + await Assert.That(value).IsEqualTo((T)(object)"three"); + } + + [Test] + [MethodDataSource(nameof(AsyncRows))] + public async Task Async_Enumerable_Row(T value) + { + await Assert.That(typeof(T)).IsEqualTo(typeof(int)); + await Assert.That(value).IsEqualTo((T)(object)4); + } + + [Test] + [MethodDataSource(nameof(TaskRows))] + public async Task Task_Row(T value) + { + await Assert.That(typeof(T)).IsEqualTo(typeof(int)); + await Assert.That(value).IsEqualTo((T)(object)5); + } + + [Test] + [MethodDataSource(nameof(TestDataRows))] + public async Task Test_Data_Row(T value) + { + await Assert.That(typeof(T)).IsEqualTo(typeof(int)); + await Assert.That(value).IsEqualTo((T)(object)6); + } + + [Test] + [MethodDataSource(nameof(ListRows))] + public async Task Nested_Generic_Row(List value) + { + await Assert.That(typeof(T)).IsEqualTo(typeof(int)); + await Assert.That(value.Count).IsEqualTo(1); + } + + [Test] + [MethodDataSource(nameof(PlainTupleRows))] + public async Task Plain_Tuple_Row(T1 number, T2 text) + { + await Assert.That(typeof(T1)).IsEqualTo(typeof(int)); + await Assert.That(typeof(T2)).IsEqualTo(typeof(string)); + await Assert.That(number).IsEqualTo((T1)(object)8); + await Assert.That(text).IsEqualTo((T2)(object)"eight"); + } + + [Test] + [MethodDataSource(nameof(RowsWithArgument), Arguments = new object[] { 9 })] + public async Task Data_Method_With_Arguments(T value) + { + await Assert.That(typeof(T)).IsEqualTo(typeof(int)); + await Assert.That(value).IsEqualTo((T)(object)9); + } + + [Test] + [MethodDataSource(nameof(IntArrayRows))] + public async Task Array_Element_Row(T[] values) + { + await Assert.That(typeof(T)).IsEqualTo(typeof(int)); + await Assert.That(values.Length).IsEqualTo(2); + } + + [Test] + [MethodDataSource(nameof(OverloadedRows), Arguments = new object[] { 12 })] + public async Task Overload_Selected_By_Arguments(T value) + { + await Assert.That(typeof(T)).IsEqualTo(typeof(string)); + await Assert.That(value).IsEqualTo((T)(object)"12"); + } + + [Test] + [MethodDataSource(nameof(OverloadedRows))] + public async Task Parameterless_Overload_Selected_Without_Arguments(T value) + { + await Assert.That(typeof(T)).IsEqualTo(typeof(int)); + await Assert.That(value).IsEqualTo((T)(object)(-1)); + } + + [Test] + [MethodDataSource(nameof(WideningRows), Arguments = new object[] { 13 })] + public async Task Numeric_Argument_Is_Widened(T value) + { + await Assert.That(typeof(T)).IsEqualTo(typeof(long)); + await Assert.That(value).IsEqualTo((T)(object)13L); + } + + [Test] + [MethodDataSource(nameof(FloatWideningRows), Arguments = new object[] { 1.5f })] + public async Task Float_Argument_Is_Widened_To_Double(T value) + { + await Assert.That(typeof(T)).IsEqualTo(typeof(double)); + await Assert.That(value).IsEqualTo((T)(object)1.5d); + } + + [Test] + [MethodDataSource(nameof(LongRows), Arguments = new object[] { 16L })] + public async Task Long_Argument_Keeps_Its_Type(T value) + { + await Assert.That(typeof(T)).IsEqualTo(typeof(long)); + await Assert.That(value).IsEqualTo((T)(object)16L); + } + + [Test] + [MethodDataSource(nameof(NullableRows), Arguments = new object[] { 17 })] + public async Task Argument_Is_Wrapped_In_Nullable(T value) + { + await Assert.That(typeof(T)).IsEqualTo(typeof(int)); + await Assert.That(value).IsEqualTo((T)(object)17); + } + + [Test] + [MethodDataSource(nameof(FieldRows))] + public async Task Field_Data_Source(T value) + { + await Assert.That(typeof(T)).IsEqualTo(typeof(int)); + await Assert.That(value).IsEqualTo((T)(object)19); + } + + [Test] + [MethodDataSource(nameof(PrivateFieldRows))] + public async Task Private_Field_Data_Source(T value) + { + await Assert.That(typeof(T)).IsEqualTo(typeof(int)); + await Assert.That(value).IsEqualTo((T)(object)21); + } + + [Test] + [MethodDataSource(nameof(PrivatePropertyRows))] + public async Task Private_Property_Data_Source(T value) + { + await Assert.That(typeof(T)).IsEqualTo(typeof(int)); + await Assert.That(value).IsEqualTo((T)(object)31); + } + + [Test] + [MethodDataSource(nameof(PrivateObjectFieldRows))] + public async Task Private_Object_Field_Holding_An_Array_Yields_A_Row_Per_Element(int value) + { + await Assert.That(value).IsBetween(41, 42); + } + + [Test] + [MethodDataSource(nameof(PrivateObjectPropertyRows))] + public async Task Private_Object_Property_Holding_An_Array_Yields_A_Row_Per_Element(int value) + { + await Assert.That(value).IsBetween(43, 44); + } + + [Test] + [MethodDataSource(nameof(NonNullTieRows), Arguments = new object[] { 23 })] + public async Task More_Specific_Overload_Wins_A_Tie(T value) + { + await Assert.That(typeof(T)).IsEqualTo(typeof(long)); + await Assert.That(value).IsEqualTo((T)(object)23L); + } + + [Test] + [MethodDataSource(nameof(LiteralRows), Arguments = new object[] { '\0', "a\u2028b\"\\", double.NaN, 1E+20, float.PositiveInfinity, DayOfWeek.Friday })] + public async Task Argument_Literals_Keep_Their_Values(T value) + { + await Assert.That(typeof(T)).IsEqualTo(typeof(int)); + await Assert.That(value).IsEqualTo((T)(object)24); + } + + [Test] + [MethodDataSource(nameof(TupleParameterRows))] + public async Task Single_Tuple_Parameter_Is_Not_Spread((T, T) pair) + { + await Assert.That(typeof(T)).IsEqualTo(typeof(int)); + await Assert.That(pair.Item1).IsEqualTo((T)(object)25); + await Assert.That(pair.Item2).IsEqualTo((T)(object)26); + } + + [Test] + [MethodDataSource(nameof(TupleParameterRows))] + public async Task NonGeneric_Single_Tuple_Parameter_Is_Not_Spread((int, int) pair) + { + await Assert.That(pair.Item1).IsEqualTo(25); + } + + [Test] + [MethodDataSource(nameof(CancellationTokenOnlyRows))] + public async Task Cancellation_Token_Is_Passed_Without_Arguments(T value) + { + await Assert.That(typeof(T)).IsEqualTo(typeof(int)); + await Assert.That(value).IsEqualTo((T)(object)18); + } + + [Test] + [MethodDataSource(nameof(ExactTypeRows), Arguments = new object[] { 15 })] + public async Task Exact_Argument_Type_Beats_Conversion(T value) + { + await Assert.That(typeof(T)).IsEqualTo(typeof(int)); + await Assert.That(value).IsEqualTo((T)(object)15); + } + + [Test] + [MethodDataSource(nameof(OptionalOverloadRows), Arguments = new object[] { "a", "b" })] + public async Task Exact_Parameter_Count_Overload_Wins(T value) + { + await Assert.That(typeof(T)).IsEqualTo(typeof(string)); + await Assert.That(value).IsEqualTo((T)(object)"ab"); + } + + // TUnit0001 requires one argument per parameter. With it suppressed, a missing optional parameter or + // CancellationToken is filled in at runtime, in both modes. +#pragma warning disable TUnit0001 + [Test] + [MethodDataSource(nameof(OptionalParameterRows), Arguments = new object[] { "abc" })] + public async Task Missing_Optional_Parameter_Uses_Default(T value) + { + await Assert.That(typeof(T)).IsEqualTo(typeof(int)); + await Assert.That(value).IsEqualTo((T)(object)5); + } + + [Test] + [MethodDataSource(nameof(CancellationTokenRows), Arguments = new object[] { 14 })] + public async Task Missing_Cancellation_Token_Is_None(T value) + { + await Assert.That(typeof(T)).IsEqualTo(typeof(int)); + await Assert.That(value).IsEqualTo((T)(object)14); + } + + // The analyzer does not yet treat a null argument as matching the string? overload (#7168) + [Test] + [MethodDataSource(nameof(NullRows), Arguments = new object?[] { null })] + public async Task Null_Argument_Skips_Value_Type_Overload(T value) + { + await Assert.That(typeof(T)).IsEqualTo(typeof(string)); + await Assert.That(value).IsEqualTo((T)(object)"null"); + } + + [Test] + [MethodDataSource(nameof(NullOptionalRows), Arguments = new object?[] { null })] + public async Task Null_Argument_With_Missing_Optional_Parameter(T value) + { + await Assert.That(typeof(T)).IsEqualTo(typeof(string)); + await Assert.That(value).IsEqualTo((T)(object)"null1"); + } + + [Test] + [MethodDataSource(nameof(NullWideningRows), Arguments = new object?[] { null, 20 })] + public async Task Null_Argument_With_Widened_Argument(T value) + { + await Assert.That(typeof(T)).IsEqualTo(typeof(long)); + await Assert.That(value).IsEqualTo((T)(object)20L); + } + + [Test] + [MethodDataSource(nameof(TieRows), Arguments = new object?[] { null, 22 })] + public async Task Null_Argument_More_Specific_Overload_Wins_A_Tie(T value) + { + await Assert.That(typeof(T)).IsEqualTo(typeof(long)); + await Assert.That(value).IsEqualTo((T)(object)22L); + } +#pragma warning restore TUnit0001 + + [Test] + [MethodDataSource(nameof(TaskOfAsyncRows))] + public async Task Task_Of_Async_Enumerable_Is_One_Row(T value) + { + await Assert.That(value is IAsyncEnumerable).IsTrue(); + } +} + +/// +/// A generic test method with a single tuple parameter and a CancellationToken. Source-gen mode passes the +/// token at its declared position, before or after the tuple. Reflection mode does not bind these rows yet +/// (https://github.com/thomhurst/TUnit/issues/7173), so they live outside +/// and carry no [EngineTest]; Issue7108Tests runs them in source-generated mode only. +/// +public class GenericSingleTupleWithCancellationTokenTests +{ + public static IEnumerable<(int, int)> TupleParameterRows() + { + yield return (25, 26); + } + + [Test] + [MethodDataSource(nameof(TupleParameterRows))] + public async Task Trailing_Token((T, T) pair, CancellationToken token) + { + await Assert.That(typeof(T)).IsEqualTo(typeof(int)); + await Assert.That(token.CanBeCanceled).IsTrue(); + await Assert.That(pair.Item1).IsEqualTo((T)(object)25); + await Assert.That(pair.Item2).IsEqualTo((T)(object)26); + } + + // TUnit0001 only ignores a trailing CancellationToken (#7173). The generated call must still compile + // and pass the token before the tuple. +#pragma warning disable TUnit0001 + [Test] + [MethodDataSource(nameof(TupleParameterRows))] + public async Task Leading_Token(CancellationToken token, (T, T) pair) + { + await Assert.That(typeof(T)).IsEqualTo(typeof(int)); + await Assert.That(token.CanBeCanceled).IsTrue(); + await Assert.That(pair.Item1).IsEqualTo((T)(object)25); + await Assert.That(pair.Item2).IsEqualTo((T)(object)26); + } +#pragma warning restore TUnit0001 +} diff --git a/tests/TUnit.TestProject/Bugs/_7108/InheritedProtectedMemberDataSourceTests.cs b/tests/TUnit.TestProject/Bugs/_7108/InheritedProtectedMemberDataSourceTests.cs new file mode 100644 index 00000000000..df16bd6fe90 --- /dev/null +++ b/tests/TUnit.TestProject/Bugs/_7108/InheritedProtectedMemberDataSourceTests.cs @@ -0,0 +1,44 @@ +using TUnit.TestProject.Attributes; + +namespace TUnit.TestProject.Bugs._7108; + +/// +/// Protected data source members declared on a base class. The generated factory cannot name them, so it reads +/// them by reflection on the declaring base type, which keeps them under native AOT. +/// +public abstract class InheritedProtectedMemberDataSourceBase +{ + protected static IEnumerable BasePropertyRows => [71]; + + protected static readonly int[] BaseFieldRows = [72]; + + // Declared as object, so only the runtime value says these are two rows + protected static readonly object BaseObjectFieldRows = new[] { 73, 74 }; +} + +[EngineTest(ExpectedResult.Pass)] +public class InheritedProtectedMemberDataSourceTests : InheritedProtectedMemberDataSourceBase +{ + [Test] + [MethodDataSource(nameof(BasePropertyRows))] + public async Task Inherited_Protected_Property(T value) + { + await Assert.That(typeof(T)).IsEqualTo(typeof(int)); + await Assert.That(value).IsEqualTo((T)(object)71); + } + + [Test] + [MethodDataSource(nameof(BaseFieldRows))] + public async Task Inherited_Protected_Field(T value) + { + await Assert.That(typeof(T)).IsEqualTo(typeof(int)); + await Assert.That(value).IsEqualTo((T)(object)72); + } + + [Test] + [MethodDataSource(nameof(BaseObjectFieldRows))] + public async Task Inherited_Protected_Object_Field_Yields_A_Row_Per_Element(int value) + { + await Assert.That(value).IsBetween(73, 74); + } +} diff --git a/tests/TUnit.TestProject/Bugs/_7108/KeywordNamedDataSourceTests.cs b/tests/TUnit.TestProject/Bugs/_7108/KeywordNamedDataSourceTests.cs new file mode 100644 index 00000000000..f2dc2281d23 --- /dev/null +++ b/tests/TUnit.TestProject/Bugs/_7108/KeywordNamedDataSourceTests.cs @@ -0,0 +1,38 @@ +using TUnit.TestProject.Attributes; + +namespace TUnit.TestProject.Bugs._7108; + +/// +/// Data source members named after C# keywords must be accessed as @name in generated code, which +/// would otherwise not compile. +/// +[EngineTest(ExpectedResult.Pass)] +public class KeywordNamedDataSourceTests +{ + public static readonly object @event = new[] { 61, 62 }; + + public static int[] @class => [63, 64]; + + public static IEnumerable @return() => [65, 66]; + + [Test] + [MethodDataSource(nameof(@event))] + public async Task Keyword_Named_Field(int value) + { + await Assert.That(value).IsBetween(61, 62); + } + + [Test] + [MethodDataSource(nameof(@class))] + public async Task Keyword_Named_Property(int value) + { + await Assert.That(value).IsBetween(63, 64); + } + + [Test] + [MethodDataSource(nameof(@return))] + public async Task Keyword_Named_Method(int value) + { + await Assert.That(value).IsBetween(65, 66); + } +} diff --git a/tests/TUnit.TestProject/Bugs/_7108/NoMatchingOverloadDataSourceTests.cs b/tests/TUnit.TestProject/Bugs/_7108/NoMatchingOverloadDataSourceTests.cs new file mode 100644 index 00000000000..de34bea794b --- /dev/null +++ b/tests/TUnit.TestProject/Bugs/_7108/NoMatchingOverloadDataSourceTests.cs @@ -0,0 +1,23 @@ +namespace TUnit.TestProject.Bugs._7108; + +/// +/// No overload of the data method accepts the Arguments. TUnit0001 reports that at compile time; with it +/// suppressed, both modes still discover the generic test and fail it when the data method is called, rather than +/// dropping it. Not an [EngineTest]: the test fails by design, and Issue7108Tests checks it in each mode. +/// +public class NoMatchingOverloadDataSourceTests +{ + public static IEnumerable Rows(int value) + { + yield return value; + } + +#pragma warning disable TUnit0001 + [Test] + [MethodDataSource(nameof(Rows), Arguments = new object[] { "not an int" })] + public async Task Generic(T value) + { + await Assert.That((object?)value).IsNotNull(); + } +#pragma warning restore TUnit0001 +} diff --git a/tests/TUnit.TestProject/Bugs/_7108/PrivateRowTypeDataSourceTests.cs b/tests/TUnit.TestProject/Bugs/_7108/PrivateRowTypeDataSourceTests.cs new file mode 100644 index 00000000000..2fd9df4671a --- /dev/null +++ b/tests/TUnit.TestProject/Bugs/_7108/PrivateRowTypeDataSourceTests.cs @@ -0,0 +1,33 @@ +namespace TUnit.TestProject.Bugs._7108; + +/// +/// The rows of these data sources have a private type, so source-generated code cannot name it as a type argument. +/// Reflection mode runs the tests. Source-generated mode cannot close them, so it reports each one as a failed test +/// that explains why, instead of generating code that does not compile. Not an [EngineTest]: the outcome differs +/// between the modes, and Issue7108Tests checks each mode. +/// +public class PrivateRowTypeDataSourceTests +{ + private sealed class Row(int value) + { + public int Value { get; } = value; + } + + private static IEnumerable PropertyRows => [new Row(61)]; + + private static readonly Row[] FieldRows = [new Row(62)]; + + [Test] + [MethodDataSource(nameof(PropertyRows))] + public async Task Private_Row_Type_From_Property(T value) + { + await Assert.That(value is Row).IsTrue(); + } + + [Test] + [MethodDataSource(nameof(FieldRows))] + public async Task Private_Row_Type_From_Field(T value) + { + await Assert.That(value is Row).IsTrue(); + } +} diff --git a/tests/TUnit.TestProject/Bugs/_7108/PublicObjectFieldDataSourceTests.cs b/tests/TUnit.TestProject/Bugs/_7108/PublicObjectFieldDataSourceTests.cs new file mode 100644 index 00000000000..d07e1e10d40 --- /dev/null +++ b/tests/TUnit.TestProject/Bugs/_7108/PublicObjectFieldDataSourceTests.cs @@ -0,0 +1,29 @@ +using TUnit.TestProject.Attributes; + +namespace TUnit.TestProject.Bugs._7108; + +/// +/// A field declared as object does not say whether it holds one row or many, so both modes decide from the +/// value it holds at run time: an array gives one row per element. +/// +[EngineTest(ExpectedResult.Pass)] +public class PublicObjectFieldDataSourceTests +{ + public static readonly object StaticObjectFieldRows = new[] { 51, 52 }; + + public readonly object InstanceObjectFieldRows = new[] { 53, 54 }; + + [Test] + [MethodDataSource(nameof(StaticObjectFieldRows))] + public async Task Static_Object_Field_Holding_An_Array_Yields_A_Row_Per_Element(int value) + { + await Assert.That(value).IsBetween(51, 52); + } + + [Test] + [MethodDataSource(nameof(InstanceObjectFieldRows))] + public async Task Instance_Object_Field_Holding_An_Array_Yields_A_Row_Per_Element(int value) + { + await Assert.That(value).IsBetween(53, 54); + } +} diff --git a/tests/TUnit.UnitTests/DataSourceFactoriesRuntimeValueTests.cs b/tests/TUnit.UnitTests/DataSourceFactoriesRuntimeValueTests.cs new file mode 100644 index 00000000000..d4bf6f5fd60 --- /dev/null +++ b/tests/TUnit.UnitTests/DataSourceFactoriesRuntimeValueTests.cs @@ -0,0 +1,66 @@ +using TUnit.Core.Enums; +using TUnit.Core.Helpers; + +namespace TUnit.UnitTests; + +/// +/// Tests for and , +/// which the generated factory uses for a private data member whose declared type does not give the row shape. +/// +public class DataSourceFactoriesRuntimeValueTests +{ + [Test] + public async Task FromRuntimeValue_Null_Yields_One_Row_Holding_Null() + { + var rows = await ReadRowsAsync(DataSourceFactories.FromRuntimeValue(CreateMetadata(instance: null), static () => null)); + + await Assert.That(rows).Count().IsEqualTo(1); + await Assert.That(rows[0]).IsNotNull(); + await Assert.That(rows[0]!).Count().IsEqualTo(1); + await Assert.That(rows[0]![0]).IsNull(); + } + + [Test] + public async Task FromInstanceRuntimeValue_Null_Yields_One_Row_Holding_Null() + { + var rows = await ReadRowsAsync(DataSourceFactories.FromInstanceRuntimeValue(CreateMetadata(instance: new object()), static _ => null)); + + await Assert.That(rows).Count().IsEqualTo(1); + await Assert.That(rows[0]).IsNotNull(); + await Assert.That(rows[0]!).Count().IsEqualTo(1); + await Assert.That(rows[0]![0]).IsNull(); + } + + [Test] + public async Task FromRuntimeValue_Array_Yields_A_Row_Per_Element() + { + var rows = await ReadRowsAsync(DataSourceFactories.FromRuntimeValue(CreateMetadata(instance: null), static () => new[] { 1, 2 })); + + await Assert.That(rows).Count().IsEqualTo(2); + await Assert.That(rows[0]![0]).IsEqualTo(1); + await Assert.That(rows[1]![0]).IsEqualTo(2); + } + + private static async Task> ReadRowsAsync(IAsyncEnumerable>> factories) + { + var rows = new List(); + await foreach (var factory in factories) + { + rows.Add(await factory()); + } + + return rows; + } + + private static DataGeneratorMetadata CreateMetadata(object? instance) => new() + { + // Not read when turning a value into rows. + TestBuilderContext = null!, + MembersToGenerate = [], + TestInformation = null, + Type = DataGeneratorType.TestParameters, + TestSessionId = string.Empty, + TestClassInstance = instance, + ClassInstanceArguments = null, + }; +}