Support IntPtr conversions in the method argument rewriter. #11751
Labels
Area-Compilers
Bug
Language-C#
Tenet-Compatibility
Violation of forwards/backwards compatibility in a design-time piece.
Milestone
IntPtr conversion can stay in the bound tree past lowering in a case where a COM method is invoked in an Expression Tree lambda.
A typical situation where this could happen is when a COM method is tested in a mock framework that is Expression Tree based.
If such conversion is seen by the call argument rewriter a crash/watson would result when code is compiled.
Short repro:
causes a crash like:
CLR: Managed code called FailFast, saying "System.InvalidOperationException: Unexpected value 'IntPtr' of type 'Microsoft.CodeAnalysis.CSharp.ConversionKind'
at Microsoft.CodeAnalysis.CSharp.LocalRewriter.IsSafeForReordering(BoundExpression expression, RefKind kind)
at Microsoft.CodeAnalysis.CSharp.LocalRewriter.BuildStoresToTemps(Boolean expanded, ImmutableArray
1 argsToParamsOpt, ImmutableArray
1 argumentRefKinds, ImmutableArray1 rewrittenArguments, BoundExpression[] arguments, ArrayBuilder
1 refKinds, ArrayBuilder1 storesToTemps) at Microsoft.CodeAnalysis.CSharp.LocalRewriter.MakeArguments(CSharpSyntaxNode syntax, ImmutableArray
1 rewrittenArguments, Symbol methodOrIndexer, MethodSymbol optionalParametersMethod, Boolean expanded, ImmutableArray1 argsToParamsOpt, ImmutableArray
1& argumentRefKindsOpt, ImmutableArray1& temps, Boolean invokedAsExtensionMethod, ThreeState enableCallerInfo) at Microsoft.CodeAnalysis.CSharp.LocalRewriter.MakeCall(CSharpSyntaxNode syntax, BoundExpression rewrittenReceiver, MethodSymbol method, ImmutableArray
1 rewrittenArguments, ImmutableArray1 argumentRefKindsOpt, Boolean expanded, Boolean invokedAsExtensionMethod, ImmutableArray
1 argsToParamsOpt, LookupResultKind resultKind, TypeSymbol type, BoundCall nodeOpt)at Microsoft.CodeAnalysis.CSharp.LocalRewriter.VisitCall(BoundCall node)
The text was updated successfully, but these errors were encountered: