0

How can I apply an attribute to all classes in a particular project?! And is it enough to apply CLSCompliant attribute to just one class or do I have to apply to all classes?

Thanks for your answers...

Dr TJ
  • 3,241
  • 2
  • 35
  • 51

2 Answers2

2

A project is an assembly, so you could use an assembly attribute.

Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928
2

This is the declaration for the attribute:

[SerializableAttribute]
[ComVisibleAttribute(true)]
[AttributeUsageAttribute(AttributeTargets.All, Inherited = true, AllowMultiple = false)]
public sealed class CLSCompliantAttribute : Attribute

Note the [AttributeUsage]. With AttributeTargets.All, it indicates that the attribute can be applied to anything. Which includes the assembly:

[assembly:CLSCompliant(true)]
Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536