Expose selected signature for bound function calls and operators
davidnx opened this issue · comments
Feature ask
There is no way (that I could find) to determine the Signature that was bound for a function call or operator.
Right now I am having to replicate large amounts of code from Binder_FunctionCalls.cs
(the entirety of GetBestMatchingSignatures
and friends).
Specifically, it would help if the SemanticInfo would somehow include the signatures that were selected.
Motivation
This would help produce better dev experiences knowing the signature that matched a given call-site or operator. It would also help projects like https://github.com/microsofthackathons/baby-kusto-csharp implementing a self-contained Kusto engine that has to figure out what overload of a function to invoke.
I've added the ability to access the matching signature via the ReferencedSignature property on a SyntaxNode. It might not be enough information to map to some particular function implementation overload you had in mind. The signatures are really just declarations of ways the arguments can be specified and how the result type is determined when the arguments match. Only some built-in functions and operators have more than one signature, and the number and order they are specified may be arbitrary. If you are using them, it would be best not to rely on knowing the specific set of signatures, but in the information they convey. You will probably need to know which arguments correspond to which parameters (sometimes parameters can be repeated). When you have the signature instance you can call GetArgumentParameters to determine the correspondence.
The signature is now available via the SyntaxNode.ReferencedSignature property.