views:

55

answers:

1

I am working with VCCodeModel in both C# and C++ CLR and I am having trouble getting the VCCodeModel type in to the CLR project. I have added Microsoft.VisualStudio.VCCodemodel as a reference, but when I type:

Microsoft::VisualStudio::VCCodeModel::VCCodeModel

Visual Studio cannot see the code model. All the other objects in the namespace like VCCodeFunction and VCFileCodeModel all work, but this one fails.

VCCodeModel Namespace

Is there some error that could cause this? I am using the default add-in project with C++ CLR as the chosen language and have added Microsoft.VisualStudio.VCCodeModel as a reference, and can successfully reference the other members in the space. What could the issue be here?

+2  A: 

You're running into a bug/quirk with the IDE's Intellisense for C++. Even if you fully-qualify a class name, if the class name is the same as the namespace name, it will not show up in intellisense. Nor will the IDE recognize it as a class-- the color of the class name stays black, not light blue like other classes.

Luckily, this is a purely cosmetic IDE problem. The class will still work fine in your code, will still compile, etc. You just have to type the name of the class yourself. :-)

Furthermore, the problem only extends to the class name, not the class's members. If you create a managed reference to VCCodeModel in your code, you'll be able to see intellisense for its members.

Here's a repro illustrating the intellisense issue in a plain unmanaged class :

namespace Foo
{
 public class Bar
 {
  public: 
   static int x();
 };
 public class Foo
 {
  public: 
   static int x();
 };
 public class Test
 {
  void ThisIsATest()
  {
   ::Foo::        // intellisense will show Bar and Test, but not Foo
   ::Foo::Foo::   // you will see "x" in intellisense
  }
 };
};
Justin Grant
Feel embarassed that this is what the problem was, but thanks, it was simply not showing up in intellisense.
Yep, sometimes the IDE plays tricks on us! ;-)
Justin Grant