This project consist of an aspect library to integrate SmartInspect with the PostSharp AOP Framework for .NET. The following article explains the basic features of this aspect library and how to get started with SmartInspect and PostSharp:
Aspect-oriented logging for .NET with PostSharp and SmartInspect

Installation
To install and use this aspect library, either download one of the releases or get the source code. After downloading the release or getting the source code, simply add the SmartInspectPostSharp* project to your solution or take a look at the included examples.
Please note that there are two flavors of this library, one for PostSharp 1.5 and one for PostSharp 2.x. Both libraries can be used in the same way and make use of the latest features of the particular PostSharp version.
Aspects
While the usage of this library and the aspects are explained in this article, the following list of included aspects and attributes provide a good overview of available features.
SiTrace
The SiTrace attribute can be used to trace the method execution of your classes. This attribute automatically calls EnterMethod and LeaveMethod for your methods and supports various options to log arguments, return values etc.
| Attribute | Type | Description |
IncludeArguments |
bool |
If true, the aspect will also log all method arguments. |
IncludeReturnValue |
bool |
If true, the aspect will also log the return value of methods. |
IncludeSpecialNames |
bool |
If true, the aspect will also trace special methods, such as property getters / setters and constructors (new with PostSharp 2.0). |
Level |
Level |
Specifies the SmartInspect log level used for log entries generated by this aspect. |
SessionName |
string |
Specifies the session name associated with log entries generated by this aspect. |
SessionPolicy |
SessionPolicy |
Specifies the mechanism for the aspect to generate a SmartInspect session
name for log entries. For example, you can tell the aspect to use the class
name of the methods as the SmartInspect session name. The following options
are supported:CustomTypeNameFullyQualifiedTypeNameNamespace
|
SiException
If the SiException attribute is applied to a type or method, all unhandled exceptions are automatically logged via SmartInspect. The following options are supported:
| Attribute | Type | Description |
IncludeMethod |
bool |
If true, the aspect will also log the method name together with the exception message. |
Level |
Level |
Specifies the SmartInspect log level used for log entries generated by this aspect. |
SessionName |
string |
Specifies the session name associated with log entries generated by this aspect. |
SessionPolicy |
SessionPolicy |
Specifies the mechanism for the aspect to generate a SmartInspect session
name for log entries. For example, you can tell the aspect to use the class
name of the methods as the SmartInspect session name. The following options
are supported:CustomTypeNameFullyQualifiedTypeNameNamespace
|
SiField
If the SiField attribute is applied to a field, all changes to the field's value are logged via SmartInspect Log* and or Watch* calls. As of PostSharp 2.0, this aspect also supports logging of property values. The following options are supported:
| Attribute | Type | Description |
IncludeInstance |
bool |
If true, the aspect will include the instance's ToString() value in the log entries and watches. |
IncludeType |
bool |
If true, the aspect will include the type name in the log entries and watches. |
Log |
bool |
If true, the aspect will generate a log entry when the value of the field changes. |
SessionName |
string |
Specifies the session name associated with log entries generated by this aspect. |
SessionPolicy |
SessionPolicy |
Specifies the mechanism for the aspect to generate a SmartInspect session
name for log entries. For example, you can tell the aspect to use the class
name of the methods as the SmartInspect session name. The following options
are supported:CustomTypeNameFullyQualifiedTypeNameNamespace
|
Watch |
bool |
If true, the aspect will generate a watch when the value of the field changes. |
