Marcel Marcel -4 years ago 89
C# Question

Roslyn detect ternary operator like ? :

I have been looking for a solution, which let find the ternary operators like

true ? DoIt() : DoItNot();
with the roslyn analyzer library.

I came up with following solution, but this returns only the "standard" if-else-Expressions.

var ifStatement = tree.GetRoot().DescendantNodes().OfType<IfStatementSyntax>().First();

I did search for another
, but I didnĀ“t find what I am looking for.
So I would be very pleased if someone has a solution for my problem.

Answer Source
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download