Home

PostSharp

PostSharp is a development tool for the .NET platform that implements aspect-oriented programming (AOP). It enables cross-cutting concerns to be modularized as reusable aspects and inserted into existing code without invasive edits. Unlike runtime proxies, PostSharp uses compile-time or build-time weaving to inject aspect logic directly into the IL of assemblies.

Aspects are implemented as classes derived from base aspect types such as OnMethodBoundaryAspect, MethodInterceptionAspect, and LocationInterceptionAspect.

Weaving is performed by a PostSharp weaver during the build process, typically integrated via MSBuild or NuGet.

Common use cases include logging, exception handling, input validation, caching, security, and performance instrumentation. Aspects can

PostSharp is available in a Community Edition (free for open-source and personal use) and several commercial

Developers
declare
aspects
with
attributes
and
apply
them
to
methods,
properties,
fields,
or
classes.
PostSharp
also
supports
multicast
attributes
to
apply
an
aspect
to
many
targets
with
a
single
declaration.
The
result
is
a
modified
assembly
that
contains
the
injected
code,
with
no
requirement
for
source
changes
or
runtime
proxies.
This
can
improve
performance
and
maintainability
by
keeping
cross-cutting
behavior
in
separate,
reusable
components.
participate
in
control
flow,
handle
exceptions,
or
intercept
method
calls,
including
asynchronous
ones.
editions
that
add
features
such
as
advanced
aspect
types,
enhanced
multicast,
centralized
configuration,
and
professional
support.