diff --git a/TUnit.Core.SourceGenerator/CodeGenerationHelpers.cs b/TUnit.Core.SourceGenerator/CodeGenerationHelpers.cs
index 0adf4b89c7..daac82b9e0 100644
--- a/TUnit.Core.SourceGenerator/CodeGenerationHelpers.cs
+++ b/TUnit.Core.SourceGenerator/CodeGenerationHelpers.cs
@@ -109,7 +109,7 @@ public static string GenerateAttributeInstantiation(AttributeData attr, Immutabl
var arg = attr.ConstructorArguments[i];
// Check if this is a params array parameter
- if (i == attr.ConstructorArguments.Length - 1 && IsParamsArrayArgument(attr, i))
+ if (i == attr.ConstructorArguments.Length - 1 && IsParamsArrayArgument(attr))
{
if (arg.Kind == TypedConstantKind.Array)
{
@@ -282,16 +282,11 @@ public static string GenerateAttributeInstantiation(AttributeData attr, Immutabl
///
/// Determines if an argument is for a params array parameter.
///
- private static bool IsParamsArrayArgument(AttributeData attr, int argumentIndex)
+ private static bool IsParamsArrayArgument(AttributeData attr)
{
var typeName = attr.AttributeClass!.GloballyQualified();
- if (typeName is "global::TUnit.Core.ArgumentsAttribute" or "global::TUnit.Core.InlineDataAttribute")
- {
- return true;
- }
-
- return false;
+ return typeName is "global::TUnit.Core.ArgumentsAttribute" or "global::TUnit.Core.InlineDataAttribute";
}
diff --git a/TUnit.Core.SourceGenerator/CodeGenerators/Helpers/InstanceFactoryGenerator.cs b/TUnit.Core.SourceGenerator/CodeGenerators/Helpers/InstanceFactoryGenerator.cs
index 3109b51e3f..daff8f2a26 100644
--- a/TUnit.Core.SourceGenerator/CodeGenerators/Helpers/InstanceFactoryGenerator.cs
+++ b/TUnit.Core.SourceGenerator/CodeGenerators/Helpers/InstanceFactoryGenerator.cs
@@ -81,7 +81,7 @@ public static void GenerateInstanceFactory(CodeWriter writer, ITypeSymbol typeSy
var constructor = GetPrimaryConstructor(typeSymbol);
if (constructor != null)
{
- GenerateTypedConstructorCall(writer, className, constructor, testMethod);
+ GenerateTypedConstructorCall(writer, className, constructor);
}
else
{
@@ -145,7 +145,7 @@ public static void GenerateInstanceFactory(CodeWriter writer, ITypeSymbol typeSy
return publicConstructors.Length == 1 ? publicConstructors[0] : publicConstructors.FirstOrDefault();
}
- private static void GenerateTypedConstructorCall(CodeWriter writer, string className, IMethodSymbol constructor, TestMethodMetadata? testMethod)
+ private static void GenerateTypedConstructorCall(CodeWriter writer, string className, IMethodSymbol constructor)
{
writer.AppendLine("InstanceFactory = (typeArgs, args) =>");
writer.AppendLine("{");
@@ -164,17 +164,17 @@ private static void GenerateTypedConstructorCall(CodeWriter writer, string class
// Generate constructor arguments
var parameterTypes = constructor.Parameters.Select(p => p.Type).ToList();
-
+
for (var i = 0; i < parameterTypes.Count; i++)
{
if (i > 0)
{
writer.Append(", ");
}
-
+
var parameterType = parameterTypes[i];
var argAccess = $"args[{i}]";
-
+
// Use CastHelper which now has AOT converter registry support
writer.Append($"global::TUnit.Core.Helpers.CastHelper.Cast<{parameterType.GloballyQualified()}>({argAccess})");
}
@@ -214,11 +214,11 @@ private static void GenerateGenericInstanceFactory(CodeWriter writer, INamedType
// Get the open generic type
writer.AppendLine($"var openGenericType = typeof({genericType.OriginalDefinition.GloballyQualified()});");
writer.AppendLine();
-
+
// Create the closed generic type
writer.AppendLine("var closedGenericType = global::TUnit.Core.Helpers.GenericTypeHelper.MakeGenericTypeSafe(openGenericType, typeArgs);");
writer.AppendLine();
-
+
// Check for constructor parameters
var constructor = GetPrimaryConstructor(genericType);
if (constructor is { Parameters.Length: > 0 })
@@ -230,7 +230,7 @@ private static void GenerateGenericInstanceFactory(CodeWriter writer, INamedType
{
writer.AppendLine("// Create instance with parameterless constructor");
writer.AppendLine("var instance = global::System.Activator.CreateInstance(closedGenericType);");
-
+
// Check for required properties
var requiredProperties = RequiredPropertyHelper.GetAllRequiredProperties(genericType);
if (requiredProperties.Any())
@@ -243,7 +243,7 @@ private static void GenerateGenericInstanceFactory(CodeWriter writer, INamedType
writer.AppendLine($"closedGenericType.GetProperty(\"{property.Name}\")?.SetValue(instance, {defaultValue});");
}
}
-
+
writer.AppendLine("return instance!;");
}
diff --git a/TUnit.Core.SourceGenerator/CodeGenerators/StaticPropertyInitializationGenerator.cs b/TUnit.Core.SourceGenerator/CodeGenerators/StaticPropertyInitializationGenerator.cs
index ca4808fda7..05f435af76 100644
--- a/TUnit.Core.SourceGenerator/CodeGenerators/StaticPropertyInitializationGenerator.cs
+++ b/TUnit.Core.SourceGenerator/CodeGenerators/StaticPropertyInitializationGenerator.cs
@@ -72,7 +72,7 @@ private static void GenerateStaticPropertyInitialization(SourceProductionContext
// Use a dictionary to deduplicate static properties by their declaring type and name
// This prevents duplicate initialization when derived classes inherit static properties
var uniqueStaticProperties = new Dictionary<(INamedTypeSymbol DeclaringType, string Name), PropertyWithDataSource>(SymbolEqualityComparer.Default.ToTupleComparer());
-
+
foreach (var testClass in testClasses)
{
var properties = GetStaticPropertyDataSources(testClass);
@@ -87,7 +87,7 @@ private static void GenerateStaticPropertyInitialization(SourceProductionContext
}
}
}
-
+
var allStaticProperties = uniqueStaticProperties.Values.ToImmutableArray();
if (allStaticProperties.IsEmpty)
@@ -109,14 +109,14 @@ private static string GenerateInitializationCode(ImmutableArray");
writer.AppendLine("/// Auto-generated static property initializer");
writer.AppendLine("/// ");
writer.AppendLine("internal static class StaticPropertyInitializer");
writer.AppendLine("{");
writer.Indent();
-
+
writer.AppendLine("/// ");
writer.AppendLine("/// Module initializer that registers static property metadata");
writer.AppendLine("/// ");
@@ -179,7 +179,7 @@ private static void GenerateIndividualPropertyInitializer(CodeWriter writer, Pro
writer.AppendLine($"private static async global::System.Threading.Tasks.Task