GarethJ
GarethJ

Reputation: 6606

What is the AttributeType property used for in the CodeDOM class CodeAttributeDeclaration?

I'm doing code generation, creating a custom attribute to decorate a class using CodeDOM, targetting C# and VB. To do this, I'm creating an instance of the CodeAttributeDeclaration class.

I'm currently setting the AttributeType property, as well as the Name, but it does not seem to be used. Instead, the Name property is all that is used to produce the attribute declaration.

Am I missing something? What is this property used for?

Upvotes: 0

Views: 291

Answers (1)

Damien_The_Unbeliever
Damien_The_Unbeliever

Reputation: 239654

It's an alternative (I believe, haven't done CodeDOM for a while) - you can define the attribute declaration using either a name or a type. If both are set, it will (apparently) use the name. Looking at the overloads for the constructor of this type gives some clues to this.

Looking in reflector, it turns out that setting the Name always forces the AttributeType to be a CodeTypeReference to the same name, and the constructors that take the TypeReference always set the name also - so it's not even that one can be set instead of the other.

Upvotes: 2

Related Questions