"Julia" <co********@012.net.il> wrote in message
news:uh**************@tk2msftngp13.phx.gbl...
Hi,
Is there any why I could use attribute or something else
to instruct the compiler to inject a specific code for a property?
There is no code generator support directly within the MS C# compiler. There
is a third party compiler that does something like this, but I can't
remember the name(or even if it works this way. It might simply have
parameter constraints). And, although I can't say for sure, this sounds like
AOP to me. You may be able to find an AOP framework for C# or perhaps go
totally overboard and use ContextBoundObject and write your own
hooks(
http://msdn.microsoft.com/msdnmag/is.../default.aspx).
It is obnoxious, but it does work(in the 1.1 framework anyway, I can't say
firsthand about 2.0).
Most of the time you would use code generators(wonderful things, even better
with partial classes) or macros to achieve this. Even a pre-build step that
parses the code, sees the attribute, and injects it would be sufficent in
most cases.
The question really is why you aren't talking about code generation but you
are. I mean, injecting code is *still* generation, even if the generation
step happens to occur during compilation time. Is there some particular
reason you can't use some form of code generation?