Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion TUnit.Analyzers/TestDataAnalyzer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ private void AnalyzeMethod(SymbolAnalysisContext context)

var attributes = methodSymbol.GetAttributes();

Analyze(context, attributes, methodSymbol.Parameters.WithoutCancellationTokenParameter().ToImmutableArray(), null, methodSymbol.ContainingType);
Analyze(context, attributes, methodSymbol.Parameters.WithoutCancellationTokenParameter(), null, methodSymbol.ContainingType);
}

private void AnalyzeProperty(SymbolAnalysisContext context)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public void Initialize(IncrementalGeneratorInitializationContext context)
predicate: (node, _) => node is ClassDeclarationSyntax,
transform: (ctx, _) => GetGenericCreateAssertionAttributeData(ctx, "AssertionFromAttribute"))
.Where(x => x != null)
.SelectMany((x, _) => x!.ToImmutableArray());
.SelectMany((x, _) => x!);

// Combine all sources
var allAttributeData = nonGenericAssertionFromData.Collect()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public void Initialize(IncrementalGeneratorInitializationContext context)
.CreateSyntaxProvider(
predicate: static (node, _) => node is TypeDeclarationSyntax or PropertyDeclarationSyntax,
transform: static (ctx, _) => ExtractConcreteGenericTypes(ctx))
.Where(static x => x.Length > 0)
.Where(static x => x.Count > 0)
.SelectMany(static (types, _) => types);

// Collect and deduplicate by fully qualified type name
Expand Down Expand Up @@ -326,17 +326,17 @@ private static IEnumerable<ClassPropertyInjectionModel> GroupPropertiesByClass(
/// 1. Inheritance chains (base types)
/// 2. IDataSourceAttribute type arguments
/// </summary>
private static ImmutableArray<ConcreteGenericTypeModel> ExtractConcreteGenericTypes(GeneratorSyntaxContext context)
private static List<ConcreteGenericTypeModel> ExtractConcreteGenericTypes(GeneratorSyntaxContext context)
{
var semanticModel = context.SemanticModel;
var results = new List<ConcreteGenericTypeModel>();

var dataSourceInterface = semanticModel.Compilation.GetTypeByMetadataName("TUnit.Core.IDataSourceAttribute");
var asyncInitializerInterface = semanticModel.Compilation.GetTypeByMetadataName("TUnit.Core.Interfaces.IAsyncInitializer");

if (dataSourceInterface == null || asyncInitializerInterface == null)
return ImmutableArray<ConcreteGenericTypeModel>.Empty;
return [];

var results = new List<ConcreteGenericTypeModel>();
// Discovery from type declarations (inheritance chains)
if (context.Node is TypeDeclarationSyntax typeDecl)
{
Expand Down Expand Up @@ -432,7 +432,7 @@ private static ImmutableArray<ConcreteGenericTypeModel> ExtractConcreteGenericTy
}
}

return results.Count > 0 ? results.ToImmutableArray() : ImmutableArray<ConcreteGenericTypeModel>.Empty;
return results;
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5039,8 +5039,7 @@ private static void GenerateConcreteTestMetadataForNonGeneric(

var attributes = filteredMethodAttributes
.Concat(filteredClassAttributes)
.Concat(testMethod.TypeSymbol.ContainingAssembly.GetAttributes())
.ToImmutableArray();
.Concat(testMethod.TypeSymbol.ContainingAssembly.GetAttributes());

testMethod.CompilationContext.AttributeWriter.WriteAttributes(writer, attributes);

Expand Down