Question

What is the best way to identify, on a NFactory parsed tree, if the current class is actually inheriting (or not) from another class?

Was it helpful?

Solution

you should see if the parsed tree has any basetypes or not.

TypeDeclaration typeDeclaration = new CSharpParser().Parse("public class A:B{}").Children.OfType<TypeDeclaration>().First();
        if(typeDeclaration.ClassType==ClassType.Class && typeDeclaration.BaseTypes.Count>=1)
        {
                //this class is inherited..
        }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top