GitPedia

PostSharp.Samples

PostSharp Samples

From postsharp·Updated January 19, 2025·View on GitHub·

**PostSharp.Samples** is a PostSharp Samples The project is written primarily in C#, distributed under the The Unlicense license, first published in 2016. Key topics include: aop, aop-architecture, aop-aspects, aop-framework, aspect-oriented-framework.

PostSharp.Samples

Welcome to this collection of PostSharp example projects.

You can browse these samples online and navigate the code just by clicking on code references,
or you can download them on GitHub.

ProjectDescription
Aspect Framework
PostSharp.Samples.CustomLoggingLogs method calls including parameter values.
PostSharp.Samples.CustomCachingCaches the results of methods calls
PostSharp.Samples.ExceptionHandlingAdd parameter values to call stack in exception details. Report and then swallow exceptions in entry points.
PostSharp.Samples.AutoRetryAutomatically retries a method call when it fails.
PostSharp.Samples.WeakEventPrevents memory leaks due to events.
PostSharp.Samples.ValidateResourceStringPrints a build-time warning when incorrect resource string name is passed to parameter.
PostSharp.Samples.SessionStateStores a field or property in the session state or page view state.
PostSharp.Samples.TransactionsAutomatically executes a method inside a transaction.
PostSharp.Samples.ProfilingMeasure different execution times of methods, including async methods.
PostSharp.Samples.EncryptionAutomatically encrypts and decrypts parameter and fields/properties
PostSharp.Samples.MiniProfilerMeasures method execution time with MiniProfiler of StackExchange.
PostSharp.Samples.PersistencePersists fields or properties into the Windows registry or app.config.
PostSharp.Samples.AutoDataContractAutomatically adds [DataContract] and [DataMember] attributes to derived classes and all properties
PostSharp.Samples.AuthorizationRequires permissions before getting or setting fields or executing methods.
PostSharp.Samples.NormalizeStringTrims and lowercases strings before they are assigned to a field or property.
PostSharp.Samples.StoredProcedureImplements something like P-Invoke, but for database stored procedures.
Diagnostics
PostSharp.Samples.Logging.ConsoleDemonstrates how to configure PostSharp Logging so that it directs its output to the system console.
PostSharp.Samples.Logging.PerRequestShows how to have different verbosity for each request,
PostSharp.Samples.Logging.CustomizationShows how to customize PostSharp Logging.
PostSharp.Samples.Logging.EtwDemonstrates how to configure PostSharp Logging so that it directs its output to ETW.
PostSharp.Samples.Logging.Etw.CustomSourceDemonstrates how use PostSharp Logging with a custom ETW source (instead of the predefined one).
PostSharp.Samples.Logging.Log4NetDemonstrates how to configure PostSharp Logging so that it directs its output to log4net.
PostSharp.Samples.Logging.NLogDemonstrates how to configure PostSharp Logging so that it directs its output to NLog.
PostSharp.Samples.Logging.SerilogDemonstrates how to configure PostSharp Logging so that it directs its output to Serilog.
PostSharp.Samples.Logging.LoupeDemonstrates how to configure PostSharp Logging so that it directs its output to Loupe.
PostSharp.Samples.Logging.CommonLoggingDemonstrates how to configure PostSharp Logging so that it directs its output to Common.Logging.
PostSharp.Samples.Logging.CustomBackend.ServiceStackDemonstrates how to implement a PostSharp Logging adapter for your custom logging framework.
PostSharp.Samples.Logging.AuditShows how to append an audit record to a database when a method is invoked.
Distributed Diagnostics with Elastic Search
PostSharp.Samples.Logging.ElasticStack/MicroserviceExampleThe server-side service demonstrating correlation of logs of a distributed application with Elastic Search.
PostSharp.Samples.Logging.ElasticStack/ClientExampleThe server-side service demonstrating correlation of logs of a distributed application with Elastic Search.
XAML
PostSharp.Samples.XamlDemonstrates a few ready-made aspects that are useful for XAML
Caching
PostSharp.Samples.CachingCaching method results with Redis and different ways to remove things from the cache.
Threading
PostSharp.Samples.Threading.PingPongThe classic educational ping-pong example.
PostSharp.Samples.Threading.ThreadDispatchingA simple WPF progress bar updated from a background thread.
Platform Support
PostSharp.Samples.Blazor.AutoRetryDemonstrates a custom aspect used in a Blazor application.

Contributors

Showing top 11 contributors by commit count.

View all contributors on GitHub →

This article is auto-generated from postsharp/PostSharp.Samples via the GitHub API.Last fetched: 6/23/2026