[Mono-devel-list] Trigger some internal action based on attributes for a method?

Bas Westerbaan bas.westerbaan at gmail.com
Mon Jun 27 15:25:02 EDT 2005


Guess there would be three options:

First just using a delegate instead of the method and add a handler to the 
delegate

eg. MyClass.MyBaseFunctionDelegate += MyHookFunction;

You could restrict usage by only allowing it to be accessed constructortime 
with the readonly keyword, although I am not sure whether that will work 
with delegates.


Secondly using attributes which will be read by a script before compilation 
which generates the implementation. This could also happen after compilation 
although converting comopiled IL is harder but makes it compatible with 
languages you didn't write the script for.


Thirdly by implementing it into Mono itself. The downside to that is that 
you block out microsoft's .net framework which will likely not implement 
such a thing.


On 6/27/05, Okehee Goh <okehee at gmail.com> wrote:
> 
> I wonder how I can support this:
> When a method is entered and starts executing ,
> I'd like to implicitly call another method or an internal
> function defined inside of CLR
> (What I'd like to do is to notify CLR certain information telling that
> the method being executed now is the one CLR should monitor..)
> 
> Seems there is 'hook' approach.
> But I don't want users to customize their methods into certain format
> in order to insert the hook.
> 
> So, I checked out Attributes because users can simply add
> corresponding attribute in front of the method definition. But, seems
> that the metadata information declared through Attribute is accessed
> through reflection in managed code only. Users' managed code calls
> some reflection to ask the type of attribute.
> However, is there a way that CLR internal can use the attribute like
> hook function?
> 
> If Attributes are not proper for that, how about event listener?
> 
> I searched the archive of the mailing list. There was a mail-thread
> "Implementing attribute-based code generation" in Jan. I wonder
> whether there has been evolved activities for that since that?
> 
> Regards,
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
> 



-- 
Bas Westerbaan
Bas.Westerbaan at gmail.com
GPG Public Keys: http://w-nz.com/keys/bas.westerbaan.asc
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20050627/f453debe/attachment.html 


More information about the Mono-devel-list mailing list