125 references to CollectionExpressionTypeKind
Microsoft.CodeAnalysis.CSharp (114)
Binder\Binder.ValueChecks.cs (5)
4778var collectionTypeKind = ConversionsBase.GetCollectionExpressionTypeKind(_compilation, expr.Type, out var elementType); 4782case CollectionExpressionTypeKind.ReadOnlySpan: 4785case CollectionExpressionTypeKind.Span: 4787case CollectionExpressionTypeKind.CollectionBuilder: 4809case CollectionExpressionTypeKind.ImplementsIEnumerable:
Binder\Binder_Attributes.cs (1)
917&& node.Conversion.GetCollectionExpressionTypeKind(out _, out _, out _) == CollectionExpressionTypeKind.Array)
Binder\Binder_Conversions.cs (16)
820var collectionTypeKind = conversion.GetCollectionExpressionTypeKind(out var elementType, out MethodSymbol? constructor, out bool isExpanded); 822if (collectionTypeKind == CollectionExpressionTypeKind.None) 843case CollectionExpressionTypeKind.Span: 847case CollectionExpressionTypeKind.ReadOnlySpan: 851case CollectionExpressionTypeKind.CollectionBuilder: 869case CollectionExpressionTypeKind.ImplementsIEnumerable: 883if (collectionTypeKind is CollectionExpressionTypeKind.ImplementsIEnumerable) 931if ((collectionTypeKind is CollectionExpressionTypeKind.ArrayInterface) || 1630if (expr.CollectionTypeKind is CollectionExpressionTypeKind.ImplementsIEnumerable) 1727collectionTypeKind: CollectionExpressionTypeKind.None, 1746var collectionTypeKind = ConversionsBase.GetCollectionExpressionTypeKind(Compilation, targetType, out TypeWithAnnotations elementTypeWithAnnotations); 1749case CollectionExpressionTypeKind.ImplementsIEnumerable: 1750case CollectionExpressionTypeKind.CollectionBuilder: 1756collectionTypeKind == CollectionExpressionTypeKind.CollectionBuilder ? 1769if (collectionTypeKind != CollectionExpressionTypeKind.None) 1775if (collectionTypeKind == CollectionExpressionTypeKind.ImplementsIEnumerable)
Binder\Semantics\Conversions\Conversion.cs (6)
110CollectionExpressionTypeKind collectionExpressionTypeKind, TypeSymbol elementType, 115Debug.Assert(collectionExpressionTypeKind != CollectionExpressionTypeKind.None); 123internal readonly CollectionExpressionTypeKind CollectionExpressionTypeKind; 130CollectionExpressionTypeKind collectionExpressionTypeKind, TypeSymbol elementType, 547internal CollectionExpressionTypeKind GetCollectionExpressionTypeKind(out TypeSymbol? elementType, out MethodSymbol? constructor, out bool isExpanded) 560return CollectionExpressionTypeKind.None;
Binder\Semantics\Conversions\Conversions.cs (5)
165var collectionTypeKind = GetCollectionExpressionTypeKind(Compilation, targetType, out TypeWithAnnotations elementTypeWithAnnotations); 169case CollectionExpressionTypeKind.None: 172case CollectionExpressionTypeKind.ImplementsIEnumerable: 173case CollectionExpressionTypeKind.CollectionBuilder: 191if (collectionTypeKind == CollectionExpressionTypeKind.ImplementsIEnumerable)
Binder\Semantics\Conversions\ConversionsBase.cs (8)
1654internal static CollectionExpressionTypeKind GetCollectionExpressionTypeKind(CSharpCompilation compilation, TypeSymbol destination, out TypeWithAnnotations elementType) 1663return CollectionExpressionTypeKind.Array; 1668return CollectionExpressionTypeKind.Span; 1672return CollectionExpressionTypeKind.ReadOnlySpan; 1677return CollectionExpressionTypeKind.CollectionBuilder; 1688return CollectionExpressionTypeKind.ImplementsIEnumerable; 1692return CollectionExpressionTypeKind.ArrayInterface; 1696return CollectionExpressionTypeKind.None;
Binder\Semantics\OverloadResolution\OverloadResolution.cs (37)
1334var collectionTypeKind = ConversionsBase.GetCollectionExpressionTypeKind(binder.Compilation, type, out elementType); 1338case CollectionExpressionTypeKind.None: 1341case CollectionExpressionTypeKind.ImplementsIEnumerable: 1342case CollectionExpressionTypeKind.CollectionBuilder: 1352if (collectionTypeKind == CollectionExpressionTypeKind.ImplementsIEnumerable) 3046var kind1 = conv1.GetCollectionExpressionTypeKind(out TypeSymbol elementType1, out _, out _); 3047var kind2 = conv2.GetCollectionExpressionTypeKind(out TypeSymbol elementType2, out _, out _); 3076TypeSymbol t1, CollectionExpressionTypeKind kind1, TypeSymbol elementType1, ImmutableArray<Conversion> underlyingElementConversions1, 3077TypeSymbol t2, CollectionExpressionTypeKind kind2, TypeSymbol elementType2, ImmutableArray<Conversion> underlyingElementConversions2, 3088var t1IsSpanType = kind1 is CollectionExpressionTypeKind.ReadOnlySpan or CollectionExpressionTypeKind.Span; 3089var t2IsSpanType = kind2 is CollectionExpressionTypeKind.ReadOnlySpan or CollectionExpressionTypeKind.Span; 3169case (CollectionExpressionTypeKind.ReadOnlySpan, CollectionExpressionTypeKind.Span): 3170case (CollectionExpressionTypeKind.ReadOnlySpan or CollectionExpressionTypeKind.Span, _) when IsSZArrayOrArrayInterface(t2, out _): 3173case (CollectionExpressionTypeKind.Span, CollectionExpressionTypeKind.ReadOnlySpan): 3174case (_, CollectionExpressionTypeKind.ReadOnlySpan or CollectionExpressionTypeKind.Span) when IsSZArrayOrArrayInterface(t1, out _): 3183TypeSymbol t1, CollectionExpressionTypeKind kind1, TypeSymbol elementType1, 3184TypeSymbol t2, CollectionExpressionTypeKind kind2, TypeSymbol elementType2, 3190if (kind1 is CollectionExpressionTypeKind.ReadOnlySpan && 3191kind2 is CollectionExpressionTypeKind.Span) 3198if (kind1 is (CollectionExpressionTypeKind.ReadOnlySpan or CollectionExpressionTypeKind.Span)) 3205Debug.Assert(kind1 is not (CollectionExpressionTypeKind.ReadOnlySpan or CollectionExpressionTypeKind.Span)); 3206if (kind2 is not (CollectionExpressionTypeKind.ReadOnlySpan or CollectionExpressionTypeKind.Span) && 3220CollectionExpressionTypeKind kind1 = ConversionsBase.GetCollectionExpressionTypeKind(Compilation, t1, out TypeWithAnnotations elementType1); 3221CollectionExpressionTypeKind kind2 = ConversionsBase.GetCollectionExpressionTypeKind(Compilation, t2, out TypeWithAnnotations elementType2); 3223if (kind1 is CollectionExpressionTypeKind.CollectionBuilder or CollectionExpressionTypeKind.ImplementsIEnumerable) 3228if (kind2 is CollectionExpressionTypeKind.CollectionBuilder or CollectionExpressionTypeKind.ImplementsIEnumerable)
FlowAnalysis\NullableWalker.cs (6)
4021static NullableFlowState getResultState(BoundCollectionExpression node, CollectionExpressionTypeKind collectionKind) 4023if (collectionKind is CollectionExpressionTypeKind.CollectionBuilder) 4036(CollectionExpressionTypeKind, TypeWithAnnotations) getCollectionDetails(BoundCollectionExpression node, TypeSymbol collectionType) 4038var collectionKind = ConversionsBase.GetCollectionExpressionTypeKind(this.compilation, collectionType, out var targetElementType); 4039if (collectionKind is CollectionExpressionTypeKind.CollectionBuilder) 4048else if (collectionKind is CollectionExpressionTypeKind.ImplementsIEnumerable)
FlowAnalysis\NullableWalker.DebugVerifier.cs (1)
126bool hasElementType = node.CollectionTypeKind is not CollectionExpressionTypeKind.None;
Generated\BoundNodes.xml.Generated.cs (3)
6439public BoundCollectionExpression(SyntaxNode syntax, CollectionExpressionTypeKind collectionTypeKind, BoundObjectOrCollectionValuePlaceholder? placeholder, BoundExpression? collectionCreation, MethodSymbol? collectionBuilderMethod, BoundValuePlaceholder? collectionBuilderInvocationPlaceholder, BoundExpression? collectionBuilderInvocationConversion, bool wasTargetTyped, BoundUnconvertedCollectionExpression unconvertedCollectionExpression, ImmutableArray<BoundNode> elements, TypeSymbol type, bool hasErrors = false) 6458public CollectionExpressionTypeKind CollectionTypeKind { get; } 6470public BoundCollectionExpression Update(CollectionExpressionTypeKind collectionTypeKind, BoundObjectOrCollectionValuePlaceholder? placeholder, BoundExpression? collectionCreation, MethodSymbol? collectionBuilderMethod, BoundValuePlaceholder? collectionBuilderInvocationPlaceholder, BoundExpression? collectionBuilderInvocationConversion, bool wasTargetTyped, BoundUnconvertedCollectionExpression unconvertedCollectionExpression, ImmutableArray<BoundNode> elements, TypeSymbol type)
Lowering\LocalRewriter\LocalRewriter_CollectionExpression.cs (14)
40var collectionTypeKind = conversion.GetCollectionExpressionTypeKind(out var elementType, out _, out _); 43case CollectionExpressionTypeKind.ImplementsIEnumerable: 57case CollectionExpressionTypeKind.Array: 58case CollectionExpressionTypeKind.Span: 59case CollectionExpressionTypeKind.ReadOnlySpan: 62case CollectionExpressionTypeKind.CollectionBuilder: 70case CollectionExpressionTypeKind.ArrayInterface: 309Debug.Assert(!IsAllocatingRefStructCollectionExpression(node, CollectionExpressionTypeKind.ReadOnlySpan, elementType.Type, _compilation)); 319Debug.Assert(!IsAllocatingRefStructCollectionExpression(node, isReadOnlySpan ? CollectionExpressionTypeKind.ReadOnlySpan : CollectionExpressionTypeKind.Span, elementType.Type, _compilation)); 575internal static bool IsAllocatingRefStructCollectionExpression(BoundCollectionExpressionBase node, CollectionExpressionTypeKind collectionKind, TypeSymbol? elementType, CSharpCompilation compilation) 577return collectionKind is CollectionExpressionTypeKind.Span or CollectionExpressionTypeKind.ReadOnlySpan 580&& !(collectionKind == CollectionExpressionTypeKind.ReadOnlySpan && ShouldUseRuntimeHelpersCreateSpan(node, elementType))
Operations\CSharpOperationFactory.cs (7)
1242case CollectionExpressionTypeKind.None: 1243case CollectionExpressionTypeKind.Array: 1244case CollectionExpressionTypeKind.ArrayInterface: 1245case CollectionExpressionTypeKind.ReadOnlySpan: 1246case CollectionExpressionTypeKind.Span: 1248case CollectionExpressionTypeKind.ImplementsIEnumerable: 1250case CollectionExpressionTypeKind.CollectionBuilder:
Symbols\Source\SourceComplexParameterSymbol.cs (5)
1618var collectionTypeKind = ConversionsBase.GetCollectionExpressionTypeKind(DeclaringCompilation, Type, out TypeWithAnnotations elementTypeWithAnnotations); 1623case CollectionExpressionTypeKind.None: 1627case CollectionExpressionTypeKind.ImplementsIEnumerable: 1685case CollectionExpressionTypeKind.CollectionBuilder: 1714if (collectionTypeKind != CollectionExpressionTypeKind.Array)
Microsoft.CodeAnalysis.CSharp.Emit3.UnitTests (11)
Semantics\CollectionExpressionTests.cs (11)
4990Assert.Equal(CollectionExpressionTypeKind.ImplementsIEnumerable, ConversionsBase.GetCollectionExpressionTypeKind(comp, collectionType, out _)); 5045Assert.Equal(CollectionExpressionTypeKind.ImplementsIEnumerable, ConversionsBase.GetCollectionExpressionTypeKind(comp, collectionType, out _)); 6109Assert.Equal(CollectionExpressionTypeKind.None, ConversionsBase.GetCollectionExpressionTypeKind(comp, listType, out var elementType)); 32381Assert.Equal(CollectionExpressionTypeKind.CollectionBuilder, ConversionsBase.GetCollectionExpressionTypeKind(comp, collectionType, out var elementType)); 32441Assert.Equal(CollectionExpressionTypeKind.CollectionBuilder, ConversionsBase.GetCollectionExpressionTypeKind(comp, collectionType, out _)); 32652Assert.Equal(CollectionExpressionTypeKind.ImplementsIEnumerable, ConversionsBase.GetCollectionExpressionTypeKind(comp, collectionType, out _)); 32676Assert.Equal(CollectionExpressionTypeKind.ImplementsIEnumerable, ConversionsBase.GetCollectionExpressionTypeKind(comp, collectionType, out _)); 32711Assert.Equal(CollectionExpressionTypeKind.ImplementsIEnumerable, ConversionsBase.GetCollectionExpressionTypeKind(comp, collectionType, out _)); 32733Assert.Equal(CollectionExpressionTypeKind.ImplementsIEnumerable, ConversionsBase.GetCollectionExpressionTypeKind(comp, collectionType, out _)); 32765Assert.Equal(CollectionExpressionTypeKind.None, ConversionsBase.GetCollectionExpressionTypeKind(comp, collectionType, out _)); 32787Assert.Equal(CollectionExpressionTypeKind.None, ConversionsBase.GetCollectionExpressionTypeKind(comp, collectionType, out _));