diff --git a/GFramework.SourceGenerators/Rule/ContextGetGenerator.cs b/GFramework.SourceGenerators/Rule/ContextGetGenerator.cs index 9248f81..4186e52 100644 --- a/GFramework.SourceGenerators/Rule/ContextGetGenerator.cs +++ b/GFramework.SourceGenerators/Rule/ContextGetGenerator.cs @@ -711,11 +711,11 @@ public sealed class ContextGetGenerator : IIncrementalGenerator if (readOnlyList is null || fieldType is not INamedTypeSymbol targetType) return false; - foreach (var candidateType in EnumerateCollectionTypeCandidates(targetType)) - { - if (candidateType is not { TypeArguments: [var candidateElementType] }) - continue; + var allTypeCandidates = EnumerateCollectionTypeCandidates(targetType) + .SelectMany(candidateType => candidateType.TypeArguments); + foreach (var candidateElementType in allTypeCandidates) + { var expectedSourceType = readOnlyList.Construct(candidateElementType); if (!expectedSourceType.IsAssignableTo(targetType)) continue; @@ -724,10 +724,10 @@ public sealed class ContextGetGenerator : IIncrementalGenerator return true; } + return false; } - private static IEnumerable EnumerateCollectionTypeCandidates(INamedTypeSymbol typeSymbol) { yield return typeSymbol;