Custom attributes in .NET suck
Well, they seem to at least. They’re semi-useful: I’ve managed to make a fairly good runtime code generator
that fills in some abstract properties for you (based on custom attributes). But how do I make my own “magic”
attributes — you know the ones: ThreadStatic is a good example. It’s an attribute that the runtime knows about,
and just does some magic stuff behind the scenes.
What if I wanted to make my own attribute that actually does something? Why can’t I? Why aren’t there hook methods
that get called when the class is loaded, or when the method is called, or something along those lines? I’d quite
like to make an equivalent of ThreadStatic for sessions: the static variable is shared between all requests in
a web session (I’m not using ASP here, I’m using my own framework). But I can’t (it seems).
It’s this sort of poorly thought out “magic” stuff that is used throughout the .NET framework — and it seems to me that, most of the time, whoever thought it up didn’t really think about who might be using it. Beyond the simplest of wizard-code-generated cases, that is. I guess I’m not supposed to actually do any real work with .NET?