开发者

How can I disable CLS compliance checking using C#

开发者 https://www.devze.com 2023-01-23 00:23 出处:网络
How do I disable CLS compliance checking? How can I do it for: The entire assembly A开发者_运维知识库 smaller scope, maybe one file or one class...

How do I disable CLS compliance checking?

How can I do it for:

  1. The entire assembly
  2. A开发者_运维知识库 smaller scope, maybe one file or one class...


You can use the CLSCompliant attribute to explicitly mark an assembly or type, e.g.

For an assembly, add the following line in AssemblyInfo.cs

[assembly: CLSCompliant(false)]

For a class

[CLSCompliant(false)]
public class Foo
{
}

You can also use it for specific type members (methods, properties, etc.) in a similar manner.


You could use the [CLSCompliant(false)] attribute.

Quote from the doc:

You can apply the CLSCompliantAttribute attribute to the following program elements: assembly, module, class, struct, enum, constructor, method, property, field, event, interface, delegate, parameter, and return value. However, the notion of CLS compliance is only meaningful for assemblies, modules, types, and members of types, not parts of a member signature. Consequently, CLSCompliantAttribute is ignored when applied to parameter or return value program elements.

There's also possibility to supress compiler warnings.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号