Compiler Warning (level 2) CS3021
'type' does not need a CLSCompliant attribute because the assembly does not have a CLSCompliant attribute
This warning occurs if [CLSCompliant(false)]
appears on a class in an assembly which does not have an assembly-level CLSCompliant attribute set to true (that is, the line [assembly: CLSCompliant(true)]
). Since the assembly is not declaring itself CLS compliant, there is no need for anything within the assembly to declare itself non-compliant, since it is assumed to be non-compliant. For more information on CLS compliance, see Language independence and language-independent components.
To get rid of this warning, remove the attribute or add the assembly level attribute.
The following example generates CS3021:
// CS3021.cs
using System;
// Uncomment the following line to declare the assembly CLS Compliant,
// and avoid the warning without removing the attribute on the class.
//[assembly: CLSCompliant(true)]
// Remove the next line to avoid the warning.
[CLSCompliant(false)] // CS3021
public class C
{
public static void Main()
{
}
}
.NET feedback
.NET is an open source project. Select a link to provide feedback: