In This Topic
A PostSharp aspect used to record how often a particular method in your application is used, how long it takes to run, and whether it was ultimately successful or not. It record both log messages and metrics to enable powerful analysis.
Syntax
'Declaration
<DebuggerNonUserCodeAttribute()>
<PostSharp.Extensibility.MulticastAttributeUsageAttribute(MulticastTargets.Constructor Or _
MulticastTargets.InstanceConstructor Or _
MulticastTargets.Method Or _
MulticastTargets.StaticConstructor,
AllowMultiple=True,
TargetMemberAttributes=MulticastAttributes.NonAbstract)>
<PostSharp.Serialization.SerializerAttribute()>
<PostSharp.Aspects.Configuration.AspectConfigurationAttributeTypeAttribute(PostSharp.Aspects.Configuration.OnMethodBoundaryAspectConfigurationAttribute)>
<AttributeUsageAttribute(AttributeTargets.Assembly Or _
AttributeTargets.Class Or _
AttributeTargets.Constructor Or _
AttributeTargets.Event Or _
AttributeTargets.Interface Or _
AttributeTargets.Method Or _
AttributeTargets.Property Or _
AttributeTargets.Struct,
AllowMultiple=True,
Inherited=False)>
<PostSharp.Extensibility.HasInheritedAttributeAttribute()>
<XmlTypeAttribute("http://schemas.postsharp.net/2.0/aspects")>
<SerializableAttribute()>
Public NotInheritable Class GFeature
Inherits GAspectBase
Implements Gibraltar.Agent.IMessageSourceProvider, PostSharp.Aspects.IAspect, PostSharp.Aspects.IAspectBuildSemantics, PostSharp.Aspects.IMethodLevelAspect, PostSharp.Aspects.IMethodLevelAspectBuildSemantics, PostSharp.Aspects.IOnMethodBoundaryAspect, PostSharp.Extensibility.IValidableAnnotation
[DebuggerNonUserCode()]
[PostSharp.Extensibility.MulticastAttributeUsage(MulticastTargets.Constructor |
MulticastTargets.InstanceConstructor |
MulticastTargets.Method |
MulticastTargets.StaticConstructor,
AllowMultiple=true,
TargetMemberAttributes=MulticastAttributes.NonAbstract)]
[PostSharp.Serialization.Serializer()]
[PostSharp.Aspects.Configuration.AspectConfigurationAttributeType(PostSharp.Aspects.Configuration.OnMethodBoundaryAspectConfigurationAttribute)]
[AttributeUsage(AttributeTargets.Assembly |
AttributeTargets.Class |
AttributeTargets.Constructor |
AttributeTargets.Event |
AttributeTargets.Interface |
AttributeTargets.Method |
AttributeTargets.Property |
AttributeTargets.Struct,
AllowMultiple=true,
Inherited=false)]
[PostSharp.Extensibility.HasInheritedAttribute()]
[XmlType("http://schemas.postsharp.net/2.0/aspects")]
[Serializable()]
public sealed class GFeature : GAspectBase, Gibraltar.Agent.IMessageSourceProvider, PostSharp.Aspects.IAspect, PostSharp.Aspects.IAspectBuildSemantics, PostSharp.Aspects.IMethodLevelAspect, PostSharp.Aspects.IMethodLevelAspectBuildSemantics, PostSharp.Aspects.IOnMethodBoundaryAspect, PostSharp.Extensibility.IValidableAnnotation
Example
You can associate the GFeature attribute with a single method, a property, or an entire class to time all methods in that class. You can also use attribute multicasting to apply it to all matching methods in your assembly.
Monitoring one method within a class
public class SampleApplication
{
[GFeature]
private void InterestingMethod(int valueOne, String anotherValue)
{
//Do something interesting here
}
}
Monitoring all methods within a class
[GFeature]
public class SampleApplication
{
private void InterestingMethod(int valueOne, String anotherValue)
{
//Do something interesting here
}
private void AnotherInterestingMethod(int valueTwo, String anotherValue)
{
//Do something even more interesting here
}
}
Inheritance Hierarchy
System.Object
System.Attribute
PostSharp.Extensibility.MulticastAttribute
PostSharp.Aspects.Aspect
PostSharp.Aspects.MethodLevelAspect
PostSharp.Aspects.OnMethodBoundaryAspect
Gibraltar.Agent.PostSharp.GAspectBase
Gibraltar.Agent.PostSharp.GFeature
Requirements
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
See Also