I'm trying to analyse the primary constructor of a class but I can't find how. It should be possible to find it in the syntax tree, I don't want to create the semantic model.
The code is pretty trivial.
string testCode = @"
public class TestClass(int someInt)
{
}";
var tree = CSharpSyntaxTree.ParseText(testCode);
var root = tree.GetRoot();
var cls = root.DescendantNodes().OfType<ClassDeclarationSyntax>().Single();
var primaryCtr = cls.DescendantNodes()
.OfType<PrimaryConstructorBaseTypeSyntax>()
.FirstOrDefault();
Console.WriteLine(primaryCtr != null ? "primaryCtr FOUND" : "NOT FOUND!");
This code outputs NOT FOUND! and I could not find any other way how to find it.