125 references to CollectionExpressionTypeKind
Microsoft.CodeAnalysis.CSharp (114)
Binder\Binder.ValueChecks.cs (5)
4769var collectionTypeKind = ConversionsBase.GetCollectionExpressionTypeKind(_compilation, expr.Type, out var elementType); 4773case CollectionExpressionTypeKind.ReadOnlySpan: 4776case CollectionExpressionTypeKind.Span: 4778case CollectionExpressionTypeKind.CollectionBuilder: 4800case CollectionExpressionTypeKind.ImplementsIEnumerable:
Binder\Binder_Attributes.cs (1)
917&& node.Conversion.GetCollectionExpressionTypeKind(out _, out _, out _) == CollectionExpressionTypeKind.Array)
Binder\Binder_Conversions.cs (16)
826var collectionTypeKind = conversion.GetCollectionExpressionTypeKind(out var elementType, out MethodSymbol? constructor, out bool isExpanded); 828if (collectionTypeKind == CollectionExpressionTypeKind.None) 849case CollectionExpressionTypeKind.Span: 853case CollectionExpressionTypeKind.ReadOnlySpan: 857case CollectionExpressionTypeKind.CollectionBuilder: 875case CollectionExpressionTypeKind.ImplementsIEnumerable: 889if (collectionTypeKind is CollectionExpressionTypeKind.ImplementsIEnumerable) 937if ((collectionTypeKind is CollectionExpressionTypeKind.ArrayInterface) || 1636if (expr.CollectionTypeKind is CollectionExpressionTypeKind.ImplementsIEnumerable) 1733collectionTypeKind: CollectionExpressionTypeKind.None, 1752var collectionTypeKind = ConversionsBase.GetCollectionExpressionTypeKind(Compilation, targetType, out TypeWithAnnotations elementTypeWithAnnotations); 1755case CollectionExpressionTypeKind.ImplementsIEnumerable: 1756case CollectionExpressionTypeKind.CollectionBuilder: 1762collectionTypeKind == CollectionExpressionTypeKind.CollectionBuilder ? 1775if (collectionTypeKind != CollectionExpressionTypeKind.None) 1781if (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)
1340var collectionTypeKind = ConversionsBase.GetCollectionExpressionTypeKind(binder.Compilation, type, out elementType); 1344case CollectionExpressionTypeKind.None: 1347case CollectionExpressionTypeKind.ImplementsIEnumerable: 1348case CollectionExpressionTypeKind.CollectionBuilder: 1358if (collectionTypeKind == CollectionExpressionTypeKind.ImplementsIEnumerable) 3052var kind1 = conv1.GetCollectionExpressionTypeKind(out TypeSymbol elementType1, out _, out _); 3053var kind2 = conv2.GetCollectionExpressionTypeKind(out TypeSymbol elementType2, out _, out _); 3082TypeSymbol t1, CollectionExpressionTypeKind kind1, TypeSymbol elementType1, ImmutableArray<Conversion> underlyingElementConversions1, 3083TypeSymbol t2, CollectionExpressionTypeKind kind2, TypeSymbol elementType2, ImmutableArray<Conversion> underlyingElementConversions2, 3094var t1IsSpanType = kind1 is CollectionExpressionTypeKind.ReadOnlySpan or CollectionExpressionTypeKind.Span; 3095var t2IsSpanType = kind2 is CollectionExpressionTypeKind.ReadOnlySpan or CollectionExpressionTypeKind.Span; 3175case (CollectionExpressionTypeKind.ReadOnlySpan, CollectionExpressionTypeKind.Span): 3176case (CollectionExpressionTypeKind.ReadOnlySpan or CollectionExpressionTypeKind.Span, _) when IsSZArrayOrArrayInterface(t2, out _): 3179case (CollectionExpressionTypeKind.Span, CollectionExpressionTypeKind.ReadOnlySpan): 3180case (_, CollectionExpressionTypeKind.ReadOnlySpan or CollectionExpressionTypeKind.Span) when IsSZArrayOrArrayInterface(t1, out _): 3189TypeSymbol t1, CollectionExpressionTypeKind kind1, TypeSymbol elementType1, 3190TypeSymbol t2, CollectionExpressionTypeKind kind2, TypeSymbol elementType2, 3196if (kind1 is CollectionExpressionTypeKind.ReadOnlySpan && 3197kind2 is CollectionExpressionTypeKind.Span) 3204if (kind1 is (CollectionExpressionTypeKind.ReadOnlySpan or CollectionExpressionTypeKind.Span)) 3211Debug.Assert(kind1 is not (CollectionExpressionTypeKind.ReadOnlySpan or CollectionExpressionTypeKind.Span)); 3212if (kind2 is not (CollectionExpressionTypeKind.ReadOnlySpan or CollectionExpressionTypeKind.Span) && 3226CollectionExpressionTypeKind kind1 = ConversionsBase.GetCollectionExpressionTypeKind(Compilation, t1, out TypeWithAnnotations elementType1); 3227CollectionExpressionTypeKind kind2 = ConversionsBase.GetCollectionExpressionTypeKind(Compilation, t2, out TypeWithAnnotations elementType2); 3229if (kind1 is CollectionExpressionTypeKind.CollectionBuilder or CollectionExpressionTypeKind.ImplementsIEnumerable) 3234if (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)
6460public 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) 6479public CollectionExpressionTypeKind CollectionTypeKind { get; } 6491public 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)); 578internal static bool IsAllocatingRefStructCollectionExpression(BoundCollectionExpressionBase node, CollectionExpressionTypeKind collectionKind, TypeSymbol? elementType, CSharpCompilation compilation) 580return collectionKind is CollectionExpressionTypeKind.Span or CollectionExpressionTypeKind.ReadOnlySpan 583&& !(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)); 32473Assert.Equal(CollectionExpressionTypeKind.CollectionBuilder, ConversionsBase.GetCollectionExpressionTypeKind(comp, collectionType, out var elementType)); 32533Assert.Equal(CollectionExpressionTypeKind.CollectionBuilder, ConversionsBase.GetCollectionExpressionTypeKind(comp, collectionType, out _)); 32744Assert.Equal(CollectionExpressionTypeKind.ImplementsIEnumerable, ConversionsBase.GetCollectionExpressionTypeKind(comp, collectionType, out _)); 32768Assert.Equal(CollectionExpressionTypeKind.ImplementsIEnumerable, ConversionsBase.GetCollectionExpressionTypeKind(comp, collectionType, out _)); 32803Assert.Equal(CollectionExpressionTypeKind.ImplementsIEnumerable, ConversionsBase.GetCollectionExpressionTypeKind(comp, collectionType, out _)); 32825Assert.Equal(CollectionExpressionTypeKind.ImplementsIEnumerable, ConversionsBase.GetCollectionExpressionTypeKind(comp, collectionType, out _)); 32857Assert.Equal(CollectionExpressionTypeKind.None, ConversionsBase.GetCollectionExpressionTypeKind(comp, collectionType, out _)); 32879Assert.Equal(CollectionExpressionTypeKind.None, ConversionsBase.GetCollectionExpressionTypeKind(comp, collectionType, out _));