Open sandboxFocus
  • TOC

Post­Sharp Documentation

Introduction

Deployment and Configuration

Adding Aspects to Code

Logging

Contracts

INotify­Property­Changed

Weak Event

XAML

Parent/Child, Visitor and Disposable

Undo/Redo

Caching

Multithreading

Developing Custom Aspects

Validating Architecture

Testing and Debugging

Miscellaneous

API Reference

Post­Sharp

Post­Sharp.​Aspects

Post­Sharp.​Aspects.​Advices

Post­Sharp.​Aspects.​Configuration

Post­Sharp.​Aspects.​Dependencies

Post­Sharp.​Aspects.​Internals

Post­Sharp.​Aspects.​Serialization

Post­Sharp.​Collections

Post­Sharp.​Constraints

Post­Sharp.​Extensibility

Post­Sharp.​Extensibility.​Build­Time­Logging

Post­Sharp.​Patterns

Post­Sharp.​Patterns.​Caching

Post­Sharp.​Patterns.​Caching.​Backends

Post­Sharp.​Patterns.​Caching.​Backends.​Azure

Post­Sharp.​Patterns.​Caching.​Backends.​Redis

Post­Sharp.​Patterns.​Caching.​Dependencies

Post­Sharp.​Patterns.​Caching.​Formatters

Post­Sharp.​Patterns.​Caching.​Implementation

Post­Sharp.​Patterns.​Caching.​Locking

Post­Sharp.​Patterns.​Caching.​Serializers

Post­Sharp.​Patterns.​Caching.​Value­Adapters

Post­Sharp.​Patterns.​Collections

Post­Sharp.​Patterns.​Collections.​Advices

Post­Sharp.​Patterns.​Contracts

Post­Sharp.​Patterns.​Diagnostics

Post­Sharp.​Patterns.​Diagnostics.​Adapters.​Asp­Net­Core

Post­Sharp.​Patterns.​Diagnostics.​Adapters.​Asp­Net­Framework

Post­Sharp.​Patterns.​Diagnostics.​Adapters.​Diagnostic­Source

Post­Sharp.​Patterns.​Diagnostics.​Adapters.​Http­Client

Post­Sharp.​Patterns.​Diagnostics.​Audit

Post­Sharp.​Patterns.​Diagnostics.​Backends

Post­Sharp.​Patterns.​Diagnostics.​Backends.​Application­Insights

Post­Sharp.​Patterns.​Diagnostics.​Backends.​Audit

Post­Sharp.​Patterns.​Diagnostics.​Backends.​Common­Logging

Post­Sharp.​Patterns.​Diagnostics.​Backends.​Console

Post­Sharp.​Patterns.​Diagnostics.​Backends.​Event­Source

Post­Sharp.​Patterns.​Diagnostics.​Backends.​Log4Net

Post­Sharp.​Patterns.​Diagnostics.​Backends.​Microsoft

Post­Sharp.​Patterns.​Diagnostics.​Backends.​Multiplexer

Post­Sharp.​Patterns.​Diagnostics.​Backends.​NLog

Post­Sharp.​Patterns.​Diagnostics.​Backends.​Null

Post­Sharp.​Patterns.​Diagnostics.​Backends.​Serilog

Post­Sharp.​Patterns.​Diagnostics.​Backends.​Trace

Post­Sharp.​Patterns.​Diagnostics.​Backends.​Trace­Source

Post­Sharp.​Patterns.​Diagnostics.​Contexts

Post­Sharp.​Patterns.​Diagnostics.​Correlation

Post­Sharp.​Patterns.​Diagnostics.​Custom

Post­Sharp.​Patterns.​Diagnostics.​Custom.​Messages

Post­Sharp.​Patterns.​Diagnostics.​Formatters

Post­Sharp.​Patterns.​Diagnostics.​Record­Builders

Post­Sharp.​Patterns.​Diagnostics.​Threading­Instrumentation

Post­Sharp.​Patterns.​Diagnostics.​Transactions

Post­Sharp.​Patterns.​Diagnostics.​Transactions.​Model

Post­Sharp.​Patterns.​Dynamic­Advising

Post­Sharp.​Patterns.​Formatters

Post­Sharp.​Patterns.​Model

Post­Sharp.​Patterns.​Model.​Controls

Post­Sharp.​Patterns.​Model.​Type­Adapters

Post­Sharp.​Patterns.​Recording

Post­Sharp.​Patterns.​Recording.​Operations

Post­Sharp.​Patterns.​Threading

Post­Sharp.​Patterns.​Threading.​Models

Post­Sharp.​Patterns.​Utilities

Post­Sharp.​Patterns.​Xaml

Post­Sharp.​Reflection

Post­Sharp.​Reflection.​Method­Body

Post­Sharp.​Serialization

  • Article

Namespace PostSharp.Patterns.Contracts

Classes

ContractExceptionFactory

Base class for contract exception factories. Implements chain of responsibility between concrete exception factories.

ContractExceptionInfo

This class holds the information from which the ContractExceptionFactory should create the exception.

ContractLocalizedTextProvider

Base class for contract error messages providers.

ContractServices

This class provides services supporting Contract aspects. By adding your own classes to the ExceptionFactory chain, you can change the way the exceptions are created when a contract is broken. By plugging into the LocalizedTextProvider chain, you can change the way the exception messages are generated. See the documentation for the classes for more details: ContractLocalizedTextProvider, ContractExceptionFactory.

CreditCardAttribute

Custom attribute that, when added to a field, property or parameter, throws an ArgumentException if the target is assigned a value that is not a valid credit card number. Null strings are accepted and do not throw an exception.

DefaultContractExceptionFactory

Default implementation of ContractExceptionFactory.

EmailAddressAttribute

Custom attribute that, when added to a field, property or parameter, throws an ArgumentException if the target is assigned a value that is not a valid email address. Null strings are accepted and do not throw an exception.

EnumDataTypeAttribute

Custom attribute that, when added to a field, property or parameter, throws an ArgumentException if the target is assigned a value that is not a valid member of an enumeration.

GreaterThanAttribute

Custom attribute that, when added to a field, property or parameter, throws an ArgumentOutOfRangeException if the target is assigned a value that is smaller than a given value.

LessThanAttribute

Custom attribute that, when added to a field, property or parameter, throws an ArgumentOutOfRangeException if the target is assigned a value that is greater than a given value.

LocationContractAttribute

Base class for other custom attributes in this namespace.

NegativeAttribute

Custom attribute that, when added to a field, property or parameter, throws an ArgumentOutOfRangeException if the target is assigned a value greater than zero.

NotEmptyAttribute

Custom attribute that, when added to a field, property or parameter, throws an ArgumentNullException if the target is assigned a null or empty value. The custom attributes can be added to locations of type string (where empty means zero characters), or ICollection, ICollection<T> or IReadOnlyCollection<T> (where empty means zero items).

NotNullAttribute

Custom attribute that, when added to a field, property or parameter, throws an ArgumentNullException if the target is assigned a null value.

PhoneAttribute

Custom attribute that, when added to a field, property or parameter, throws an ArgumentException if the target is assigned a value that is not a valid phone number. Null strings are accepted and do not throw an exception.

PositiveAttribute

Custom attribute that, when added to a field, property or parameter, throws an ArgumentOutOfRangeException if the target is assigned a value smaller than zero.

PostconditionFailedException

The exception that is thrown when a postcondition contract was not fulfilled by a method.

RangeAttribute

Custom attribute that, when added to a field, property or parameter, throws an ArgumentOutOfRangeException if the target is assigned a value that is outside a given range.

RegularExpressionAttribute

Custom attribute that, when added to a field, property or parameter, throws an ArgumentException if the target is assigned a value that does not match a given regular expression. Null strings are accepted and do not throw an exception.

RequiredAttribute

Custom attribute that, when added to a field, property or parameter, throws:

StrictRangeAttribute

Custom attribute that, when added to a field, property or parameter, throws an ArgumentOutOfRangeException if the target is assigned a value that is not strictly within the given range.

StrictlyGreaterThanAttribute

Custom attribute that, when added to a field, property or parameter, throws an ArgumentOutOfRangeException if the target is assigned a value that is smaller than or equal to a given value.

StrictlyLessThanAttribute

Custom attribute that, when added to a field, property or parameter, throws an ArgumentOutOfRangeException if the target is assigned a value that is greater than or equal to a given value.

StrictlyNegativeAttribute

Custom attribute that, when added to a field, property or parameter, throws an ArgumentOutOfRangeException if the target is assigned a value greater than or equal to zero.

StrictlyPositiveAttribute

Custom attribute that, when added to a field, property or parameter, throws an ArgumentOutOfRangeException if the target is assigned a value smaller than or equal to zero.

StringLengthAttribute

Custom attribute that, when added to a field, property or parameter, throws an ArgumentException if the target is assigned a string of invalid length. Null strings are accepted and do not throw an exception.

UrlAttribute

Custom attribute that, when added to a field, property or parameter, throws an ArgumentException if the target is assigned a value that is not a valid URL starting with http://, https:// or ftp://. Null strings are accepted and do not throw an exception.