ArxOne / MrAdvice

.NET aspect weaver (build task under NuGet package)
MIT License
311 stars 45 forks source link

How to exclude things from being weaved #162

Open kampilan opened 4 years ago

kampilan commented 4 years ago

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 commented 4 years ago

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

picrap commented 4 years ago

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

kampilan commented 4 years ago

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 commented 3 years ago

Any chance of these items being considered?

Thanks Jim

picrap commented 3 years ago

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 😉

kampilan commented 3 years ago

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!

picrap commented 3 years ago

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