locked
multiple custom attributes for a method to be generated in a single line using codedom RRS feed

  • Question

  • Hi

    Can any one tell me how to generate multiple custom attributes for a method in single line?

    Actually i want to generate code  using codedom like this

    [Description("xyz"),Owner("Admin")]

    public void GetDetails(){

    ....

    }

    but when I used the following code for generating the custom attributes

     

    'Declaring a collection object

     

    Dim CodeAttrcollection As New CodeAttributeDeclarationCollection(New CodeAttributeDeclarationCollection())

    CodeAttrcollection.Add(

    New CodeAttributeDeclaration("Description", New CodeAttributeArgument(New CodePrimitiveExpression("xyz"))))

     

    'Owner name for each test method

    CodeAttrcollection.Add(

    New CodeAttributeDeclaration("Owner", New CodeAttributeArgument(New CodePrimitiveExpression("Admin"))))

    Execmtd.CustomAttributes.Add(CodeAttrcollection)

    It created the cosde like this:

    [Description("xyz")]

    [Owner("Admin")]

    public void GetDetails(){

    ....

    }

    So can anyone tell me how to generate multiple custom attributes in a single row??????

    Thursday, March 25, 2010 1:41 PM

Answers

  • CodeDom does not give you complete control over formatting of the generated code. If formatting and readability of generated code is more important to you than generating multiple languages from a single code generator, consider using T4.


    Oleg
    • Marked as answer by Nancy Shao Thursday, April 1, 2010 7:04 AM
    Sunday, March 28, 2010 1:56 PM

All replies

  • CodeDom does not give you complete control over formatting of the generated code. If formatting and readability of generated code is more important to you than generating multiple languages from a single code generator, consider using T4.


    Oleg
    • Marked as answer by Nancy Shao Thursday, April 1, 2010 7:04 AM
    Sunday, March 28, 2010 1:56 PM
  • Thanks.
    Thursday, April 1, 2010 11:41 AM