73 instantiations of Conversion
Microsoft.CodeAnalysis.CSharp (73)
Binder\Semantics\Conversions\Conversion.cs (56)
134
return new
Conversion
(
197
return new
Conversion
(this.Kind, conversionMethod, isExtensionMethod: IsExtensionMethod);
205
return new
Conversion
(
263
return new
Conversion
(kind);
266
internal static Conversion UnsetConversion => new
Conversion
(ConversionKind.UnsetConversionKind);
267
internal static Conversion NoConversion => new
Conversion
(ConversionKind.NoConversion);
268
internal static Conversion Identity => new
Conversion
(ConversionKind.Identity);
269
internal static Conversion ImplicitConstant => new
Conversion
(ConversionKind.ImplicitConstant);
270
internal static Conversion ImplicitNumeric => new
Conversion
(ConversionKind.ImplicitNumeric);
271
internal static Conversion ImplicitReference => new
Conversion
(ConversionKind.ImplicitReference);
272
internal static Conversion ImplicitEnumeration => new
Conversion
(ConversionKind.ImplicitEnumeration);
273
internal static Conversion ImplicitThrow => new
Conversion
(ConversionKind.ImplicitThrow);
274
internal static Conversion ObjectCreation => new
Conversion
(ConversionKind.ObjectCreation);
275
internal static Conversion CollectionExpression => new
Conversion
(ConversionKind.CollectionExpression);
276
internal static Conversion AnonymousFunction => new
Conversion
(ConversionKind.AnonymousFunction);
277
internal static Conversion Boxing => new
Conversion
(ConversionKind.Boxing);
278
internal static Conversion NullLiteral => new
Conversion
(ConversionKind.NullLiteral);
279
internal static Conversion DefaultLiteral => new
Conversion
(ConversionKind.DefaultLiteral);
280
internal static Conversion NullToPointer => new
Conversion
(ConversionKind.ImplicitNullToPointer);
281
internal static Conversion PointerToVoid => new
Conversion
(ConversionKind.ImplicitPointerToVoid);
282
internal static Conversion PointerToPointer => new
Conversion
(ConversionKind.ExplicitPointerToPointer);
283
internal static Conversion PointerToInteger => new
Conversion
(ConversionKind.ExplicitPointerToInteger);
284
internal static Conversion IntegerToPointer => new
Conversion
(ConversionKind.ExplicitIntegerToPointer);
285
internal static Conversion Unboxing => new
Conversion
(ConversionKind.Unboxing);
286
internal static Conversion ExplicitReference => new
Conversion
(ConversionKind.ExplicitReference);
287
internal static Conversion IntPtr => new
Conversion
(ConversionKind.IntPtr);
288
internal static Conversion ExplicitEnumeration => new
Conversion
(ConversionKind.ExplicitEnumeration);
289
internal static Conversion ExplicitNumeric => new
Conversion
(ConversionKind.ExplicitNumeric);
290
internal static Conversion ImplicitDynamic => new
Conversion
(ConversionKind.ImplicitDynamic);
291
internal static Conversion ExplicitDynamic => new
Conversion
(ConversionKind.ExplicitDynamic);
292
internal static Conversion InterpolatedString => new
Conversion
(ConversionKind.InterpolatedString);
293
internal static Conversion InterpolatedStringHandler => new
Conversion
(ConversionKind.InterpolatedStringHandler);
294
internal static Conversion Deconstruction => new
Conversion
(ConversionKind.Deconstruction);
295
internal static Conversion PinnedObjectToPointer => new
Conversion
(ConversionKind.PinnedObjectToPointer);
296
internal static Conversion ImplicitPointer => new
Conversion
(ConversionKind.ImplicitPointer);
297
internal static Conversion FunctionType => new
Conversion
(ConversionKind.FunctionType);
298
internal static Conversion InlineArray => new
Conversion
(ConversionKind.InlineArray);
299
internal static Conversion ImplicitSpan => new
Conversion
(ConversionKind.ImplicitSpan);
300
internal static Conversion ExplicitSpan => new
Conversion
(ConversionKind.ExplicitSpan);
312
internal static readonly Conversion ExplicitNullableWithExplicitEnumerationUnderlying = new
Conversion
(ConversionKind.ExplicitNullable, ExplicitEnumerationUnderlying);
313
internal static readonly Conversion ExplicitNullableWithPointerToIntegerUnderlying = new
Conversion
(ConversionKind.ExplicitNullable, PointerToIntegerUnderlying);
314
internal static readonly Conversion ExplicitNullableWithIdentityUnderlying = new
Conversion
(ConversionKind.ExplicitNullable, IdentityUnderlying);
315
internal static readonly Conversion ExplicitNullableWithImplicitNumericUnderlying = new
Conversion
(ConversionKind.ExplicitNullable, ImplicitNumericUnderlying);
316
internal static readonly Conversion ExplicitNullableWithExplicitNumericUnderlying = new
Conversion
(ConversionKind.ExplicitNullable, ExplicitNumericUnderlying);
317
internal static readonly Conversion ExplicitNullableWithImplicitConstantUnderlying = new
Conversion
(ConversionKind.ExplicitNullable, ImplicitConstantUnderlying);
319
internal static readonly Conversion ImplicitNullableWithExplicitEnumerationUnderlying = new
Conversion
(ConversionKind.ImplicitNullable, ExplicitEnumerationUnderlying);
320
internal static readonly Conversion ImplicitNullableWithPointerToIntegerUnderlying = new
Conversion
(ConversionKind.ImplicitNullable, PointerToIntegerUnderlying);
321
internal static readonly Conversion ImplicitNullableWithIdentityUnderlying = new
Conversion
(ConversionKind.ImplicitNullable, IdentityUnderlying);
322
internal static readonly Conversion ImplicitNullableWithImplicitNumericUnderlying = new
Conversion
(ConversionKind.ImplicitNullable, ImplicitNumericUnderlying);
323
internal static readonly Conversion ImplicitNullableWithExplicitNumericUnderlying = new
Conversion
(ConversionKind.ImplicitNullable, ExplicitNumericUnderlying);
324
internal static readonly Conversion ImplicitNullableWithImplicitConstantUnderlying = new
Conversion
(ConversionKind.ImplicitNullable, ImplicitConstantUnderlying);
340
return new
Conversion
(ConversionKind.StackAllocToPointerType, ImmutableArray.Create(underlyingConversion));
345
return new
Conversion
(ConversionKind.StackAllocToSpanType, ImmutableArray.Create(underlyingConversion));
360
_ => new
Conversion
(kind, ImmutableArray.Create(nestedConversion)),
366
return new
Conversion
(ConversionKind.SwitchExpression, innerConversions);
371
return new
Conversion
(ConversionKind.ConditionalExpression, innerConversions);
Binder\Semantics\Conversions\Conversions.cs (1)
481
return new
Conversion
(ConversionKind.MethodGroup, method, methodGroup.IsExtensionMethodGroup);
Binder\Semantics\Conversions\ConversionsBase.cs (8)
785
return new
Conversion
(conversionResult, isImplicit: true);
875
return new
Conversion
(conversionResult, isImplicit: false);
1176
return new
Conversion
(ConversionKind.ImplicitNullable, ImmutableArray.Create(underlyingConversion));
1312
return new
Conversion
(ConversionKind.ImplicitNullable, ImmutableArray.Create(underlyingTupleConversion));
1341
return new
Conversion
(ConversionKind.ExplicitNullable, ImmutableArray.Create(underlyingTupleConversion));
1750
return new
Conversion
(result, isImplicit: true);
2275
return new
Conversion
(ConversionKind.ImplicitNullable, ImmutableArray.Create(tupleConversion));
2472
return new
Conversion
(ConversionKind.ExplicitNullable, ImmutableArray.Create(tupleConversion));
Compilation\CSharpSemanticModel.cs (4)
2101
conversion = new
Conversion
(ConversionKind.AnonymousFunction, lambda.Symbol, false);
2222
conversion = new
Conversion
(ConversionKind.MethodGroup, delegateCreation.MethodOpt, delegateCreation.IsExtensionMethod);
2228
conversion = new
Conversion
(ConversionKind.AnonymousFunction, lambda.Symbol, delegateCreation.IsExtensionMethod);
2234
conversion = new
Conversion
(ConversionKind.AnonymousFunction, lambda.Symbol, delegateCreation.IsExtensionMethod);
Lowering\LocalRewriter\LocalRewriter_Conversion.cs (4)
1132
var result = new BoundConversion(syntax, rewrittenOperand, new
Conversion
(conversionKind, method, false), @checked, explicitCastInCode: explicitCastInCode, conversionGroup, constantValueOpt: null, rewrittenType);
1738
var conversion = new
Conversion
(conversionKind, method, isExtensionMethod: false);
1783
var resultConversion = new
Conversion
(result, conversion.IsImplicit);
1883
return new
Conversion
(result, isImplicit);
1239 references to Conversion
ConfigurationSchemaGenerator (1)
RuntimeSource\Configuration.Binder\ConfigurationBindingGenerator.Parser.cs (1)
527
Conversion
conversion = _typeSymbols.Compilation.ClassifyConversion(source, dest);
Microsoft.AspNetCore.Components.Analyzers (3)
ComponentFacts.cs (1)
102
var
conversion = compilation.ClassifyConversion(symbols.IComponentType, type);
ComponentParameterAnalyzer.cs (1)
102
var
conversion = context.Compilation.ClassifyConversion(symbols.ParameterCaptureUnmatchedValuesRuntimeType, property.Type);
ComponentParameterUsageAnalyzer.cs (1)
89
var
conversion = context.Compilation.ClassifyConversion(propertyContainingType, assignmentContainingType);
Microsoft.AspNetCore.Components.SdkAnalyzers (3)
ComponentFacts.cs (1)
102
var
conversion = compilation.ClassifyConversion(symbols.IComponentType, type);
ComponentParameterAnalyzer.cs (1)
96
var
conversion = context.Compilation.ClassifyConversion(symbols.ParameterCaptureUnmatchedValuesRuntimeType, property.Type);
ComponentParameterUsageAnalyzer.cs (1)
89
var
conversion = context.Compilation.ClassifyConversion(propertyContainingType, assignmentContainingType);
Microsoft.CodeAnalysis.CSharp (834)
Binder\Binder.cs (1)
624
internal void ReportDiagnosticsIfObsolete(BindingDiagnosticBag diagnostics,
Conversion
conversion, SyntaxNodeOrToken node, bool hasBaseReceiver)
Binder\Binder.ValueChecks.cs (1)
3971
if (conversion.Conversion ==
Conversion
.ImplicitThrow)
Binder\Binder_Await.cs (1)
416
var
conversion = this.Conversions.ClassifyImplicitConversionFromType(awaiterType, INotifyCompletion, ref useSiteInfo);
Binder\Binder_Conversions.cs (10)
26
var
conversion = Conversions.ClassifyConversionFromExpression(source, destination, isChecked: CheckOverflowAtRuntime, ref useSiteInfo);
34
Conversion
conversion,
44
Conversion
conversion,
56
Conversion
conversion,
82
static bool filterConversion(
Conversion
conversion)
98
Conversion
conversion,
300
void reportUseSiteDiagnostics(SyntaxNode syntax,
Conversion
conversion, BoundExpression source, TypeSymbol destination, BindingDiagnosticBag diagnostics)
314
void ensureAllUnderlyingConversionsChecked(SyntaxNode syntax, BoundExpression source,
Conversion
conversion, bool wasCompilerGenerated, TypeSymbol destination, BindingDiagnosticBag diagnostics)
407
void checkConstraintLanguageVersionAndRuntimeSupportForConversion(SyntaxNode syntax,
Conversion
conversion, BoundExpression source, TypeSymbol destination, BindingDiagnosticBag diagnostics)
1530
var
conversion = conversions.ConvertExtensionMethodThisArg(constructed.Parameters[0].Type, receiverType, ref useSiteInfo, isMethodGroupConversion: false);
Binder\Binder_Deconstruct.cs (5)
132
new BoundConversion(boundRHS.Syntax, boundRHS,
Conversion
.Deconstruction, @checked: false, explicitCastInCode: false, conversionGroupOpt: null,
139
Conversion
conversion;
248
out
Conversion
conversion)
252
conversion =
Conversion
.Deconstruction;
300
Conversion
nestedConversion;
Binder\Binder_Expressions.cs (18)
1222
Conversion
conversion = this.Conversions.ClassifyConversionFromExpression(argument, typedReferenceType, isChecked: CheckOverflowAtRuntime, ref useSiteInfo);
1271
Conversion
conversion = this.Conversions.ClassifyConversionFromExpression(argument, typedReferenceType, isChecked: CheckOverflowAtRuntime, ref useSiteInfo);
2581
Conversion
conversion = this.Conversions.ClassifyImplicitConversionFromExpression(boundOperand, intType, ref useSiteInfo);
2687
Conversion
conversion = this.Conversions.ClassifyImplicitConversionFromExpression(boundOperand, indexType, ref useSiteInfo);
2702
Conversion
conversion = this.Conversions.ClassifyConversionFromExpression(operand, targetType, isChecked: CheckOverflowAtRuntime, ref useSiteInfo, forCast: true);
2719
Conversion
conversion,
2860
var
elementConversion = Conversions.ClassifyConversionFromExpression(argument, targetElementType, isChecked: CheckOverflowAtRuntime, ref discardedUseSiteInfo);
2886
var
underlyingConversion = Conversions.ClassifyBuiltInConversion(operand.Type, underlyingTargetTypeWithAnnotations.Type, isChecked: CheckOverflowAtRuntime, ref discardedUseSiteInfo);
3510
var
kind = result.ConversionForArg(arg);
3691
var
interpolatedStringConversion = memberAnalysisResult.ConversionForArg(interpolatedStringArgNum);
5246
var
conversion = @this.Conversions.ClassifyConversionFromExpression(expression, collectionType, isChecked: @this.CheckOverflowAtRuntime, ref useSiteInfo);
5338
var
conversion = this.Conversions.ClassifyConversionFromExpression(unboundLambda, type, isChecked: CheckOverflowAtRuntime, ref useSiteInfo);
5378
Conversion
conversion;
5411
Conversion
conv = Conversions.MethodGroupConversion(argument.Syntax, methodGroup, type, ref useSiteInfo);
6949
Conversion
conversion = this.Conversions.ClassifyConversionFromExpression(classCreation, interfaceType, isChecked: CheckOverflowAtRuntime, ref useSiteInfo, forCast: true);
8651
Conversion
.ImplicitNumeric,
9444
Conversion
failedConversion = this.Conversions.ClassifyConversionFromExpression(index, int32, isChecked: CheckOverflowAtRuntime, ref useSiteInfo);
9499
Conversion
conversion = this.Conversions.ClassifyImplicitConversionFromExpression(expr, targetType, ref useSiteInfo);
Binder\Binder_Invocation.cs (2)
1680
Conversion
conversion = Conversions.ClassifyConversionFromExpression(defaultValue, parameterType, isChecked: CheckOverflowAtRuntime, ref useSiteInfo);
1743
Conversion
conversion = Conversions.ClassifyImplicitConversionFromExpression(unconvertedCollection, collectionType, ref useSiteInfo);
Binder\Binder_Operators.cs (15)
64
var
finalDynamicConversion = this.Compilation.Conversions.ClassifyConversionFromExpression(placeholder, left.Type, isChecked: CheckOverflowAtRuntime, ref useSiteInfo);
223
Conversion
rightToLeftConversion = this.Conversions.ClassifyConversionFromExpression(right, leftType, isChecked: CheckOverflowAtRuntime, ref useSiteInfo);
270
Conversion
argumentConversion = this.Conversions.ClassifyConversionFromExpression(right, delegateType, isChecked: CheckOverflowAtRuntime, ref useSiteInfo);
820
var
conversion = this.Conversions.ClassifyConversionFromExpression(right, left.Type, isChecked: CheckOverflowAtRuntime, ref discardedUseSiteInfo);
1068
var
implicitConversion = Conversions.ClassifyImplicitConversionFromExpression(left, booleanType, ref useSiteInfo);
1276
var
conversion = this.Conversions.ClassifyConversionFromType(argumentType, op.GetParameterType(0), isChecked: CheckOverflowAtRuntime, ref useSiteInfo);
3306
Conversion
conv = Conversions.ClassifyConversionFromExpression(operand, targetType, isChecked: CheckOverflowAtRuntime, ref useSiteInfo);
3328
Conversion
conversion = Conversions.ClassifyBuiltInConversion(operandType, targetType, isChecked: CheckOverflowAtRuntime, ref useSiteInfo);
3785
Conversion
.NullLiteral,
3824
Conversion
conversion = Conversions.ClassifyBuiltInConversion(operandType, targetType, isChecked: CheckOverflowAtRuntime, ref useSiteInfo);
4067
var
rightConversion = Conversions.ClassifyImplicitConversionFromExpression(rightOperand, optLeftType0, ref useSiteInfo);
4085
var
rightConversion = Conversions.ClassifyImplicitConversionFromExpression(rightOperand, optLeftType, ref useSiteInfo);
4122
Conversion
leftConversionClassification;
4202
var
underlyingRightConversion = Conversions.ClassifyImplicitConversionFromExpression(rightOperand, underlyingLeftType, ref useSiteInfo);
4216
var
rightConversion = Conversions.ClassifyImplicitConversionFromExpression(rightOperand, leftType, ref useSiteInfo);
Binder\Binder_Patterns.cs (15)
424
var convertedExpression = BindExpressionOrTypeForPattern(inputType, innerExpression, ref hasErrors, diagnostics, out var constantValueOpt, out bool wasExpression, out
Conversion
patternConversion);
453
private bool ShouldBlockINumberBaseConversion(
Conversion
patternConversion, TypeSymbol inputType)
504
out
Conversion
patternExpressionConversion)
517
patternExpressionConversion =
Conversion
.NoConversion;
532
out
Conversion
patternExpressionConversion)
538
patternExpressionConversion =
Conversion
.NoConversion;
549
out
Conversion
patternExpressionConversion)
594
out
Conversion
patternExpressionConversion)
640
patternExpressionConversion =
Conversion
.NoConversion;
647
patternExpressionConversion =
Conversion
.NoConversion;
676
patternExpressionConversion =
Conversion
.NoConversion;
766
Conversions, inputType, patternType, ref useSiteInfo, out
Conversion
conversion, operandConstantValue: null, operandCouldBeNull: true);
807
out
Conversion
conversion,
817
conversion =
Conversion
.Identity;
1631
BoundExpression value = BindExpressionForPattern(inputType, node.Expression, ref hasErrors, diagnostics, out var constantValueOpt, out _, out
Conversion
patternConversion);
Binder\Binder_Statements.cs (11)
1367
Conversion
elementConversionClassification = this.Conversions.ClassifyConversionFromType(pointerType, declType, isChecked: CheckOverflowAtRuntime, ref useSiteInfo);
1920
internal BoundExpression GenerateConversionForAssignment(TypeSymbol targetType, BoundExpression expression, BindingDiagnosticBag diagnostics, out
Conversion
conversion, ConversionForAssignmentFlags flags = ConversionForAssignmentFlags.None)
2229
Conversion
conversion, TypeSymbol sourceType, TypeSymbol targetType, ConstantValue sourceConstantValueOpt = null)
2299
Conversion
conversion,
2421
var
conversion = this.Conversions.ClassifyImplicitConversionFromExpression(expr, targetType, ref useSiteInfo);
2521
var
elementConversion = Conversions.ClassifyImplicitConversionFromExpression(argument, targetElementType, ref discardedUseSiteInfo);
2644
return BoundConversion.Synthesized(node, BindToTypeForErrorRecovery(expr),
Conversion
.NoConversion, false, explicitCastInCode: false, conversionGroupOpt: null, ConstantValue.NotAvailable, boolean, hasErrors: true);
2669
var
conversion = this.Conversions.ClassifyConversionFromExpression(expr, boolean, isChecked: CheckOverflowAtRuntime, ref useSiteInfo);
2710
return BoundConversion.Synthesized(node, expr,
Conversion
.NoConversion, false, explicitCastInCode: false, conversionGroupOpt: null, ConstantValue.NotAvailable, boolean, hasErrors: true);
3132
Conversion
conversion;
3141
conversion =
Conversion
.NoConversion;
Binder\Binder_TupleOperators.cs (1)
132
Conversion
conversion = this.Conversions.ClassifyImplicitConversionFromType(type, boolean, ref useSiteInfo);
Binder\DecisionDagBuilder.cs (2)
460
Conversion
conversion = _conversions.ClassifyBuiltInConversion(inputType, type, isChecked: false, ref useSiteInfo);
1544
ConstantValue result = Binder.ExpressionOfTypeMatchesPatternType(_conversions, expressionType, patternType, ref useSiteInfo, out
Conversion
conversion);
Binder\ForEachLoopBinder.cs (5)
469
Conversion
elementConversionClassification = this.Conversions.ClassifyConversionFromType(inferredType.Type, iterationVariableType.Type, isChecked: CheckOverflowAtRuntime, ref useSiteInfo, forCast: true);
523
Conversion
collectionConversionClassification = this.Conversions.ClassifyConversionFromExpression(collectionExpr, builder.CollectionType, isChecked: CheckOverflowAtRuntime, ref useSiteInfo);
524
Conversion
currentConversionClassification = this.Conversions.ClassifyConversionFromType(builder.CurrentPropertyGetter.ReturnType, builder.ElementType, isChecked: CheckOverflowAtRuntime, ref useSiteInfo);
622
Conversion
collectionConversionClassification,
1529
var
collectionConversion = this.Conversions.ClassifyConversionFromExpression(collectionExpr, result.Parameters[0].Type, isChecked: CheckOverflowAtRuntime, ref useSiteInfo);
Binder\RefSafetyAnalysis.cs (2)
921
private void VisitDeconstructionArguments(ArrayBuilder<DeconstructionVariable> variables, SyntaxNode syntax,
Conversion
conversion, BoundExpression right)
985
var
underlyingConversion = BoundNode.GetConversion(placeholderConversion, placeholder);
Binder\Semantics\Conversions\Conversion.cs (117)
19
public readonly struct Conversion : IEquatable<
Conversion
>, IConvertibleConversion
83
public NestedUncommonData(ImmutableArray<
Conversion
> nestedConversions)
88
internal readonly ImmutableArray<
Conversion
> _nestedConversionsOpt;
112
ImmutableArray<
Conversion
> elementConversions) :
129
internal static
Conversion
CreateCollectionExpressionConversion(
132
ImmutableArray<
Conversion
> elementConversions)
173
internal Conversion(ConversionKind kind, ImmutableArray<
Conversion
> nestedConversions)
188
internal
Conversion
SetConversionMethod(MethodSymbol conversionMethod)
200
internal
Conversion
SetArrayIndexConversionForDynamic()
260
internal static
Conversion
GetTrivialConversion(ConversionKind kind)
266
internal static
Conversion
UnsetConversion => new Conversion(ConversionKind.UnsetConversionKind);
267
internal static
Conversion
NoConversion => new Conversion(ConversionKind.NoConversion);
268
internal static
Conversion
Identity => new Conversion(ConversionKind.Identity);
269
internal static
Conversion
ImplicitConstant => new Conversion(ConversionKind.ImplicitConstant);
270
internal static
Conversion
ImplicitNumeric => new Conversion(ConversionKind.ImplicitNumeric);
271
internal static
Conversion
ImplicitReference => new Conversion(ConversionKind.ImplicitReference);
272
internal static
Conversion
ImplicitEnumeration => new Conversion(ConversionKind.ImplicitEnumeration);
273
internal static
Conversion
ImplicitThrow => new Conversion(ConversionKind.ImplicitThrow);
274
internal static
Conversion
ObjectCreation => new Conversion(ConversionKind.ObjectCreation);
275
internal static
Conversion
CollectionExpression => new Conversion(ConversionKind.CollectionExpression);
276
internal static
Conversion
AnonymousFunction => new Conversion(ConversionKind.AnonymousFunction);
277
internal static
Conversion
Boxing => new Conversion(ConversionKind.Boxing);
278
internal static
Conversion
NullLiteral => new Conversion(ConversionKind.NullLiteral);
279
internal static
Conversion
DefaultLiteral => new Conversion(ConversionKind.DefaultLiteral);
280
internal static
Conversion
NullToPointer => new Conversion(ConversionKind.ImplicitNullToPointer);
281
internal static
Conversion
PointerToVoid => new Conversion(ConversionKind.ImplicitPointerToVoid);
282
internal static
Conversion
PointerToPointer => new Conversion(ConversionKind.ExplicitPointerToPointer);
283
internal static
Conversion
PointerToInteger => new Conversion(ConversionKind.ExplicitPointerToInteger);
284
internal static
Conversion
IntegerToPointer => new Conversion(ConversionKind.ExplicitIntegerToPointer);
285
internal static
Conversion
Unboxing => new Conversion(ConversionKind.Unboxing);
286
internal static
Conversion
ExplicitReference => new Conversion(ConversionKind.ExplicitReference);
287
internal static
Conversion
IntPtr => new Conversion(ConversionKind.IntPtr);
288
internal static
Conversion
ExplicitEnumeration => new Conversion(ConversionKind.ExplicitEnumeration);
289
internal static
Conversion
ExplicitNumeric => new Conversion(ConversionKind.ExplicitNumeric);
290
internal static
Conversion
ImplicitDynamic => new Conversion(ConversionKind.ImplicitDynamic);
291
internal static
Conversion
ExplicitDynamic => new Conversion(ConversionKind.ExplicitDynamic);
292
internal static
Conversion
InterpolatedString => new Conversion(ConversionKind.InterpolatedString);
293
internal static
Conversion
InterpolatedStringHandler => new Conversion(ConversionKind.InterpolatedStringHandler);
294
internal static
Conversion
Deconstruction => new Conversion(ConversionKind.Deconstruction);
295
internal static
Conversion
PinnedObjectToPointer => new Conversion(ConversionKind.PinnedObjectToPointer);
296
internal static
Conversion
ImplicitPointer => new Conversion(ConversionKind.ImplicitPointer);
297
internal static
Conversion
FunctionType => new Conversion(ConversionKind.FunctionType);
298
internal static
Conversion
InlineArray => new Conversion(ConversionKind.InlineArray);
299
internal static
Conversion
ImplicitSpan => new Conversion(ConversionKind.ImplicitSpan);
300
internal static
Conversion
ExplicitSpan => new Conversion(ConversionKind.ExplicitSpan);
304
internal static ImmutableArray<
Conversion
> IdentityUnderlying => ConversionSingletons.IdentityUnderlying;
305
internal static ImmutableArray<
Conversion
> ImplicitConstantUnderlying => ConversionSingletons.ImplicitConstantUnderlying;
306
internal static ImmutableArray<
Conversion
> ImplicitNumericUnderlying => ConversionSingletons.ImplicitNumericUnderlying;
307
internal static ImmutableArray<
Conversion
> ExplicitNumericUnderlying => ConversionSingletons.ExplicitNumericUnderlying;
308
internal static ImmutableArray<
Conversion
> ExplicitEnumerationUnderlying => ConversionSingletons.ExplicitEnumerationUnderlying;
309
internal static ImmutableArray<
Conversion
> PointerToIntegerUnderlying => ConversionSingletons.PointerToIntegerUnderlying;
312
internal static readonly
Conversion
ExplicitNullableWithExplicitEnumerationUnderlying = new Conversion(ConversionKind.ExplicitNullable, ExplicitEnumerationUnderlying);
313
internal static readonly
Conversion
ExplicitNullableWithPointerToIntegerUnderlying = new Conversion(ConversionKind.ExplicitNullable, PointerToIntegerUnderlying);
314
internal static readonly
Conversion
ExplicitNullableWithIdentityUnderlying = new Conversion(ConversionKind.ExplicitNullable, IdentityUnderlying);
315
internal static readonly
Conversion
ExplicitNullableWithImplicitNumericUnderlying = new Conversion(ConversionKind.ExplicitNullable, ImplicitNumericUnderlying);
316
internal static readonly
Conversion
ExplicitNullableWithExplicitNumericUnderlying = new Conversion(ConversionKind.ExplicitNullable, ExplicitNumericUnderlying);
317
internal static readonly
Conversion
ExplicitNullableWithImplicitConstantUnderlying = new Conversion(ConversionKind.ExplicitNullable, ImplicitConstantUnderlying);
319
internal static readonly
Conversion
ImplicitNullableWithExplicitEnumerationUnderlying = new Conversion(ConversionKind.ImplicitNullable, ExplicitEnumerationUnderlying);
320
internal static readonly
Conversion
ImplicitNullableWithPointerToIntegerUnderlying = new Conversion(ConversionKind.ImplicitNullable, PointerToIntegerUnderlying);
321
internal static readonly
Conversion
ImplicitNullableWithIdentityUnderlying = new Conversion(ConversionKind.ImplicitNullable, IdentityUnderlying);
322
internal static readonly
Conversion
ImplicitNullableWithImplicitNumericUnderlying = new Conversion(ConversionKind.ImplicitNullable, ImplicitNumericUnderlying);
323
internal static readonly
Conversion
ImplicitNullableWithExplicitNumericUnderlying = new Conversion(ConversionKind.ImplicitNullable, ExplicitNumericUnderlying);
324
internal static readonly
Conversion
ImplicitNullableWithImplicitConstantUnderlying = new Conversion(ConversionKind.ImplicitNullable, ImplicitConstantUnderlying);
330
internal static ImmutableArray<
Conversion
> IdentityUnderlying = ImmutableArray.Create(Identity);
331
internal static ImmutableArray<
Conversion
> ImplicitConstantUnderlying = ImmutableArray.Create(ImplicitConstant);
332
internal static ImmutableArray<
Conversion
> ImplicitNumericUnderlying = ImmutableArray.Create(ImplicitNumeric);
333
internal static ImmutableArray<
Conversion
> ExplicitNumericUnderlying = ImmutableArray.Create(ExplicitNumeric);
334
internal static ImmutableArray<
Conversion
> ExplicitEnumerationUnderlying = ImmutableArray.Create(ExplicitEnumeration);
335
internal static ImmutableArray<
Conversion
> PointerToIntegerUnderlying = ImmutableArray.Create(PointerToInteger);
338
internal static
Conversion
MakeStackAllocToPointerType(
Conversion
underlyingConversion)
343
internal static
Conversion
MakeStackAllocToSpanType(
Conversion
underlyingConversion)
348
internal static
Conversion
MakeNullableConversion(ConversionKind kind,
Conversion
nestedConversion)
364
internal static
Conversion
MakeSwitchExpression(ImmutableArray<
Conversion
> innerConversions)
369
internal static
Conversion
MakeConditionalExpression(ImmutableArray<
Conversion
> innerConversions)
398
internal ImmutableArray<
Conversion
> UnderlyingConversions
404
default(ImmutableArray<
Conversion
>);
425
foreach (
var
underlying in underlyingConversions)
464
foreach (
var
underlying in underlyingConversions)
575
foreach (
var
conv in nestedConversions)
1079
internal
Conversion
UserDefinedFromConversion
1084
return best == null ?
Conversion
.NoConversion : best.SourceConversion;
1091
internal
Conversion
UserDefinedToConversion
1096
return best == null ?
Conversion
.NoConversion : best.TargetConversion;
1147
/// This is a lossy conversion; it is not possible to recover the original <see cref="
Conversion
"/>
1167
/// Determines whether the specified <see cref="
Conversion
"/> object is equal to the current <see cref="
Conversion
"/> object.
1169
/// <param name="obj">The <see cref="
Conversion
"/> object to compare with the current <see cref="
Conversion
"/> object.</param>
1170
/// <returns>true if the specified <see cref="
Conversion
"/> object is equal to the current <see cref="
Conversion
"/> object; otherwise, false.</returns>
1173
return obj is
Conversion
&& this.Equals((
Conversion
)obj);
1177
/// Determines whether the specified <see cref="
Conversion
"/> object is equal to the current <see cref="
Conversion
"/> object.
1179
/// <param name="other">The <see cref="
Conversion
"/> object to compare with the current <see cref="
Conversion
"/> object.</param>
1180
/// <returns>true if the specified <see cref="
Conversion
"/> object is equal to the current <see cref="
Conversion
"/> object; otherwise, false.</returns>
1181
public bool Equals(
Conversion
other)
1187
/// Returns a hash code for the current <see cref="
Conversion
"/> object.
1189
/// <returns>A hash code for the current <see cref="
Conversion
"/> object.</returns>
1196
/// Returns true if the specified <see cref="
Conversion
"/> objects are equal and false otherwise.
1198
/// <param name="left">The first <see cref="
Conversion
"/> object.</param>
1199
/// <param name="right">The second <see cref="
Conversion
"/> object.</param>
1201
public static bool operator ==(
Conversion
left,
Conversion
right)
1207
/// Returns false if the specified <see cref="
Conversion
"/> objects are equal and true otherwise.
1209
/// <param name="left">The first <see cref="
Conversion
"/> object.</param>
1210
/// <param name="right">The second <see cref="
Conversion
"/> object.</param>
1212
public static bool operator !=(
Conversion
left,
Conversion
right)
1222
TreeDumperNode Dump(
Conversion
self)
Binder\Semantics\Conversions\Conversions.cs (39)
44
public override
Conversion
GetMethodGroupDelegateConversion(BoundMethodGroup source, TypeSymbol destination, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
49
return
Conversion
.NoConversion;
55
return
Conversion
.NoConversion;
105
var
conversion = (resolution.IsEmpty || resolution.HasAnyErrors) ?
106
Conversion
.NoConversion :
113
public override
Conversion
GetMethodGroupFunctionPointerConversion(BoundMethodGroup source, FunctionPointerTypeSymbol destination, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
122
var
conversion = (resolution.IsEmpty || resolution.HasAnyErrors) ?
123
Conversion
.NoConversion :
129
protected override
Conversion
GetInterpolatedStringConversion(BoundExpression source, TypeSymbol destination, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
135
return
Conversion
.NoConversion;
140
return
Conversion
.InterpolatedStringHandler;
145
return
Conversion
.NoConversion;
153
?
Conversion
.InterpolatedString :
Conversion
.NoConversion;
157
protected override
Conversion
GetCollectionExpressionConversion(
168
return
Conversion
.NoConversion;
177
return
Conversion
.NoConversion;
193
return
Conversion
.NoConversion;
199
return
Conversion
.NoConversion;
203
var builder = ArrayBuilder<
Conversion
>.GetInstance(elements.Length);
206
Conversion
elementConversion = convertElement(element, elementType, ref useSiteInfo);
210
return
Conversion
.NoConversion;
216
return
Conversion
.CreateCollectionExpressionConversion(collectionTypeKind, elementType, constructor, isExpanded, builder.ToImmutableAndFree());
218
Conversion
convertElement(BoundNode element, TypeSymbol elementType, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
228
internal
Conversion
GetCollectionExpressionSpreadElementConversion(
236
return
Conversion
.NoConversion;
376
public
Conversion
MethodGroupConversion(SyntaxNode syntax, MethodGroup methodGroup, NamedTypeSymbol delegateType, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
395
var
conversion = ToConversion(result, methodGroup, delegateType.DelegateInvokeMethod.ParameterCount);
427
private static
Conversion
ToConversion(OverloadResolutionResult<MethodSymbol> result, MethodGroup methodGroup, int parameterCount)
447
return
Conversion
.NoConversion;
454
return
Conversion
.NoConversion;
460
return
Conversion
.NoConversion;
465
return
Conversion
.NoConversion;
484
public override
Conversion
GetStackAllocConversion(BoundStackAllocArrayCreation sourceExpression, TypeSymbol destination, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
492
var
pointerConversion = ClassifyImplicitConversionFromType(sourceAsPointer, destination, ref useSiteInfo);
496
return
Conversion
.MakeStackAllocToPointerType(pointerConversion);
504
var
spanConversion = ClassifyImplicitConversionFromType(spanType_T, destination, ref useSiteInfo);
508
return
Conversion
.MakeStackAllocToSpanType(spanConversion);
514
return
Conversion
.NoConversion;
Binder\Semantics\Conversions\ConversionsBase.cs (218)
67
public abstract
Conversion
GetMethodGroupDelegateConversion(BoundMethodGroup source, TypeSymbol destination, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo);
69
public abstract
Conversion
GetMethodGroupFunctionPointerConversion(BoundMethodGroup source, FunctionPointerTypeSymbol destination, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo);
71
public abstract
Conversion
GetStackAllocConversion(BoundStackAllocArrayCreation sourceExpression, TypeSymbol destination, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo);
75
protected abstract
Conversion
GetInterpolatedStringConversion(BoundExpression source, TypeSymbol destination, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo);
78
protected abstract
Conversion
GetCollectionExpressionConversion(BoundUnconvertedCollectionExpression source, TypeSymbol destination, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo);
98
public
Conversion
ClassifyImplicitConversionFromExpression(BoundExpression sourceExpression, TypeSymbol destination, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
109
return
Conversion
.Identity;
112
Conversion
conversion = ClassifyImplicitBuiltInConversionFromExpression(sourceExpression, sourceType, destination, ref useSiteInfo);
121
Conversion
fastConversion = FastClassifyConversion(sourceType, destination);
142
return
Conversion
.FunctionType;
169
public
Conversion
ClassifyImplicitConversionFromType(TypeSymbol source, TypeSymbol destination, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
177
return
Conversion
.Identity;
181
Conversion
fastConversion = FastClassifyConversion(source, destination);
184
return fastConversion.IsImplicit ? fastConversion :
Conversion
.NoConversion;
188
Conversion
conversion = ClassifyImplicitBuiltInConversionSlow(source, destination, ref useSiteInfo);
204
public
Conversion
ClassifyImplicitConversionFromTypeWhenNeitherOrBothFunctionTypes(TypeSymbol source, TypeSymbol destination, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
217
Conversion
.FunctionType :
218
Conversion
.NoConversion;
222
return
Conversion
.NoConversion;
234
public
Conversion
ClassifyConversionFromExpressionType(TypeSymbol source, TypeSymbol destination, bool isChecked, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
242
return
Conversion
.ImplicitDynamic;
248
private static bool TryGetVoidConversion(TypeSymbol source, TypeSymbol destination, out
Conversion
conversion)
259
conversion =
Conversion
.Identity;
266
conversion =
Conversion
.NoConversion;
283
public
Conversion
ClassifyConversionFromExpression(BoundExpression sourceExpression, TypeSymbol destination, bool isChecked, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo, bool forCast = false)
289
if (TryGetVoidConversion(sourceExpression.Type, destination, out
var
conversion))
299
var
result = ClassifyImplicitConversionFromExpression(sourceExpression, destination, ref useSiteInfo);
317
public
Conversion
ClassifyConversionFromType(TypeSymbol source, TypeSymbol destination, bool isChecked, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo, bool forCast = false)
322
if (TryGetVoidConversion(source, destination, out
var
voidConversion))
333
Conversion
fastConversion = FastClassifyConversion(source, destination);
340
Conversion
conversion1 = ClassifyImplicitBuiltInConversionSlow(source, destination, ref useSiteInfo);
347
Conversion
conversion = GetImplicitUserDefinedConversion(source, destination, ref useSiteInfo);
375
private
Conversion
ClassifyConversionFromExpressionForCast(BoundExpression source, TypeSymbol destination, bool isChecked, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
381
Conversion
implicitConversion = ClassifyImplicitConversionFromExpression(source, destination, ref useSiteInfo);
387
Conversion
explicitConversion = ClassifyExplicitOnlyConversionFromExpression(source, destination, isChecked: isChecked, ref useSiteInfo, forCast: true);
429
private
Conversion
ClassifyConversionFromTypeForCast(TypeSymbol source, TypeSymbol destination, bool isChecked, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
435
Conversion
fastConversion = FastClassifyConversion(source, destination);
441
Conversion
implicitBuiltInConversion = ClassifyImplicitBuiltInConversionSlow(source, destination, ref useSiteInfo);
447
Conversion
explicitBuiltInConversion = ClassifyExplicitBuiltInOnlyConversion(source, destination, isChecked: isChecked, ref useSiteInfo, forCast: true);
474
var
conversion = GetExplicitUserDefinedConversion(source, destination, isChecked: isChecked, ref useSiteInfo);
488
public static
Conversion
FastClassifyConversion(TypeSymbol source, TypeSymbol target)
493
return
Conversion
.GetTrivialConversion(convKind);
496
return
Conversion
.MakeNullableConversion(convKind, FastClassifyConversion(source.StrippedType(), target.StrippedType()));
499
public
Conversion
ClassifyBuiltInConversion(TypeSymbol source, TypeSymbol destination, bool isChecked, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
505
Conversion
fastConversion = FastClassifyConversion(source, destination);
512
Conversion
conversion = ClassifyImplicitBuiltInConversionSlow(source, destination, ref useSiteInfo);
529
public
Conversion
ClassifyStandardConversion(TypeSymbol source, TypeSymbol destination, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
541
public
Conversion
ClassifyStandardConversion(BoundExpression sourceExpression, TypeSymbol source, TypeSymbol destination, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
569
Conversion
conversion = ClassifyStandardImplicitConversion(sourceExpression, source, destination, ref useSiteInfo);
580
return
Conversion
.NoConversion;
605
private
Conversion
ClassifyStandardImplicitConversion(BoundExpression sourceExpression, TypeSymbol source, TypeSymbol destination, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
642
Conversion
conversion = ClassifyImplicitBuiltInConversionFromExpression(sourceExpression, source, destination, ref useSiteInfo);
656
return
Conversion
.NoConversion;
658
static bool isImplicitCollectionExpressionConversion(
Conversion
conversion)
695
private
Conversion
ClassifyStandardImplicitConversion(TypeSymbol source, TypeSymbol destination, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
697
var
conversion = classifyConversion(source, destination, ref useSiteInfo);
701
Conversion
classifyConversion(TypeSymbol source, TypeSymbol destination, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
708
return
Conversion
.Identity;
713
return
Conversion
.ImplicitNumeric;
716
var
nullableConversion = ClassifyImplicitNullableConversion(source, destination, ref useSiteInfo);
725
return
Conversion
.NoConversion;
730
return
Conversion
.ImplicitReference;
735
return
Conversion
.Boxing;
740
return
Conversion
.PointerToVoid;
745
return
Conversion
.ImplicitPointer;
748
var
tupleConversion = ClassifyImplicitTupleConversion(source, destination, ref useSiteInfo);
756
return
Conversion
.ImplicitSpan;
759
return
Conversion
.NoConversion;
763
private
Conversion
ClassifyImplicitBuiltInConversionSlow(TypeSymbol source, TypeSymbol destination, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
770
return
Conversion
.NoConversion;
773
Conversion
conversion = ClassifyStandardImplicitConversion(source, destination, ref useSiteInfo);
779
return
Conversion
.NoConversion;
782
private
Conversion
GetImplicitUserDefinedConversion(BoundExpression sourceExpression, TypeSymbol source, TypeSymbol destination, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
788
private
Conversion
GetImplicitUserDefinedConversion(TypeSymbol source, TypeSymbol destination, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
793
private
Conversion
ClassifyExplicitBuiltInOnlyConversion(TypeSymbol source, TypeSymbol destination, bool isChecked, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo, bool forCast)
800
return
Conversion
.NoConversion;
814
return
Conversion
.IntPtr;
819
return
Conversion
.ExplicitEnumeration;
822
var
nullableConversion = ClassifyExplicitNullableConversion(source, destination, isChecked: isChecked, ref useSiteInfo, forCast);
830
return (source.Kind == SymbolKind.DynamicType) ?
Conversion
.ExplicitDynamic :
Conversion
.ExplicitReference;
835
return
Conversion
.Unboxing;
838
var
tupleConversion = ClassifyExplicitTupleConversion(source, destination, isChecked: isChecked, ref useSiteInfo, forCast);
846
return
Conversion
.PointerToPointer;
851
return
Conversion
.PointerToInteger;
856
return
Conversion
.IntegerToPointer;
861
return
Conversion
.ExplicitDynamic;
866
return
Conversion
.ExplicitSpan;
869
return
Conversion
.NoConversion;
872
private
Conversion
GetExplicitUserDefinedConversion(BoundExpression sourceExpression, TypeSymbol source, TypeSymbol destination, bool isChecked, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
878
private
Conversion
GetExplicitUserDefinedConversion(TypeSymbol source, TypeSymbol destination, bool isChecked, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
883
private
Conversion
DeriveStandardExplicitFromOppositeStandardImplicitConversion(TypeSymbol source, TypeSymbol destination, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
885
var
oppositeConversion = ClassifyStandardImplicitConversion(destination, source, ref useSiteInfo);
886
Conversion
impliedExplicitConversion;
891
impliedExplicitConversion =
Conversion
.Identity;
894
impliedExplicitConversion =
Conversion
.ExplicitNumeric;
897
impliedExplicitConversion =
Conversion
.ExplicitReference;
900
impliedExplicitConversion =
Conversion
.Unboxing;
903
impliedExplicitConversion =
Conversion
.NoConversion;
906
impliedExplicitConversion =
Conversion
.PointerToPointer;
912
impliedExplicitConversion =
Conversion
.NoConversion;
918
var
underlyingConversion = DeriveStandardExplicitFromOppositeStandardImplicitConversion(strippedSource, strippedDestination, ref useSiteInfo);
923
Conversion
.MakeNullableConversion(ConversionKind.ExplicitNullable, underlyingConversion) :
924
Conversion
.NoConversion;
929
impliedExplicitConversion =
Conversion
.NoConversion;
1010
private static bool ExplicitConversionMayDifferFromImplicit(
Conversion
implicitConversion)
1029
private
Conversion
ClassifyImplicitBuiltInConversionFromExpression(BoundExpression sourceExpression, TypeSymbol source, TypeSymbol destination, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
1038
return
Conversion
.ImplicitDynamic;
1045
return
Conversion
.NoConversion;
1050
return
Conversion
.ImplicitEnumeration;
1053
var
constantConversion = ClassifyImplicitConstantExpressionConversion(sourceExpression, destination);
1062
var
nullLiteralConversion = ClassifyNullLiteralConversion(sourceExpression, destination);
1070
return
Conversion
.DefaultLiteral;
1075
var
innerConversion = ClassifyImplicitBuiltInConversionFromExpression(innerExpression, innerExpression.Type, destination, ref useSiteInfo);
1083
var
tupleConversion = ClassifyImplicitTupleLiteralConversion((BoundTupleLiteral)sourceExpression, destination, ref useSiteInfo);
1093
return
Conversion
.AnonymousFunction;
1098
Conversion
methodGroupConversion = GetMethodGroupDelegateConversion((BoundMethodGroup)sourceExpression, destination, ref useSiteInfo);
1107
Conversion
interpolatedStringConversion = GetInterpolatedStringConversion(sourceExpression, destination, ref useSiteInfo);
1114
var
stackAllocConversion = GetStackAllocConversion((BoundStackAllocArrayCreation)sourceExpression, destination, ref useSiteInfo);
1122
var
addressOfConversion = GetMethodGroupFunctionPointerConversion(((BoundUnconvertedAddressOfOperator)sourceExpression).Operand, funcPtrType, ref useSiteInfo);
1130
return
Conversion
.ImplicitThrow;
1133
return
Conversion
.ObjectCreation;
1136
var
collectionExpressionConversion = GetImplicitCollectionExpressionConversion((BoundUnconvertedCollectionExpression)sourceExpression, destination, ref useSiteInfo);
1152
return
Conversion
.InlineArray;
1155
return
Conversion
.NoConversion;
1159
private
Conversion
GetImplicitCollectionExpressionConversion(BoundUnconvertedCollectionExpression collectionExpression, TypeSymbol destination, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
1161
var
collectionExpressionConversion = GetCollectionExpressionConversion(collectionExpression, destination, ref useSiteInfo);
1173
var
underlyingConversion = GetCollectionExpressionConversion(collectionExpression, underlyingDestination, ref useSiteInfo);
1180
return
Conversion
.NoConversion;
1184
private
Conversion
GetSwitchExpressionConversion(BoundExpression source, TypeSymbol destination, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
1192
return
Conversion
.NoConversion;
1194
var innerConversions = ArrayBuilder<
Conversion
>.GetInstance(switchExpression.SwitchArms.Length);
1197
var
nestedConversion = this.ClassifyImplicitConversionFromExpression(arm.Value, destination, ref useSiteInfo);
1201
return
Conversion
.NoConversion;
1207
return
Conversion
.MakeSwitchExpression(innerConversions.ToImmutableAndFree());
1209
return
Conversion
.NoConversion;
1213
private
Conversion
GetConditionalExpressionConversion(BoundExpression source, TypeSymbol destination, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
1218
return
Conversion
.NoConversion;
1220
var
trueConversion = this.ClassifyImplicitConversionFromExpression(conditionalOperator.Consequence, destination, ref useSiteInfo);
1222
return
Conversion
.NoConversion;
1224
var
falseConversion = this.ClassifyImplicitConversionFromExpression(conditionalOperator.Alternative, destination, ref useSiteInfo);
1226
return
Conversion
.NoConversion;
1228
return
Conversion
.MakeConditionalExpression(ImmutableArray.Create(trueConversion, falseConversion));
1231
private static
Conversion
ClassifyNullLiteralConversion(BoundExpression source, TypeSymbol destination)
1238
return
Conversion
.NoConversion;
1246
return
Conversion
.NullLiteral;
1256
return
Conversion
.ImplicitReference;
1264
return
Conversion
.NullToPointer;
1267
return
Conversion
.NoConversion;
1270
private static
Conversion
ClassifyImplicitConstantExpressionConversion(BoundExpression source, TypeSymbol destination)
1274
return
Conversion
.ImplicitConstant;
1286
return
Conversion
.ImplicitNullableWithImplicitConstantUnderlying;
1290
return
Conversion
.NoConversion;
1293
private
Conversion
ClassifyImplicitTupleLiteralConversion(BoundTupleLiteral source, TypeSymbol destination, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
1297
var
tupleConversion = GetImplicitTupleLiteralConversion(source, destination, ref useSiteInfo);
1309
var
underlyingTupleConversion = GetImplicitTupleLiteralConversion(source, underlyingDestination, ref useSiteInfo);
1316
return
Conversion
.NoConversion;
1319
private
Conversion
ClassifyExplicitTupleLiteralConversion(BoundTupleLiteral source, TypeSymbol destination, bool isChecked, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo, bool forCast)
1323
var
tupleConversion = GetExplicitTupleLiteralConversion(source, destination, isChecked: isChecked, ref useSiteInfo, forCast);
1337
var
underlyingTupleConversion = GetExplicitTupleLiteralConversion(source, underlyingDestination, isChecked: isChecked, ref useSiteInfo, forCast);
1346
return
Conversion
.NoConversion;
1401
private
Conversion
ClassifyExplicitOnlyConversionFromExpression(BoundExpression sourceExpression, TypeSymbol destination, bool isChecked, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo, bool forCast)
1412
Conversion
tupleConversion = ClassifyExplicitTupleLiteralConversion((BoundTupleLiteral)sourceExpression, destination, isChecked: isChecked, ref useSiteInfo, forCast);
1423
Conversion
fastConversion = FastClassifyConversion(sourceType, destination);
1430
var
conversion = ClassifyExplicitBuiltInOnlyConversion(sourceType, destination, isChecked: isChecked, ref useSiteInfo, forCast);
1721
internal
Conversion
ClassifyImplicitUserDefinedConversionForV6SwitchGoverningType(TypeSymbol sourceType, out TypeSymbol switchGoverningType, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
1753
internal
Conversion
GetCallerLineNumberConversion(TypeSymbol destination, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
1766
return
Conversion
.ImplicitEnumeration;
1769
var
constantConversion = ClassifyImplicitConstantExpressionConversion(intMaxValueLiteral, destination);
1786
Conversion
conversion = ClassifyStandardImplicitConversion(expectedAttributeType, destination, ref useSiteInfo);
1912
public
Conversion
ConvertExtensionMethodThisArg(TypeSymbol parameterType, TypeSymbol thisType, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo, bool isMethodGroupConversion)
1915
var
conversion = this.ClassifyImplicitExtensionMethodThisArgConversion(sourceExpressionOpt: null, thisType, parameterType, ref useSiteInfo, isMethodGroupConversion);
1916
return IsValidExtensionMethodThisArgConversion(conversion) ? conversion :
Conversion
.NoConversion;
1922
public
Conversion
ClassifyImplicitExtensionMethodThisArgConversion(BoundExpression sourceExpressionOpt, TypeSymbol sourceType, TypeSymbol destination, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo, bool isMethodGroupConversion)
1932
return
Conversion
.Identity;
1937
return
Conversion
.Boxing;
1942
return
Conversion
.ImplicitReference;
1947
return
Conversion
.ImplicitSpan;
1956
var
tupleConversion = GetTupleLiteralConversion(
1973
var
tupleConversion = ClassifyTupleConversion(
1982
return
Conversion
.NoConversion;
1994
return
Conversion
.NoConversion;
2003
public static bool IsValidExtensionMethodThisArgConversion(
Conversion
conversion)
2016
foreach (
var
elementConversion in conversion.UnderlyingConversions)
2238
private
Conversion
ClassifyImplicitNullableConversion(TypeSymbol source, TypeSymbol destination, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
2251
return
Conversion
.NoConversion;
2259
return
Conversion
.NoConversion;
2264
return
Conversion
.ImplicitNullableWithIdentityUnderlying;
2269
return
Conversion
.ImplicitNullableWithImplicitNumericUnderlying;
2272
var
tupleConversion = ClassifyImplicitTupleConversion(unwrappedSource, unwrappedDestination, ref useSiteInfo);
2278
return
Conversion
.NoConversion;
2281
private delegate
Conversion
ClassifyConversionFromExpressionDelegate(ConversionsBase conversions, BoundExpression sourceExpression, TypeWithAnnotations destination, bool isChecked, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo, bool forCast);
2282
private delegate
Conversion
ClassifyConversionFromTypeDelegate(ConversionsBase conversions, TypeWithAnnotations source, TypeWithAnnotations destination, bool isChecked, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo, bool forCast);
2284
private
Conversion
GetImplicitTupleLiteralConversion(BoundTupleLiteral source, TypeSymbol destination, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
2302
private
Conversion
GetExplicitTupleLiteralConversion(BoundTupleLiteral source, TypeSymbol destination, bool isChecked, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo, bool forCast)
2320
private
Conversion
GetTupleLiteralConversion(
2336
return
Conversion
.NoConversion;
2343
var argumentConversions = ArrayBuilder<
Conversion
>.GetInstance(arguments.Length);
2347
var
result = classifyConversion(this, argument, targetElementTypes[i], isChecked: isChecked, ref useSiteInfo, forCast: forCast);
2351
return
Conversion
.NoConversion;
2360
private
Conversion
ClassifyImplicitTupleConversion(TypeSymbol source, TypeSymbol destination, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
2371
return
Conversion
.NoConversion;
2379
private
Conversion
ClassifyExplicitTupleConversion(TypeSymbol source, TypeSymbol destination, bool isChecked, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo, bool forCast)
2390
return
Conversion
.NoConversion;
2398
private
Conversion
ClassifyTupleConversion(
2414
return
Conversion
.NoConversion;
2417
var nestedConversions = ArrayBuilder<
Conversion
>.GetInstance(sourceTypes.Length);
2420
var
conversion = classifyConversion(this, sourceTypes[i], destTypes[i], isChecked: isChecked, ref useSiteInfo, forCast);
2424
return
Conversion
.NoConversion;
2433
private
Conversion
ClassifyExplicitNullableConversion(TypeSymbol source, TypeSymbol destination, bool isChecked, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo, bool forCast)
2448
return
Conversion
.NoConversion;
2456
return
Conversion
.ExplicitNullableWithIdentityUnderlying;
2461
return
Conversion
.ExplicitNullableWithImplicitNumericUnderlying;
2466
return
Conversion
.ExplicitNullableWithExplicitNumericUnderlying;
2469
var
tupleConversion = ClassifyExplicitTupleConversion(unwrappedSource, unwrappedDestination, isChecked: isChecked, ref useSiteInfo, forCast);
2477
return
Conversion
.ExplicitNullableWithExplicitEnumerationUnderlying;
2482
return
Conversion
.ExplicitNullableWithPointerToIntegerUnderlying;
2485
return
Conversion
.NoConversion;
Binder\Semantics\Conversions\TypeConversions.cs (5)
36
public override
Conversion
GetMethodGroupDelegateConversion(BoundMethodGroup source, TypeSymbol destination, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
42
public override
Conversion
GetMethodGroupFunctionPointerConversion(BoundMethodGroup source, FunctionPointerTypeSymbol destination, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
48
public override
Conversion
GetStackAllocConversion(BoundStackAllocArrayCreation sourceExpression, TypeSymbol destination, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
54
protected override
Conversion
GetInterpolatedStringConversion(BoundExpression source, TypeSymbol destination, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
60
protected override
Conversion
GetCollectionExpressionConversion(BoundUnconvertedCollectionExpression source, TypeSymbol destination, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
Binder\Semantics\Conversions\UserDefinedConversionAnalysis.cs (8)
26
public readonly
Conversion
SourceConversion;
27
public readonly
Conversion
TargetConversion;
33
Conversion
sourceConversion,
34
Conversion
targetConversion,
51
Conversion
sourceConversion,
52
Conversion
targetConversion,
70
Conversion
sourceConversion,
71
Conversion
targetConversion,
Binder\Semantics\Conversions\UserDefinedExplicitConversions.cs (8)
269
Conversion
fromConversion = EncompassingExplicitConversion(sourceExpression, source, convertsFrom, ref useSiteInfo);
270
Conversion
toConversion = EncompassingExplicitConversion(convertsTo, target, ref useSiteInfo);
321
Conversion
liftedFromConversion = EncompassingExplicitConversion(sourceExpression, source, nullableFrom, ref useSiteInfo);
322
Conversion
liftedToConversion = EncompassingExplicitConversion(nullableTo, target, ref useSiteInfo);
475
private
Conversion
EncompassingExplicitConversion(BoundExpression expr, TypeSymbol a, TypeSymbol b, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
494
var
result = ClassifyStandardConversion(expr, a, b, ref useSiteInfo);
495
return result.IsEnumeration ?
Conversion
.NoConversion : result;
498
private
Conversion
EncompassingExplicitConversion(TypeSymbol a, TypeSymbol b, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
Binder\Semantics\Conversions\UserDefinedImplicitConversions.cs (11)
299
Conversion
fromConversion = EncompassingImplicitConversion(sourceExpression, source, convertsFrom, ref useSiteInfo);
300
Conversion
toConversion = allowAnyTarget ?
Conversion
.Identity :
321
toConversion = allowAnyTarget ?
Conversion
.Identity :
347
Conversion
liftedFromConversion = EncompassingImplicitConversion(sourceExpression, source, nullableFrom, ref useSiteInfo);
348
Conversion
liftedToConversion = !allowAnyTarget ?
350
Conversion
.Identity;
589
private
Conversion
EncompassingImplicitConversion(BoundExpression aExpr, TypeSymbol a, TypeSymbol b, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
600
var
result = ClassifyStandardImplicitConversion(aExpr, a, b, ref useSiteInfo);
601
return IsEncompassingImplicitConversionKind(result.Kind) ? result :
Conversion
.NoConversion;
604
private
Conversion
EncompassingImplicitConversion(TypeSymbol a, TypeSymbol b, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
Binder\Semantics\Operators\BinaryOperatorAnalysisResult.cs (8)
16
public readonly
Conversion
LeftConversion;
17
public readonly
Conversion
RightConversion;
21
private BinaryOperatorAnalysisResult(OperatorAnalysisResultKind kind, BinaryOperatorSignature signature,
Conversion
leftConversion,
Conversion
rightConversion)
53
public static BinaryOperatorAnalysisResult Applicable(BinaryOperatorSignature signature,
Conversion
leftConversion,
Conversion
rightConversion)
58
public static BinaryOperatorAnalysisResult Inapplicable(BinaryOperatorSignature signature,
Conversion
leftConversion,
Conversion
rightConversion)
Binder\Semantics\Operators\BinaryOperatorEasyOut.cs (2)
314
Conversion
leftConversion = Conversions.FastClassifyConversion(leftType, signature.LeftType);
315
Conversion
rightConversion = Conversions.FastClassifyConversion(rightType, signature.RightType);
Binder\Semantics\Operators\BinaryOperatorOverloadResolution.cs (6)
728
var
convLeft = getOperandConversionForAllowByRefLikeNullCheck(isChecked, left, op.LeftType, ref useSiteInfo);
729
var
convRight = getOperandConversionForAllowByRefLikeNullCheck(isChecked, right, op.RightType, ref useSiteInfo);
777
Conversion
getOperandConversionForAllowByRefLikeNullCheck(bool isChecked, BoundExpression operand, TypeSymbol objectType, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
779
return (operand.Type is TypeParameterSymbol { AllowsRefLikeType: true }) ?
Conversion
.Boxing : Conversions.ClassifyConversionFromExpression(operand, objectType, isChecked: isChecked, ref useSiteInfo);
800
var
convLeft = Conversions.ClassifyConversionFromExpression(left, op.LeftType, isChecked: isChecked, ref useSiteInfo);
801
var
convRight = Conversions.ClassifyConversionFromExpression(right, op.RightType, isChecked: isChecked, ref useSiteInfo);
Binder\Semantics\Operators\UnaryOperatorAnalysisResult.cs (4)
14
public readonly
Conversion
Conversion;
17
private UnaryOperatorAnalysisResult(OperatorAnalysisResultKind kind, UnaryOperatorSignature signature,
Conversion
conversion)
36
public static UnaryOperatorAnalysisResult Applicable(UnaryOperatorSignature signature,
Conversion
conversion)
41
public static UnaryOperatorAnalysisResult Inapplicable(UnaryOperatorSignature signature,
Conversion
conversion)
Binder\Semantics\Operators\UnaryOperatorEasyOut.cs (1)
114
Conversion
? conversion = Conversions.FastClassifyConversion(operandType, signature.OperandType);
Binder\Semantics\Operators\UnaryOperatorOverloadResolution.cs (1)
277
var
conversion = Conversions.ClassifyConversionFromExpression(operand, op.OperandType, isChecked: isChecked, ref useSiteInfo);
Binder\Semantics\OverloadResolution\MemberAnalysisResult.cs (8)
24
private readonly ImmutableArray<
Conversion
> _conversionsOpt;
25
public ImmutableArray<
Conversion
> ConversionsOpt
121
ImmutableArray<
Conversion
> conversionsOpt = default,
152
public
Conversion
ConversionForArg(int arg)
156
return
Conversion
.Identity;
321
public static MemberAnalysisResult BadArgumentConversions(ImmutableArray<int> argsToParamsOpt, BitVector badArguments, ImmutableArray<
Conversion
> conversions, TypeWithAnnotations definitionParamsElementTypeOpt, TypeWithAnnotations paramsElementTypeOpt)
376
public static MemberAnalysisResult NormalForm(ImmutableArray<int> argsToParamsOpt, ImmutableArray<
Conversion
> conversions, bool hasAnyRefOmittedArgument)
381
public static MemberAnalysisResult ExpandedForm(ImmutableArray<int> argsToParamsOpt, ImmutableArray<
Conversion
> conversions, bool hasAnyRefOmittedArgument, TypeWithAnnotations definitionParamsElementType, TypeWithAnnotations paramsElementType)
Binder\Semantics\OverloadResolution\OverloadResolution.cs (37)
2614
var
c1 = m1.Result.ConversionForArg(i);
2615
var
c2 = m2.Result.ConversionForArg(i);
2827
Conversion
conv1,
2830
Conversion
conv2,
2880
private BetterResult BetterConversionFromExpression(BoundExpression node, TypeSymbol t1,
Conversion
conv1, TypeSymbol t2,
Conversion
conv2, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo, out bool okToDowngradeToNeither)
2989
TypeSymbol t1,
Conversion
conv1,
2990
TypeSymbol t2,
Conversion
conv2,
3023
TypeSymbol t1, CollectionExpressionTypeKind kind1, TypeSymbol elementType1, ImmutableArray<
Conversion
> underlyingElementConversions1,
3024
TypeSymbol t2, CollectionExpressionTypeKind kind2, TypeSymbol elementType2, ImmutableArray<
Conversion
> underlyingElementConversions2,
3075
var
conversionToE1 = underlyingElementConversions1[i];
3076
var
conversionToE2 = underlyingElementConversions2[i];
3403
return BetterConversionTargetCore(null, type1, default(
Conversion
), type2, default(
Conversion
), ref useSiteInfo, out okToDowngradeToNeither, betterConversionTargetRecursionLimit - 1);
3409
Conversion
conv1,
3411
Conversion
conv2,
3421
Conversion
conv1,
3423
Conversion
conv2,
3576
private bool IsMethodGroupConversionIncompatibleWithDelegate(BoundMethodGroup node, NamedTypeSymbol delegateType,
Conversion
conv)
3669
currentResult == BetterConversionTargetCore(null, type1, default(
Conversion
), type2, default(
Conversion
), ref useSiteInfo, out _, BetterConversionTargetRecursionLimit));
4396
ArrayBuilder<
Conversion
> conversions = null;
4401
Conversion
conversion;
4408
conversion =
Conversion
.Identity;
4418
conversion =
Conversion
.NoConversion;
4503
conversions = ArrayBuilder<
Conversion
>.GetInstance(paramCount);
4504
conversions.AddMany(
Conversion
.Identity, argumentPosition);
4515
var conversionsArray = conversions != null ? conversions.ToImmutableAndFree() : default(ImmutableArray<
Conversion
>);
4537
private
Conversion
CheckArgumentForApplicability(
4559
return
Conversion
.NoConversion;
4571
return
Conversion
.ImplicitDynamic;
4582
return
Conversion
.Identity;
4587
var
conversion = forExtensionMethodThisArg ?
4591
Conversion
.ImplicitDynamic);
4598
return
Conversion
.NoConversion;
4606
return
Conversion
.Identity;
4610
return
Conversion
.NoConversion;
Binder\SwitchBinder.cs (2)
257
Conversion
conversion = Conversions.ClassifyConversionFromExpression(caseExpression, SwitchGoverningType, isChecked: CheckOverflowAtRuntime, ref useSiteInfo);
412
Conversion
conversion = binder.Conversions.ClassifyImplicitUserDefinedConversionForV6SwitchGoverningType(switchGoverningType, out resultantGoverningType, ref useSiteInfo);
BoundTree\BoundExpressionExtensions.cs (2)
240
public static
Conversion
GetConversion(this BoundExpression boundNode)
249
return
Conversion
.Identity;
BoundTree\BoundNode.cs (3)
443
public static
Conversion
GetConversion(BoundExpression? conversion, BoundValuePlaceholder? placeholder)
448
return
Conversion
.NoConversion;
477
return
Conversion
.Identity;
BoundTree\Constructors.cs (5)
328
public static BoundConversion SynthesizedNonUserDefined(SyntaxNode syntax, BoundExpression operand,
Conversion
conversion, TypeSymbol type, ConstantValue? constantValueOpt = null)
352
Conversion
conversion,
378
Conversion
conversion,
402
Conversion
conversion,
415
Conversion
conversion,
BoundTree\ConversionGroup.cs (2)
18
internal ConversionGroup(
Conversion
conversion, TypeWithAnnotations explicitType = default)
33
internal readonly
Conversion
Conversion;
Compilation\BuiltInOperators.cs (2)
933
var
leftConversion = Conversions.ClassifyConversionFromType(leftType, rightType, isChecked: false, ref useSiteInfo);
939
var
rightConversion = Conversions.ClassifyConversionFromType(rightType, leftType, isChecked: false, ref useSiteInfo);
Compilation\CSharpCompilation.cs (6)
2284
/// <returns>A <see cref="
Conversion
"/> that classifies the conversion from the
2286
public
Conversion
ClassifyConversion(ITypeSymbol source, ITypeSymbol destination)
2332
return
Conversion
.NoConversion;
2343
return
Conversion
.NullLiteral;
2346
return
Conversion
.NoConversion;
2349
Conversion
result = ClassifyConversion(sourceType, destination);
Compilation\CSharpSemanticModel.cs (23)
966
return new CSharpTypeInfo(declarationTypeSymbol, declarationTypeSymbol, nullabilityInfo, nullabilityInfo,
Conversion
.Identity);
970
return new CSharpTypeInfo(declarationInfo.Type, declarationInfo.Type, declarationInfo.Nullability, declarationInfo.Nullability,
Conversion
.Identity);
1008
public
Conversion
GetConversion(SyntaxNode expression, CancellationToken cancellationToken = default(CancellationToken))
1069
public
Conversion
GetSpeculativeConversion(int position, ExpressionSyntax expression, SpeculativeBindingOption bindingOption)
2031
return new CSharpTypeInfo(member.Type, member.Type, nullability: default, convertedNullability: default,
Conversion
.Identity);
2088
Conversion
conversion;
2137
conversion = convertedSwitchConversion.IsValid ? convertedSwitchConversion :
Conversion
.NoConversion;
2144
conversion =
Conversion
.Identity;
2155
conversion =
Conversion
.MakeConditionalExpression(ImmutableArray<
Conversion
>.Empty);
2162
conversion =
Conversion
.Identity;
2185
conversion =
Conversion
.Identity;
2193
conversion =
Conversion
.Identity;
2238
conversion =
Conversion
.Identity;
2257
conversion =
Conversion
.Identity;
2355
return new CSharpTypeInfo(type, type, default, default,
Conversion
.Identity);
2808
public abstract
Conversion
ClassifyConversion(ExpressionSyntax expression, ITypeSymbol destination, bool isExplicitInSource = false);
2826
public
Conversion
ClassifyConversion(int position, ExpressionSyntax expression, ITypeSymbol destination, bool isExplicitInSource = false)
2838
return
Conversion
.NoConversion;
2864
return
Conversion
.NoConversion;
2879
internal abstract
Conversion
ClassifyConversionForCast(ExpressionSyntax expression, TypeSymbol destination);
2895
internal
Conversion
ClassifyConversionForCast(int position, ExpressionSyntax expression, TypeSymbol destination)
2916
return
Conversion
.NoConversion;
Compilation\DeconstructionInfo.cs (4)
29
private readonly
Conversion
_conversion;
47
public
Conversion
? Conversion
53
: (
Conversion
?)_conversion;
77
internal DeconstructionInfo(
Conversion
conversion)
Compilation\ForEachStatementInfo.cs (4)
55
public
Conversion
ElementConversion { get; }
60
public
Conversion
CurrentConversion { get; }
71
Conversion
elementConversion,
72
Conversion
currentConversion)
Compilation\MemberSemanticModel.cs (5)
429
public override
Conversion
ClassifyConversion(
444
return
Conversion
.NoConversion;
478
return
Conversion
.NoConversion;
486
internal override
Conversion
ClassifyConversionForCast(
502
return
Conversion
.NoConversion;
Compilation\SpeculativeSemanticModelWithMemberModel.cs (2)
220
public override
Conversion
ClassifyConversion(
228
internal override
Conversion
ClassifyConversionForCast(
Compilation\SyntaxTreeSemanticModel.cs (5)
520
public override
Conversion
ClassifyConversion(ExpressionSyntax expression, ITypeSymbol destination, bool isExplicitInSource = false)
527
return
Conversion
.NoConversion;
552
return
Conversion
.NoConversion;
558
internal override
Conversion
ClassifyConversionForCast(ExpressionSyntax expression, TypeSymbol destination)
573
return
Conversion
.NoConversion;
Compilation\TypeInfo.cs (3)
15
internal static readonly CSharpTypeInfo None = new CSharpTypeInfo(type: null, convertedType: null, nullability: default, convertedNullability: default,
Conversion
.Identity);
39
public readonly
Conversion
ImplicitConversion;
41
internal CSharpTypeInfo(TypeSymbol type, TypeSymbol convertedType, NullabilityInfo nullability, NullabilityInfo convertedNullability,
Conversion
implicitConversion)
Compiler\AnonymousTypeMethodBodySynthesizer.cs (1)
273
Conversion
.ImplicitReference);
Compiler\MethodBodySynthesizer.cs (4)
128
Conversion
.ExplicitReference,
157
Conversion
.ExplicitReference,
403
conversion:
Conversion
.ExplicitReference,
468
conversion:
Conversion
.ExplicitReference,
Compiler\MethodBodySynthesizer.Lowered.cs (2)
102
Conversion
.ImplicitNumeric),
191
Conversion
.ImplicitNumeric),
CSharpExtensions.cs (23)
438
public static
Conversion
ClassifyConversion(this Compilation? compilation, ITypeSymbol source, ITypeSymbol destination)
447
return
Conversion
.NoConversion;
764
public static
Conversion
GetConversion(this SemanticModel? semanticModel, SyntaxNode expression, CancellationToken cancellationToken = default(CancellationToken))
773
return
Conversion
.NoConversion;
778
/// Gets the underlying <see cref="
Conversion
"/> information from this <see cref="IConversionOperation"/>. This
782
/// <returns>The underlying <see cref="
Conversion
"/>.</returns>
784
public static
Conversion
GetConversion(this IConversionOperation conversionExpression)
793
return (
Conversion
)((ConversionOperation)conversionExpression).ConversionConvertible;
804
/// Gets the underlying <see cref="
Conversion
"/> information from this <see cref="ICompoundAssignmentOperation"/>. This
810
public static
Conversion
GetInConversion(this ICompoundAssignmentOperation compoundAssignment)
819
return (
Conversion
)((CompoundAssignmentOperation)compoundAssignment).InConversionConvertible;
830
/// Gets the underlying <see cref="
Conversion
"/> information from this <see cref="ICompoundAssignmentOperation"/>. This
836
public static
Conversion
GetOutConversion(this ICompoundAssignmentOperation compoundAssignment)
845
return (
Conversion
)((CompoundAssignmentOperation)compoundAssignment).OutConversionConvertible;
856
/// Gets the underlying element <see cref="
Conversion
"/> information from this <see cref="ISpreadOperation"/>.
861
public static
Conversion
GetElementConversion(this ISpreadOperation spread)
870
return (
Conversion
)((SpreadOperation)spread).ElementConversionConvertible;
878
public static
Conversion
GetSpeculativeConversion(this SemanticModel? semanticModel, int position, ExpressionSyntax expression, SpeculativeBindingOption bindingOption)
887
return
Conversion
.NoConversion;
1306
public static
Conversion
ClassifyConversion(this SemanticModel? semanticModel, ExpressionSyntax expression, ITypeSymbol destination, bool isExplicitInSource = false)
1317
return
Conversion
.NoConversion;
1326
public static
Conversion
ClassifyConversion(this SemanticModel? semanticModel, int position, ExpressionSyntax expression, ITypeSymbol destination, bool isExplicitInSource = false)
1335
return
Conversion
.NoConversion;
FlowAnalysis\AbstractFlowPass.cs (2)
2977
BoundConversion { Conversion:
Conversion
conversion, Operand: BoundConditionalAccess ca } when CanPropagateStateWhenNotNull(conversion) => ca,
2999
protected static bool CanPropagateStateWhenNotNull(
Conversion
conversion)
FlowAnalysis\NullableWalker.cs (62)
247
/// The delegate is invoked by <see cref="VisitConversion(BoundConversion, BoundExpression,
Conversion
, TypeWithAnnotations, TypeWithState, bool, bool, bool, AssignmentKind, ParameterSymbol, bool, bool, bool, bool, Optional<LocalState>,bool, Location, ArrayBuilder<VisitResult>)"/>.
2721
var
conversion = conversionsWithoutNullability.ClassifyImplicitConversionFromType(actualType, targetType, ref discardedUseSiteInfo);
4593
var conversions = ArrayBuilder<
Conversion
>.GetInstance(n);
4599
(BoundExpression expressionNoConversion,
Conversion
conversion) = RemoveConversion(expression, includeExplicitConversions: false);
4642
_ = VisitConversion(conversionOpt: null, conversionOperand: expressionsNoConversions[i],
Conversion
.Identity, targetTypeWithNullability: inferredType, operandType: expressionTypes[i],
4743
Conversion
conversion = conversionsWithoutNullability.ClassifyConversionFromExpression(placeholder, bestType, isChecked: returns[i].isChecked, ref discardedUseSiteInfo);
4938
leftConversion =
Conversion
.Identity;
4958
leftConversion =
Conversion
.Identity;
5060
Conversion
leftConversion,
5063
Conversion
rightConversion,
5078
Conversion
leftConversion,
5082
Conversion
rightConversion,
5110
Conversion
conversion,
5151
Conversion
conversion,
5197
var
conversion = _conversions.ClassifyBuiltInConversion(derivedType, baseType, isChecked: false, ref discardedUseSiteInfo);
5208
Conversion
leftConversion,
5652
var
conversion = GenerateConversionForConditionalOperator(node.LeftOperand, leftType, rightType, reportMismatch: true, isChecked: node.Checked);
5925
(var consequence,
var
consequenceConversion, consequenceRValue) = visitConditionalOperand(consequenceState, originalConsequence);
5930
(var alternative,
var
alternativeConversion, alternativeRValue) = visitConditionalOperand(alternativeState, originalAlternative);
6005
TypeWithState consequenceRValue, TypeWithState alternativeRValue, BoundExpression consequence,
Conversion
consequenceConversion, bool consequenceEndReachable,
6006
BoundExpression alternative,
Conversion
alternativeConversion, bool alternativeEndReachable, TypeWithAnnotations resultTypeWithAnnotations, bool wasTargetTyped)
6056
Conversion
consequenceConversion,
6059
Conversion
alternativeConversion,
6072
(BoundExpression,
Conversion
, TypeWithState) visitConditionalOperand(LocalState state, BoundExpression operand)
6074
Conversion
conversion;
6105
Conversion
conversion,
6790
(ImmutableArray<BoundExpression> argumentsNoConversions, ImmutableArray<
Conversion
> conversions) = RemoveArgumentConversions(arguments, refKindsOpt);
6805
ImmutableArray<
Conversion
> conversions,
6892
conversions.IsDefault || i >= conversions.Length ?
Conversion
.Identity : conversions[i],
6976
ImmutableArray<
Conversion
> conversions,
7348
Conversion
conversion,
7737
private (ImmutableArray<BoundExpression> arguments, ImmutableArray<
Conversion
> conversions) RemoveArgumentConversions(
7742
var conversions = default(ImmutableArray<
Conversion
>);
7746
var conversionsBuilder = ArrayBuilder<
Conversion
>.GetInstance(n);
7752
var
conversion =
Conversion
.Identity;
8044
private static (BoundExpression expression,
Conversion
conversion) RemoveConversion(BoundExpression expr, bool includeExplicitConversions)
8063
return (expr,
Conversion
.Identity);
8078
return (expr, group?.Conversion ??
Conversion
.Identity);
8082
private
Conversion
GenerateConversionForConditionalOperator(BoundExpression sourceExpression, TypeSymbol? sourceType, TypeSymbol destinationType, bool reportMismatch, bool isChecked)
8084
var
conversion = GenerateConversion(_conversions, sourceExpression, sourceType, destinationType, fromExplicitCast: false, extensionMethodThisArgument: false, isChecked: isChecked);
8093
private
Conversion
GenerateConversion(Conversions conversions, BoundExpression? sourceExpression, TypeSymbol? sourceType, TypeSymbol destinationType, bool fromExplicitCast, bool extensionMethodThisArgument, bool isChecked)
8275
(BoundExpression operand,
Conversion
conversion) = RemoveConversion(node, includeExplicitConversions: true);
8330
(BoundExpression operand,
Conversion
conversion) = RemoveConversion(expr, includeExplicitConversions: false);
8341
Conversion
conversion, TypeWithState operandType,
8373
Func<TypeWithAnnotations, TypeWithState> visitConversionAsContinuation(BoundExpression expr, bool useLegacyWarnings, bool trackMembers, AssignmentKind assignmentKind, BoundExpression operand,
Conversion
conversion, TypeWithState operandType)
8526
Conversion
conversion,
8554
void trackConvertedValue(FieldSymbol targetField,
Conversion
conversion, FieldSymbol valueField)
8780
Conversion
conversion,
8812
conversion =
Conversion
.MakeNullableConversion(ConversionKind.ImplicitNullable,
Conversion
.Identity);
9332
Conversion
conversion,
9564
var
conversion = _conversions.ClassifyStandardConversion(operandType.Type, targetType.Type, ref discardedUseSiteInfo);
9838
CheckExtensionMethodThisNullability(receiverOpt,
Conversion
.Identity, method.Parameters[0], receiverType);
10134
private void VisitDeconstructionArguments(ArrayBuilder<DeconstructionVariable> variables,
Conversion
conversion, BoundExpression right, TypeWithState? rightResultOpt = null)
10148
private void VisitDeconstructMethodArguments(ArrayBuilder<DeconstructionVariable> variables,
Conversion
conversion, BoundExpression right, TypeWithState? rightResultOpt)
10206
var
argConversion = RemoveConversion(invocation.Arguments[0], includeExplicitConversions: false).conversion;
10215
var
underlyingConversion = BoundNode.GetConversion(placeholderConversion, placeholder);
10256
var
underlyingConversion = BoundNode.GetConversion(placeholderConversion, placeholder);
10862
Conversion
conversion,
11125
Conversion
conversion = BoundNode.GetConversion(node.ElementConversion, node.ElementPlaceholder);
11837
private void CheckExtensionMethodThisNullability(BoundExpression expr,
Conversion
conversion, ParameterSymbol parameter, TypeWithState result)
FlowAnalysis\NullableWalker_Patterns.cs (4)
913
var conversions = ArrayBuilder<
Conversion
>.GetInstance(numSwitchArms);
931
(BoundExpression expression,
Conversion
conversion) = RemoveConversion(arm.Value, includeExplicitConversions: false);
988
ArrayBuilder<
Conversion
> conversions,
1033
ArrayBuilder<
Conversion
> conversions,
Generated\BoundNodes.xml.Generated.cs (3)
2951
public BoundConversion(SyntaxNode syntax, BoundExpression operand,
Conversion
conversion, bool isBaseConversion, bool @checked, bool explicitCastInCode, ConstantValue? constantValueOpt, ConversionGroup? conversionGroupOpt, ImmutableArray<MethodSymbol> originalUserDefinedConversionsOpt, TypeSymbol type, bool hasErrors = false)
2970
public
Conversion
Conversion { get; }
2981
public BoundConversion Update(BoundExpression operand,
Conversion
conversion, bool isBaseConversion, bool @checked, bool explicitCastInCode, ConstantValue? constantValueOpt, ConversionGroup? conversionGroupOpt, ImmutableArray<MethodSymbol> originalUserDefinedConversionsOpt, TypeSymbol type)
Lowering\AsyncRewriter\AsyncMethodToStateMachineRewriter.cs (1)
567
F.Convert(notifyCompletionTemp.Type, F.Local(awaiterTemp),
Conversion
.ExplicitReference)),
Lowering\ClosureConversion\ExpressionLambdaRewriter.cs (1)
889
private BoundExpression MakeConversionLambda(
Conversion
conversion, TypeSymbol fromType, TypeSymbol toType)
Lowering\LocalRewriter\LocalRewriter.DecisionDagRewriter.cs (2)
211
void visitConversion(
Conversion
conversion)
225
foreach (
var
underlying in conversion.UnderlyingConversions)
Lowering\LocalRewriter\LocalRewriter.PatternLocalRewriter.cs (2)
211
Conversion
conversion = _factory.Compilation.Conversions.ClassifyBuiltInConversion(inputType, output.Type, isChecked: false, ref useSiteInfo);
484
_factory.Compilation.Conversions.ClassifyBuiltInConversion(test.Input.Type, typeEvaluation2.Type, isChecked: false, ref useSiteInfo) is
Conversion
conv &&
Lowering\LocalRewriter\LocalRewriter_AsOperator.cs (1)
49
var
conversion = BoundNode.GetConversion(operandConversion, operandPlaceholder);
Lowering\LocalRewriter\LocalRewriter_BinaryOperator.cs (11)
738
var
conversion = _compilation.Conversions.ClassifyConversionFromExpression(loweredLeft, boolean, isChecked: false, ref useSiteInfo);
2033
MakeConversionNode(syntax, call,
Conversion
.ExplicitReference, type, @checked: false) :
2104
rewrittenExpr = MakeConversionNode(syntax, rewrittenExpr,
Conversion
.Boxing, objectType, @checked: false);
2370
: _factory.Convert(_factory.SpecialType(destinationType), numericOperand,
Conversion
.IntegerToPointer);
2387
numericOperand = _factory.Convert(nativeIntType, numericOperand,
Conversion
.IntegerToPointer, isChecked);
2399
numericOperand = _factory.Convert(longType, numericOperand,
Conversion
.ExplicitNumeric, isChecked);
2400
sizeOfExpression = _factory.Convert(longType, sizeOfExpression,
Conversion
.ExplicitNumeric, isChecked);
2412
sizeOfExpression = _factory.Convert(longType, sizeOfExpression,
Conversion
.ExplicitNumeric, isChecked);
2424
sizeOfExpression = _factory.Convert(ulongType, sizeOfExpression,
Conversion
.ExplicitNumeric, isChecked);
2443
: _factory.Convert(convertedMultiplicationResultType, multiplication,
Conversion
.IntegerToPointer); // NOTE: for some reason, dev10 doesn't check this conversion.
2473
Conversion
.PointerToInteger);
Lowering\LocalRewriter\LocalRewriter_CollectionExpression.cs (2)
31
private BoundExpression RewriteCollectionExpressionConversion(
Conversion
conversion, BoundCollectionExpression node)
194
Conversion
conversion;
Lowering\LocalRewriter\LocalRewriter_CompoundAssignmentOperator.cs (1)
770
Conversion
.Boxing,
Lowering\LocalRewriter\LocalRewriter_Conversion.cs (41)
266
Conversion
conversion,
285
Conversion
.Identity,
301
Conversion
conversion,
422
conversion =
Conversion
.ExplicitNumeric;
473
var
outerConversion =
Conversion
.ImplicitNullableWithIdentityUnderlying;
789
Conversion
conversion = MakeConversion(rewrittenOperand, rewrittenType, @checked: @checked, _compilation, _diagnostics, acceptFailingConversion);
805
private static
Conversion
MakeConversion(
815
Conversion
conversion = compilation.Conversions.ClassifyConversionFromType(rewrittenOperand.Type, rewrittenType, isChecked: @checked, ref useSiteInfo);
839
Conversion
conversion,
949
Conversion
conversion,
1036
Conversion
conversion,
1092
Conversion
conversion,
1119
rewrittenOperand = BoundConversion.SynthesizedNonUserDefined(syntax, rewrittenOperand,
Conversion
.ImplicitEnumeration, rewrittenOperandType);
1144
Conversion
conversion,
1206
Conversion
conversion,
1238
Conversion
conversion,
1278
Conversion
conversion,
1340
Conversion
conversion,
1394
Conversion
conversion,
1401
Conversion
conv = TryMakeConversion(syntax, conversion, rewrittenOperand.Type, rewrittenType, @checked: @checked);
1482
Conversion
conversion,
1738
var
conversion = new Conversion(conversionKind, method, isExtensionMethod: false);
1752
private
Conversion
TryMakeConversion(SyntaxNode syntax,
Conversion
conversion, TypeSymbol fromType, TypeSymbol toType, bool @checked)
1762
Conversion
fromConversion = TryMakeConversion(syntax, conversion.UserDefinedFromConversion, fromType, meth.Parameters[0].Type, @checked: @checked);
1765
return
Conversion
.NoConversion;
1768
Conversion
toConversion = TryMakeConversion(syntax, conversion.UserDefinedToConversion, meth.ReturnType, toType, @checked: @checked);
1771
return
Conversion
.NoConversion;
1783
var
resultConversion = new Conversion(result, conversion.IsImplicit);
1795
return
Conversion
.NoConversion;
1809
return
Conversion
.NoConversion;
1826
return
Conversion
.NoConversion;
1839
return
Conversion
.NoConversion;
1853
private
Conversion
TryMakeConversion(SyntaxNode syntax, TypeSymbol fromType, TypeSymbol toType, bool @checked)
1856
var
result = TryMakeConversion(syntax, _compilation.Conversions.ClassifyConversionFromType(fromType, toType, isChecked: @checked, ref useSiteInfo), fromType, toType, @checked: @checked);
1864
private
Conversion
TryMakeUserDefinedConversion(SyntaxNode syntax, MethodSymbol meth, TypeSymbol fromType, TypeSymbol toType, bool @checked, bool isImplicit)
1868
Conversion
fromConversion = TryMakeConversion(syntax, fromType, meth.Parameters[0].Type, @checked: @checked);
1871
return
Conversion
.NoConversion;
1874
Conversion
toConversion = TryMakeConversion(syntax, meth.ReturnType, toType, @checked: @checked);
1877
return
Conversion
.NoConversion;
Lowering\LocalRewriter\LocalRewriter_DeconstructionAssignmentOperator.cs (4)
37
private BoundExpression? RewriteDeconstruction(BoundTupleExpression left,
Conversion
conversion, BoundExpression right, bool isUsed)
57
Conversion
conversion,
213
Conversion
conversion,
277
private ImmutableArray<BoundExpression> GetRightParts(BoundExpression right,
Conversion
conversion,
Lowering\LocalRewriter\LocalRewriter_FixedStatement.cs (1)
466
Conversion
.PinnedObjectToPointer);
Lowering\LocalRewriter\LocalRewriter_ForEachStatement.cs (5)
353
Conversion
receiverConversion = enumeratorType.IsStructType() ?
354
Conversion
.Boxing :
355
Conversion
.ImplicitReference;
495
private BoundExpression ConvertReceiverForInvocation(CSharpSyntaxNode syntax, BoundExpression receiver, MethodSymbol method,
Conversion
receiverConversion, TypeSymbol convertedReceiverType)
1225
private static BoundExpression GetUnconvertedCollectionExpression(BoundForEachStatement node, out
Conversion
collectionConversion)
Lowering\LocalRewriter\LocalRewriter_LockStatement.cs (1)
93
Conversion
.Boxing,
Lowering\LocalRewriter\LocalRewriter_StackAlloc.cs (3)
134
return _factory.Convert(uintPtrType, _factory.Literal((uint)folded),
Conversion
.IntegerToPointer);
139
BoundExpression convertedCount = _factory.Convert(uintType, countExpression,
Conversion
.ExplicitNumeric);
140
convertedCount = _factory.Convert(uintPtrType, convertedCount,
Conversion
.IntegerToPointer);
Lowering\LocalRewriter\LocalRewriter_SwitchExpression.cs (1)
151
Conversion
c = _localRewriter._compilation.Conversions.ClassifyConversionFromExpression(expression, type, isChecked: false, ref discardedUseSiteInfo);
Lowering\LocalRewriter\LocalRewriter_TupleBinaryOperator.cs (5)
68
var
elementConversion = underlyingConversions[i];
211
var
conversion =
Conversion
.MakeNullableConversion(ConversionKind.ImplicitNullable,
Conversion
.Identity);
472
BoundExpression MakeBoundConversion(BoundExpression expr,
Conversion
conversion, TypeWithAnnotations type, BoundConversion enclosing)
Lowering\LocalRewriter\LocalRewriter_UnaryOperator.cs (1)
161
return MakeConversionNode(newNode.Syntax, newNode,
Conversion
.ExplicitEnumeration, type, @checked: false);
Lowering\LocalRewriter\LocalRewriter_UsingStatement.cs (2)
171
Conversion
.ImplicitDynamic,
247
Conversion
.ImplicitDynamic,
Lowering\MethodToClassRewriter.cs (1)
293
var
conversion = node.Conversion;
Lowering\SyntheticBoundNodeFactory.cs (7)
556
var
conversion = Compilation.Conversions.ClassifyConversionFromType(expression.Type, CurrentFunction.ReturnType, isChecked: false, ref useSiteInfo);
644
Conversion
c = Compilation.Conversions.ClassifyBuiltInConversion(operand.Type, type, isChecked: false, ref discardedUseSiteInfo);
1234
? BoundConversion.SynthesizedNonUserDefined(syntax, nullLiteral,
Conversion
.NullToPointer, type)
1477
Conversion
c = Compilation.Conversions.ClassifyConversionFromExpression(arg, type, isChecked: false, ref useSiteInfo);
1482
c =
Conversion
.Boxing;
1492
public BoundExpression Convert(TypeSymbol type, BoundExpression arg,
Conversion
conversion, bool isChecked = false)
1776
rewrittenExpr = Convert(objectType, rewrittenExpr,
Conversion
.Boxing);
Operations\CSharpOperationFactory.cs (8)
1078
Conversion
conversion = boundConversion.Conversion;
1143
Conversion
conversion = BoundNode.GetConversion(boundAsOperator.OperandConversion, boundAsOperator.OperandPlaceholder);
1274
var
elementConversion = BoundNode.GetConversion(iteratorItem, element.ElementPlaceholder);
1360
Conversion
inConversion = BoundNode.GetConversion(boundCompoundAssignmentOperator.LeftConversion, boundCompoundAssignmentOperator.LeftPlaceholder);
1361
Conversion
outConversion = BoundNode.GetConversion(boundCompoundAssignmentOperator.FinalConversion, boundCompoundAssignmentOperator.FinalPlaceholder);
1593
Conversion
valueConversion = BoundNode.GetConversion(boundNullCoalescingOperator.LeftConversion, boundNullCoalescingOperator.LeftPlaceholder);
1598
valueConversion =
Conversion
.Identity;
1906
inlineArrayConversion: enumeratorInfoOpt.InlineArraySpanType is WellKnownType.Unknown ? null :
Conversion
.InlineArray,
Symbols\ReducedExtensionMethodSymbol.cs (1)
52
var
conversion = conversions.ConvertExtensionMethodThisArg(method.Parameters[0].Type, receiverType, ref useSiteInfo, isMethodGroupConversion: false);
Symbols\Source\ParameterHelpers.cs (1)
737
Conversion
conversion = binder.Conversions.ClassifyImplicitConversionFromExpression(defaultExpression, parameterType, ref useSiteInfo);
Microsoft.CodeAnalysis.CSharp.CodeStyle (44)
src\Analyzers\CSharp\Analyzers\MakeStructMemberReadOnly\CSharpMakeStructMemberReadOnlyAnalyzer.cs (1)
363
var
conversion = conversionOperation.GetConversion();
src\Analyzers\CSharp\Analyzers\RemoveUnnecessaryLambdaExpression\CSharpRemoveUnnecessaryLambdaExpressionDiagnosticAnalyzer.cs (1)
274
var
conversion = compilation.ClassifyConversion(type1, type2);
src\Analyzers\CSharp\Analyzers\UseCoalesceExpression\UseCoalesceExpressionHelpers.cs (1)
14
var
conversion = semanticModel.GetConversion(conditional, cancellationToken);
src\Analyzers\CSharp\Analyzers\UseCollectionExpression\UseCollectionExpressionHelpers.cs (2)
146
var
conversion = speculationAnalyzer.SpeculativeSemanticModel.GetConversion(speculationAnalyzer.ReplacedExpression, cancellationToken);
261
var
conversion = compilation.ClassifyConversion(type, convertedType);
src\Analyzers\CSharp\Analyzers\UseDeconstruction\CSharpUseDeconstructionDiagnosticAnalyzer.cs (3)
108
var
initializerConversion = semanticModel.GetConversion(initializerValue, cancellationToken);
127
var
elementConversion = semanticModel.GetForEachStatementInfo(forEachStatement).ElementConversion;
139
Conversion
conversion,
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\ConversionExtensions.cs (2)
9
public static bool IsIdentityOrImplicitReference(this
Conversion
conversion)
15
public static bool IsImplicitUserDefinedConversion(this
Conversion
conversion)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Simplification\Simplifiers\CastSimplifier.cs (18)
225
var
conversion = conversionOperation.GetConversion();
289
var
originalConversion = originalConversionOperation.GetConversion();
391
var
originalParentConversion = originalParentConversionOperation.GetConversion();
645
var
conversion = semanticModel.GetConversion(castedExpressionNode, cancellationToken);
700
var
innerOriginalConversion = originalConversionOperation.GetConversion();
711
var
outerOriginalConversion = outerOriginalConversionOperation.GetConversion();
738
var
originalConversion = originalConversionOperation.GetConversion();
764
var
rewrittenBitwiseNotConversion = rewrittenBitwiseNotConversionOperation.GetConversion();
806
var
originalConversion = conversionOperation.GetConversion();
946
Conversion
conversion,
1005
var
conversion = semanticModel.GetConversion(castedExpressionNode, cancellationToken);
1033
var
parentConversion = semanticModel.GetConversion(castNode, cancellationToken);
1081
var
conversion = semanticModel.GetConversion(current, cancellationToken);
1192
var
oldConversion = oldForEachInfo.ElementConversion;
1193
var
newConversion = newForEachInfo.ElementConversion;
1450
private static (ITypeSymbol? rewrittenConvertedType,
Conversion
rewrittenConversion) GetRewrittenInfo(
1453
Conversion
originalConversion, ITypeSymbol originalConvertedType,
1469
var
rewrittenConversion = rewrittenSemanticModel.GetConversion(rewrittenExpression, cancellationToken);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\SpeculationAnalyzer.cs (15)
38
Conversion
>
409
var
originalConversion = this.OriginalSemanticModel.ClassifyConversion(originalOtherPartOfConditional, originalExpressionType);
410
var
newConversion = this.SpeculativeSemanticModel.ClassifyConversion(newOtherPartOfConditional, newExpressionType);
444
var
originalConversion = this.OriginalSemanticModel.ClassifyConversion(oldSwitchStatement.Expression, originalCaseType);
445
var
newConversion = this.SpeculativeSemanticModel.ClassifyConversion(newSwitchStatement.Expression, newCaseType);
547
var
originalConvertedTypeConversion = this.OriginalSemanticModel.ClassifyConversion(previousOriginalNode, originalExpressionTypeInfo.ConvertedType);
548
var
newExpressionConvertedTypeConversion = this.SpeculativeSemanticModel.ClassifyConversion(previousReplacedNode, newExpressionTypeInfo.ConvertedType);
710
var
originalConversion = this.OriginalSemanticModel.ClassifyConversion(originalIsOrAsExpression.Left, originalConvertedType, isExplicitInSource: true);
711
var
newConversion = this.SpeculativeSemanticModel.ClassifyConversion(newIsOrAsExpression.Left, newConvertedType, isExplicitInSource: true);
815
var
originalConversion = originalModel.GetConversion(originalExpression);
816
var
newConversion = newModel.GetConversion(newExpression);
853
private bool ConversionsAreCompatible(
Conversion
originalConversion,
Conversion
newConversion)
934
protected override
Conversion
ClassifyConversion(SemanticModel model, ExpressionSyntax expression, ITypeSymbol targetType)
937
protected override
Conversion
ClassifyConversion(SemanticModel model, ITypeSymbol originalType, ITypeSymbol targetType)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\TypeStyle\CSharpUseImplicitTypeHelper.cs (1)
328
var
conversion = semanticModel.GetConversion(expression, cancellationToken);
Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes (3)
src\Analyzers\CSharp\CodeFixes\AddExplicitCast\CSharpAddExplicitCastCodeFixProvider.cs (1)
102
var
conversion = semanticModel.Compilation.ClassifyConversion(rightType, leftType);
src\Analyzers\CSharp\CodeFixes\ConvertSwitchStatementToExpression\ConvertSwitchStatementToExpressionCodeFixProvider.Rewriter.cs (1)
197
var
conversion = _semanticModel.Compilation.ClassifyConversion(typeInfo.Type, typeInfo.ConvertedType);
src\Analyzers\CSharp\CodeFixes\GenerateParameterizedMember\CSharpGenerateParameterizedMemberService.cs (1)
145
var
conversion = compilation.ClassifyConversion(sourceType, targetType);
Microsoft.CodeAnalysis.CSharp.EditorFeatures.UnitTests (1)
SymbolKey\SymbolKeyTestBase.cs (1)
399
var
conv = model.GetConversion(expr);
Microsoft.CodeAnalysis.CSharp.Emit.UnitTests (34)
CodeGen\CodeGenDeconstructTests.cs (2)
314
Assert.Equal(
Conversion
.UnsetConversion, deconstructionInfo.Conversion);
1130
var
tupleConversion = model.GetConversion(tuple);
CodeGen\CodeGenFunctionPointersTests.cs (2)
10809
var
conversion = model.GetConversion(lambdas[0]);
10814
Assert.Equal(
Conversion
.NoConversion, conversion);
CodeGen\CodeGenTupleEqualityTests.cs (4)
364
Assert.Equal(
Conversion
.Identity, model.GetConversion(tupleX));
369
Assert.Equal(
Conversion
.Identity, model.GetConversion(lastX));
387
Assert.Equal(
Conversion
.ImplicitNumeric, model.GetConversion(lastY));
729
Assert.Equal(
Conversion
.Identity, model.GetConversion(tuple));
CodeGen\CodeGenTupleTest.cs (26)
7500
var
castConversion = model.GetConversion(value);
7504
var
tupleConversion = model.GetConversion(tuple);
7533
var
tupleConversion = model.GetConversion(value);
7575
var
conversion1 = model.GetConversion(tuple1);
7584
var
conversion2 = model.GetConversion(tuple2);
7593
var
conversion3 = model.GetConversion(tuple3);
7641
var
conversion = model.GetConversion(tuple);
8329
Assert.Equal(
Conversion
.Identity, model.GetConversion(l11));
8354
Assert.Equal(
Conversion
.Identity, model.GetConversion(node.Parent));
8496
Assert.Equal(
Conversion
.Identity, model.GetConversion(node));
8530
Assert.Equal(
Conversion
.Identity, model.GetConversion(node));
8603
Assert.Equal(
Conversion
.Identity, model.GetConversion(node.Parent));
8632
Assert.Equal(
Conversion
.Identity, model.GetConversion(node));
8667
Assert.Equal(
Conversion
.Identity, model.GetConversion(node));
8696
Assert.Equal(
Conversion
.Identity, model.GetConversion(node));
8756
Assert.Equal(
Conversion
.Identity, model.GetConversion(l11));
8781
Assert.Equal(
Conversion
.Identity, model.GetConversion(node.Parent));
8841
Assert.Equal(
Conversion
.Identity, model.GetConversion(lnull));
8854
Assert.Equal(
Conversion
.Identity, model.GetConversion(node.Parent));
8964
Assert.Equal(
Conversion
.Identity, model.GetConversion(node.Parent));
9077
Assert.Equal(
Conversion
.NoConversion, model.GetConversion(node));
17217
Assert.Equal(
Conversion
.Identity, model.GetConversion(n1));
17224
Assert.Equal(
Conversion
.Identity, model.GetConversion(n2));
17231
Assert.Equal(
Conversion
.Identity, model.GetConversion(n3));
17238
Assert.Equal(
Conversion
.Identity, model.GetConversion(n4));
17299
Assert.Equal(
Conversion
.ImplicitReference, model.GetConversion(n4));
Microsoft.CodeAnalysis.CSharp.Emit2.UnitTests (1)
Emit\NumericIntPtrTests.cs (1)
58
internal static void AssertMatches(ConversionKind[] expected,
Conversion
conversion)
Microsoft.CodeAnalysis.CSharp.Emit3.UnitTests (78)
FirstClassSpanTests.cs (3)
2738
var
argConv = model.GetConversion(arg);
2772
var
conv = op.GetConversion();
2788
var
conv = op.GetConversion();
Semantics\CollectionExpressionTests.cs (73)
14301
var
conversion = model.GetConversion(returnValue);
14307
var
underlyingConversion = conversion.UnderlyingConversions[0];
14377
var
conversion = model.GetConversion(returnValue);
14383
var
underlyingConversion = conversion.UnderlyingConversions[0];
14450
var
conversion = model.GetConversion(collection);
14514
var
castConversion = model.GetConversion(cast);
14519
var
conversion = model.GetConversion(value);
14638
var
castConversion = model.GetConversion(cast);
14643
var
conversion = model.GetConversion(value);
14722
var
conversion = model.GetConversion(nestedCollection);
14811
var
conversion = model.GetConversion(nestedCollection);
14817
var
underlyingConversion = conversion.UnderlyingConversions[0];
15165
var
conversion = model.GetConversion(expr);
26817
var
expectedConversion = new Conversion(ConversionKind.CollectionExpression, nestedConversions: ImmutableArray.Create(
Conversion
.Identity,
Conversion
.Identity));
26872
var
expectedConversion = new Conversion(ConversionKind.CollectionExpression, nestedConversions: ImmutableArray.Create(
Conversion
.Identity,
Conversion
.Identity));
27106
var
expectedConversion = new Conversion(ConversionKind.Boxing, nestedConversions: default);
27129
var
expectedConversion = new Conversion(ConversionKind.ImplicitReference, nestedConversions: default);
28695
var
conversion1 = model.GetConversion(collections[0]);
28697
Assert.Equal(
Conversion
.NoConversion, conversion1);
28699
var
conversion2 = model.GetConversion(collections[1]);
28739
var
conversion1 = model.GetConversion(collections[0]);
28741
Assert.Equal(
Conversion
.NoConversion, conversion1);
28743
var
conversion2 = model.GetConversion(collections[1]);
28788
var
conversion1 = model.GetConversion(collections[0]);
28793
var
conversion2 = model.GetConversion(collections[1]);
28829
var
conversion1 = model.GetConversion(collections[0]);
28831
Assert.Equal(
Conversion
.NoConversion, conversion1);
28833
var
conversion2 = model.GetConversion(collections[1]);
28872
var
conversion1 = model.GetConversion(collections[0]);
28874
Assert.Equal(
Conversion
.NoConversion, conversion1);
28876
var
conversion2 = model.GetConversion(collections[1]);
28915
var
conversion = model.GetConversion(collection);
28955
var
conversion = model.GetConversion(collection);
28987
var
conversion = model.GetConversion(collection);
29021
var
conversion1 = model.GetConversion(collections[0]);
29023
Assert.Equal(
Conversion
.NoConversion, conversion1);
29025
var
conversion2 = model.GetConversion(collections[1]);
29033
var
conversion3 = model.GetConversion(collections[2]);
29041
var
conversion4 = model.GetConversion(collections[3]);
29043
Assert.Equal(
Conversion
.NoConversion, conversion4);
29074
var
conversion1 = model.GetConversion(collections[0]);
29076
Assert.Equal(
Conversion
.NoConversion, conversion1);
29078
var
conversion2 = model.GetConversion(collections[1]);
29086
var
conversion3 = model.GetConversion(collections[2]);
29094
var
conversion4 = model.GetConversion(collections[3]);
29096
Assert.Equal(
Conversion
.NoConversion, conversion4);
29140
var
conversion1 = model.GetConversion(collections[0]);
29143
var
conversion2 = model.GetConversion(collections[1]);
29150
var
conversion3 = model.GetConversion(collections[2]);
29157
var
conversion4 = model.GetConversion(collections[3]);
29201
var
conversion1 = model.GetConversion(collections[0]);
29204
var
conversion2 = model.GetConversion(collections[1]);
29211
var
conversion3 = model.GetConversion(collections[2]);
29218
var
conversion4 = model.GetConversion(collections[3]);
29277
var
conversion1 = model.GetConversion(collection);
29279
Assert.Equal(
Conversion
.NoConversion, conversion1);
29320
var
conversion1 = model.GetConversion(collections[0]);
29325
var
conversion2 = model.GetConversion(collections[1]);
29327
Assert.Equal(
Conversion
.NoConversion, conversion2);
29367
var
conversion = model.GetConversion(collection);
29369
Assert.Equal(
Conversion
.NoConversion, conversion);
32389
var
collectionConversion = model.GetConversion(collection);
32395
var
elementConversion = model.GetConversion(element);
32486
var
elementConversion1 = model.GetConversion(element1);
32492
var
elementConversion2 = model.GetConversion(element2);
32528
var
elementConversion1 = model.GetConversion(element1);
32534
var
elementConversion2 = model.GetConversion(element2);
32573
var
elementConversion1 = model.GetConversion(element1);
32579
var
elementConversion2 = model.GetConversion(element2);
Semantics\OutVarTests.cs (1)
1058
var
conversion = model.ClassifyConversion(decl, model.Compilation.ObjectType, false);
Semantics\PatternMatchingTests2.cs (1)
2875
var
conversion = model.GetConversion(expr);
Microsoft.CodeAnalysis.CSharp.Features (14)
ExtractMethod\CSharpSelectionResult.ExpressionResult.cs (2)
97
var
conv = semanticModel.GetConversion(expression);
131
private static bool IsCoClassImplicitConversion(TypeInfo info,
Conversion
conversion, ISymbol? coclassSymbol)
src\Analyzers\CSharp\Analyzers\MakeStructMemberReadOnly\CSharpMakeStructMemberReadOnlyAnalyzer.cs (1)
363
var
conversion = conversionOperation.GetConversion();
src\Analyzers\CSharp\Analyzers\RemoveUnnecessaryLambdaExpression\CSharpRemoveUnnecessaryLambdaExpressionDiagnosticAnalyzer.cs (1)
274
var
conversion = compilation.ClassifyConversion(type1, type2);
src\Analyzers\CSharp\Analyzers\UseCoalesceExpression\UseCoalesceExpressionHelpers.cs (1)
14
var
conversion = semanticModel.GetConversion(conditional, cancellationToken);
src\Analyzers\CSharp\Analyzers\UseCollectionExpression\UseCollectionExpressionHelpers.cs (2)
146
var
conversion = speculationAnalyzer.SpeculativeSemanticModel.GetConversion(speculationAnalyzer.ReplacedExpression, cancellationToken);
261
var
conversion = compilation.ClassifyConversion(type, convertedType);
src\Analyzers\CSharp\Analyzers\UseDeconstruction\CSharpUseDeconstructionDiagnosticAnalyzer.cs (3)
108
var
initializerConversion = semanticModel.GetConversion(initializerValue, cancellationToken);
127
var
elementConversion = semanticModel.GetForEachStatementInfo(forEachStatement).ElementConversion;
139
Conversion
conversion,
src\Analyzers\CSharp\CodeFixes\AddExplicitCast\CSharpAddExplicitCastCodeFixProvider.cs (1)
102
var
conversion = semanticModel.Compilation.ClassifyConversion(rightType, leftType);
src\Analyzers\CSharp\CodeFixes\ConvertSwitchStatementToExpression\ConvertSwitchStatementToExpressionCodeFixProvider.Rewriter.cs (1)
197
var
conversion = _semanticModel.Compilation.ClassifyConversion(typeInfo.Type, typeInfo.ConvertedType);
src\Analyzers\CSharp\CodeFixes\GenerateParameterizedMember\CSharpGenerateParameterizedMemberService.cs (1)
145
var
conversion = compilation.ClassifyConversion(sourceType, targetType);
UseNamedArguments\CSharpUseNamedArgumentsCodeRefactoringProvider.cs (1)
49
var
conversion = semanticModel.Compilation.ClassifyConversion(argType, parameters[0].Type);
Microsoft.CodeAnalysis.CSharp.IOperation.UnitTests (6)
IOperation\IOperationTests_ICompoundAssignmentOperation.cs (4)
48
Assert.Equal(
Conversion
.Identity, compoundAssignment.GetInConversion());
49
Assert.Equal(
Conversion
.Identity, compoundAssignment.GetOutConversion());
88
var
inConversion = new Conversion(ConversionKind.ImplicitUserDefined, inSymbol, false);
89
var
outConversion = new Conversion(ConversionKind.ImplicitUserDefined, outSymbol, false);
IOperation\IOperationTests_IVariableDeclaration.cs (2)
932
Assert.Equal(
Conversion
.Identity, model.GetConversion(literalExpr));
939
Assert.Equal(
Conversion
.Identity, model.GetConversion(invocExpr));
Microsoft.CodeAnalysis.CSharp.Semantic.UnitTests (107)
Semantics\ForEachTests.cs (4)
1224
private static
Conversion
GetCollectionConversion(BoundForEachStatement boundNode)
2147
var
conv = model.GetConversion(loopSyntax.Type);
3362
Assert.Equal(
Conversion
.Identity, info.CurrentConversion);
3363
Assert.Equal(
Conversion
.Identity, info.ElementConversion);
Semantics\FunctionPointerTests.cs (14)
213
var
conversion = model.GetConversion(initializer1);
218
var
classifiedConversion = comp.ClassifyConversion(typeInfo.Type, typeInfo.ConvertedType!);
295
var
conversion = model.GetConversion(literal);
303
var
classifiedConversion = model.ClassifyConversion(literal, typeInfo.ConvertedType);
355
var
conversion = model.ClassifyConversion(conversions[0].Expression, typeInfoOuter.Type!);
406
var
conversion = model.ClassifyConversion(conversions[0].Expression, typeInfoOuter.Type!);
458
var
conversion = model.ClassifyConversion(conversions[0].Expression, typeInfoOuter.Type!);
508
var
conversion = model.ClassifyConversion(conv.Expression, typeInfoOuter.Type!);
605
var
conversion = model.GetConversion(decl);
609
var
classifiedConversion = comp.ClassifyConversion(typeInfo.Type!, typeInfo.ConvertedType!);
844
var
conversion = model.GetConversion(decl);
850
var
classifiedConversion = comp.ClassifyConversion(typeInfo.Type!, typeInfo.ConvertedType!);
902
var
conversion = model.GetConversion(initializer);
909
var
classifiedConversion = comp.ClassifyConversion(typeInfo.Type!, typeInfo.ConvertedType!);
Semantics\LambdaTests.cs (1)
845
var
conv = model.GetConversion(expr);
Semantics\NativeIntegerTests.cs (1)
51
internal static void AssertMatches(ConversionKind[] expected,
Conversion
conversion)
Semantics\ObjectAndCollectionInitializerTests.cs (3)
3812
var
conversion = model.GetConversion(literal);
3835
var
conversion = model.GetConversion(literal);
3859
var
conversion = model.GetConversion(literal);
Semantics\OperatorTests.cs (2)
3254
"valuePlaceholder" =>
Conversion
.Identity,
3257
Conversion
.NoConversion
Semantics\ScriptSemanticsTests.cs (2)
253
Assert.Equal(
Conversion
.Identity, summary.ImplicitConversion);
570
Assert.Equal(
Conversion
.Identity, summary.ImplicitConversion);
Semantics\StackAllocInitializerTests.cs (47)
376
Assert.Equal(
Conversion
.Identity, stackallocInfo.ImplicitConversion);
382
Assert.Equal(
Conversion
.Identity, element0Info.ImplicitConversion);
390
Assert.Equal(
Conversion
.Identity, stackallocInfo.ImplicitConversion);
396
Assert.Equal(
Conversion
.Identity, element0Info.ImplicitConversion);
404
Assert.Equal(
Conversion
.Identity, stackallocInfo.ImplicitConversion);
410
Assert.Equal(
Conversion
.Identity, element0Info.ImplicitConversion);
452
Assert.Equal(
Conversion
.Identity, stackallocInfo.ImplicitConversion);
458
Assert.Equal(
Conversion
.Identity, element0Info.ImplicitConversion);
466
Assert.Equal(
Conversion
.Identity, stackallocInfo.ImplicitConversion);
472
Assert.Equal(
Conversion
.Identity, element0Info.ImplicitConversion);
480
Assert.Equal(
Conversion
.Identity, stackallocInfo.ImplicitConversion);
486
Assert.Equal(
Conversion
.Identity, element0Info.ImplicitConversion);
2368
Assert.Equal(
Conversion
.Identity, stackallocInfo.ImplicitConversion);
2374
Assert.Equal(
Conversion
.ImplicitNumeric, element0Info.ImplicitConversion);
2380
Assert.Equal(
Conversion
.Identity, element1Info.ImplicitConversion);
2386
Assert.Equal(
Conversion
.Identity, sizeInfo.ImplicitConversion);
2396
Assert.Equal(
Conversion
.Identity, stackallocInfo.ImplicitConversion);
2402
Assert.Equal(
Conversion
.ImplicitNumeric, element0Info.ImplicitConversion);
2408
Assert.Equal(
Conversion
.Identity, element1Info.ImplicitConversion);
2414
Assert.Equal(
Conversion
.Identity, sizeInfo.ImplicitConversion);
2424
Assert.Equal(
Conversion
.Identity, stackallocInfo.ImplicitConversion);
2430
Assert.Equal(
Conversion
.ImplicitNumeric, element0Info.ImplicitConversion);
2436
Assert.Equal(
Conversion
.Identity, element1Info.ImplicitConversion);
2442
Assert.Equal(
Conversion
.Identity, sizeInfo.ImplicitConversion);
2474
Assert.Equal(
Conversion
.Identity, stackallocInfo.ImplicitConversion);
2480
Assert.Equal(
Conversion
.ImplicitNumeric, element0Info.ImplicitConversion);
2486
Assert.Equal(
Conversion
.Identity, element1Info.ImplicitConversion);
2496
Assert.Equal(
Conversion
.Identity, stackallocInfo.ImplicitConversion);
2502
Assert.Equal(
Conversion
.ImplicitNumeric, element0Info.ImplicitConversion);
2508
Assert.Equal(
Conversion
.Identity, element1Info.ImplicitConversion);
2518
Assert.Equal(
Conversion
.Identity, stackallocInfo.ImplicitConversion);
2524
Assert.Equal(
Conversion
.ImplicitNumeric, element0Info.ImplicitConversion);
2530
Assert.Equal(
Conversion
.Identity, element1Info.ImplicitConversion);
2574
Assert.Equal(
Conversion
.NoConversion, stackallocInfo.ImplicitConversion);
2580
Assert.Equal(
Conversion
.ImplicitNumeric, element0Info.ImplicitConversion);
2586
Assert.Equal(
Conversion
.ImplicitNumeric, element1Info.ImplicitConversion);
2592
Assert.Equal(
Conversion
.ImplicitNumeric, sizeInfo.ImplicitConversion);
2602
Assert.Equal(
Conversion
.NoConversion, stackallocInfo.ImplicitConversion);
2608
Assert.Equal(
Conversion
.ImplicitNumeric, element0Info.ImplicitConversion);
2614
Assert.Equal(
Conversion
.ImplicitNumeric, element1Info.ImplicitConversion);
2620
Assert.Equal(
Conversion
.Identity, sizeInfo.ImplicitConversion);
2658
Assert.Equal(
Conversion
.Identity, stackallocInfo.ImplicitConversion);
2664
Assert.Equal(
Conversion
.Identity, element0Info.ImplicitConversion);
2670
Assert.Equal(
Conversion
.Identity, element1Info.ImplicitConversion);
2680
Assert.Equal(
Conversion
.Identity, stackallocInfo.ImplicitConversion);
2686
Assert.Equal(
Conversion
.Identity, element0Info.ImplicitConversion);
2692
Assert.Equal(
Conversion
.ImplicitNumeric, element1Info.ImplicitConversion);
Semantics\TargetTypedDefaultTests.cs (3)
336
Assert.Equal(
Conversion
.Identity, model.GetConversion(default2));
3529
Conversion
conversion = model.GetConversion(conversionSyntax);
3602
Conversion
conversion = model.GetConversion(default4);
Semantics\TopLevelStatementsTests.cs (2)
9708
var
conversionInTopLevel = speculativeModelInTopLevel.GetConversion(nodeToSpeculate.DescendantTokens().Single(n => n.ValueText == "x").Parent);
9713
var
conversionOutsideTopLevel = speculativeModelOutsideTopLevel.GetConversion(nodeToSpeculate.DescendantTokens().Single(n => n.ValueText == "x").Parent);
Semantics\UnsafeTests.cs (28)
7267
var
conv = model.GetConversion(syntax);
7270
Assert.Equal(
Conversion
.Identity, conv);
7334
var
conv = model.GetConversion(syntax);
7337
Assert.Equal(
Conversion
.Identity, conv);
7372
var
conv = model.GetConversion(syntax);
7375
Assert.Equal(
Conversion
.Identity, conv);
7414
var
conv = model.GetConversion(syntax);
7417
Assert.Equal(
Conversion
.Identity, conv);
7545
var
conv = model.GetConversion(syntax);
7548
Assert.Equal(
Conversion
.Identity, conv);
8349
var
conv = model.GetConversion(node);
8394
var
conv = model.GetConversion(value);
8884
Assert.Equal(
Conversion
.Identity, summary.ImplicitConversion);
8919
Assert.Equal(
Conversion
.Identity, summary.ImplicitConversion);
9346
Assert.Equal(
Conversion
.Identity, summary.ImplicitConversion);
10237
Assert.Equal(
Conversion
.Identity, summary.ImplicitConversion);
10313
Assert.Equal(
Conversion
.PointerToVoid, summary0.ImplicitConversion);
10320
Assert.Equal(
Conversion
.PointerToVoid, summary1.ImplicitConversion);
10326
Assert.Equal(
Conversion
.PointerToVoid, summary2.ImplicitConversion);
10639
Assert.Equal(
Conversion
.Identity, typeSummary.ImplicitConversion);
10651
Assert.Equal(
Conversion
.Identity, sizeOfSummary.ImplicitConversion);
10701
Assert.Equal(
Conversion
.Identity, typeSummary.ImplicitConversion);
10713
Assert.Equal(
Conversion
.Identity, sizeOfSummary.ImplicitConversion);
10761
Assert.Equal(
Conversion
.Identity, typeSummary.ImplicitConversion);
10773
Assert.Equal(
Conversion
.Identity, sizeOfSummary.ImplicitConversion);
11313
Assert.Equal(
Conversion
.PointerToVoid, stackAllocSummary.ImplicitConversion);
11325
Assert.Equal(
Conversion
.Identity, typeSummary.ImplicitConversion);
11337
Assert.Equal(
Conversion
.ImplicitNumeric, countSummary.ImplicitConversion);
Microsoft.CodeAnalysis.CSharp.Symbol.UnitTests (58)
Compilation\ForEachStatementInfoTests.cs (4)
42
var
conv1 =
Conversion
.Identity;
49
var
conv2 =
Conversion
.NoConversion;
Compilation\GetSemanticInfoTests.cs (46)
108
var
conv = model.GetConversion(expr);
142
var
conv = model.GetConversion(expr);
604
var
impconv = model.GetConversion(expr1);
605
Assert.Equal(
Conversion
.Identity, impconv);
606
Conversion
conv = model.ClassifyConversion(expr1, info.ConvertedType);
634
var
impconv = model.GetConversion(expr1);
638
Conversion
conv = model.ClassifyConversion(expr1, info.ConvertedType);
648
var conversion = info.Type != null && info.ConvertedType != null ? model.Compilation.ClassifyConversion(info.Type, info.ConvertedType) :
Conversion
.NoConversion;
655
ValidateConversion(
Conversion
.PointerToVoid, ConversionKind.ImplicitPointerToVoid);
656
ValidateConversion(
Conversion
.NullToPointer, ConversionKind.ImplicitNullToPointer);
657
ValidateConversion(
Conversion
.PointerToPointer, ConversionKind.ExplicitPointerToPointer);
658
ValidateConversion(
Conversion
.IntegerToPointer, ConversionKind.ExplicitIntegerToPointer);
659
ValidateConversion(
Conversion
.PointerToInteger, ConversionKind.ExplicitPointerToInteger);
660
ValidateConversion(
Conversion
.IntPtr, ConversionKind.IntPtr);
664
private void ValidateConversion(
Conversion
conv, ConversionKind kind)
847
var
conv = semanticModel.GetConversion(expr);
850
Conversion
act1 = semanticModel.ClassifyConversion(expr, info.ConvertedType);
863
var
act2 = semanticModel.Compilation.ClassifyConversion(info.Type, info.ConvertedType);
876
Conversion
act1 = semanticModel.ClassifyConversion(expr, expsym);
2456
var
conv = model.GetConversion(expr);
2485
var
conv = model.GetConversion(expr);
2734
var
conv = model.GetConversion(expr);
2735
Assert.Equal(
Conversion
.Identity, conv);
2805
var
conv = model.GetConversion(expr);
3336
var
conversion = model.ClassifyConversion(expr, gNullableType);
3402
var
conversion = model.ClassifyConversion(expr, gNullableType);
3477
var
argConversion = model.GetConversion(argexpr);
3531
var
argConversion = model.GetConversion(argexpr);
3610
var
conv = model.GetConversion(literal);
3635
var
literalConversion = model.GetConversion(literal);
3643
var
castConversion = model.GetConversion(cast);
3668
var
literalConversion = model.GetConversion(literal);
3676
var
castConversion = model.GetConversion(cast);
3704
var
literalConversion = model.GetConversion(literal);
3712
var
cast1Conversion = model.GetConversion(cast1);
3724
var
cast2Conversion = model.GetConversion(cast2);
4300
Assert.Equal(
Conversion
.Identity, info.ImplicitConversion);
4379
var
conv = model.GetConversion(syntax);
5538
var
conversion = model.ClassifyConversion(lambdaSyntax, otherFuncType);
5586
var
conversion = model.ClassifyConversion(nullSyntax, typeC);
5625
var
conversion = model.ClassifyConversion(lambdaSyntax, typeFuncB);
5672
var
conversion = model.ClassifyConversion(lambdaSyntax, typeFuncC);
5733
var
conversionA = model.ClassifyConversion(methodGroupSyntax, typeFuncA);
5737
var
conversionB = model.ClassifyConversion(methodGroupSyntax, typeFuncB);
5740
var
conversionC = model.ClassifyConversion(methodGroupSyntax, typeFuncC);
5991
Assert.Equal(
Conversion
.UnsetConversion, foreachSymbolInfo.CurrentConversion);
Compilation\SemanticModelAPITests.cs (1)
2281
var
conv = speculativeModel.GetConversion(initializer);
Compilation\SemanticModelGetSemanticInfoTests.cs (3)
14809
var
conv = model.GetConversion(creation.Type);
14905
var
conv = model.GetConversion(creation.Type);
15016
var
conv = model.GetConversion(creation.Type);
Symbols\ConversionTests.cs (4)
181
var
result = c.ClassifyConversionFromType(types[j], types[i], ref useSiteDiagnostics);
185
var
result2 = c.ClassifyConversionFromType(types[j], types[i], ref useSiteDiagnostics); // set breakpoint here if this test is failing...
401
Conversion
conversion = model.ClassifyConversion(sourceExpression1, targetType);
1738
var
elementConversion = BoundNode.GetConversion(boundForEach.ElementConversion, boundForEach.ElementPlaceholder);
Microsoft.CodeAnalysis.CSharp.Test.Utilities (6)
CompilationTestUtils.cs (2)
214
public
Conversion
ImplicitConversion = default(
Conversion
);
Extensions.cs (4)
887
public static
Conversion
ClassifyConversionFromType(this ConversionsBase conversions, TypeSymbol source, TypeSymbol destination, ref HashSet<DiagnosticInfo> useSiteDiagnostics, bool forCast = false)
890
Conversion
result = conversions.ClassifyConversionFromType(source, destination, isChecked: false, ref useSiteInfo, forCast);
910
public static
Conversion
ClassifyConversionFromExpression(this Conversions conversions, BoundExpression sourceExpression, TypeSymbol destination, ref HashSet<DiagnosticInfo> useSiteDiagnostics, bool forCast = false)
913
Conversion
result = conversions.ClassifyConversionFromExpression(sourceExpression, destination, isChecked: false, ref useSiteInfo, forCast);
Microsoft.CodeAnalysis.CSharp.Workspaces (36)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\ConversionExtensions.cs (2)
9
public static bool IsIdentityOrImplicitReference(this
Conversion
conversion)
15
public static bool IsImplicitUserDefinedConversion(this
Conversion
conversion)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Simplification\Simplifiers\CastSimplifier.cs (18)
225
var
conversion = conversionOperation.GetConversion();
289
var
originalConversion = originalConversionOperation.GetConversion();
391
var
originalParentConversion = originalParentConversionOperation.GetConversion();
645
var
conversion = semanticModel.GetConversion(castedExpressionNode, cancellationToken);
700
var
innerOriginalConversion = originalConversionOperation.GetConversion();
711
var
outerOriginalConversion = outerOriginalConversionOperation.GetConversion();
738
var
originalConversion = originalConversionOperation.GetConversion();
764
var
rewrittenBitwiseNotConversion = rewrittenBitwiseNotConversionOperation.GetConversion();
806
var
originalConversion = conversionOperation.GetConversion();
946
Conversion
conversion,
1005
var
conversion = semanticModel.GetConversion(castedExpressionNode, cancellationToken);
1033
var
parentConversion = semanticModel.GetConversion(castNode, cancellationToken);
1081
var
conversion = semanticModel.GetConversion(current, cancellationToken);
1192
var
oldConversion = oldForEachInfo.ElementConversion;
1193
var
newConversion = newForEachInfo.ElementConversion;
1450
private static (ITypeSymbol? rewrittenConvertedType,
Conversion
rewrittenConversion) GetRewrittenInfo(
1453
Conversion
originalConversion, ITypeSymbol originalConvertedType,
1469
var
rewrittenConversion = rewrittenSemanticModel.GetConversion(rewrittenExpression, cancellationToken);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\SpeculationAnalyzer.cs (15)
38
Conversion
>
409
var
originalConversion = this.OriginalSemanticModel.ClassifyConversion(originalOtherPartOfConditional, originalExpressionType);
410
var
newConversion = this.SpeculativeSemanticModel.ClassifyConversion(newOtherPartOfConditional, newExpressionType);
444
var
originalConversion = this.OriginalSemanticModel.ClassifyConversion(oldSwitchStatement.Expression, originalCaseType);
445
var
newConversion = this.SpeculativeSemanticModel.ClassifyConversion(newSwitchStatement.Expression, newCaseType);
547
var
originalConvertedTypeConversion = this.OriginalSemanticModel.ClassifyConversion(previousOriginalNode, originalExpressionTypeInfo.ConvertedType);
548
var
newExpressionConvertedTypeConversion = this.SpeculativeSemanticModel.ClassifyConversion(previousReplacedNode, newExpressionTypeInfo.ConvertedType);
710
var
originalConversion = this.OriginalSemanticModel.ClassifyConversion(originalIsOrAsExpression.Left, originalConvertedType, isExplicitInSource: true);
711
var
newConversion = this.SpeculativeSemanticModel.ClassifyConversion(newIsOrAsExpression.Left, newConvertedType, isExplicitInSource: true);
815
var
originalConversion = originalModel.GetConversion(originalExpression);
816
var
newConversion = newModel.GetConversion(newExpression);
853
private bool ConversionsAreCompatible(
Conversion
originalConversion,
Conversion
newConversion)
934
protected override
Conversion
ClassifyConversion(SemanticModel model, ExpressionSyntax expression, ITypeSymbol targetType)
937
protected override
Conversion
ClassifyConversion(SemanticModel model, ITypeSymbol originalType, ITypeSymbol targetType)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\TypeStyle\CSharpUseImplicitTypeHelper.cs (1)
328
var
conversion = semanticModel.GetConversion(expression, cancellationToken);
Microsoft.CodeAnalysis.Test.Utilities (3)
Compilation\TestOperationVisitor.cs (3)
851
CSharp.
Conversion
csharpConversion = CSharp.CSharpExtensions.GetConversion(operation);
1180
var
inConversionInternal = CSharp.CSharpExtensions.GetInConversion(operation);
1181
var
outConversionInternal = CSharp.CSharpExtensions.GetOutConversion(operation);
Microsoft.Extensions.Logging.Generators (1)
LoggerMessageGenerator.Parser.cs (1)
728
Conversion
conversion = _compilation.ClassifyConversion(source, dest);
Microsoft.Extensions.Options.SourceGeneration (2)
Parser.cs (1)
730
var
conversion = _compilation.ClassifyConversion(source, dest);
ParserUtilities.cs (1)
54
var
conversion = comp.ClassifyConversion(source, dest);
Microsoft.Gen.ComplianceReports (1)
Parser.cs (1)
287
var
conversion = _compilation.ClassifyConversion(source, dest);
Microsoft.Gen.Logging (1)
src\Generators\Shared\ParserUtilities.cs (1)
59
var
conversion = comp.ClassifyConversion(source, dest);
Microsoft.Gen.Metrics (1)
src\Generators\Shared\ParserUtilities.cs (1)
59
var
conversion = comp.ClassifyConversion(source, dest);
Microsoft.Gen.MetricsReports (1)
src\Generators\Shared\ParserUtilities.cs (1)
59
var
conversion = comp.ClassifyConversion(source, dest);