How to get reference to user-defined operator

Topics: APIs
Jun 19, 2014 at 3:14 AM
Edited Jun 19, 2014 at 3:15 AM
Given a class X:
class X
    public static bool operator true(X x) { return true; }
And an if statement as follows:
if (x)
where x is an instance of class X.

I obtain an instance of IfStatementSyntax whose Condition property is an instance of IdentifierName. How do I obtain the method symbol of the implicit call to the user-defined operator true?

I have tried the following methods on SemanticModel but to no avail:
  • GetConversion
  • ClassifyConversion
  • GetSpeculativeConversion
However, none of these will return the IMethodSymbol corresponding to this operator method.