Page 1 of 1

How to: add display-name and documentation for Enum members

Posted: Tue 20 Dec 2011 15:28
by mindplay
I found that enum type-members are incomplete without a display-name and documentation - I wanted the following output:

Code: Select all

    /// 
    /// This is my type
    /// 
    public enum Test : int
 {


    /// 
    /// Value A
    /// 
        [Display(Name="The First Value")]
        A = 1,

    /// 
    /// Value B
    /// 
        [Display(Name="The Second Value")]
        B = 2,

    /// 
    /// This is the third value
    /// 
        [Display(Name="The Third Value")]
        C = 3
    }
Go to Model Settings -> Extended Properties -> EnumTypeMember and add the following two properties:
  • DisplayName : System.String
    Documentation : System.String
Near the top of your template, add the following:

Code: Select all



Near line 480, copy/paste from the following snippet of code:

Code: Select all

     // enum type members
    if (enumType.Members.Count > 0) {
      foreach (EnumTypeMember member in enumType.Members) {
#>


        [Display(Name="")]

<# // --- COPY TO HERE ---
    if (GenerateDataContracts && (bool)member.GetProperty("GenerateEnumMemberAttribute")) {
Copy the range between the two comments - the lines before/after that are just there to show you where it fits into the standard template.

Hope this is useful to others :-)

Posted: Tue 20 Dec 2011 15:30
by mindplay
PS: the indentation is a bit wonky - for some reason doing output.Indent++ before calling GenerateDocumentation() doesn't seem to work...

Posted: Fri 23 Dec 2011 09:38
by Shalex
Thank you for posting. We will fix the "add display-name and documentation for Enum members" and "output.Indent++" issues.

Posted: Fri 23 Dec 2011 14:23
by Shalex
mindplay wrote:PS: the indentation is a bit wonky - for some reason doing output.Indent++ before calling GenerateDocumentation() doesn't seem to work...
The bug with formatting indents when generating code is fixed. Look forward to the next build of Entity Developer.

Posted: Tue 10 Jan 2012 14:33
by Shalex
The documentation generation for Enum members is implemented. We will post here when the corresponding build of Entity Developer is available for download.

Posted: Thu 12 Jan 2012 16:39
by Shalex
New build of Entity Developer 4.2.110 is available for download now!
It can be downloaded from http://www.devart.com/entitydeveloper/download.html (trial version) or from Registered Users' Area (for users with valid subscription only).
For more information, please refer to http://www.devart.com/forums/viewtopic.php?t=23135 .