138 references to CollectionExpressionTypeKind
Microsoft.CodeAnalysis.CSharp (127)
Binder\Binder.ValueChecks.cs (5)
4790
var
collectionTypeKind = ConversionsBase.GetCollectionExpressionTypeKind(_compilation, expr.Type, out var elementType);
4793
case
CollectionExpressionTypeKind
.ReadOnlySpan:
4802
case
CollectionExpressionTypeKind
.Span:
4806
case
CollectionExpressionTypeKind
.CollectionBuilder:
4817
case
CollectionExpressionTypeKind
.ImplementsIEnumerable:
Binder\Binder_Attributes.cs (1)
917
&& node.Conversion.GetCollectionExpressionTypeKind(out _, out _, out _) ==
CollectionExpressionTypeKind
.Array)
Binder\Binder_Conversions.cs (26)
858
CollectionExpressionTypeKind
collectionTypeKind, ImmutableArray<BoundNode> elements, BoundObjectOrCollectionValuePlaceholder? placeholder = null, BoundExpression? collectionCreation = null, MethodSymbol? collectionBuilderMethod = null, BoundCollectionBuilderElementsPlaceholder? collectionBuilderElementsPlaceholder = null)
880
var
collectionTypeKind = _conversion.GetCollectionExpressionTypeKind(out var elementType, out MethodSymbol? constructor, out bool isExpanded);
882
if (collectionTypeKind ==
CollectionExpressionTypeKind
.None)
893
if (collectionTypeKind !=
CollectionExpressionTypeKind
.ImplementsIEnumerable &&
910
CollectionExpressionTypeKind
collectionTypeKind,
928
if (collectionTypeKind ==
CollectionExpressionTypeKind
.ImplementsIEnumerable)
931
if (collectionTypeKind is
CollectionExpressionTypeKind
.ArrayInterface ||
950
CollectionExpressionTypeKind
.Array or
CollectionExpressionTypeKind
.Span or
CollectionExpressionTypeKind
.ReadOnlySpan
953
CollectionExpressionTypeKind
.ArrayInterface
956
CollectionExpressionTypeKind
.CollectionBuilder
1025
CollectionExpressionTypeKind
.ImplementsIEnumerable,
1150
CollectionExpressionTypeKind
collectionTypeKind,
1156
case
CollectionExpressionTypeKind
.Span:
1160
case
CollectionExpressionTypeKind
.ReadOnlySpan:
1190
CollectionExpressionTypeKind
.ArrayInterface,
1273
CollectionExpressionTypeKind
.CollectionBuilder,
2150
if (expr.CollectionTypeKind is
CollectionExpressionTypeKind
.ImplementsIEnumerable)
2259
collectionTypeKind:
CollectionExpressionTypeKind
.None,
2281
var
collectionTypeKind = ConversionsBase.GetCollectionExpressionTypeKind(Compilation, targetType, out TypeWithAnnotations elementTypeWithAnnotations);
2284
case
CollectionExpressionTypeKind
.ImplementsIEnumerable:
2285
case
CollectionExpressionTypeKind
.CollectionBuilder:
2291
collectionTypeKind ==
CollectionExpressionTypeKind
.CollectionBuilder ?
2304
if (collectionTypeKind !=
CollectionExpressionTypeKind
.None)
2310
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)
1340
var
collectionTypeKind = ConversionsBase.GetCollectionExpressionTypeKind(binder.Compilation, type, out elementType);
1344
case
CollectionExpressionTypeKind
.None:
1347
case
CollectionExpressionTypeKind
.ImplementsIEnumerable:
1348
case
CollectionExpressionTypeKind
.CollectionBuilder:
1358
if (collectionTypeKind ==
CollectionExpressionTypeKind
.ImplementsIEnumerable)
3053
var
kind1 = conv1.GetCollectionExpressionTypeKind(out TypeSymbol elementType1, out _, out _);
3054
var
kind2 = conv2.GetCollectionExpressionTypeKind(out TypeSymbol elementType2, out _, out _);
3083
TypeSymbol t1,
CollectionExpressionTypeKind
kind1, TypeSymbol elementType1, ImmutableArray<Conversion> underlyingElementConversions1,
3084
TypeSymbol t2,
CollectionExpressionTypeKind
kind2, TypeSymbol elementType2, ImmutableArray<Conversion> underlyingElementConversions2,
3095
var t1IsSpanType = kind1 is
CollectionExpressionTypeKind
.ReadOnlySpan or
CollectionExpressionTypeKind
.Span;
3096
var t2IsSpanType = kind2 is
CollectionExpressionTypeKind
.ReadOnlySpan or
CollectionExpressionTypeKind
.Span;
3176
case (
CollectionExpressionTypeKind
.ReadOnlySpan,
CollectionExpressionTypeKind
.Span):
3177
case (
CollectionExpressionTypeKind
.ReadOnlySpan or
CollectionExpressionTypeKind
.Span, _) when IsSZArrayOrArrayInterface(t2, out _):
3180
case (
CollectionExpressionTypeKind
.Span,
CollectionExpressionTypeKind
.ReadOnlySpan):
3181
case (_,
CollectionExpressionTypeKind
.ReadOnlySpan or
CollectionExpressionTypeKind
.Span) when IsSZArrayOrArrayInterface(t1, out _):
3190
TypeSymbol t1,
CollectionExpressionTypeKind
kind1, TypeSymbol elementType1,
3191
TypeSymbol t2,
CollectionExpressionTypeKind
kind2, TypeSymbol elementType2,
3197
if (kind1 is
CollectionExpressionTypeKind
.ReadOnlySpan &&
3198
kind2 is
CollectionExpressionTypeKind
.Span)
3205
if (kind1 is (
CollectionExpressionTypeKind
.ReadOnlySpan or
CollectionExpressionTypeKind
.Span))
3212
Debug.Assert(kind1 is not (
CollectionExpressionTypeKind
.ReadOnlySpan or
CollectionExpressionTypeKind
.Span));
3213
if (kind2 is not (
CollectionExpressionTypeKind
.ReadOnlySpan or
CollectionExpressionTypeKind
.Span) &&
3227
CollectionExpressionTypeKind
kind1 = ConversionsBase.GetCollectionExpressionTypeKind(Compilation, t1, out TypeWithAnnotations elementType1);
3228
CollectionExpressionTypeKind
kind2 = ConversionsBase.GetCollectionExpressionTypeKind(Compilation, t2, out TypeWithAnnotations elementType2);
3230
if (kind1 is
CollectionExpressionTypeKind
.CollectionBuilder or
CollectionExpressionTypeKind
.ImplementsIEnumerable)
3235
if (kind2 is
CollectionExpressionTypeKind
.CollectionBuilder or
CollectionExpressionTypeKind
.ImplementsIEnumerable)
BoundTree\BoundCollectionExpression.cs (2)
19
Debug.Assert(this.CollectionTypeKind ==
CollectionExpressionTypeKind
.CollectionBuilder);
31
Debug.Assert(this.CollectionTypeKind !=
CollectionExpressionTypeKind
.CollectionBuilder);
FlowAnalysis\NullableWalker.cs (7)
3916
node.CollectionTypeKind ==
CollectionExpressionTypeKind
.ImplementsIEnumerable)
4153
static NullableFlowState getResultState(BoundCollectionExpression node,
CollectionExpressionTypeKind
collectionKind)
4155
if (collectionKind is
CollectionExpressionTypeKind
.CollectionBuilder)
4168
(
CollectionExpressionTypeKind
, TypeWithAnnotations) getCollectionDetails(BoundCollectionExpression node, TypeSymbol collectionType)
4170
var
collectionKind = ConversionsBase.GetCollectionExpressionTypeKind(this.compilation, collectionType, out var targetElementType);
4171
if (collectionKind is
CollectionExpressionTypeKind
.CollectionBuilder)
4180
else if (collectionKind is
CollectionExpressionTypeKind
.ImplementsIEnumerable)
FlowAnalysis\NullableWalker.DebugVerifier.cs (1)
128
bool hasElementType = node.CollectionTypeKind is not
CollectionExpressionTypeKind
.None;
Generated\BoundNodes.xml.Generated.cs (3)
6530
public 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)
6553
public
CollectionExpressionTypeKind
CollectionTypeKind { get; }
6565
public 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)
40
var
collectionTypeKind = conversion.GetCollectionExpressionTypeKind(out var elementType, out _, out _);
43
case
CollectionExpressionTypeKind
.ImplementsIEnumerable:
79
case
CollectionExpressionTypeKind
.Array:
80
case
CollectionExpressionTypeKind
.Span:
81
case
CollectionExpressionTypeKind
.ReadOnlySpan:
84
case
CollectionExpressionTypeKind
.CollectionBuilder:
95
case
CollectionExpressionTypeKind
.ArrayInterface:
337
Debug.Assert(!IsAllocatingRefStructCollectionExpression(node,
CollectionExpressionTypeKind
.ReadOnlySpan, elementType.Type, _compilation));
347
Debug.Assert(!IsAllocatingRefStructCollectionExpression(node, isReadOnlySpan ?
CollectionExpressionTypeKind
.ReadOnlySpan :
CollectionExpressionTypeKind
.Span, elementType.Type, _compilation));
612
internal static bool IsAllocatingRefStructCollectionExpression(BoundCollectionExpressionBase node,
CollectionExpressionTypeKind
collectionKind, TypeSymbol? elementType, CSharpCompilation compilation)
614
return collectionKind is
CollectionExpressionTypeKind
.Span or
CollectionExpressionTypeKind
.ReadOnlySpan
617
&& !(collectionKind ==
CollectionExpressionTypeKind
.ReadOnlySpan && ShouldUseRuntimeHelpersCreateSpan(node, elementType))
Operations\CSharpOperationFactory.cs (7)
1253
case
CollectionExpressionTypeKind
.None:
1254
case
CollectionExpressionTypeKind
.Array:
1255
case
CollectionExpressionTypeKind
.ReadOnlySpan:
1256
case
CollectionExpressionTypeKind
.Span:
1258
case
CollectionExpressionTypeKind
.ArrayInterface:
1259
case
CollectionExpressionTypeKind
.ImplementsIEnumerable:
1261
case
CollectionExpressionTypeKind
.CollectionBuilder:
Symbols\Source\SourceComplexParameterSymbol.cs (5)
1618
var
collectionTypeKind = ConversionsBase.GetCollectionExpressionTypeKind(DeclaringCompilation, Type, out TypeWithAnnotations elementTypeWithAnnotations);
1623
case
CollectionExpressionTypeKind
.None:
1627
case
CollectionExpressionTypeKind
.ImplementsIEnumerable:
1686
case
CollectionExpressionTypeKind
.CollectionBuilder:
1721
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 _));
6110
Assert.Equal(
CollectionExpressionTypeKind
.None, ConversionsBase.GetCollectionExpressionTypeKind(comp, listType, out var elementType));
32543
Assert.Equal(
CollectionExpressionTypeKind
.CollectionBuilder, ConversionsBase.GetCollectionExpressionTypeKind(comp, collectionType, out var elementType));
32603
Assert.Equal(
CollectionExpressionTypeKind
.CollectionBuilder, ConversionsBase.GetCollectionExpressionTypeKind(comp, collectionType, out _));
32814
Assert.Equal(
CollectionExpressionTypeKind
.ImplementsIEnumerable, ConversionsBase.GetCollectionExpressionTypeKind(comp, collectionType, out _));
32838
Assert.Equal(
CollectionExpressionTypeKind
.ImplementsIEnumerable, ConversionsBase.GetCollectionExpressionTypeKind(comp, collectionType, out _));
32873
Assert.Equal(
CollectionExpressionTypeKind
.ImplementsIEnumerable, ConversionsBase.GetCollectionExpressionTypeKind(comp, collectionType, out _));
32895
Assert.Equal(
CollectionExpressionTypeKind
.ImplementsIEnumerable, ConversionsBase.GetCollectionExpressionTypeKind(comp, collectionType, out _));
32927
Assert.Equal(
CollectionExpressionTypeKind
.None, ConversionsBase.GetCollectionExpressionTypeKind(comp, collectionType, out _));
32949
Assert.Equal(
CollectionExpressionTypeKind
.None, ConversionsBase.GetCollectionExpressionTypeKind(comp, collectionType, out _));