How do I add an attribute to my class

Hello again,

I want to add an attribute to my class and i don't seem the way how...

I need somehow the IAttributeInstance to pass it to the factory but i
couln't
find a way to create it from the project declarations cache

thanks again,
guy.



3 comments
Comment actions Permalink

please i still don't know how to do that and its very important to me,

thank you very much,

Guy.

"Ga" <t4m.productions@gmail.com> wrote in message
news:fa658n$a07$1@is.intellij.net...

Hello again,

>

I want to add an attribute to my class and i don't seem the way how...

>

I need somehow the IAttributeInstance to pass it to the factory but i
couln't
find a way to create it from the project declarations cache

>

thanks again,
guy.

>
>



0
Comment actions Permalink

You have to construct "IAttribute" and add it to IClassDeclaration.

IClassDeclaration classDeclaration;
....
classDeclaration/AddAttributeAffter (attribute, null);

The easiest way to construct IAttribute - is to use CSharpElementFacotry.
For example, you can construct class declaration with necessary attributes,
and then extract it from built declaration

IClassDeclaration tempDeclaration =
(IClassDeclaration)factory.CreateTypememberDeclaration("[MyAttribute] class
C{}");
IAttribute attribute = tempDeclaration.Attributes[0]




--
Eugene Pasynkov
Developer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"
"Ga" <t4m.productions@gmail.com> wrote in message
news:fa658n$a07$1@is.intellij.net...

Hello again,

>

I want to add an attribute to my class and i don't seem the way how...

>

I need somehow the IAttributeInstance to pass it to the factory but i
couln't
find a way to create it from the project declarations cache

>

thanks again,
guy.

>
>




0
Comment actions Permalink

Wow thanks,
it's brilliant.

Guy.

"Eugene Pasynkov (JetBrains)" <Eugene.Pasynkov@jetbrains.com> wrote in
message news:fam3uo$n6p$1@is.intellij.net...

You have to construct "IAttribute" and add it to IClassDeclaration.

>

IClassDeclaration classDeclaration;
....
classDeclaration/AddAttributeAffter (attribute, null);

>

The easiest way to construct IAttribute - is to use CSharpElementFacotry.
For example, you can construct class declaration with necessary
attributes, and then extract it from built declaration

>

IClassDeclaration tempDeclaration =
(IClassDeclaration)factory.CreateTypememberDeclaration("[MyAttribute]
class C{}");
IAttribute attribute = tempDeclaration.Attributes[0]

>
>
>
>

--
Eugene Pasynkov
Developer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"
"Ga" <t4m.productions@gmail.com> wrote in message
news:fa658n$a07$1@is.intellij.net...

>> Hello again,
>>
>> I want to add an attribute to my class and i don't seem the way how...
>>
>> I need somehow the IAttributeInstance to pass it to the factory but i
>> couln't
>> find a way to create it from the project declarations cache
>>
>> thanks again,
>> guy.
>>
>>
>>
>



0

Please sign in to leave a comment.