可能重复:
‘Arrays as attribute arguments is not CLS-compliant’ warning, but no type information given
我有一些代码,在几个地方生成这个警告。我想修复它们,但是我不知道它们在哪里,因为C#编译器没有报告错误行(有一个开放的MS问题)。
有没有一个工具,可以告诉我问题代码在哪里?IL级工具很好,知道方法的名称和声明类型是足够好的。
发布于 2010-05-26 12:35:34
您已经声明了一个类,如:
[SomeAttribute(new string[] { "foo", "bar" })
class SomeClass { }
或者声明了如下属性:
class SomeAttribute : Attribute
{
public SomeAttribute(string[] arr) { } // or another array
}
这一切之所以发生,是因为您的程序集被标记为CLSCompliant:
[assembly:CLSCompliant(true)]
发布于 2010-05-26 12:54:55
我将采用以下程序:
如果在解决方案中定义了所讨论的属性,那么第一部分应该相当容易。
如果属性来自依赖项,那么您可能需要使用regex搜索来查找使用这些属性的位置。
https://stackoverflow.com/questions/2912861
复制相似问题