138 references to CollectionExpressionTypeKind
Microsoft.CodeAnalysis.CSharp (127)
Binder\Binder.ValueChecks.cs (5)
4795var collectionTypeKind = ConversionsBase.GetCollectionExpressionTypeKind(_compilation, expr.Type, out var elementType); 4798case CollectionExpressionTypeKind.ReadOnlySpan: 4807case CollectionExpressionTypeKind.Span: 4811case CollectionExpressionTypeKind.CollectionBuilder: 4822case CollectionExpressionTypeKind.ImplementsIEnumerable:
Binder\Binder_Attributes.cs (1)
923&& node.Conversion.GetCollectionExpressionTypeKind(out _, out _, out _) == CollectionExpressionTypeKind.Array)
Binder\Binder_Conversions.cs (26)
908CollectionExpressionTypeKind collectionTypeKind, ImmutableArray<BoundNode> elements, BoundObjectOrCollectionValuePlaceholder? placeholder = null, BoundExpression? collectionCreation = null, MethodSymbol? collectionBuilderMethod = null, BoundCollectionBuilderElementsPlaceholder? collectionBuilderElementsPlaceholder = null) 930var collectionTypeKind = _conversion.GetCollectionExpressionTypeKind(out var elementType, out MethodSymbol? constructor, out bool isExpanded); 932if (collectionTypeKind == CollectionExpressionTypeKind.None) 943if (collectionTypeKind != CollectionExpressionTypeKind.ImplementsIEnumerable && 960CollectionExpressionTypeKind collectionTypeKind, 978if (collectionTypeKind == CollectionExpressionTypeKind.ImplementsIEnumerable) 981if (collectionTypeKind is CollectionExpressionTypeKind.ArrayInterface || 1000CollectionExpressionTypeKind.Array or CollectionExpressionTypeKind.Span or CollectionExpressionTypeKind.ReadOnlySpan 1003CollectionExpressionTypeKind.ArrayInterface 1006CollectionExpressionTypeKind.CollectionBuilder 1075CollectionExpressionTypeKind.ImplementsIEnumerable, 1200CollectionExpressionTypeKind collectionTypeKind, 1206case CollectionExpressionTypeKind.Span: 1210case CollectionExpressionTypeKind.ReadOnlySpan: 1240CollectionExpressionTypeKind.ArrayInterface, 1323CollectionExpressionTypeKind.CollectionBuilder, 2203if (expr.CollectionTypeKind is CollectionExpressionTypeKind.ImplementsIEnumerable) 2312collectionTypeKind: CollectionExpressionTypeKind.None, 2334var collectionTypeKind = ConversionsBase.GetCollectionExpressionTypeKind(Compilation, targetType, out TypeWithAnnotations elementTypeWithAnnotations); 2337case CollectionExpressionTypeKind.ImplementsIEnumerable: 2338case CollectionExpressionTypeKind.CollectionBuilder: 2344collectionTypeKind == CollectionExpressionTypeKind.CollectionBuilder ? 2357if (collectionTypeKind != CollectionExpressionTypeKind.None) 2363if (collectionTypeKind == CollectionExpressionTypeKind.ImplementsIEnumerable)
Binder\Semantics\Conversions\Conversion.cs (6)
111CollectionExpressionTypeKind collectionExpressionTypeKind, TypeSymbol elementType, 116Debug.Assert(collectionExpressionTypeKind != CollectionExpressionTypeKind.None); 124internal readonly CollectionExpressionTypeKind CollectionExpressionTypeKind; 131CollectionExpressionTypeKind collectionExpressionTypeKind, TypeSymbol elementType, 573internal CollectionExpressionTypeKind GetCollectionExpressionTypeKind(out TypeSymbol? elementType, out MethodSymbol? constructor, out bool isExpanded) 586return 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)
1669internal static CollectionExpressionTypeKind GetCollectionExpressionTypeKind(CSharpCompilation compilation, TypeSymbol destination, out TypeWithAnnotations elementType) 1678return CollectionExpressionTypeKind.Array; 1683return CollectionExpressionTypeKind.Span; 1687return CollectionExpressionTypeKind.ReadOnlySpan; 1692return CollectionExpressionTypeKind.CollectionBuilder; 1703return CollectionExpressionTypeKind.ImplementsIEnumerable; 1707return CollectionExpressionTypeKind.ArrayInterface; 1711return 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) 3053var kind1 = conv1.GetCollectionExpressionTypeKind(out TypeSymbol elementType1, out _, out _); 3054var kind2 = conv2.GetCollectionExpressionTypeKind(out TypeSymbol elementType2, out _, out _); 3083TypeSymbol t1, CollectionExpressionTypeKind kind1, TypeSymbol elementType1, ImmutableArray<Conversion> underlyingElementConversions1, 3084TypeSymbol t2, CollectionExpressionTypeKind kind2, TypeSymbol elementType2, ImmutableArray<Conversion> underlyingElementConversions2, 3095var t1IsSpanType = kind1 is CollectionExpressionTypeKind.ReadOnlySpan or CollectionExpressionTypeKind.Span; 3096var t2IsSpanType = kind2 is CollectionExpressionTypeKind.ReadOnlySpan or CollectionExpressionTypeKind.Span; 3176case (CollectionExpressionTypeKind.ReadOnlySpan, CollectionExpressionTypeKind.Span): 3177case (CollectionExpressionTypeKind.ReadOnlySpan or CollectionExpressionTypeKind.Span, _) when IsSZArrayOrArrayInterface(t2, out _): 3180case (CollectionExpressionTypeKind.Span, CollectionExpressionTypeKind.ReadOnlySpan): 3181case (_, CollectionExpressionTypeKind.ReadOnlySpan or CollectionExpressionTypeKind.Span) when IsSZArrayOrArrayInterface(t1, out _): 3190TypeSymbol t1, CollectionExpressionTypeKind kind1, TypeSymbol elementType1, 3191TypeSymbol t2, CollectionExpressionTypeKind kind2, TypeSymbol elementType2, 3197if (kind1 is CollectionExpressionTypeKind.ReadOnlySpan && 3198kind2 is CollectionExpressionTypeKind.Span) 3205if (kind1 is (CollectionExpressionTypeKind.ReadOnlySpan or CollectionExpressionTypeKind.Span)) 3212Debug.Assert(kind1 is not (CollectionExpressionTypeKind.ReadOnlySpan or CollectionExpressionTypeKind.Span)); 3213if (kind2 is not (CollectionExpressionTypeKind.ReadOnlySpan or CollectionExpressionTypeKind.Span) && 3227CollectionExpressionTypeKind kind1 = ConversionsBase.GetCollectionExpressionTypeKind(Compilation, t1, out TypeWithAnnotations elementType1); 3228CollectionExpressionTypeKind kind2 = ConversionsBase.GetCollectionExpressionTypeKind(Compilation, t2, out TypeWithAnnotations elementType2); 3230if (kind1 is CollectionExpressionTypeKind.CollectionBuilder or CollectionExpressionTypeKind.ImplementsIEnumerable) 3235if (kind2 is CollectionExpressionTypeKind.CollectionBuilder or CollectionExpressionTypeKind.ImplementsIEnumerable)
BoundTree\BoundCollectionExpression.cs (2)
19Debug.Assert(this.CollectionTypeKind == CollectionExpressionTypeKind.CollectionBuilder); 31Debug.Assert(this.CollectionTypeKind != CollectionExpressionTypeKind.CollectionBuilder);
FlowAnalysis\NullableWalker.cs (7)
3945node.CollectionTypeKind == CollectionExpressionTypeKind.ImplementsIEnumerable) 4182static NullableFlowState getResultState(BoundCollectionExpression node, CollectionExpressionTypeKind collectionKind) 4184if (collectionKind is CollectionExpressionTypeKind.CollectionBuilder) 4197(CollectionExpressionTypeKind, TypeWithAnnotations) getCollectionDetails(BoundCollectionExpression node, TypeSymbol collectionType) 4199var collectionKind = ConversionsBase.GetCollectionExpressionTypeKind(this.compilation, collectionType, out var targetElementType); 4200if (collectionKind is CollectionExpressionTypeKind.CollectionBuilder) 4209else if (collectionKind is CollectionExpressionTypeKind.ImplementsIEnumerable)
FlowAnalysis\NullableWalker.DebugVerifier.cs (1)
128bool hasElementType = node.CollectionTypeKind is not CollectionExpressionTypeKind.None;
Generated\BoundNodes.xml.Generated.cs (3)
6565public BoundCollectionExpression(SyntaxNode syntax, CollectionExpressionTypeKind collectionTypeKind, BoundObjectOrCollectionValuePlaceholder? placeholder, BoundExpression? collectionCreation, MethodSymbol? collectionBuilderMethod, BoundCollectionBuilderElementsPlaceholder? collectionBuilderElementsPlaceholder, bool wasTargetTyped, bool hasWithElement, BoundUnconvertedCollectionExpression unconvertedCollectionExpression, ImmutableArray<BoundNode> elements, TypeSymbol type, bool hasErrors = false) 6588public CollectionExpressionTypeKind CollectionTypeKind { get; } 6600public BoundCollectionExpression Update(CollectionExpressionTypeKind collectionTypeKind, BoundObjectOrCollectionValuePlaceholder? placeholder, BoundExpression? collectionCreation, MethodSymbol? collectionBuilderMethod, BoundCollectionBuilderElementsPlaceholder? collectionBuilderElementsPlaceholder, bool wasTargetTyped, bool hasWithElement, 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: 79case CollectionExpressionTypeKind.Array: 80case CollectionExpressionTypeKind.Span: 81case CollectionExpressionTypeKind.ReadOnlySpan: 84case CollectionExpressionTypeKind.CollectionBuilder: 95case CollectionExpressionTypeKind.ArrayInterface: 337Debug.Assert(!IsAllocatingRefStructCollectionExpression(node, CollectionExpressionTypeKind.ReadOnlySpan, elementType.Type, _compilation)); 347Debug.Assert(!IsAllocatingRefStructCollectionExpression(node, isReadOnlySpan ? CollectionExpressionTypeKind.ReadOnlySpan : CollectionExpressionTypeKind.Span, elementType.Type, _compilation)); 612internal static bool IsAllocatingRefStructCollectionExpression(BoundCollectionExpressionBase node, CollectionExpressionTypeKind collectionKind, TypeSymbol? elementType, CSharpCompilation compilation) 614return collectionKind is CollectionExpressionTypeKind.Span or CollectionExpressionTypeKind.ReadOnlySpan 617&& !(collectionKind == CollectionExpressionTypeKind.ReadOnlySpan && ShouldUseRuntimeHelpersCreateSpan(node, elementType))
Operations\CSharpOperationFactory.cs (7)
1278case CollectionExpressionTypeKind.None: 1279case CollectionExpressionTypeKind.Array: 1280case CollectionExpressionTypeKind.ReadOnlySpan: 1281case CollectionExpressionTypeKind.Span: 1283case CollectionExpressionTypeKind.ArrayInterface: 1284case CollectionExpressionTypeKind.ImplementsIEnumerable: 1286case CollectionExpressionTypeKind.CollectionBuilder:
Symbols\Source\SourceComplexParameterSymbol.cs (5)
1618var collectionTypeKind = ConversionsBase.GetCollectionExpressionTypeKind(DeclaringCompilation, Type, out TypeWithAnnotations elementTypeWithAnnotations); 1623case CollectionExpressionTypeKind.None: 1627case CollectionExpressionTypeKind.ImplementsIEnumerable: 1686case CollectionExpressionTypeKind.CollectionBuilder: 1721if (collectionTypeKind != CollectionExpressionTypeKind.Array)
Microsoft.CodeAnalysis.CSharp.Emit3.UnitTests (11)
Semantics\CollectionExpressionTests.cs (11)
4991Assert.Equal(CollectionExpressionTypeKind.ImplementsIEnumerable, ConversionsBase.GetCollectionExpressionTypeKind(comp, collectionType, out _)); 5046Assert.Equal(CollectionExpressionTypeKind.ImplementsIEnumerable, ConversionsBase.GetCollectionExpressionTypeKind(comp, collectionType, out _)); 6110Assert.Equal(CollectionExpressionTypeKind.None, ConversionsBase.GetCollectionExpressionTypeKind(comp, listType, out var elementType)); 32543Assert.Equal(CollectionExpressionTypeKind.CollectionBuilder, ConversionsBase.GetCollectionExpressionTypeKind(comp, collectionType, out var elementType)); 32603Assert.Equal(CollectionExpressionTypeKind.CollectionBuilder, ConversionsBase.GetCollectionExpressionTypeKind(comp, collectionType, out _)); 32814Assert.Equal(CollectionExpressionTypeKind.ImplementsIEnumerable, ConversionsBase.GetCollectionExpressionTypeKind(comp, collectionType, out _)); 32838Assert.Equal(CollectionExpressionTypeKind.ImplementsIEnumerable, ConversionsBase.GetCollectionExpressionTypeKind(comp, collectionType, out _)); 32873Assert.Equal(CollectionExpressionTypeKind.ImplementsIEnumerable, ConversionsBase.GetCollectionExpressionTypeKind(comp, collectionType, out _)); 32895Assert.Equal(CollectionExpressionTypeKind.ImplementsIEnumerable, ConversionsBase.GetCollectionExpressionTypeKind(comp, collectionType, out _)); 32927Assert.Equal(CollectionExpressionTypeKind.None, ConversionsBase.GetCollectionExpressionTypeKind(comp, collectionType, out _)); 32949Assert.Equal(CollectionExpressionTypeKind.None, ConversionsBase.GetCollectionExpressionTypeKind(comp, collectionType, out _));