MrAdvice icon indicating copy to clipboard operation
MrAdvice copied to clipboard

How to exclude things from being weaved

Open kampilan opened this issue 5 years ago • 7 comments

First off, I have to congratulate you on a fantastic product. I just works great. I am using it to add an automatic logging feature to my logging framework.

I can't seam to figure out how to exclude things from automatic logging. Specifically I am trying to prevent the logging of getters and setters of automatic properties and default constructors. These things create a lot of clutter with no instrumentation value. I have searched through the test but I just can't seem to find an example of how to use ExcludePointcut. What patterns are supported? Where to place the attribute. On the Advice or the Class or Assembly etc?

Thanks Jim

kampilan avatar Feb 20 '20 21:02 kampilan

OK I dug through the closed issues and mostly answered my own question.

[ExcludePointcut( "get_", "set_")] on my advice does the trick. Is there a way to only apply this filter to automatic properties and not manually coded setters and getters?

Facing one last issue .. exclude default constructors, ones implied by the compiler. Any ideas?

Thanks

kampilan avatar Feb 21 '20 13:02 kampilan

Hi, sorry for my late answer. Currently there is no way to exclude constructors, we could open an issue for these.

picrap avatar Feb 22 '20 09:02 picrap

Thanks for the reply. From my own selfish use case perspective:

  1. Excluding automatic property setters and getters
  2. Excluding default constructors
  3. Excluding based on an attribute I define. My advice is called AutoWatch and having a NoAutoWatch that excludes when placed on classes and methods is clearer. I currently use a NoAutoWatch attribute to perform the exclude in my Advice (post weaving). It would be better to have the NoAutoWatch exclude from weaving altogether.

Thanks for considering these. Jim

kampilan avatar Feb 24 '20 11:02 kampilan

Any chance of these items being considered?

Thanks Jim

kampilan avatar Dec 04 '20 16:12 kampilan

Yes, unfortunately I don’t work much for MrAdvice at the moment. This is probably quite simple to implement, so a pull request could be appreciated 😉

picrap avatar Dec 04 '20 16:12 picrap

Thanks for the status update. You should probably mention that you are no longer actively working on this project on the front page. A project like this is quite complex and the value I derive from it compared to the effort it would take me to figure out how to make those enhancements on my own says I should find something else. Good luck!

kampilan avatar Dec 04 '20 16:12 kampilan

I think we’ll probably go with advising from code at build-time, so anyone will be able to perform its own customizations.

picrap avatar Apr 27 '21 21:04 picrap