Hi,
What is the most innovative usage of C# attributes you've implemented or have seen implemented?
Hi,
What is the most innovative usage of C# attributes you've implemented or have seen implemented?
Before LINQ to SQL (and when I wasn't allowed to use Open Source or Off-The-Shelf ORMs), I built an entire ORM solution using attributes and reflection.
...the crowning achievement was that performance didn't suck.
We implemented a hierarchy of custom attributes using PostSharp to take care of all the validations required for each of the WCF methods.
As the services implement the request/response pattern and the response objects have ErrorCode and ErrorMessage, the attributes also act as a catch-all and returns a Failed response when an exception bubbles up and it'll include the appropriate ErrorCode and message in the response.
It worked really well and we were able to cut out most of our boiler plate code from before :-)