How to: add display-name and documentation for Enum members
Posted: Tue 20 Dec 2011 15:28
I found that enum type-members are incomplete without a display-name and documentation - I wanted the following output:
Go to Model Settings -> Extended Properties -> EnumTypeMember and add the following two properties:
Near line 480, copy/paste from the following snippet of code:
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
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
}
- DisplayName : System.String
Documentation : System.String
Code: Select all
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")) {
Hope this is useful to others
