TL; DR; No, there is no single method call for this (as of September 2012 CTP Roslyn).
The parent classes to look for can be (and usually) a completely separate syntax tree for the class you are in. If all your classes were in the same namespace declaration (shudder), you could look for the root from this SyntaxNode .
Most likely, your classes are one for each file, so although they use the same namespace, they are not under the same root of the syntax tree.
Roslyn causes a lot of head scratches because the syntax trees are more like the location of the code files, rather than the types that the code represents.
Perhaps there is a way to create a new syntax tree (existing syntax trees are immutable) from all classes existing under this namsepace , and then search for this tree. For me, this seems more complicated than necessary, especially in the sense that the walking parent method is much more convenient to maintain.
source share