1

I have a class like this

public class cmdGetAllCustomers : CommandBase
{
    public cmdGetAllCustomers(WToken token)
        : base(token, false, typeof(WCustomer))
    {
    }

    // ...
}

I need to get the type of the third base constructor parameter. In this case that would be WCustomer.

I have already found the CodeClass object for the class and also the CodeFunction object which, in my understanding, represents the constructor.

Within CodeFunction there are CodeParameters, which describe almost what I am searching for, all constructor parameters, except the ones from the base class.

Got anyone a idea on how to get these types with EnvDTE?

psubsee2003
  • 8,563
  • 8
  • 61
  • 79
Peter Bucher
  • 295
  • 2
  • 13
  • I have no experience with EnvDTE, but as the `CodeFunction` represents the constructor itself, I guess it won't contain the parameters of the call to the base constructor. Have you had a look at the [`Children`](http://msdn.microsoft.com/en-us/library/vstudio/envdte.codefunction.children.aspx) property? Maybe you can find the call to the base class constructor inside this property as another `CodeFunction` object? – Daniel Hilgarth Feb 21 '13 at 13:04
  • Did you meant the Childrens of my CodeClass? In that case: There are only die function itself and all properties hold by that class. Unfortunately not some base members or parameters. – Peter Bucher Feb 21 '13 at 13:16
  • No, I indeed meant the Children of the constructor, i.e. of your `CodeFunction` instance. – Daniel Hilgarth Feb 21 '13 at 13:17
  • Alright. Children property holds exactly the same as the Parameters property. Unfortunately. – Peter Bucher Feb 21 '13 at 13:20
  • I tried: codeFunction.Type.Parent, where codefunction is the constructor instance. Seems to be the same as the codefunction itself. No additional parameters. Unfortunately. Hope for other ideas. – Peter Bucher Feb 21 '13 at 13:38
  • Hm, what about the following: Use [`GetStartPoint`](http://msdn.microsoft.com/en-us/library/vstudio/envdte.codefunction.getstartpoint.aspx) on your `CodeFunction` with `vsCMPartWhole` as the parameter and move the result until the [`CodeElement`](http://msdn.microsoft.com/en-us/library/vstudio/envdte.textpoint.codeelement.aspx) is the base class constructor? Unfortunatelly, I don't know how to actually "move" the `TextPoint` instance. – Daniel Hilgarth Feb 21 '13 at 13:40
  • Thanks, i got the full content and parse it. Should be the solution! (string functionContent = codeFunction.StartPoint.CreateEditPoint().GetText(codeFunction.EndPoint);) – Peter Bucher Feb 21 '13 at 14:06

1 Answers1

0

If found that solutions made in comments are not really read-friendly and therfore will not be read.

So, here ist the solution which worked for me:

Thanks, i got the full content and parse it. Should be the solution! (string functionContent = codeFunction.StartPoint.CreateEditPoint().GetText(codeFunction.EndPoint);)

Peter Bucher
  • 295
  • 2
  • 13