0

I am putting together a template for creating buddy classes for classes generated by the Entity Framework -> Reverse Engineer Code First context menu item.

I really don't want to include the navigation properties that are marked as virtual. So how, using CodeProperty interface (or other EnvDTE code) discover if a property is marked as virtual?

To say it with pseudo code:

<# foreach (CodeElement ce in classInFile.Members)
        { 
            if (ce.Kind == vsCMElement.vsCMElementProperty && [ce not marked as virtual]) 
            {
                WriteDisplayName(ce); 
                WriteProperty(ce);
                WriteLine("");
            }
        } #>

Ie, how do I determine that ce is not marked as virtual?

awrigley
  • 13,481
  • 10
  • 83
  • 129

1 Answers1

3

Cast the CodeElement to a CodeProperty2 and check its OverrideKind property.

Matt Ward
  • 47,057
  • 5
  • 93
  • 94
  • that sounds correct, but I have had a conflict with the Tangible T4 library I am using when I try to use EnvDTE80, so shied off. I will have another look at why that conflict happened. I am pretty sure your answer is the correct answer, so have voted it up and marked it (provisionally) as the answer. Thanks. – awrigley May 23 '14 at 08:29