33using Microsoft . CodeAnalysis . CSharp . Syntax ;
44using NetFabric . CodeAnalysis ;
55using System ;
6+ using System . Collections . Generic ;
67using System . Threading ;
78
89namespace NetFabric . Hyperlinq . SourceGenerator
@@ -11,22 +12,28 @@ public partial class Generator
1112 {
1213 static bool HandleAsValueEnumerable ( Compilation compilation , TypeSymbolsCache typeSymbolsCache , MemberAccessExpressionSyntax expressionSyntax , CodeBuilder builder , CancellationToken cancellationToken , bool isUnitTest )
1314 {
14- // Get the type this operator is applied to
1515 var semanticModel = compilation . GetSemanticModel ( expressionSyntax . SyntaxTree ) ;
16+
17+ // Check if an extension method is defined for this type
18+ if ( semanticModel . GetSymbolInfo ( expressionSyntax ) . Symbol is not null )
19+ return false ;
20+
21+ // Get the type this operator is applied to
1622 var receiverTypeSymbol = semanticModel . GetTypeInfo ( expressionSyntax . Expression ) . Type ;
1723
1824 // Check if NetFabric.Hyperlinq already contains specific overloads for this type
19- if ( receiverTypeSymbol is null
25+ // This is required for when the 'using NetFabric.Hyperlinq;' statement is missing
26+ if ( receiverTypeSymbol is null
2027 or { TypeKind : TypeKind . Array } // is array
2128 || SymbolEqualityComparer . Default . Equals ( receiverTypeSymbol . OriginalDefinition , typeSymbolsCache [ typeof ( ArraySegment < > ) ] )
2229 || SymbolEqualityComparer . Default . Equals ( receiverTypeSymbol . OriginalDefinition , typeSymbolsCache [ typeof ( Span < > ) ] )
2330 || SymbolEqualityComparer . Default . Equals ( receiverTypeSymbol . OriginalDefinition , typeSymbolsCache [ typeof ( ReadOnlySpan < > ) ] )
2431 || SymbolEqualityComparer . Default . Equals ( receiverTypeSymbol . OriginalDefinition , typeSymbolsCache [ typeof ( Memory < > ) ] )
2532 || SymbolEqualityComparer . Default . Equals ( receiverTypeSymbol . OriginalDefinition , typeSymbolsCache [ typeof ( ReadOnlyMemory < > ) ] )
33+ || SymbolEqualityComparer . Default . Equals ( receiverTypeSymbol . OriginalDefinition , typeSymbolsCache [ typeof ( List < > ) ] )
2634 )
2735 return false ; // no need to generate an implementation
2836
29- // Generate the method source depending on receiver type characteristics
3037 var receiverTypeString = receiverTypeSymbol . ToDisplayString ( ) ;
3138
3239 // Receiver type implements IValueEnumerable<,>
0 commit comments