|
|
|
Community Member
|
|
I am running C# 3.5 (on XP Pro) and am having issues with entries at the assembly level. I have rolled the build back to 2.0 and 3.0 as well, and no luck.
In the first example, Logging , one of the two entries work. This one works: [assembly: Trace("Logging")] ...with TraceAttribute class ignored: [Trace(null, AttributeExclude = true)]
and this one doesn't: [assembly: Trace("Logging", AttributeTargetTypes = "say*")]
In the second example, PerformanceCounter, the entry is:
[assembly: PerformanceCounter(AttributeTargetAssemblies = "mscorlib", AttributeTargetTypes = "System.IO.*")]
The results in both cases that fail are that the code compiles, but the overrides never happen. So it seems that AttributeTargetTypes may be incompatible with 3.5. On the logging example, I tried replacing say* with sayHello (and verified the case is correct) but still no luck.
Has anyone else run into this, or do you have any ideas?
Thanks! Damon
|
|
|
|
|
Gael Fraiteur
SharpCrafters
|
|
I am not sure I understand your problem. Anyway, PostSharp is not related to the version of .NET (a fortiori C#) you are running, if 2.0 or 3.5.
Remember that the property AttributeTargetTypes evaluates the full type name (including namespace, excluding member name).
-g
|
|
|
|
|
Community Member
|
|
|
Your comment "Remember that the property AttributeTargetTypes evaluates the full type name (including namespace, excluding member name)." helped.
So now this is halfway resolved. I'm following your tracing/logging example over at codeproject http://www.codeproject.com/KB/cs/ps-custom-attributes-1.aspx
I was having problems with the performance monitoring (also from the assembly level) and tracing from the assembly level, filtering by the method.
On the performance monitoring, I still need a tip or pointer These statements do not work:
[assembly: PerformanceCounter(AttributeTargetAssemblies = "mscorlib", AttributeTargetTypes = "System.IO.*")]// - FAILS [assembly: PerformanceCounter(AttributeTargetAssemblies = "*", AttributeTargetTypes = "System.IO.*")]// - FAILS [assembly: PerformanceCounter(AttributeTargetTypes = "System.IO.*")]// - FAILS
These statements work, but only traces the HavingFunWith...
[assembly: PerformanceCounter(AttributeTargetTypes = "*")]//WORKS [assembly: PerformanceCounter(AttributeTargetTypes = "HaveFun*.PerformanceCounter.*")]//WORKS // output is HaveFun...PerformanceCounter.Program/Void ListFolder(System.String, Int32): 22 hits, 849.89 ms total, 38.63 ms average
On the tracing, your comment helped me solve it. When you said AttributeTargetTypes excludes the member name, I went back and looked at the example (which was passing the method names "Say*". Anyway I got hit with the copy/paste (or impatiently reading too fast) bug, because I needed AttributeTargetMembers="say*" instead; that solved that part of it.
|
|
|
|
|
Gael Fraiteur
SharpCrafters
|
|
There may be a bug somewhere, because that stuff is supposed to work. Could you report it to <!-- m --><a class="postlink" href="http://www.postsharp.org/tracker">http://www.postsharp.org/tracker</a><!-- m -->?
Thanks.
-gael
|
|
|
|
|
Community Member
|
|
Sorry for the delay, I just returned from vacation.
Reported at: <!-- m --><a class="postlink" href="http://www.postsharp.org/tracker/view.php?id=325">http://www.postsharp.org/tracker/view.php?id=325</a><!-- m -->
|
|
|
|