Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Excluding properties weaving attribute on the level of class #98

Open
hhblaze opened this issue Mar 15, 2017 · 8 comments
Open

Excluding properties weaving attribute on the level of class #98

hhblaze opened this issue Mar 15, 2017 · 8 comments

Comments

@hhblaze
Copy link

hhblaze commented Mar 15, 2017

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
#97 (comment)

@picrap
Copy link
Member

picrap commented Mar 15, 2017

You can try [ExcludePointcut("*.get_@","*.set_@")] on your advice, this will exclude methods whose name starts with set_ and get_ from it.

@hhblaze
Copy link
Author

hhblaze commented Mar 15, 2017

Very well, thank you!

@picrap
Copy link
Member

picrap commented Mar 16, 2017

Did it work? If yes, you can close the issue.

@hhblaze
Copy link
Author

hhblaze commented Mar 16, 2017

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..

@picrap
Copy link
Member

picrap commented Mar 16, 2017

Do you mean use the [CompilerGenerated] as a selection criterion? So for example we could include or exclude everything that was generated.

@hhblaze
Copy link
Author

hhblaze commented Mar 16, 2017

[CompilerGenerated] looks like a good idea!

@picrap picrap reopened this Mar 16, 2017
@hhblaze
Copy link
Author

hhblaze commented Mar 16, 2017

I think, that behavior must be specified per aspect how to react on [CompilerGenerated].

@picrap
Copy link
Member

picrap commented Mar 16, 2017

Yes, using the [ExcludePointcut] (or [IncludePointcut]).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants