Excluding properties weaving attribute on the level of class
Some more optimization thoughts (may be it's already possible, but I don't know how to achieve that).
In my scenario the advice is applied on the complete assembly. I have only one IMethod advice, but it's applied to all methods, properties and .actors after weaving (it is correct). Mentioned method (with dropped down performance) has a loop inside that creates 1000 objects of one type. This type is a POCO class with 20 properties and a constructor. Properties are quite simple, something like "public bool MyProperty {get; set;}" and I am ready to declare them as safe. Mr.Advice applies the advice on each of them. I would like to exclude those properties from weaving, but without un-decorating each of them. I know that there is an exclusion attribute in Mr.Advice, but is there a way to exclude from weaving class only properties leaving methods? So, such attribute must be on the level of a class.
taken from https://github.com/ArxOne/MrAdvice/issues/97#issuecomment-286679643
You can try [ExcludePointcut("*.get_@","*.set_@")] on your advice, this will exclude methods whose name starts with set_ and get_ from it.
Very well, thank you!
Did it work? If yes, you can close the issue.
This technique is very useful.
I need a bit other scenario, by default all assembly properties must be weaved by the aspect - it's important from security point of view and code observation. But, actually there is no necessity to weave such "public bool MyProperty {get;set}", for try-catch aspect. In such, "public bool MyProperty { get { return _myprop == "test" }}" (in this strange example _myprop can be null and it should lead to unhandled exception), such try-catch aspect with logging is very important here. From the statistic point of view, "passive" properties like "public bool MyProperty {get;set}" are most common. I close the issue with the soaring in the air: ... would be cool, if Mr.Aspect could distinguish between passive and active properties (by signature..don't know) and could apply corresponding configured behaviors..
Do you mean use the [CompilerGenerated] as a selection criterion? So for example we could include or exclude everything that was generated.
[CompilerGenerated] looks like a good idea!
I think, that behavior must be specified per aspect how to react on [CompilerGenerated].
Yes, using the [ExcludePointcut] (or [IncludePointcut]).