Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cool uses of Attributes or Annotations (CLR or Java)?

What are some cool applications for custom attributes in CLR/C# code that you've done or heard about? Also interesting new uses of the standard attributes is also ok!

Edit: Since Java's annotations seems to be the same as CLR's attrbutes, uses of Java annotations is also valid.

like image 846
Robert Gould Avatar asked Jan 28 '09 07:01

Robert Gould


1 Answers

  • postsharp, which uses attributes to inject code (AOP)?
  • [TypeDescriptionProvider] which can be used to provide a custom runtime property model - either completely different properties, or perhaps faster ones

And some core ones that are often overlooked:

  • [TypeForwardedTo] - used to move types between assemblies without re-building
  • [PrincipalPermission] - used to automatically enforce security on members
like image 114
Marc Gravell Avatar answered Oct 06 '22 23:10

Marc Gravell