我正在 C# 和 C++ CLR 中使用 VCCodeModel,但无法将 VCCodeModel 类型输入到 CLR 项目中。我添加了 Microsoft.VisualStudio.VCCodemodel 作为引用,但是当我输入时:
Microsoft::VisualStudio::VCCodeModel::VCCodeModel
Visual Studio 看不到代码模型。命名空间中的所有其他对象,如 VCCodeFunction 和 VCFileCodeModel 都可以工作,但这个失败了。
VCCodeModel Namespace
是否有一些错误可能导致这种情况?我使用默认的插件项目,C++ CLR作为选择的语言,并添加了Microsoft.VisualStudio.VCCodeModel作为引用,可以成功引用空间中的其他成员。这可能是什么问题?
最佳答案
您在使用 IDE 的 C++ 智能感知时遇到了错误/怪癖。即使你完全限定了一个类名,如果类名与命名空间名称相同,它也不会出现在智能感知中。 IDE 也不会将其识别为类——类名的颜色保持黑色,而不是像其他类一样的浅蓝色。
幸运的是,这纯粹是一个装饰性的 IDE 问题。该类在您的代码中仍然可以正常工作,仍然可以编译,等等。您只需要自己键入类的名称。 :-)
此外,问题仅扩展到类名,而不是类的成员。如果您在代码中创建对 VCCodeModel 的托管引用,您将能够看到其成员的智能感知。
这是说明普通非托管类中的智能感知问题的再现:
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
}
};
};
关于c# - VCCodeModel 不在 VCCodeModel 命名空间中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1273847/