How create an attribute in CodeDom

T

Tapas

Hi,

I need to generate an Attribute [SetUp] and associate it with a
method in CodeDom.

// Code snippet
CodeMemberMethod setUp = new CodeMemberMethod();
setUp.CustomAttributes.Add(new CodeAttributeDeclaration("SetUp"));

But, this creates an Attribute [SetUp()]. Which doesn't go well with
NUnit testing. I want to get reed of the brackets and final generated
output should be [SetUp]. How do I do this?

Thanks in advance.

Regards
Tapas
 
L

Lars Wilhelmsen

Hi Tapas,
But, this creates an Attribute [SetUp()]. Which doesn't go well with
NUnit testing. I want to get reed of the brackets and final generated
output should be [SetUp]. How do I do this?
AFAIK [Setup()] is equivalent to [Setup] - as [SetupAttribute] is to
[Setup].

I.e. your code is just fine.

Regards,

Lars Wilhelmsen
Software Engineer
Teleplan A/S, Norway
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top