Visual studio 2010 代码分析AssemblyNode.GetType始终返回null

Visual studio 2010 代码分析AssemblyNode.GetType始终返回null,visual-studio-2010,code-analysis,Visual Studio 2010,Code Analysis,我正在为VisualStudio2010编写自定义代码分析规则(基本上是FxCop,但是最新版本)。我正在尝试使用如下代码获取应用于被检查程序集的属性(或所有属性的集合): public override ProblemCollection Check( ModuleNode module ) { AssemblyNode assembly = module as AssemblyNode; if ( assembly != null ) { Identi

我正在为VisualStudio2010编写自定义代码分析规则(基本上是FxCop,但是最新版本)。我正在尝试使用如下代码获取应用于被检查程序集的属性(或所有属性的集合):

public override ProblemCollection Check( ModuleNode module )
{
    AssemblyNode assembly = module as AssemblyNode;
    if ( assembly != null )
    {
        Identifier ns = Identifier.For( "System.Reflection" );
        Identifier attr = Identifier.For( "AssemblyCopyrightAttribute" );
        TypeNode type = assembly.GetType( ns, attr );         
        ...
…但是“type”总是空的,即使我知道这样一个属性是为程序集定义的

此外。。。调试此程序时,我看到assembly.ModuleAttributes集合是空的,ExportedTypes和Modules也是空的。。。看起来程序集似乎什么都不包含!但是,“基本”ModuleNode已完全填充,例如,在其属性集合中包含14个属性


似乎“模块作为AssemblyNode”是错误的,但如果是这样,它将返回null!有人能解释我做错了什么吗?

ModuleNode.GetType查找类型的定义,而不是类型的用法。AssemblyCopyrightAttribute在mscorlib程序集中定义,这可能不是规则的目标。要查找AssemblyCopyrightAttribute的用法,请尝试改用
assembly.GetAttribute
。有关示例,请参见