125 references to CollectionExpressionTypeKind
Microsoft.CodeAnalysis.CSharp (114)
Binder\Binder.ValueChecks.cs (5)
4769
var
collectionTypeKind = ConversionsBase.GetCollectionExpressionTypeKind(_compilation, expr.Type, out var elementType);
4773
case
CollectionExpressionTypeKind
.ReadOnlySpan:
4776
case
CollectionExpressionTypeKind
.Span:
4778
case
CollectionExpressionTypeKind
.CollectionBuilder:
4800
case
CollectionExpressionTypeKind
.ImplementsIEnumerable:
Binder\Binder_Attributes.cs (1)
917
&& node.Conversion.GetCollectionExpressionTypeKind(out _, out _, out _) ==
CollectionExpressionTypeKind
.Array)
Binder\Binder_Conversions.cs (16)
826
var
collectionTypeKind = conversion.GetCollectionExpressionTypeKind(out var elementType, out MethodSymbol? constructor, out bool isExpanded);
828
if (collectionTypeKind ==
CollectionExpressionTypeKind
.None)
849
case
CollectionExpressionTypeKind
.Span:
853
case
CollectionExpressionTypeKind
.ReadOnlySpan:
857
case
CollectionExpressionTypeKind
.CollectionBuilder:
875
case
CollectionExpressionTypeKind
.ImplementsIEnumerable:
889
if (collectionTypeKind is
CollectionExpressionTypeKind
.ImplementsIEnumerable)
937
if ((collectionTypeKind is
CollectionExpressionTypeKind
.ArrayInterface) ||
1636
if (expr.CollectionTypeKind is
CollectionExpressionTypeKind
.ImplementsIEnumerable)
1733
collectionTypeKind:
CollectionExpressionTypeKind
.None,
1752
var
collectionTypeKind = ConversionsBase.GetCollectionExpressionTypeKind(Compilation, targetType, out TypeWithAnnotations elementTypeWithAnnotations);
1755
case
CollectionExpressionTypeKind
.ImplementsIEnumerable:
1756
case
CollectionExpressionTypeKind
.CollectionBuilder:
1762
collectionTypeKind ==
CollectionExpressionTypeKind
.CollectionBuilder ?
1775
if (collectionTypeKind !=
CollectionExpressionTypeKind
.None)
1781
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)
3052
var
kind1 = conv1.GetCollectionExpressionTypeKind(out TypeSymbol elementType1, out _, out _);
3053
var
kind2 = conv2.GetCollectionExpressionTypeKind(out TypeSymbol elementType2, out _, out _);
3082
TypeSymbol t1,
CollectionExpressionTypeKind
kind1, TypeSymbol elementType1, ImmutableArray<Conversion> underlyingElementConversions1,
3083
TypeSymbol t2,
CollectionExpressionTypeKind
kind2, TypeSymbol elementType2, ImmutableArray<Conversion> underlyingElementConversions2,
3094
var t1IsSpanType = kind1 is
CollectionExpressionTypeKind
.ReadOnlySpan or
CollectionExpressionTypeKind
.Span;
3095
var t2IsSpanType = kind2 is
CollectionExpressionTypeKind
.ReadOnlySpan or
CollectionExpressionTypeKind
.Span;
3175
case (
CollectionExpressionTypeKind
.ReadOnlySpan,
CollectionExpressionTypeKind
.Span):
3176
case (
CollectionExpressionTypeKind
.ReadOnlySpan or
CollectionExpressionTypeKind
.Span, _) when IsSZArrayOrArrayInterface(t2, out _):
3179
case (
CollectionExpressionTypeKind
.Span,
CollectionExpressionTypeKind
.ReadOnlySpan):
3180
case (_,
CollectionExpressionTypeKind
.ReadOnlySpan or
CollectionExpressionTypeKind
.Span) when IsSZArrayOrArrayInterface(t1, out _):
3189
TypeSymbol t1,
CollectionExpressionTypeKind
kind1, TypeSymbol elementType1,
3190
TypeSymbol t2,
CollectionExpressionTypeKind
kind2, TypeSymbol elementType2,
3196
if (kind1 is
CollectionExpressionTypeKind
.ReadOnlySpan &&
3197
kind2 is
CollectionExpressionTypeKind
.Span)
3204
if (kind1 is (
CollectionExpressionTypeKind
.ReadOnlySpan or
CollectionExpressionTypeKind
.Span))
3211
Debug.Assert(kind1 is not (
CollectionExpressionTypeKind
.ReadOnlySpan or
CollectionExpressionTypeKind
.Span));
3212
if (kind2 is not (
CollectionExpressionTypeKind
.ReadOnlySpan or
CollectionExpressionTypeKind
.Span) &&
3226
CollectionExpressionTypeKind
kind1 = ConversionsBase.GetCollectionExpressionTypeKind(Compilation, t1, out TypeWithAnnotations elementType1);
3227
CollectionExpressionTypeKind
kind2 = ConversionsBase.GetCollectionExpressionTypeKind(Compilation, t2, out TypeWithAnnotations elementType2);
3229
if (kind1 is
CollectionExpressionTypeKind
.CollectionBuilder or
CollectionExpressionTypeKind
.ImplementsIEnumerable)
3234
if (kind2 is
CollectionExpressionTypeKind
.CollectionBuilder or
CollectionExpressionTypeKind
.ImplementsIEnumerable)
FlowAnalysis\NullableWalker.cs (6)
4021
static NullableFlowState getResultState(BoundCollectionExpression node,
CollectionExpressionTypeKind
collectionKind)
4023
if (collectionKind is
CollectionExpressionTypeKind
.CollectionBuilder)
4036
(
CollectionExpressionTypeKind
, TypeWithAnnotations) getCollectionDetails(BoundCollectionExpression node, TypeSymbol collectionType)
4038
var
collectionKind = ConversionsBase.GetCollectionExpressionTypeKind(this.compilation, collectionType, out var targetElementType);
4039
if (collectionKind is
CollectionExpressionTypeKind
.CollectionBuilder)
4048
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)
6460
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)
6479
public
CollectionExpressionTypeKind
CollectionTypeKind { get; }
6491
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 (14)
40
var
collectionTypeKind = conversion.GetCollectionExpressionTypeKind(out var elementType, out _, out _);
43
case
CollectionExpressionTypeKind
.ImplementsIEnumerable:
57
case
CollectionExpressionTypeKind
.Array:
58
case
CollectionExpressionTypeKind
.Span:
59
case
CollectionExpressionTypeKind
.ReadOnlySpan:
62
case
CollectionExpressionTypeKind
.CollectionBuilder:
70
case
CollectionExpressionTypeKind
.ArrayInterface:
309
Debug.Assert(!IsAllocatingRefStructCollectionExpression(node,
CollectionExpressionTypeKind
.ReadOnlySpan, elementType.Type, _compilation));
319
Debug.Assert(!IsAllocatingRefStructCollectionExpression(node, isReadOnlySpan ?
CollectionExpressionTypeKind
.ReadOnlySpan :
CollectionExpressionTypeKind
.Span, elementType.Type, _compilation));
578
internal static bool IsAllocatingRefStructCollectionExpression(BoundCollectionExpressionBase node,
CollectionExpressionTypeKind
collectionKind, TypeSymbol? elementType, CSharpCompilation compilation)
580
return collectionKind is
CollectionExpressionTypeKind
.Span or
CollectionExpressionTypeKind
.ReadOnlySpan
583
&& !(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)
1618
var
collectionTypeKind = ConversionsBase.GetCollectionExpressionTypeKind(DeclaringCompilation, Type, out TypeWithAnnotations elementTypeWithAnnotations);
1623
case
CollectionExpressionTypeKind
.None:
1627
case
CollectionExpressionTypeKind
.ImplementsIEnumerable:
1685
case
CollectionExpressionTypeKind
.CollectionBuilder:
1714
if (collectionTypeKind !=
CollectionExpressionTypeKind
.Array)
Microsoft.CodeAnalysis.CSharp.Emit3.UnitTests (11)
Semantics\CollectionExpressionTests.cs (11)
4990
Assert.Equal(
CollectionExpressionTypeKind
.ImplementsIEnumerable, ConversionsBase.GetCollectionExpressionTypeKind(comp, collectionType, out _));
5045
Assert.Equal(
CollectionExpressionTypeKind
.ImplementsIEnumerable, ConversionsBase.GetCollectionExpressionTypeKind(comp, collectionType, out _));
6109
Assert.Equal(
CollectionExpressionTypeKind
.None, ConversionsBase.GetCollectionExpressionTypeKind(comp, listType, out var elementType));
32473
Assert.Equal(
CollectionExpressionTypeKind
.CollectionBuilder, ConversionsBase.GetCollectionExpressionTypeKind(comp, collectionType, out var elementType));
32533
Assert.Equal(
CollectionExpressionTypeKind
.CollectionBuilder, ConversionsBase.GetCollectionExpressionTypeKind(comp, collectionType, out _));
32744
Assert.Equal(
CollectionExpressionTypeKind
.ImplementsIEnumerable, ConversionsBase.GetCollectionExpressionTypeKind(comp, collectionType, out _));
32768
Assert.Equal(
CollectionExpressionTypeKind
.ImplementsIEnumerable, ConversionsBase.GetCollectionExpressionTypeKind(comp, collectionType, out _));
32803
Assert.Equal(
CollectionExpressionTypeKind
.ImplementsIEnumerable, ConversionsBase.GetCollectionExpressionTypeKind(comp, collectionType, out _));
32825
Assert.Equal(
CollectionExpressionTypeKind
.ImplementsIEnumerable, ConversionsBase.GetCollectionExpressionTypeKind(comp, collectionType, out _));
32857
Assert.Equal(
CollectionExpressionTypeKind
.None, ConversionsBase.GetCollectionExpressionTypeKind(comp, collectionType, out _));
32879
Assert.Equal(
CollectionExpressionTypeKind
.None, ConversionsBase.GetCollectionExpressionTypeKind(comp, collectionType, out _));