Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Clean up whitespace and remove unnecessary comments in TestMetadataGe…
…nerator.cs
  • Loading branch information
thomhurst committed Aug 14, 2025
commit 2ced42dac11c7fd247787630ac25a09cddc79c89
18 changes: 8 additions & 10 deletions TUnit.Core.SourceGenerator/Generators/TestMetadataGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ private static void GenerateInheritedTestSources(SourceProductionContext context

// Find the concrete implementation of this method in the derived class
var concreteMethod = FindConcreteMethodImplementation(classInfo.TypeSymbol, method);

// Calculate inheritance depth for this test
int inheritanceDepth = CalculateInheritanceDepth(classInfo.TypeSymbol, method);

Expand Down Expand Up @@ -159,11 +159,11 @@ private static int CalculateInheritanceDepth(INamedTypeSymbol testClass, IMethod
{
return 0;
}

// Count how many levels up the inheritance chain the method is declared
int depth = 0;
INamedTypeSymbol? currentType = testClass.BaseType;

while (currentType != null)
{
depth++;
Expand All @@ -173,7 +173,7 @@ private static int CalculateInheritanceDepth(INamedTypeSymbol testClass, IMethod
}
currentType = currentType.BaseType;
}

// This shouldn't happen in normal cases, but return the depth anyway
return depth;
}
Expand Down Expand Up @@ -361,7 +361,7 @@ private static void GenerateSpecificGenericInstantiation(

// Generate AOT-friendly invokers that use the specific types
GenerateAotFriendlyInvokers(writer, testMethod, className, typeArguments);

// Add file location metadata
writer.AppendLine($"FilePath = @\"{testMethod.FilePath.Replace("\\", "\\\\")}\",");
writer.AppendLine($"LineNumber = {testMethod.LineNumber},");
Expand Down Expand Up @@ -562,7 +562,7 @@ private static void GenerateMetadata(CodeWriter writer, Compilation compilation,

// Inheritance depth
writer.AppendLine($"InheritanceDepth = {testMethod.InheritanceDepth},");

// File location metadata
writer.AppendLine($"FilePath = @\"{testMethod.FilePath.Replace("\\", "\\\\")}\",");
writer.AppendLine($"LineNumber = {testMethod.LineNumber},");
Expand Down Expand Up @@ -606,7 +606,7 @@ private static void GenerateMetadataForConcreteInstantiation(CodeWriter writer,

// Inheritance depth
writer.AppendLine($"InheritanceDepth = {testMethod.InheritanceDepth},");

// File location metadata
writer.AppendLine($"FilePath = @\"{testMethod.FilePath.Replace("\\", "\\\\")}\",");
writer.AppendLine($"LineNumber = {testMethod.LineNumber},");
Expand Down Expand Up @@ -1550,7 +1550,6 @@ private static void GenerateConcreteTestInvoker(CodeWriter writer, TestMethodMet
var requiredParamCount = parametersFromArgs.Count(p => !p.HasExplicitDefaultValue && !p.IsOptional && !p.IsParams);

// Generate runtime logic to handle variable argument counts
writer.AppendLine("// Invoke with only the arguments that were provided");
writer.AppendLine("switch (args.Length)");
writer.AppendLine("{");
writer.Indent();
Expand Down Expand Up @@ -1643,7 +1642,6 @@ private static void GenerateConcreteTestInvoker(CodeWriter writer, TestMethodMet
var requiredParamCount = parametersFromArgs.Count(p => !p.HasExplicitDefaultValue && !p.IsOptional && !p.IsParams);

// Generate runtime logic to handle variable argument counts
writer.AppendLine("// Invoke with only the arguments that were provided");
writer.AppendLine("switch (args.Length)");
writer.AppendLine("{");
writer.Indent();
Expand Down Expand Up @@ -4250,7 +4248,7 @@ private static void GenerateConcreteTestMetadataForNonGeneric(

// Generate typed invoker
GenerateTypedInvokers(writer, testMethod, className);

// Add file location metadata
writer.AppendLine($"FilePath = @\"{testMethod.FilePath.Replace("\\", "\\\\")}\",");
writer.AppendLine($"LineNumber = {testMethod.LineNumber},");
Expand Down