Pregunta

Estoy trabajando en código que tiene los siguientes atributos en algunos de sus métodos:

[CLSCompliantAttribute(false)] 

¿Cómo es que cuando construyo el código como está, veo que se está realizando la comprobación del cumplimiento, y cuando comento a cabo, parece que la comprobación de cumplimiento no se está realizando?

He esperaba el comportamiento opuesto ...

¿Fue útil?

Solución

Adición de marcas [CLSCompliant(false)] el miembro se agrega a como no conforme.

Si marca el miembro como no conforme, el compilador no le avisará si no es compatible. (Puesto que ya ha dicho que no es compatible.)

Sin embargo, si el miembro se ha marcado como compatible (ya sea explícitamente o indirectamente de un atributo de nivel de ensamblado), pero de hecho no es compatible (por ejemplo, se necesita un uint), el compilador le advertirá (ya el atributo está mintiendo sobre el miembro).

Otros consejos

Puede añadirlo a AssemblyInfo.cs por ejemplo, y el grupo todo el montaje: *. Como:

using System;
using System.Reflection;
using System.Runtime.InteropServices;
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")]
[assembly: CLSCompliant(false)]


// Setting ComVisible to false makes the types in this assembly not visible 
// to COM components.  If you need to access a type in this assembly from 
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is     exposed to COM
[assembly: Guid("d29c53b6-88e4-4b33-bb86-f39b4c733542")]

// Version information for an assembly consists of the following four     values:
//
//      Major Version
//      Minor Version 
//      Build Number
//      Revision
//
// You can specify all the values or you can default the Revision and Build     Numbers 
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top