'Arrays as attribute arguments is not CLS-compliant' warning, but no type information given

♀尐吖头ヾ 提交于 2019-12-01 15:50:15

CS3016.

If you have an attribute which takes an array as argument and the project is marked as CLSCompliant you will get this warning.

Brent

I ran into this today. I had 4 instances of the warning showing up. I then found that I had the attribute decorating 4 public methods in that assembly. As I removed them one by one, the errors went away one by one.

Also, if you are OK with not being CLS compliant, you can put [CLSCompliant(false)] on the methods decorated with the attribute (or the class on which the methods are defined). Putting it on the offending attribute constructor/class doesn't do the trick. I guess this makes sense since ultimately the attribute is probably exposed outside the assembly as part of the public method's metadata.

I ran into the same issue, and what I had to do was to use the "Find in Files" dialog in VS2010 select Use: Wildcards and in the Find What: text box, enter

\[*\(*\)\]

That produces a list of all attribute instances. Went one by one and I was able to identify and correct the warnings.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!