131 references to CollectionExpressionTypeKind
Microsoft.CodeAnalysis.CSharp (120)
Binder\Binder.ValueChecks.cs (5)
4600
var
collectionTypeKind = ConversionsBase.GetCollectionExpressionTypeKind(_compilation, expr.Type, out var elementType);
4604
case
CollectionExpressionTypeKind
.ReadOnlySpan:
4607
case
CollectionExpressionTypeKind
.Span:
4609
case
CollectionExpressionTypeKind
.CollectionBuilder:
4631
case
CollectionExpressionTypeKind
.ImplementsIEnumerable:
Binder\Binder_Attributes.cs (1)
915
&& node.Conversion.GetCollectionExpressionTypeKind(out _, out _, out _) ==
CollectionExpressionTypeKind
.Array)
Binder\Binder_Conversions.cs (16)
820
var
collectionTypeKind = conversion.GetCollectionExpressionTypeKind(out var elementType, out MethodSymbol? constructor, out bool isExpanded);
822
if (collectionTypeKind ==
CollectionExpressionTypeKind
.None)
843
case
CollectionExpressionTypeKind
.Span:
847
case
CollectionExpressionTypeKind
.ReadOnlySpan:
851
case
CollectionExpressionTypeKind
.CollectionBuilder:
869
case
CollectionExpressionTypeKind
.ImplementsIEnumerable:
883
if (collectionTypeKind is
CollectionExpressionTypeKind
.ImplementsIEnumerable)
931
if ((collectionTypeKind is
CollectionExpressionTypeKind
.ArrayInterface) ||
1648
if (expr.CollectionTypeKind is
CollectionExpressionTypeKind
.ImplementsIEnumerable)
1745
collectionTypeKind:
CollectionExpressionTypeKind
.None,
1764
var
collectionTypeKind = ConversionsBase.GetCollectionExpressionTypeKind(Compilation, targetType, out TypeWithAnnotations elementTypeWithAnnotations);
1767
case
CollectionExpressionTypeKind
.ImplementsIEnumerable:
1768
case
CollectionExpressionTypeKind
.CollectionBuilder:
1774
collectionTypeKind ==
CollectionExpressionTypeKind
.CollectionBuilder ?
1787
if (collectionTypeKind !=
CollectionExpressionTypeKind
.None)
1793
if (collectionTypeKind ==
CollectionExpressionTypeKind
.ImplementsIEnumerable)
Binder\Semantics\Conversions\Conversion.cs (6)
110
CollectionExpressionTypeKind
collectionExpressionTypeKind, TypeSymbol elementType,
115
Debug.Assert(collectionExpressionTypeKind !=
CollectionExpressionTypeKind
.None);
123
internal readonly
CollectionExpressionTypeKind
CollectionExpressionTypeKind;
130
CollectionExpressionTypeKind
collectionExpressionTypeKind, TypeSymbol elementType,
547
internal
CollectionExpressionTypeKind
GetCollectionExpressionTypeKind(out TypeSymbol? elementType, out MethodSymbol? constructor, out bool isExpanded)
560
return
CollectionExpressionTypeKind
.None;
Binder\Semantics\Conversions\Conversions.cs (5)
165
var
collectionTypeKind = GetCollectionExpressionTypeKind(Compilation, targetType, out TypeWithAnnotations elementTypeWithAnnotations);
169
case
CollectionExpressionTypeKind
.None:
172
case
CollectionExpressionTypeKind
.ImplementsIEnumerable:
173
case
CollectionExpressionTypeKind
.CollectionBuilder:
191
if (collectionTypeKind ==
CollectionExpressionTypeKind
.ImplementsIEnumerable)
Binder\Semantics\Conversions\ConversionsBase.cs (8)
1654
internal static
CollectionExpressionTypeKind
GetCollectionExpressionTypeKind(CSharpCompilation compilation, TypeSymbol destination, out TypeWithAnnotations elementType)
1663
return
CollectionExpressionTypeKind
.Array;
1668
return
CollectionExpressionTypeKind
.Span;
1672
return
CollectionExpressionTypeKind
.ReadOnlySpan;
1677
return
CollectionExpressionTypeKind
.CollectionBuilder;
1688
return
CollectionExpressionTypeKind
.ImplementsIEnumerable;
1692
return
CollectionExpressionTypeKind
.ArrayInterface;
1696
return
CollectionExpressionTypeKind
.None;
Binder\Semantics\OverloadResolution\OverloadResolution.cs (37)
1334
var
collectionTypeKind = ConversionsBase.GetCollectionExpressionTypeKind(binder.Compilation, type, out elementType);
1338
case
CollectionExpressionTypeKind
.None:
1341
case
CollectionExpressionTypeKind
.ImplementsIEnumerable:
1342
case
CollectionExpressionTypeKind
.CollectionBuilder:
1352
if (collectionTypeKind ==
CollectionExpressionTypeKind
.ImplementsIEnumerable)
3033
var
kind1 = conv1.GetCollectionExpressionTypeKind(out TypeSymbol elementType1, out _, out _);
3034
var
kind2 = conv2.GetCollectionExpressionTypeKind(out TypeSymbol elementType2, out _, out _);
3063
TypeSymbol t1,
CollectionExpressionTypeKind
kind1, TypeSymbol elementType1, ImmutableArray<Conversion> underlyingElementConversions1,
3064
TypeSymbol t2,
CollectionExpressionTypeKind
kind2, TypeSymbol elementType2, ImmutableArray<Conversion> underlyingElementConversions2,
3075
var t1IsSpanType = kind1 is
CollectionExpressionTypeKind
.ReadOnlySpan or
CollectionExpressionTypeKind
.Span;
3076
var t2IsSpanType = kind2 is
CollectionExpressionTypeKind
.ReadOnlySpan or
CollectionExpressionTypeKind
.Span;
3156
case (
CollectionExpressionTypeKind
.ReadOnlySpan,
CollectionExpressionTypeKind
.Span):
3157
case (
CollectionExpressionTypeKind
.ReadOnlySpan or
CollectionExpressionTypeKind
.Span, _) when IsSZArrayOrArrayInterface(t2, out _):
3160
case (
CollectionExpressionTypeKind
.Span,
CollectionExpressionTypeKind
.ReadOnlySpan):
3161
case (_,
CollectionExpressionTypeKind
.ReadOnlySpan or
CollectionExpressionTypeKind
.Span) when IsSZArrayOrArrayInterface(t1, out _):
3170
TypeSymbol t1,
CollectionExpressionTypeKind
kind1, TypeSymbol elementType1,
3171
TypeSymbol t2,
CollectionExpressionTypeKind
kind2, TypeSymbol elementType2,
3177
if (kind1 is
CollectionExpressionTypeKind
.ReadOnlySpan &&
3178
kind2 is
CollectionExpressionTypeKind
.Span)
3185
if (kind1 is (
CollectionExpressionTypeKind
.ReadOnlySpan or
CollectionExpressionTypeKind
.Span))
3192
Debug.Assert(kind1 is not (
CollectionExpressionTypeKind
.ReadOnlySpan or
CollectionExpressionTypeKind
.Span));
3193
if (kind2 is not (
CollectionExpressionTypeKind
.ReadOnlySpan or
CollectionExpressionTypeKind
.Span) &&
3207
CollectionExpressionTypeKind
kind1 = ConversionsBase.GetCollectionExpressionTypeKind(Compilation, t1, out TypeWithAnnotations elementType1);
3208
CollectionExpressionTypeKind
kind2 = ConversionsBase.GetCollectionExpressionTypeKind(Compilation, t2, out TypeWithAnnotations elementType2);
3210
if (kind1 is
CollectionExpressionTypeKind
.CollectionBuilder or
CollectionExpressionTypeKind
.ImplementsIEnumerable)
3215
if (kind2 is
CollectionExpressionTypeKind
.CollectionBuilder or
CollectionExpressionTypeKind
.ImplementsIEnumerable)
FlowAnalysis\NullableWalker.cs (6)
4006
static NullableFlowState getResultState(BoundCollectionExpression node,
CollectionExpressionTypeKind
collectionKind)
4008
if (collectionKind is
CollectionExpressionTypeKind
.CollectionBuilder)
4021
(
CollectionExpressionTypeKind
, TypeWithAnnotations) getCollectionDetails(BoundCollectionExpression node, TypeSymbol collectionType)
4023
var
collectionKind = ConversionsBase.GetCollectionExpressionTypeKind(this.compilation, collectionType, out var targetElementType);
4024
if (collectionKind is
CollectionExpressionTypeKind
.CollectionBuilder)
4033
else if (collectionKind is
CollectionExpressionTypeKind
.ImplementsIEnumerable)
FlowAnalysis\NullableWalker.DebugVerifier.cs (1)
126
bool hasElementType = node.CollectionTypeKind is not
CollectionExpressionTypeKind
.None;
Generated\BoundNodes.xml.Generated.cs (3)
6425
public 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)
6444
public
CollectionExpressionTypeKind
CollectionTypeKind { get; }
6456
public 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 (20)
41
var
collectionTypeKind = conversion.GetCollectionExpressionTypeKind(out var elementType, out _, out _);
44
case
CollectionExpressionTypeKind
.ImplementsIEnumerable:
58
case
CollectionExpressionTypeKind
.Array:
59
case
CollectionExpressionTypeKind
.Span:
60
case
CollectionExpressionTypeKind
.ReadOnlySpan:
63
case
CollectionExpressionTypeKind
.CollectionBuilder:
85
case
CollectionExpressionTypeKind
.ArrayInterface:
238
CollectionExpressionTypeKind
.Array,
245
private BoundExpression VisitArrayOrSpanCollectionExpression(BoundCollectionExpression node,
CollectionExpressionTypeKind
collectionTypeKind, TypeSymbol collectionType, TypeWithAnnotations elementType)
262
Debug.Assert(collectionTypeKind is
CollectionExpressionTypeKind
.Span or
CollectionExpressionTypeKind
.ReadOnlySpan);
264
collectionTypeKind ==
CollectionExpressionTypeKind
.Span ? WellKnownType.System_Span_T : WellKnownType.System_ReadOnlySpan_T), TypeCompareKind.AllIgnoreOptions));
273
if (collectionTypeKind ==
CollectionExpressionTypeKind
.ReadOnlySpan &&
291
asReadOnlySpan: collectionTypeKind ==
CollectionExpressionTypeKind
.ReadOnlySpan);
297
collectionTypeKind ==
CollectionExpressionTypeKind
.Span ? WellKnownMember.System_Span_T__ctor_Array : WellKnownMember.System_ReadOnlySpan_T__ctor_Array)!).AsMember(spanType);
490
: VisitArrayOrSpanCollectionExpression(node,
CollectionExpressionTypeKind
.ReadOnlySpan, spanType, elementType);
515
internal static bool IsAllocatingRefStructCollectionExpression(BoundCollectionExpressionBase node,
CollectionExpressionTypeKind
collectionKind, TypeSymbol? elementType, CSharpCompilation compilation)
517
return collectionKind is
CollectionExpressionTypeKind
.Span or
CollectionExpressionTypeKind
.ReadOnlySpan
520
&& !(collectionKind ==
CollectionExpressionTypeKind
.ReadOnlySpan && ShouldUseRuntimeHelpersCreateSpan(node, elementType))
Operations\CSharpOperationFactory.cs (7)
1242
case
CollectionExpressionTypeKind
.None:
1243
case
CollectionExpressionTypeKind
.Array:
1244
case
CollectionExpressionTypeKind
.ArrayInterface:
1245
case
CollectionExpressionTypeKind
.ReadOnlySpan:
1246
case
CollectionExpressionTypeKind
.Span:
1248
case
CollectionExpressionTypeKind
.ImplementsIEnumerable:
1250
case
CollectionExpressionTypeKind
.CollectionBuilder:
Symbols\Source\SourceComplexParameterSymbol.cs (5)
1571
var
collectionTypeKind = ConversionsBase.GetCollectionExpressionTypeKind(DeclaringCompilation, Type, out TypeWithAnnotations elementTypeWithAnnotations);
1576
case
CollectionExpressionTypeKind
.None:
1580
case
CollectionExpressionTypeKind
.ImplementsIEnumerable:
1638
case
CollectionExpressionTypeKind
.CollectionBuilder:
1667
if (collectionTypeKind !=
CollectionExpressionTypeKind
.Array)
Microsoft.CodeAnalysis.CSharp.Emit3.UnitTests (11)
Semantics\CollectionExpressionTests.cs (11)
4991
Assert.Equal(
CollectionExpressionTypeKind
.ImplementsIEnumerable, ConversionsBase.GetCollectionExpressionTypeKind(comp, collectionType, out _));
5046
Assert.Equal(
CollectionExpressionTypeKind
.ImplementsIEnumerable, ConversionsBase.GetCollectionExpressionTypeKind(comp, collectionType, out _));
5100
Assert.Equal(
CollectionExpressionTypeKind
.None, ConversionsBase.GetCollectionExpressionTypeKind(comp, listType, out var elementType));
30147
Assert.Equal(
CollectionExpressionTypeKind
.CollectionBuilder, ConversionsBase.GetCollectionExpressionTypeKind(comp, collectionType, out var elementType));
30207
Assert.Equal(
CollectionExpressionTypeKind
.CollectionBuilder, ConversionsBase.GetCollectionExpressionTypeKind(comp, collectionType, out _));
30418
Assert.Equal(
CollectionExpressionTypeKind
.ImplementsIEnumerable, ConversionsBase.GetCollectionExpressionTypeKind(comp, collectionType, out _));
30442
Assert.Equal(
CollectionExpressionTypeKind
.ImplementsIEnumerable, ConversionsBase.GetCollectionExpressionTypeKind(comp, collectionType, out _));
30477
Assert.Equal(
CollectionExpressionTypeKind
.ImplementsIEnumerable, ConversionsBase.GetCollectionExpressionTypeKind(comp, collectionType, out _));
30499
Assert.Equal(
CollectionExpressionTypeKind
.ImplementsIEnumerable, ConversionsBase.GetCollectionExpressionTypeKind(comp, collectionType, out _));
30531
Assert.Equal(
CollectionExpressionTypeKind
.None, ConversionsBase.GetCollectionExpressionTypeKind(comp, collectionType, out _));
30553
Assert.Equal(
CollectionExpressionTypeKind
.None, ConversionsBase.GetCollectionExpressionTypeKind(comp, collectionType, out _));