Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

CodeAttributeDeclaration Class

 

Represents an attribute declaration.

Namespace:   System.CodeDom
Assembly:  System (in System.dll)

System::Object
  System.CodeDom::CodeAttributeDeclaration

[SerializableAttribute]
[ClassInterfaceAttribute(ClassInterfaceType::AutoDispatch)]
[ComVisibleAttribute(true)]
public ref class CodeAttributeDeclaration 

NameDescription
System_CAPS_pubmethodCodeAttributeDeclaration()

Initializes a new instance of the CodeAttributeDeclaration class.

System_CAPS_pubmethodCodeAttributeDeclaration(CodeTypeReference^)

Initializes a new instance of the CodeAttributeDeclaration class using the specified code type reference.

System_CAPS_pubmethodCodeAttributeDeclaration(CodeTypeReference^, array<CodeAttributeArgument^>^)

Initializes a new instance of the CodeAttributeDeclaration class using the specified code type reference and arguments.

System_CAPS_pubmethodCodeAttributeDeclaration(String^)

Initializes a new instance of the CodeAttributeDeclaration class using the specified name.

System_CAPS_pubmethodCodeAttributeDeclaration(String^, array<CodeAttributeArgument^>^)

Initializes a new instance of the CodeAttributeDeclaration class using the specified name and arguments.

NameDescription
System_CAPS_pubpropertyArguments

Gets the arguments for the attribute.

System_CAPS_pubpropertyAttributeType

Gets the code type reference for the code attribute declaration.

System_CAPS_pubpropertyName

Gets or sets the name of the attribute being declared.

NameDescription
System_CAPS_pubmethodEquals(Object^)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_protmethodFinalize()

Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_protmethodMemberwiseClone()

Creates a shallow copy of the current Object.(Inherited from Object.)

System_CAPS_pubmethodToString()

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 {
//}

.NET Framework
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.

Return to top
Show:
© 2017 Microsoft