Log4PostSharp - How to supress code generation for iterators
8 posts • Page 1 of 1
Log4PostSharp - How to supress code generation for iterators
Greetings,
I'm working with Postsharp since a few days now but I'm impressed how powerful it is.
Great work
Now I want to simplyfy my logging mechanism and found Log4PostSharp. Also great code but I encountered a problem with iterators.
My Intention is to activate code generation for the whole classes an suppress it for a couple one. One of the classes where I want to suppress logging contains an iterator as returntype (IEnumerable<T>) and yield return.
For that the compiler generates an anonymous generic class and Log4PostSharp injects logging for that (seen in .NET Reflector).
My question now is how to I suppress the code injection for that anonymous class?
For the surrounding classes it works pretty well with Log(AttributeExclude = true) but not for that private generated class ...
I also testet Log(AttributeTargetTypes="Log4PostSharp.Test.Testclass*", AttributeExclude = true).
The attached file contains a testclass placed in the Log4PostSharp.Test-Project of Log4PostSharp.
Is there a way to supress code generation?
torsten
I'm working with Postsharp since a few days now but I'm impressed how powerful it is.
Now I want to simplyfy my logging mechanism and found Log4PostSharp. Also great code but I encountered a problem with iterators.
My Intention is to activate code generation for the whole classes an suppress it for a couple one. One of the classes where I want to suppress logging contains an iterator as returntype (IEnumerable<T>) and yield return.
For that the compiler generates an anonymous generic class and Log4PostSharp injects logging for that (seen in .NET Reflector).
My question now is how to I suppress the code injection for that anonymous class?
For the surrounding classes it works pretty well with Log(AttributeExclude = true) but not for that private generated class ...
I also testet Log(AttributeTargetTypes="Log4PostSharp.Test.Testclass*", AttributeExclude = true).
The attached file contains a testclass placed in the Log4PostSharp.Test-Project of Log4PostSharp.
Is there a way to supress code generation?
torsten
You do not have the required permissions to view the files attached to this post.
"Things should be as simple as possible, but no simpler" A. Einstein
- tbaer
- Posts: 2
- Joined: Tue May 27, 2008 5:10 pm
- First Name: Torsten
- Last Name: Bär
Re: Log4PostSharp - How to supress code generation for iterators
What I would do is to patch this project to add some more logic: if the method is decorated with the [CompilerGenerated] custom attribute, we don't trace it.
You could propose it to Michal, the author. (Use for instance private messaging: ucp.php?i=pm&mode=compose&u=219).
You could propose it to Michal, the author. (Use for instance private messaging: ucp.php?i=pm&mode=compose&u=219).
Gael Fraiteur, project leader
- gfraiteur
- Site Admin
- Posts: 834
- Joined: Tue Dec 18, 2007 3:09 pm
- First Name: Gael
- Last Name: Fraiteur
- Company: postsharp.org
Re: Log4PostSharp - How to supress code generation for iterators
Hi,
this is something that I have missed, thank you for the report. I'll work on this during the weekend.
@Gael: thank you for the advice, your solution looks like the right one. Do you know if this attribute is placed automatically on all classes/methods generated by the compiler (iterators, anonymous delegates)?
this is something that I have missed, thank you for the report. I'll work on this during the weekend.
@Gael: thank you for the advice, your solution looks like the right one. Do you know if this attribute is placed automatically on all classes/methods generated by the compiler (iterators, anonymous delegates)?
- herrmic
- Posts: 20
- Joined: Sat Jan 12, 2008 4:55 pm
- First Name: Michal
- Last Name: Dabrowski
Re: Log4PostSharp - How to supress code generation for iterators
Yes, the compiler always puts this custom attribute on auto-generated artifacts.
I would also add a property to your custom attribute to force logging even if it is compiler-generated.
G
I would also add a property to your custom attribute to force logging even if it is compiler-generated.
G
Gael Fraiteur, project leader
- gfraiteur
- Site Admin
- Posts: 834
- Joined: Tue Dec 18, 2007 3:09 pm
- First Name: Gael
- Last Name: Fraiteur
- Company: postsharp.org
Re: Log4PostSharp - How to supress code generation for iterators
I created a new forum for the project Log4PostSharp. Michal, could you subscribe to receive notifications on all posts of this forum?
Thanks,
Gael
Thanks,
Gael
Gael Fraiteur, project leader
- gfraiteur
- Site Admin
- Posts: 834
- Joined: Tue Dec 18, 2007 3:09 pm
- First Name: Gael
- Last Name: Fraiteur
- Company: postsharp.org
Re: Log4PostSharp - How to supress code generation for iterators
Sure, subscription already done
Thanks for the separate forum.
I'll work on the issue today or tomorrow.
I'll work on the issue today or tomorrow.
- herrmic
- Posts: 20
- Joined: Sat Jan 12, 2008 4:55 pm
- First Name: Michal
- Last Name: Dabrowski
Re: Log4PostSharp - How to supress code generation for iterators
Hi,
I've added IncludeCompilerGeneratedCode property to the Log attribute.
By default, methods decorated with CompilerGeneratedAttribute are not woven. This also applies to methods declared in types that are decorated with the attribute.
I've added IncludeCompilerGeneratedCode property to the Log attribute.
By default, methods decorated with CompilerGeneratedAttribute are not woven. This also applies to methods declared in types that are decorated with the attribute.
- herrmic
- Posts: 20
- Joined: Sat Jan 12, 2008 4:55 pm
- First Name: Michal
- Last Name: Dabrowski
Re: Log4PostSharp - How to supress code generation for iterators
Works great now
Thanks for quick response!
"Things should be as simple as possible, but no simpler" A. Einstein
- tbaer
- Posts: 2
- Joined: Tue May 27, 2008 5:10 pm
- First Name: Torsten
- Last Name: Bär
8 posts • Page 1 of 1
