Finding the Base Class of a Function with Phoenix


This came up on an internal alias today, so I thought I would post the solution.


 The issue is when there is some code like the following:


    class BaseClass


    {


    }


 


    class InheritedClass : BaseClass


    {


        void SomeFunction() { }


    }


And you have a pointer to the SomeFunction function unit, how do you find out the associated base class of that function (in this case it is BaseClass).


The answer is: 


functionSymbol.EnclosingAggregateType.PrimaryBaseAggregateType

Comments (3)
  1. Frank says:

    Naming them FunctionSymbol.DeclaringType.BaseType too concise?

  2. MSDN Archive says:

    Yes, yes.  We know that some things are a bit more verbose than they should be.  

Comments are closed.

Skip to main content