When I generate a view from the List template I notice that the names of the columns are not based on the DisplayName() annotation. I know how to edit the list.tt code template but I have no idea how to retrieve the DisplayName attributes from the class properties.
+1
A:
The common way to get the DisplayName attribute is via reflection. The issue your going to have is .tt templates and reflection don't play nice together. Reflection relies on code being loaded into the AppDomain. Since .tt files don't actually load code you can't reflect over them.
More information about this issue, and a possible solution here:
http://www.olegsych.com/2007/12/how-to-use-t4-to-generate-decorator-classes/
MVC and Visual Studio must use some type of code inspection to generate some of the generated so I'd look along that path, maybe some crazy regex, if your not into solving the reflection issue.
jfar
2010-07-01 14:24:40