Open gafter opened 9 years ago
Where the +(int, int)
is exposed?
I tried:
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
CSharpCompilation comp = CSharpCompilation.Create(null, new[] { CSharpSyntaxTree.ParseText("class C { public void M() => _ = 5 + 5; }") }, new[] { MetadataReference.CreateFromFile(typeof(int).Assembly.Location) });
var model = comp.GetSemanticModel(comp.SyntaxTrees[0]);
var operation = model.GetOperation(comp.SyntaxTrees[0].GetRoot().DescendantNodes().OfType<BinaryExpressionSyntax>().Single());
But the resulting operation has a null OperatorMethod
.
The compiler already provides symbols for built-in operators such as +(int,int). I think this would be one of those built-in operators, probably something like
even though the argument might be something like a namespace.
This would (only) be visible through the
SemanticModel
API.[Ported from TFS DevDiv 1078941]