-
Notifications
You must be signed in to change notification settings - Fork 4.2k
API for IFunctionPointerInvocationOperation #57195
Copy link
Copy link
Closed
Labels
Area-CompilersConcept-APIThis issue involves adding, removing, clarification, or modification of an API.This issue involves adding, removing, clarification, or modification of an API.Feature Requestapi-approvedAPI was approved in API review, it can be implementedAPI was approved in API review, it can be implemented
Milestone
Metadata
Metadata
Assignees
Labels
Area-CompilersConcept-APIThis issue involves adding, removing, clarification, or modification of an API.This issue involves adding, removing, clarification, or modification of an API.Feature Requestapi-approvedAPI was approved in API review, it can be implementedAPI was approved in API review, it can be implemented
Type
Fields
Give feedbackNo fields configured for issues without a type.
Background and Motivation
As described in #48082 the Operations-API is not usable today for function pointer invocations. This should be changed.
Proposed API
namespace Microsoft.CodeAnalysis.Operations { + public interface IFunctionPointerInvocationOperation : IOperation + { + IOperation InvokedPointer { get; } + ImmutableArray<IArgumentOperation> Arguments { get; } + } } namespace Microsoft.CodeAnalysis { public enum OperationKind { + FunctionPointerInvocation = 0x72, } }Usage Examples
See #48082
Alternative Designs
It would be possible to reuse the IInvocationOperation to represent the function pointer operation. But the usage of this interface has some drawbacks.
For example
IsVirtualdoes not apply to function pointer invocations. In addition we can not model the invoked pointer appropriate.Therefore we propose the new API.
We could add a property to the interface for retrieving the function pointer method signature as well, rather than requiring the user to do
((IFunctionPointerTypeSymbol)invPointerOperation.InvokedPointer.Type).Signatureto get access to the pointer type signature. In addition we could add a property for the function pointer type. But both features could be implemented via extension method, too.Risks
No knwon risk.