EntityFramework-Reverse-POCO-Code-First-Generator icon indicating copy to clipboard operation
EntityFramework-Reverse-POCO-Code-First-Generator copied to clipboard

Is there a way to generate the a description attribute for enums?

Open agentKnipe opened this issue 5 years ago • 1 comments

We would like to include the description attribute on enums. Is there a way to do that? we arent finding a setting the the tt files for this.

example output

public enum MyEnum
{
    Name1 = 1,

    [Description("Here is another")]
    HereIsAnother = 2,

    [Description("Last one")]
    LastOne = 3
}

agentKnipe avatar May 05 '20 14:05 agentKnipe

No it doesn't. It would be fairly straight forward to add though

Add a DescriptionField property to EnumerationSettings

Update protected override string EnumSQL(string table, string nameField, string valueField) to return SQL to also get the DescriptionField.

The ReadEnums function will need to be updated to also store the DescriptionField data. It's currently in a KeyValuePair<string, string> so will need to change to store two values as the value field: (ValueField & DescriptionField)

Modify Enumeration class to match the KeyValuePair type above.

Finally modify the relevant Template Enums() function. to include the Description attribute. The template is currently:

public enum {{EnumName}}{{#newline}}
{{{#newline}}
{{#each Items}}
    {{Key}} = {{Value}},{{#newline}}
{{/each}}
}{{#newline}}

sjh37 avatar May 05 '20 16:05 sjh37