Write customized attribute which has functionality like ObseleteAttribute

  • Thread starter Thread starter Whidbey Wave
  • Start date Start date
W

Whidbey Wave

Hello again Attribute Gurus...
Can someone throw an idea, on what to tweak, or flush out, some kind
of code. if one has to write a custom attribute like
ObseleteAttribute, with the aim to inject the code in various methods
at compile time, the example of code that needs to be injected is like
customized logging.
Have a nice day.
Thank you
Dino
 
Unless you reimplement the compiler, it just can not be done.

Period.

Reality.

--
Regards

Thomas Tomiczek
THONA Software & Consulting Ltd.
(Microsoft MVP C#/.NET)
(CTO PowerNodes Ltd.)
 
Thomas,

This isn't completely true. You can implement context-bound objects
which will allow for call interception when it is determined that a call is
coming from outside of that context. There is an article in MSDN magazine
that explains how to to this titled "Aspect-Oriented Programming Enables
Better Code Encapsulation and Reuse", and it can be found at (watch for line
wrap):

http://msdn.microsoft.com/msdnmag/issues/02/03/aop/default.aspx
 
Thomas pointed out that the original poster wanted to do this at compile
time. What I recommended can't be done at compile time, but it can be done
at runtime to provide AOP-like functionality to objects.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Nicholas Paldino said:
Thomas,

This isn't completely true. You can implement context-bound objects
which will allow for call interception when it is determined that a call is
coming from outside of that context. There is an article in MSDN magazine
that explains how to to this titled "Aspect-Oriented Programming Enables
Better Code Encapsulation and Reuse", and it can be found at (watch for line
wrap):

http://msdn.microsoft.com/msdnmag/issues/02/03/aop/default.aspx


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Thomas Tomiczek said:
Unless you reimplement the compiler, it just can not be done.

Period.

Reality.

--
Regards

Thomas Tomiczek
THONA Software & Consulting Ltd.
(Microsoft MVP C#/.NET)
(CTO PowerNodes Ltd.)
---

Still waiting for ObjectSpaces? Try the EntityBroker today - more versatile,
more powerfull.
And something in use NOW. for the projects you have to deliver - NOW.
 
It is absolutly true.

See the original question:


Your approach does not work at compile time, so it is not a valid solution
per definition.

--
Regards

Thomas Tomiczek
THONA Software & Consulting Ltd.
(Microsoft MVP C#/.NET)
(CTO PowerNodes Ltd.)
---

Still waiting for ObjectSpaces? Try the EntityBroker today - more versatile,
more powerfull.
And something in use NOW. for the projects you have to deliver - NOW.


Nicholas Paldino said:
Thomas,

This isn't completely true. You can implement context-bound objects
which will allow for call interception when it is determined that a call is
coming from outside of that context. There is an article in MSDN magazine
that explains how to to this titled "Aspect-Oriented Programming Enables
Better Code Encapsulation and Reuse", and it can be found at (watch for line
wrap):

http://msdn.microsoft.com/msdnmag/issues/02/03/aop/default.aspx


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Thomas Tomiczek said:
Unless you reimplement the compiler, it just can not be done.

Period.

Reality.

--
Regards

Thomas Tomiczek
THONA Software & Consulting Ltd.
(Microsoft MVP C#/.NET)
(CTO PowerNodes Ltd.)
---

Still waiting for ObjectSpaces? Try the EntityBroker today - more versatile,
more powerfull.
And something in use NOW. for the projects you have to deliver - NOW.
 
Back
Top