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