Reputation: 1979
I want to apply my VerboseTraceAspect
to my solution, and apply the attribute everywhere except for
TestProject.Logging.*
and TestProject.Tracing.*
I am using the following sample but it does not seem to work. Am I doing this wrong? If so, how should it be done?
Thanks heaps.
[assembly: VerboseTraceAspect(AspectPriority = 0, AttributeExclude = true, AttributeTargetTypes = "TestProject.Logging.*|TestProject.Tracing.*")]
[assembly: VerboseTraceAspect(AspectPriority = 1, AttributeExclude = true, AttributeTargetMembers = "regex:get_.*|set_.*")]
[assembly: VerboseTraceAspect(AspectPriority = 2, AttributeTargetTypes = "TestProject.*",
AttributeTargetTypeAttributes = MulticastAttributes.Public,
AttributeTargetMemberAttributes = MulticastAttributes.Public,
AttributeTargetElements = MulticastTargets.Method)]
Upvotes: 2
Views: 1400
Reputation: 5101
You need to correct the target types expression in the first line where you remove your trace attribute from TestProject.Logging.*
and TestProject.Tracing.*
. If you want to specify several options separated with pipeline, then you should use regular expressions syntax.
You also need to use AttributePriority
instead of AspectPriority
property. The attribute multicasting is performed before the AspectPriority
has any effect. It's used later to determine the order in which your aspects will execute.
The "exclude" attributes must have a higher priority value (higher values are processed after lower values).
[assembly: VerboseTraceAspect(
AttributePriority = 1,
AttributeExclude = true,
AttributeTargetTypes = @"regex:TestProject\.Logging\..+|TestProject\.Tracing\..+")]
[assembly: VerboseTraceAspect(
AttributePriority = 2,
AttributeExclude = true,
AttributeTargetMembers = "regex:get_.*|set_.*")]
[assembly: VerboseTraceAspect(
AttributePriority = 0,
AttributeTargetTypes = "TestProject.*",
AttributeTargetTypeAttributes = MulticastAttributes.Public,
AttributeTargetMemberAttributes = MulticastAttributes.Public,
AttributeTargetElements = MulticastTargets.Method)]
Upvotes: 2