CodeAttributeDeclaration Class
Represents an attribute declaration.
Assembly: System (in System.dll)
| Name | Description | |
|---|---|---|
![]() | CodeAttributeDeclaration() | Initializes a new instance of the CodeAttributeDeclaration class. |
![]() | CodeAttributeDeclaration(CodeTypeReference^) | Initializes a new instance of the CodeAttributeDeclaration class using the specified code type reference. |
![]() | CodeAttributeDeclaration(CodeTypeReference^, array<CodeAttributeArgument^>^) | Initializes a new instance of the CodeAttributeDeclaration class using the specified code type reference and arguments. |
![]() | CodeAttributeDeclaration(String^) | Initializes a new instance of the CodeAttributeDeclaration class using the specified name. |
![]() | CodeAttributeDeclaration(String^, array<CodeAttributeArgument^>^) | Initializes a new instance of the CodeAttributeDeclaration class using the specified name and arguments. |
| Name | Description | |
|---|---|---|
![]() | Arguments | Gets the arguments for the attribute. |
![]() | AttributeType | Gets the code type reference for the code attribute declaration. |
![]() | Name | Gets or sets the name of the attribute being declared. |
| Name | Description | |
|---|---|---|
![]() | Equals(Object^) | Determines whether the specified object is equal to the current object.(Inherited from Object.) |
![]() | Finalize() | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.) |
![]() | GetHashCode() | Serves as the default hash function. (Inherited from Object.) |
![]() | GetType() | |
![]() | MemberwiseClone() | |
![]() | ToString() | Returns a string that represents the current object.(Inherited from Object.) |
A CodeAttributeDeclaration can be used to represent an expression that declares an attribute. The attribute name and the arguments for the attribute are stored as properties of the object. A CodeAttributeArgument can be used to represent each argument for the attribute.
The following code example creates a CodeAttributeDeclaration that declares a CLSCompliantAttribute with an argument of false:
#using <System.dll> #using <System.Xml.dll> using namespace System; using namespace System::CodeDom; using namespace System::CodeDom::Compiler; int main() { // Declare a new type called Class1. CodeTypeDeclaration^ class1 = gcnew CodeTypeDeclaration("Class1"); // Declare a new code attribute CodeAttributeDeclaration^ codeAttrDecl = gcnew CodeAttributeDeclaration( "System.CLSCompliantAttribute", gcnew CodeAttributeArgument(gcnew CodePrimitiveExpression(false))); class1->CustomAttributes->Add(codeAttrDecl); // Create a C# code provider CodeDomProvider^ provider = CodeDomProvider::CreateProvider("CSharp"); // Generate code and send the output to the console provider->GenerateCodeFromType(class1, Console::Out, gcnew CodeGeneratorOptions()); } // The CPP code generator produces the following source code for the preceeding example code: // //[System.CLSCompliantAttribute(false)] //public class Class1 { //}
Available since 1.1
Any public static ( Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.


