c# - 清理 C# 编译器警告 CS3016 : Arrays as attribute arguments is not CLS-compliant

标签 c# .net cls-compliant

<分区>

Possible Duplicate:
‘Arrays as attribute arguments is not CLS-compliant’ warning, but no type information given

我有一些代码会在多个地方生成此警告。我想修复它们,但我不知道它们在哪里,因为 C# 编译器不报告错误行(有一个 Unresolved MS Connect 问题)。

有没有工具可以告诉我哪里有问题的代码? IL 级别的工具很好,知道方法名称和声明类型就足够了。

最佳答案

你已经声明了一个类:

[SomeAttribute(new string[] { "foo", "bar" })
class SomeClass { }

或已声明如下属性:

class SomeAttribute : Attribute
{
    public SomeAttribute(string[] arr) { } // or another array
}

所有这一切的发生是因为您的程序集被标记为符合 CLS:

[程序集:CLSCompliant(true)]

关于c# - 清理 C# 编译器警告 CS3016 : Arrays as attribute arguments is not CLS-compliant,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2912861/

相关文章:

c# - Blazor 关闭有条件的 div 包装器上的 div 标签

c# - 无法跟踪实体类型 'x' 的实例,因为已在跟踪键值为 '{Id: 6}' 的另一个实例

c# - 删除子域的cookie

.net - BDD 和单元测试

c# - 在 C# 中禁用 CLS 合规性检查

vb.net - 了解 CLS 合规性和正确的代码

.net - BCL 与 CLS 有何关系?

c# - Asp.net objectdatasource TypeName 属性错误

c# - 使用 Regex 替换特定的 HTML 标签

c# - DDD、EF、聚合